@odoo/o-spreadsheet 19.5.0-alpha.8 → 19.5.0-alpha.9
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.
- package/dist/o_spreadsheet.cjs +12 -9
- package/dist/o_spreadsheet.css +3 -3
- package/dist/o_spreadsheet.esm.js +12 -9
- package/dist/o_spreadsheet.iife.js +12 -9
- package/dist/o_spreadsheet.min.iife.js +4 -4
- package/dist/o_spreadsheet.xml +3 -3
- package/dist/types/components/standalone_grid_canvas/standalone_grid_canvas.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/types/rendering.d.ts +1 -0
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14
14
|
`,e.endsWith(`{`)&&n++;return t.trim()}let gd=ml.content,_d={"=":`EQ`,"+":`ADD`,"-":`MINUS`,"*":`MULTIPLY`,"/":`DIVIDE`,">=":`GTE`,"<>":`NE`,">":`GT`,"<=":`LTE`,"<":`LT`,"^":`POWER`,"&":`CONCATENATE`},vd={"-":`UMINUS`,"+":`UPLUS`,"%":`UNARY.PERCENT`,"#":`SPILLED.RANGE`},yd={},bd={},xd=new Intl.Collator(`en`,{sensitivity:`accent`});var Sd=class e{sheetId;tokens;literalValues;symbols;isBadExpression;normalizedFormula;execute;computeFunctions;rangeDependencies;hasDependencies;constructor(e,t,n,r,i,a,o,s,c){this.sheetId=e,this.tokens=t,this.literalValues=n,this.symbols=r,this.isBadExpression=a,this.normalizedFormula=o,this.execute=s,this.computeFunctions=c,this.hasDependencies=i?.length>0,this.tokens.forEach(e=>{[`REFERENCE`,`NUMBER`,`STRING`,`INVALID_REFERENCE`].includes(e.type)&&(e.value=`__NO_REAL_VALUE__`)}),this.rangeDependencies=i}getTokens(e,t){let n=0,r=0,i=0;return this.isBadExpression||this.tokens.forEach(a=>{switch(a.type){case`REFERENCE`:case`INVALID_REFERENCE`:a.value=e.getRangeString(this.rangeDependencies[n++],this.sheetId,t);break;case`NUMBER`:a.value=this.literalValues.numbers[r++].value.toString();break;case`STRING`:a.value=`"${this.literalValues.strings[i++].value}"`;break}}),this.tokens}getAst(e){return xu(this.getTokens(e))}toFormulaString(e,t){return this.isBadExpression?this.normalizedFormula:Jt(this.getTokens(e,t).filter(e=>e.type!==`SPACE`).map(e=>e.value))}getNamedRangesInFormula(e){let t=[];for(let n=0;n<this.tokens.length;n++)if(td(this.tokens,n)){let r=e.getNamedRange(this.tokens[n].value);r&&t.push(r)}return t}usesSymbol(e){return this.symbols.some(t=>xd.compare(t,e)===0)}areAllFunctionsExportableToExcel(){return this.isBadExpression?!1:!Cu(xu(this.tokens)).some(e=>e.type===`FUNCALL`&&!gd[e.value.toUpperCase()]?.isExported)}getFunctionsFromTokens(e,t){return this.isBadExpression||!e.some(e=>this.usesSymbol(e))?[]:Cu(this.getAst(t)).filter(t=>t.type===`FUNCALL`&&e.includes(t.value.toUpperCase())).map(e=>({functionName:e.value.toUpperCase(),args:e.args}))}isFirstNonWhitespaceSymbol(e){let t=this.tokens.find((e,t)=>t>0&&e.type!==`SPACE`);return t?.type===`SYMBOL`&&t.value.toUpperCase()===e}adaptCompiledFormula(t,n){let r=[],i=!1;for(let e of this.rangeDependencies){let n=t(e);r.push(n.range),n.changeType!==`NONE`&&(i=!0)}let a=this.renameNamedRangeTokens(n);return i||a?new e(this.sheetId,a?.newTokens||this.tokens,this.literalValues,a?.newSymbols||this.symbols,r,this.isBadExpression,Td(a?.newTokens||this.tokens),this.execute,this.computeFunctions):this}renameNamedRangeTokens(e){let t=!1,n=[],r=[];for(let i=0;i<this.tokens.length;i++){let a=this.tokens[i];if(td(this.tokens,i)){let n=e(this.tokens[i].value);n!==this.tokens[i].value&&(t=!0,a={...this.tokens[i],value:n})}n.push(a),a.type===`SYMBOL`&&r.push(a.value)}return t?{newSymbols:r,newTokens:n}:void 0}static IsBadExpression(e){return Cd(cu(e)).isBadExpression}static CopyWithDependencies(t,n,r){return new e(n,t.tokens,t.literalValues,t.symbols,r,t.isBadExpression,t.normalizedFormula,t.execute,t.computeFunctions)}static CopyWithDependenciesAndLiteral(t,n,r,i,a){return new e(n,t.tokens,{numbers:i,strings:a},t.symbols,r,t.isBadExpression,t.normalizedFormula,t.execute,t.computeFunctions)}static CompileForSerializedFormula(t,n){let r=Cd(n.tokens);return new e(t,n.tokens,n.literalValues,n.symbols,n.rangeDependencies,n.isBadExpression,n.normalizedFormula,r.execute,r.computeFunctions)}static Compile(t,n,r){let i=Cd(cu(t));return new e(n,i.tokens,i.literalValues,i.symbols,i.dependencies.map(e=>r.getRangeFromSheetXC(n,e)),i.isBadExpression,i.normalizedFormula,i.execute,i.computeFunctions)}areRangeShapesInLineWithNormalizedFormula(){return Array.from(this.normalizedFormula.matchAll(/\|C\||\|R\|/g)).every((e,t)=>this.rangeDependencies[t].parts.length===1&&e[0]===`|C|`||this.rangeDependencies[t].parts.length===2&&e[0]===`|R|`||this.rangeDependencies[t].invalidXc||this.rangeDependencies[t].invalidSheetName)}};function Cd(e){try{return wd(e)}catch(t){if(!(t instanceof P))throw t;return{tokens:e,literalValues:{numbers:[],strings:[]},symbols:[],dependencies:[],execute:function(){return t},computeFunctions:[],isBadExpression:!0,normalizedFormula:e.map(e=>e.value).join(``)}}}function wd(e){let{dependencies:t,literalValues:n,symbols:r}=Ed(e),i=Td(e);if(!yd[i]){let t=xu([...e]),n=new pd,s=0,c=0,l=0,u=[];if(t.type===`BIN_OPERATION`&&t.value===`:`||t.type===`EMPTY`)throw new No(M(`Invalid formula`));let d=o(t),f=new dd;f.append(d),f.append(ld`return ${d.returnExpression};`),yd[i]=Function(`deps`,`ref`,`range`,`getSymbolValue`,`ctx`,`computeFunctions`,f.toString()),bd[i]=u;function a(e){let{args:t}=e,n=e.value.toUpperCase(),r=gd[n];if(!r)throw new Lo(M(`Unknown function: "%s"`,e.value));Dd(e);let i=[],a=el(r,t.length);for(let e=0;e<t.length;e++){let s=r.args[a[e].index],c=t[e],l=o(c,s.acceptMatrix);if(s.acceptMatrixOnly&&!l.returnsMatrix)throw new No(M(`Function %s expects the parameter '%s' to be reference to a cell or range.`,n,(e+1).toString()));let u=!s.acceptMatrix&&l.returnsMatrix;i.push({argAST:l,toVectorize:u})}return i}function o(e,t=!1){let i=new dd(n);switch(e.debug&&(i.append(ld`debugger;`),i.append(ld`ctx["debug"] = true;`)),e.type){case`BOOLEAN`:return i.return(ld`{ value: ${e.value} }`);case`NUMBER`:return i.return(ld`this.literalValues.numbers[${c++}]`);case`STRING`:return i.return(ld`this.literalValues.strings[${s++}]`);case`REFERENCE`:let n=e.value.includes(`:`)||t;return i.return(ld`${n?ld`range`:ld`ref`}(deps[${l++}])`,n);case`FUNCALL`:let d=a(e),f=d.map(e=>e.argAST.assignResultToVariable());i.append(...f);let p=e.value.toUpperCase();if(!Object.hasOwn(gd,p))throw Error(`Unknown function: "${p}"`);let m=cd(p),h=u.length,g=[];for(let e=0;e<d.length;e++)d[e].toVectorize&&g.push(e);u.push(ol(gd[p],f.length,g));let _=gd[p].computeArray!==void 0||g.length>0,v=ld`// ${m}`,ee=[ld`ctx`,...f.map(e=>e.returnExpression)];return i.return(ld`computeFunctions[${h}](${ee}); ${v}`,_);case`ARRAY`:return o(Od(`ARRAY.LITERAL`,e.value.map(e=>Od(`ARRAY.ROW`,e))));case`UNARY_OPERATION`:return o(Od(vd[e.value],[e.operand]));case`BIN_OPERATION`:return o(Od(_d[e.value],[e.left,e.right]));case`SYMBOL`:let y=r.indexOf(e.value);return i.return(ld`getSymbolValue(this.symbols[${y}], ${t})`,!0);case`EMPTY`:return i.return(ld`undefined`)}}}return{execute:yd[i],computeFunctions:bd[i],dependencies:t,literalValues:n,symbols:r,tokens:e,isBadExpression:!1,normalizedFormula:i}}function Td(e){let t=``;for(let n of e)switch(n.type){case`STRING`:t+=`|S|`;break;case`NUMBER`:t+=`|N|`;break;case`REFERENCE`:case`INVALID_REFERENCE`:n.value.includes(`:`)?t+=`|R|`:t+=`|C|`;break;case`SPACE`:break;default:t+=n.value;break}return t}function Ed(e){let t={numbers:[],strings:[]},n=[],r=[];for(let i of e)switch(i.type){case`INVALID_REFERENCE`:case`REFERENCE`:n.push(i.value);break;case`STRING`:let e=Ot(i.value);t.strings.push({value:e});break;case`NUMBER`:{let e=So(i.value,z);t.numbers.push({value:e});break}case`SYMBOL`:r.push(Ot(i.value,`'`))}return{dependencies:n,literalValues:t,symbols:r}}function Dd(e){let t=e.args.length,n=e.value.toUpperCase(),r=gd[n],{nbrArgRepeating:i,minArgRequired:a}=r;if(t<a)throw new No(M(`Invalid number of arguments for the %(functionName)s function. Expected %(minArgRequired)s minimum, but got %(nbrArgSupplied)s instead.`,{functionName:n,minArgRequired:a,nbrArgSupplied:t}));if(t>r.maxArgPossible)throw new No(M(`Invalid number of arguments for the %(functionName)s function. Expected %(maxArgPossible)s maximum, but got %(nbrArgSupplied)s instead.`,{functionName:n,maxArgPossible:r.maxArgPossible,nbrArgSupplied:t}));if(i>1){let e=i*Math.floor((t-a)/i),o=t-a-e-r.nbrOptionalNonRepeatingArgs;if(o>0)throw new No(M(`Invalid number of arguments for the %(functionName)s function. Repeatable arguments should be supplied in groups of %(nbrArgRepeating)s, with up to %(nbrArgOptional)s optional. Got %(nbrValueRemaining)s too many.`,{functionName:n,nbrArgRepeating:i,nbrArgOptional:r.nbrOptionalNonRepeatingArgs,nbrValueRemaining:o}))}}function Od(e,t){return{type:`FUNCALL`,value:e,args:t,tokenStartIndex:0,tokenEndIndex:0}}let kd=function(e){return e.boolean=`boolean`,e.number=`number`,e.text=`text`,e.empty=`empty`,e.error=`error`,e}({});function Ad(e){return`sheetId`in e}function jd(e){return`dimension`in e&&`sheetId`in e&&`elements`in e}function Md(e){return`target`in e&&`sheetId`in e}function Nd(e){return`ranges`in e}function Pd(e){return`col`in e&&`row`in e&&`sheetId`in e}function Fd(e){return`sheetId`in e&&`zone`in e}let Id=new Set([`RENAME_SHEET`,`DELETE_SHEET`,`CREATE_SHEET`,`DUPLICATE_SHEET`,`ADD_COLUMNS_ROWS`,`REMOVE_COLUMNS_ROWS`,`UNDO`,`REDO`,`ADD_MERGE`,`REMOVE_MERGE`,`UPDATE_LOCALE`,`ADD_PIVOT`,`UPDATE_PIVOT`,`INSERT_PIVOT`,`RENAME_PIVOT`,`REMOVE_PIVOT`,`DUPLICATE_PIVOT`,`CREATE_NAMED_RANGE`,`UPDATE_NAMED_RANGE`,`DELETE_NAMED_RANGE`]),Ld=new Set([`EVALUATE_CELLS`,`EVALUATE_CHARTS`,`UPDATE_CELL`,`UNHIDE_COLUMNS_ROWS`,`HIDE_COLUMNS_ROWS`,`GROUP_HEADERS`,`UNGROUP_HEADERS`,`FOLD_ALL_HEADER_GROUPS`,`FOLD_HEADER_GROUP`,`FOLD_HEADER_GROUPS_IN_ZONE`,`UNFOLD_ALL_HEADER_GROUPS`,`UNFOLD_HEADER_GROUP`,`UNFOLD_HEADER_GROUPS_IN_ZONE`,`UPDATE_TABLE`,`UPDATE_FILTER`,`UNDO`,`REDO`]),Rd=new Set([`MOVE_RANGES`]),zd=new Set([`EVALUATE_CELLS`,`ADD_CONDITIONAL_FORMAT`,`REMOVE_CONDITIONAL_FORMAT`,`CHANGE_CONDITIONAL_FORMAT_PRIORITY`]),Bd=new Set([`AUTOFILL_CELL`,`SET_BORDER`,`SET_ZONE_BORDERS`,`SET_BORDERS_ON_TARGET`]),Vd=new Set([`UNHIDE_COLUMNS_ROWS`,`HIDE_COLUMNS_ROWS`,`GROUP_HEADERS`,`UNGROUP_HEADERS`,`FOLD_ALL_HEADER_GROUPS`,`FOLD_HEADER_GROUP`,`FOLD_HEADER_GROUPS_IN_ZONE`,`UNFOLD_ALL_HEADER_GROUPS`,`UNFOLD_HEADER_GROUP`,`UNFOLD_HEADER_GROUPS_IN_ZONE`,`UPDATE_TABLE`,`UPDATE_FILTER`]),Hd=new Set([`START`,`ACTIVATE_SHEET`,`COPY`,`EVALUATE_CELLS`,`EVALUATE_CHARTS`,`SET_FORMULA_VISIBILITY`,`SET_AUTOMATIC_EVALUATION`,`UPDATE_FILTER`,`UPDATE_CHART`,`UPDATE_CHART_REGION`,`UPDATE_CAROUSEL_ACTIVE_ITEM`,`UPDATE_PIVOT`]),Ud=new Set([`LOCK_SHEET`,`UNLOCK_SHEET`,`MOVE_SHEET`,`DUPLICATE_SHEET`,`CREATE_SHEET`,`HIDE_SHEET`,`SHOW_SHEET`,`COPY`,`START`,`ACTIVATE_SHEET`,`SET_FORMULA_VISIBILITY`,`SELECT_FIGURE`,`EVALUATE_CHARTS`,`EVALUATE_CELLS`,`REQUEST_UNDO`,`REQUEST_REDO`,`REPLACE_SEARCH`,`UPDATE_CAROUSEL_ACTIVE_ITEM`,`DUPLICATE_PIVOT_IN_NEW_SHEET`,`UPDATE_FILTER`,`ACTIVATE_NEXT_SHEET`,`ACTIVATE_PREVIOUS_SHEET`]),Wd=new Set(`UPDATE_CELL.UPDATE_CELL_POSITION.CLEAR_CELL.CLEAR_CELLS.DELETE_CONTENT.ADD_COLUMNS_ROWS.REMOVE_COLUMNS_ROWS.RESIZE_COLUMNS_ROWS.HIDE_COLUMNS_ROWS.UNHIDE_COLUMNS_ROWS.SET_GRID_LINES_VISIBILITY.UNFREEZE_COLUMNS.UNFREEZE_ROWS.FREEZE_COLUMNS.FREEZE_ROWS.UNFREEZE_COLUMNS_ROWS.ADD_MERGE.REMOVE_MERGE.CREATE_SHEET.DELETE_SHEET.DUPLICATE_SHEET.MOVE_SHEET.RENAME_SHEET.COLOR_SHEET.SET_SHEET_BACKGROUND_COLOR.HIDE_SHEET.SHOW_SHEET.LOCK_SHEET.UNLOCK_SHEET.MOVE_RANGES.ADD_CONDITIONAL_FORMAT.REMOVE_CONDITIONAL_FORMAT.CHANGE_CONDITIONAL_FORMAT_PRIORITY.CREATE_FIGURE.DELETE_FIGURE.UPDATE_FIGURE.CREATE_CAROUSEL.UPDATE_CAROUSEL.SET_FORMATTING.CLEAR_FORMATTING.SET_BORDER.SET_ZONE_BORDERS.SET_BORDERS_ON_TARGET.CREATE_CHART.UPDATE_CHART.DELETE_CHART.CREATE_TABLE.REMOVE_TABLE.UPDATE_TABLE.CREATE_TABLE_STYLE.REMOVE_TABLE_STYLE.CREATE_IMAGE.GROUP_HEADERS.UNGROUP_HEADERS.UNFOLD_HEADER_GROUP.FOLD_HEADER_GROUP.FOLD_ALL_HEADER_GROUPS.UNFOLD_ALL_HEADER_GROUPS.UNFOLD_HEADER_GROUPS_IN_ZONE.FOLD_HEADER_GROUPS_IN_ZONE.ADD_DATA_VALIDATION_RULE.REMOVE_DATA_VALIDATION_RULE.UPDATE_LOCALE.CREATE_NAMED_RANGE.UPDATE_NAMED_RANGE.DELETE_NAMED_RANGE.ADD_PIVOT.UPDATE_PIVOT.INSERT_PIVOT.RENAME_PIVOT.REMOVE_PIVOT.DUPLICATE_PIVOT`.split(`.`));function Gd(e){return Wd.has(e.type)}function Kd(e){return Hd.has(e.type)}var qd=class{reasons;constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter(e=>e!==`Success`)}static get Success(){return Jd}get isSuccessful(){return this.reasons.length===0}isCancelledBecause(e){return this.reasons.includes(e)}};let Jd=new qd,Yd=function(e){return e.Success=`Success`,e.CancelledForUnknownReason=`CancelledForUnknownReason`,e.WillRemoveExistingMerge=`WillRemoveExistingMerge`,e.CannotMoveTableHeader=`CannotMoveTableHeader`,e.MergeIsDestructive=`MergeIsDestructive`,e.CellIsMerged=`CellIsMerged`,e.InvalidTarget=`InvalidTarget`,e.EmptyUndoStack=`EmptyUndoStack`,e.EmptyRedoStack=`EmptyRedoStack`,e.NotEnoughElements=`NotEnoughElements`,e.NotEnoughSheets=`NotEnoughSheets`,e.MissingSheetName=`MissingSheetName`,e.UnchangedSheetName=`UnchangedSheetName`,e.DuplicatedSheetName=`DuplicatedSheetName`,e.DuplicatedSheetId=`DuplicatedSheetId`,e.ForbiddenCharactersInSheetName=`ForbiddenCharactersInSheetName`,e.WrongSheetMove=`WrongSheetMove`,e.WrongSheetPosition=`WrongSheetPosition`,e.InvalidAnchorZone=`InvalidAnchorZone`,e.SelectionOutOfBound=`SelectionOutOfBound`,e.TargetOutOfSheet=`TargetOutOfSheet`,e.WrongCutSelection=`WrongCutSelection`,e.WrongPasteSelection=`WrongPasteSelection`,e.WrongPasteOption=`WrongPasteOption`,e.WrongFigurePasteOption=`WrongFigurePasteOption`,e.EmptyClipboard=`EmptyClipboard`,e.EmptyRange=`EmptyRange`,e.EmptyTarget=`EmptyTarget`,e.InvalidRange=`InvalidRange`,e.InvalidZones=`InvalidZones`,e.InvalidSheetId=`InvalidSheetId`,e.InvalidCellId=`InvalidCellId`,e.InvalidFigureId=`InvalidFigureId`,e.InputAlreadyFocused=`InputAlreadyFocused`,e.MaximumRangesReached=`MaximumRangesReached`,e.MinimumRangesReached=`MinimumRangesReached`,e.InvalidChartDefinition=`InvalidChartDefinition`,e.InvalidDataSet=`InvalidDataSet`,e.InvalidYRange=`InvalidYRange`,e.InvalidXRange=`InvalidXRange`,e.InvalidLabelRange=`InvalidLabelRange`,e.InvalidBubbleSizeRange=`InvalidBubbleSizeRange`,e.InvalidScorecardKeyValue=`InvalidScorecardKeyValue`,e.InvalidScorecardBaseline=`InvalidScorecardBaseline`,e.InvalidGaugeDataRange=`InvalidGaugeDataRange`,e.EmptyGaugeRangeMin=`EmptyGaugeRangeMin`,e.GaugeRangeMinNaN=`GaugeRangeMinNaN`,e.EmptyGaugeRangeMax=`EmptyGaugeRangeMax`,e.GaugeRangeMaxNaN=`GaugeRangeMaxNaN`,e.GaugeLowerInflectionPointNaN=`GaugeLowerInflectionPointNaN`,e.GaugeUpperInflectionPointNaN=`GaugeUpperInflectionPointNaN`,e.InvalidAutofillSelection=`InvalidAutofillSelection`,e.MinBiggerThanMax=`MinBiggerThanMax`,e.LowerBiggerThanUpper=`LowerBiggerThanUpper`,e.MidBiggerThanMax=`MidBiggerThanMax`,e.MinBiggerThanMid=`MinBiggerThanMid`,e.FirstArgMissing=`FirstArgMissing`,e.SecondArgMissing=`SecondArgMissing`,e.MinNaN=`MinNaN`,e.MidNaN=`MidNaN`,e.MaxNaN=`MaxNaN`,e.ValueUpperInflectionNaN=`ValueUpperInflectionNaN`,e.ValueLowerInflectionNaN=`ValueLowerInflectionNaN`,e.MinInvalidFormula=`MinInvalidFormula`,e.MidInvalidFormula=`MidInvalidFormula`,e.MaxInvalidFormula=`MaxInvalidFormula`,e.ValueUpperInvalidFormula=`ValueUpperInvalidFormula`,e.ValueLowerInvalidFormula=`ValueLowerInvalidFormula`,e.InvalidSortAnchor=`InvalidSortAnchor`,e.InvalidSortZone=`InvalidSortZone`,e.SortZoneWithArrayFormulas=`SortZoneWithArrayFormulas`,e.WaitingSessionConfirmation=`WaitingSessionConfirmation`,e.MergeOverlap=`MergeOverlap`,e.TooManyHiddenElements=`TooManyHiddenElements`,e.Readonly=`Readonly`,e.FigureDoesNotExist=`FigureDoesNotExist`,e.InvalidConditionalFormatId=`InvalidConditionalFormatId`,e.InvalidConditionalFormatType=`InvalidConditionalFormatType`,e.InvalidCellPopover=`InvalidCellPopover`,e.EmptySelectedRange=`EmptySelectedRange`,e.InvalidFreezeQuantity=`InvalidFreezeQuantity`,e.FrozenPaneOverlap=`FrozenPaneOverlap`,e.InvalidFilterZone=`InvalidFilterZone`,e.TableNotFound=`TableNotFound`,e.TableOverlap=`TableOverlap`,e.InvalidTableConfig=`InvalidTableConfig`,e.InvalidTableStyle=`InvalidTableStyle`,e.FilterNotFound=`FilterNotFound`,e.MergeInTable=`MergeInTable`,e.NonContinuousTargets=`NonContinuousTargets`,e.DuplicatedFigureId=`DuplicatedFigureId`,e.InvalidSelectionStep=`InvalidSelectionStep`,e.DuplicatedChartId=`DuplicatedChartId`,e.ChartDoesNotExist=`ChartDoesNotExist`,e.InvalidHeaderIndex=`InvalidHeaderIndex`,e.InvalidQuantity=`InvalidQuantity`,e.MoreThanOneColumnSelected=`MoreThanOneColumnSelected`,e.EmptySplitSeparator=`EmptySplitSeparator`,e.SplitWillOverwriteContent=`SplitWillOverwriteContent`,e.NoSplitSeparatorInSelection=`NoSplitSeparatorInSelection`,e.NoActiveSheet=`NoActiveSheet`,e.InvalidLocale=`InvalidLocale`,e.MoreThanOneRangeSelected=`MoreThanOneRangeSelected`,e.NoColumnsProvided=`NoColumnsProvided`,e.ColumnsNotIncludedInZone=`ColumnsNotIncludedInZone`,e.InvalidHeaderGroupStartEnd=`InvalidHeaderGroupStartEnd`,e.HeaderGroupAlreadyExists=`HeaderGroupAlreadyExists`,e.UnknownHeaderGroup=`UnknownHeaderGroup`,e.UnknownDataValidationRule=`UnknownDataValidationRule`,e.UnknownDataValidationCriterionType=`UnknownDataValidationCriterionType`,e.InvalidDataValidationCriterionValue=`InvalidDataValidationCriterionValue`,e.InvalidNumberOfCriterionValues=`InvalidNumberOfCriterionValues`,e.InvalidCopyPasteSelection=`InvalidCopyPasteSelection`,e.NoChanges=`NoChanges`,e.InvalidInputId=`InvalidInputId`,e.SheetIsHidden=`SheetIsHidden`,e.InvalidTableResize=`InvalidTableResize`,e.PivotIdNotFound=`PivotIdNotFound`,e.PivotIdTaken=`PivotIdTaken`,e.PivotInError=`PivotInError`,e.EmptyName=`EmptyName`,e.ValueCellIsInvalidFormula=`ValueCellIsInvalidFormula`,e.InvalidDefinition=`InvalidDefinition`,e.InvalidColor=`InvalidColor`,e.InvalidPivotDataSet=`InvalidPivotDataSet`,e.InvalidPivotCustomField=`InvalidPivotCustomField`,e.MissingFigureArguments=`MissingFigureArguments`,e.InvalidCarouselItem=`InvalidCarouselItem`,e.SheetLocked=`SheetLocked`,e.NamedRangeNameAlreadyExists=`NamedRangeNameAlreadyExists`,e.NamedRangeInvalidName=`NamedRangeInvalidName`,e.NamedRangeNameLooksLikeCellReference=`NamedRangeNameLooksLikeCellReference`,e.NamedRangeNotFound=`NamedRangeNotFound`,e.SubCommandOnly=`SubCommandOnly`,e.NoChangeInAutomaticEvaluation=`NoChangeInAutomaticEvaluation`,e}({});function Xd(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}let Zd=new D;function Qd(e,t){return e=Xd(e),{url:e,label:t||e,isExternal:!0,isUrlEditable:!0}}Zd.add(`sheet_URL`,{match:e=>Vt(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){let n=Ut(e);return t.tryGetSheetName(n)||M(`Invalid sheet`)},open(e,t){let n=Ut(e);t.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:n}).isCancelledBecause(`SheetIsHidden`)&&t.notifyUser({type:`warning`,sticky:!1,text:M(`Cannot open the link because the linked sheet is hidden.`)})},sequence:0,title:M(`Sheets`),getLinkProposals(e){return e.model.getters.getSheetIds().map(t=>{let n=e.model.getters.getSheet(t);return{...this.createLink(Ht(t),n.name),icon:`o-spreadsheet-Icon.INSERT_SHEET`}})}});let $d={createLink:Qd,match:e=>Lt(e),open:e=>window.open(e,`_blank`),urlRepresentation:e=>e,sequence:0,title:M(`Web`)};function ef(e){return Zd.getAll().sort((e,t)=>e.sequence-t.sequence).find(t=>t.match(e))||$d}function tf(e,t){return ef(e.url).urlRepresentation(e.url,t)}function nf(e,t,n){ef(e.url).open(e.url,t,n)}function rf(e){if(typeof e==`string`){if(It(e)){let{label:t,url:n}=zt(e);return ef(n).createLink(n,t)}else if(Lt(e))return Qd(e)}}function af(e,t,n){return df({value:Wc(t.format)&&e.parsedValue!==null?e.content:e.parsedValue,format:t.format,origin:n},t.locale,n)}function of(e,t,n,r,i,a,o){return n.startsWith(`=`)?cf(e,t,n,r,i,a):sf(e,t,n,r,i,o)}function sf(e,t,n,r,i,a){let o=e.getLocale(),s=uf(n,o);if(r===void 0&&typeof s==`number`){let e=Dc(n,o);if(a?.avoidAutomaticDateFormat&&e)return{id:t,content:n,style:i,format:r,isFormula:!1,parsedValue:n};r=e||Oc(n)}return!Wc(r)&&!n.startsWith(`'`)&&!Uo(n)&&(n=I(s)),{id:t,content:n,style:i,format:r,isFormula:!1,parsedValue:s}}function cf(e,t,n,r,i,a){return lf(t,Sd.Compile(n,a,e),r,i)}function lf(e,t,n,r){return{id:e,format:n,style:r,isFormula:!0,compiledFormula:t}}function uf(e,t){if(e.startsWith(`=`))throw Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);if(e.startsWith(`'`))return e.slice(1);if(e===``)return null;if(e.includes(`
|
|
15
15
|
`))return e;if(bo(e,z))return So(e,z);let n=Ua(e,t);return n?n.value:Nt(e)?e.toUpperCase()===`TRUE`:e}function df(e,t=z,n,r,i){let a=rf(e.value);if(!a)return wf(ff(e,t,n,r),e.origin??i);let o=uf(a.label,t);return wf({...ff({value:o,format:e.format||(typeof o==`number`?Dc(a.label,t)||Oc(a.label):void 0)},t,n,r),link:a},e.origin??n)}function ff(e,t,n,r){let{value:i,format:a,message:o,errorOriginPosition:s}=e;a=r||a;let c=B(i,{format:a,locale:t});return Uo(i)?Cf(i,o,n,s):i===null?bf(a):Wc(a)?vf(I(i),a,c,n):typeof i==`number`?Sc(a||``)?xf(i,a,c,n):yf(i,a,c,n):typeof i==`boolean`?Sf(i,a,c,n):vf(i,a,c,n)}function pf(e){return!!e&&_f(e)===`number`}function mf(e){return!!e&&_f(e)===`text`}function hf(e){return!!e&&_f(e)===`boolean`}function gf(e){return!!e&&_f(e)===`error`}function _f({value:e,format:t}){if(e===null)return`empty`;if(Uo(e))return`error`;if(Wc(t))return`text`;switch(typeof e){case`number`:return`number`;case`boolean`:return`boolean`;case`string`:return`text`}}function vf(e,t,n,r){return{value:e,format:t,formattedValue:n,position:r,type:`text`,isAutoSummable:!0,defaultAlign:`left`}}function yf(e,t,n,r){return{value:e||0,format:t,formattedValue:n,position:r,type:`number`,isAutoSummable:!0,defaultAlign:`right`}}let bf=ln(function(e){return{value:null,format:e,formattedValue:``,type:`empty`,isAutoSummable:!0,defaultAlign:`left`}});function xf(e,t,n,r){return{value:e,format:t,formattedValue:n,position:r,type:`number`,isAutoSummable:!1,defaultAlign:`right`}}function Sf(e,t,n,r){return{value:e,format:t,formattedValue:n,position:r,type:`boolean`,isAutoSummable:!1,defaultAlign:`center`}}function Cf(e,t,n,r){return{value:e,formattedValue:e,message:t,position:n,type:`error`,isAutoSummable:!1,defaultAlign:`center`,errorOriginPosition:r}}function wf(e,t){return e.value===null||`origin`in e||(e.origin=t),e}let Tf=/rgba?\(|\s+|\)/gi,Ef=/^#([A-F\d]{2}){3,4}$/,Df=/^light-dark\(\s*(rgba?\([0-9.,\s]+\)|#[a-f0-9]+)\s*,\s*(rgba?\([0-9.,\s]+\)|#[a-f0-9]+)\s*\)$/i,Of=[`#eb6d00`,`#0074d9`,`#ad8e00`,`#169ed4`,`#b10dc9`,`#00a82d`,`#00a3a3`,`#f012be`,`#3d9970`,`#62A300`,`#ff4136`,`#949494`,`#ff5c9d`];function kf(e,t=1){let n=t===1?``:Math.round(t*255).toString(16).padStart(2,`0`);return jf(e.toString(16).padStart(6,`0`))+n}function Af(e){return typeof e==`number`?e:Number.parseInt(jf(e).slice(1,7),16)}function jf(e){let t=e;if(e.startsWith(`light-dark`)){let t=e.match(Df);if(!t)throw Error(`Invalid light-dark color: ${e}`);return`light-dark(${jf(t[1])}, ${jf(t[2])})`}if(e.startsWith(`rgb`)?t=Lf(e):(t=e.replace(`#`,``).toUpperCase(),(t.length===3||t.length===4)&&(t=t.split(``).reduce((e,t)=>e+t+t,``)),t=`#${t}`),!Ef.test(t))throw Error(`invalid color input: ${e}`);return t}function Mf(e){try{return jf(e),!0}catch{return!1}}function Nf(e){try{return Hf(e),!0}catch{return!1}}let Pf=e=>e>=0&&e<=255;function Ff(e,t,n,r=1){if(!Pf(e)||!Pf(t)||!Pf(n)||r<0||r>1)throw Error(`Invalid RGBA values ${[e,t,n,r]}`);return{a:r,b:n,g:t,r:e}}function If(e){let{r:t,g:n,b:r}=zf(e);t/=255,n/=255,r/=255;let i=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4,a=i(t),o=i(n),s=i(r);return .2126*a+.7152*o+.0722*s}function Lf(e){let t=e.replace(Tf,``).split(`,`),n=255;if(t.length!==3&&t.length!==4)throw Error(`invalid color`);if(t.length===4){let e=parseFloat(t.pop()||`1`);if(isNaN(e))throw Error(`invalid alpha value`);n=Math.round(e*255)}let r=t.map(e=>parseInt(e,10));return n!==255&&r.push(n),`#`+Jt(r.map(e=>e.toString(16).padStart(2,`0`))).toUpperCase()}function Rf(e){let t=e.r.toString(16),n=e.g.toString(16),r=e.b.toString(16),i=Math.round(e.a*255).toString(16);return t.length===1&&(t=`0`+t),n.length===1&&(n=`0`+n),r.length===1&&(r=`0`+r),i.length===1&&(i=`0`+i),i===`ff`&&(i=``),(`#`+t+n+r+i).toUpperCase()}function zf(e){e=jf(e);let t,n,r,i;if(e.length===7)t=parseInt(e[1]+e[2],16),n=parseInt(e[3]+e[4],16),r=parseInt(e[5]+e[6],16),i=255;else if(e.length===9)t=parseInt(e[1]+e[2],16),n=parseInt(e[3]+e[4],16),r=parseInt(e[5]+e[6],16),i=parseInt(e[7]+e[8],16);else throw Error(`Invalid color`);return i=+(i/255).toFixed(3),{a:i,r:t,g:n,b:r}}function Bf(e){e={...e},e.s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,n=t*(1-Math.abs(e.h/60%2-1)),r=e.l-t/2,i=0,a=0,o=0;return 0<=e.h&&e.h<60?(i=t,a=n,o=0):60<=e.h&&e.h<120?(i=n,a=t,o=0):120<=e.h&&e.h<180?(i=0,a=t,o=n):180<=e.h&&e.h<240?(i=0,a=n,o=t):240<=e.h&&e.h<300?(i=n,a=0,o=t):300<=e.h&&e.h<360&&(i=t,a=0,o=n),i=Math.round((i+r)*255),a=Math.round((a+r)*255),o=Math.round((o+r)*255),{a:e.a,r:i,g:a,b:o}}function Vf(e){let t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=a-i,s=0,c=0,l=0;return s=o===0?0:a===t?(n-r)/o%6:a===n?(r-t)/o+2:(t-n)/o+4,s=Math.round(s*60),s<0&&(s+=360),l=(a+i)/2,c=o===0?0:o/(1-Math.abs(2*l-1)),c=+(c*100).toFixed(1),l=+(l*100).toFixed(1),{a:e.a,h:s,s:c,l}}function Hf(e){return Rf(Bf(e))}function Uf(e){return Vf(zf(e))}function Wf(e,t){let n=zf(t),r=zf(e),i=n.a+r.a*(1-n.a);return Rf({r:Math.round((n.r*n.a+r.r*r.a*(1-n.a))/i),g:Math.round((n.g*n.a+r.g*r.a*(1-n.a))/i),b:Math.round((n.b*n.a+r.b*r.a*(1-n.a))/i),a:i})}function Gf(e){return zf(typeof e==`number`?kf(e):e)}function Kf(e,t,n=0){if(!(Mf(e)&&Mf(t)))return!1;let r=zf(e),i=zf(t);return r.a===i.a?Math.sqrt(((r.r-i.r)/255)**2+((r.g-i.g)/255)**2+((r.b-i.b)/255)**2)<=n:!1}function qf(e,t){if(e.startsWith(`light-dark`)){let n=e.match(Df);if(!n)throw Error(`Invalid light-dark color: ${e}`);return`light-dark(${qf(n[1],t)}, ${qf(n[2],t)})`}return t===1?jf(e).slice(0,7):Rf({...zf(e),a:t})}function Jf(e,t){let n=Uf(e);return t===1?`#fff`:(n.l=t*(100-n.l)+n.l,Hf(n))}let Yf={invert:1,hueRotate:170,contrast:.85,brightness:1.2},Xf=`invert(${Yf.invert}) hue-rotate(${Yf.hueRotate}deg) contrast(${Yf.contrast}) brightness(${Yf.brightness})`;function Zf(e){let t=e*Math.PI/180,n=Math.cos(t),r=Math.sin(t);return[[.213+n*.787-r*.213,.715-n*.715-r*.715,.072-n*.072+r*.928],[.213-n*.213+r*.143,.715+n*.285+r*.14,.072-n*.072-r*.283],[.213-n*.213-r*.787,.715-n*.715+r*.715,.072+n*.928+r*.072]]}function Qf(e){let{r:t,g:n,b:r,a:i}=zf(e),a=t/255,o=n/255,s=r/255;a/=Yf.brightness,o/=Yf.brightness,s/=Yf.brightness,a=(a-.5)/Yf.contrast+.5,o=(o-.5)/Yf.contrast+.5,s=(s-.5)/Yf.contrast+.5,a=Math.max(0,Math.min(1,a)),o=Math.max(0,Math.min(1,o)),s=Math.max(0,Math.min(1,s));let c=Zf(-Yf.hueRotate),l=Math.max(0,Math.min(1,c[0][0]*a+c[0][1]*o+c[0][2]*s)),u=Math.max(0,Math.min(1,c[1][0]*a+c[1][1]*o+c[1][2]*s)),d=Math.max(0,Math.min(1,c[2][0]*a+c[2][1]*o+c[2][2]*s));return Rf({r:Math.round((1-l)*255),g:Math.round((1-u)*255),b:Math.round((1-d)*255),a:i})}function $f(e,t){let n=Uf(e);return t===1?`#000`:(n.s=Math.min(100,t*n.s+n.s),n.l-=t*n.l,Hf(n))}function ep(e){return If(e)<.6?Jf(e,.9):$f(e,.75)}let tp=`#4EA7F2`,np=[tp,`#EA6175`,`#43C5B1`,`#F4A261`,`#8481DD`,`#FFD86D`],rp=[tp,`#3188E6`,`#43C5B1`,`#00A78D`,`#EA6175`,`#CE4257`,`#F4A261`,`#F48935`,`#8481DD`,`#5752D1`,`#FFD86D`,`#FFBC2C`],ip=[tp,`#3188E6`,`#056BD9`,`#A76DBC`,`#7F4295`,`#6D2387`,`#EA6175`,`#CE4257`,`#982738`,`#43C5B1`,`#00A78D`,`#0E8270`,`#F4A261`,`#F48935`,`#BE5D10`,`#8481DD`,`#5752D1`,`#3A3580`,`#A4A8B6`,`#7E8290`,`#545B70`,`#FFD86D`,`#FFBC2C`,`#C08A16`],ap=[tp,`#3188E6`,`#056BD9`,`#155193`,`#A76DBC`,`#7F4295`,`#6D2387`,`#4F1565`,`#EA6175`,`#CE4257`,`#982738`,`#791B29`,`#43C5B1`,`#00A78D`,`#0E8270`,`#105F53`,`#F4A261`,`#F48935`,`#BE5D10`,`#7D380D`,`#8481DD`,`#5752D1`,`#3A3580`,`#26235F`,`#A4A8B6`,`#7E8290`,`#545B70`,`#3F4250`,`#FFD86D`,`#FFBC2C`,`#C08A16`,`#936A12`],op=[tp,`#43C5B1`,`#EA6175`,`#F4A261`,`#8481DD`,`#FFD86D`,`#3188E6`,`#00A78D`,`#CE4257`,`#F48935`,`#5752D1`,`#FFBC2C`],sp=[tp,`#A76DBC`,`#EA6175`,`#43C5B1`,`#F4A261`,`#8481DD`,`#A4A8B6`,`#FFD86D`,`#3188E6`,`#7F4295`,`#CE4257`,`#00A78D`,`#F48935`,`#5752D1`,`#7E8290`,`#FFBC2C`,`#056BD9`,`#6D2387`,`#982738`,`#0E8270`,`#BE5D10`,`#3A3580`,`#545B70`,`#C08A16`],cp=[tp,`#A76DBC`,`#EA6175`,`#43C5B1`,`#F4A261`,`#8481DD`,`#A4A8B6`,`#FFD86D`,`#3188E6`,`#7F4295`,`#CE4257`,`#00A78D`,`#F48935`,`#5752D1`,`#7E8290`,`#FFBC2C`,`#056BD9`,`#6D2387`,`#982738`,`#0E8270`,`#BE5D10`,`#3A3580`,`#545B70`,`#C08A16`,`#155193`,`#4F1565`,`#791B29`,`#105F53`,`#7D380D`,`#26235F`,`#3F4250`,`#936A12`];function lp(e,t){return t[e%t.length]}function up(e){return e<=6?np:e<=12?rp:e<=24?ip:ap}function dp(e){return e<=6?np:e<=12?op:e<=24?sp:cp}var fp=class{preferredColors;currentColorIndex=0;palette;constructor(e,t=[]){this.preferredColors=t,this.palette=up(e).filter(e=>!t.includes(e))}next(){return this.preferredColors?.[this.currentColorIndex]?this.preferredColors[this.currentColorIndex++]:lp(this.currentColorIndex++,this.palette)}},pp=class extends fp{constructor(e,t=[]){super(e,t),this.palette=dp(e).filter(e=>!t.includes(e))}},mp=class{availableColors;colors={};constructor(e=12){this.availableColors=new pp(e)}get(e){return this.colors[e]||(this.colors[e]=this.availableColors.next()),this.colors[e]}};let hp={greys:[`#ffffff`,`#808080`,`#000000`],blues:[`#f7fbff`,`#6aaed6`,`#08306b`],reds:[`#fff5f0`,`#fb694a`,`#67000d`],greens:[`#f7fcf5`,`#73c476`,`#00441b`],oranges:[`#fff5eb`,`#fd8c3b`,`#7f2704`],purples:[`#fcfbfd`,`#9e9ac8`,`#3f007d`],viridis:[`#440154`,`#21918c`,`#fde725`],cividis:[`#00224e`,`#7d7c78`,`#fee838`],rainbow:[`#B41DB4`,`#FFFF00`,`#00FFFF`]},gp=Object.keys(hp);function _p(e){if(e.length<2)throw Error(`Color scale must have at least 2 points`);let t=[...e.sort((e,t)=>e.value-t.value)],n=[];for(let e=1;e<t.length;e++){let r=Gf(t[e-1].color).a,i=Gf(t[e].color).a,a=Af(t[e-1].color),o=Af(t[e].color);n.push({min:t[e-1].value,max:t[e].value,minColor:a,maxColor:o,minColorAlpha:r,maxColorAlpha:i,colorDiff:vp(t[e-1].value,t[e].value,a,o)})}return e=>{if(e<n[0].min)return kf(n[0].minColor,n[0].minColorAlpha);for(let t of n)if(e>=t.min&&e<=t.max)return kf(yp(e,t.min,t.minColor,t.colorDiff),t.maxColorAlpha);return kf(n[n.length-1].maxColor,n[n.length-1].maxColorAlpha)}}function vp(e,t,n,r){let i=t-e,a=(n>>16)%256-(r>>16)%256,o=(n>>8)%256-(r>>8)%256,s=n%256-r%256;return[a/i,o/i,s/i]}function yp(e,t,n,r){let[i,a,o]=r,s=Math.round((n>>16)%256-i*(e-t)),c=Math.round((n>>8)%256-a*(e-t)),l=Math.round(n%256-o*(e-t));return s<<16|c<<8|l}function bp(e,t=1){return t*(e+4)-4}function xp(e=100,t=100){return new OffscreenCanvas(e,t).getContext(`2d`)}function Sp(e,t,n,r){if(!t||!t.isFormula&&!t.content)return 23;let i=``;try{if(!t.isFormula){let e={format:t.format,locale:n};i=B(uf(t.content,n),e)}}catch{i=N.GenericError}return Cp(e,i,t.style,r)}function Cp(e,t,n,r){return Tp(e,Fp(e,t,n,n?.wrapping===`wrap`?r-8:void 0),n).height+6}function wp(e,t=!1,n=!1){return`${n?`italic`:``} ${t?`bold`:``} ${e}px ${Qe}`}function Tp(e,t,n={},r=`pt`){if(!t.length)return{width:0,height:0};let i=Mp(n,r),a=t.map(t=>Ap(e,t,i)),o=bp(a[0].height,t.length),s=Math.max(...a.map(e=>e.width));if(!n.rotation)return{height:o,width:s};let c=Math.abs(Math.cos(n.rotation)),l=Math.abs(Math.sin(n.rotation));return{width:s*c+o*l,height:l*s+c*o}}function Ep(e,t,n={},r=`pt`){return Dp(e,t,Mp(n,r),n.rotation)}function Dp(e,t,n,r){let i=Ap(e,t,n);if(!r)return i.width;let a=Math.abs(Math.cos(r)),o=Math.abs(Math.sin(r));return i.width*a+i.height*o}let Op={};function kp(e,t,n,r=`pt`){let i=Ap(e,t,Mp(n,r));if(!n.rotation)return i;let a=Math.abs(Math.cos(n.rotation)),o=Math.abs(Math.sin(n.rotation));return{width:i.width*a+i.height*o,height:i.height*a+i.width*o}}function Ap(e,t,n){if(Op[n]||(Op[n]={}),Op[n][t]===void 0){e.save(),e.font=n;let r=e.measureText(t);e.restore();let i=r.width,a=r.fontBoundingBoxAscent+r.fontBoundingBoxDescent;Op[n][t]={width:i,height:a}}return Op[n][t]}function jp(e){return Math.round(e*96/72)}function Mp(e,t=`pt`){return`${e.italic?`italic `:``}${e.bold?`bold`:`400`} ${(t===`pt`?Np(e):e.fontSize)??Ze}px ${Qe}`}function Np(e){return jp(e?.fontSize||Ze)}function Pp(e,t,n,r){if(Ep(e,t,r)<=n)return[t];let i=[],a=``;for(let o of t)Ep(e,a+o,r)>n?(i.push(a),a=o):a+=o;return i.push(a),i}function Fp(e,t,n,r){n||={},It(t)&&(t=zt(t).label);let i=[],a=t.includes(`
|
|
16
16
|
`)?t.split(`
|
|
17
|
-
`):[t];for(let t of a){let a=t.includes(` `)?t.split(` `):[t];if(!r){i.push(t);continue}let o=``,s=r;for(let t of a){let a=Pp(e,t,r,n),c=a.pop(),l=Ep(e,c,n);if(a.length)o!==``&&(i.push(o),o=``,s=r),a.forEach(e=>{i.push(e)}),o=c,s=r-l;else{let t=o===``?c:` `+c,a=Ep(e,t,n);a<=s?(o+=t,s-=a):(i.push(o),o=c,s=r-l)}}o!==``&&i.push(o)}return i}function Ip(e,t,n,r=.25){let i=1;if(n(i)>e)return i;if(n(t)<e)return t;let a=(i+t)/2,o=n(a),s=0;for(;Math.abs(o-e)>r&&s<20;)o>=e?t=(i+t)/2:i=(i+t)/2,a=(i+t)/2,o=n(a),s++;return a}function Lp(e){return e?e.toLowerCase().trim():``}let Rp=/([0-9\.]*)px/;function zp(e){return Number(e.match(Rp)?.[1])}function Bp(e,t,n){let r=Dp(e,t,e.font);if(r<=n)return t;let i=Dp(e,`…`,e.font);if(r<=i)return t;let a=t.length;for(;r>=n-i&&a-->0;)t=t.substring(0,a),r=Dp(e,t,e.font);return t+`…`}function Vp(e,t,n,r=!1,i=!1,a=zp(e.font)/10,o=!1){if(o&&(e.save(),e.fillStyle=Jf(e.fillStyle,Xe)),e.fillText(t,n.x,n.y),!r&&!i)return;let s=e.measureText(t),c=s.width,l=s.actualBoundingBoxAscent+s.actualBoundingBoxDescent,u=s.fontBoundingBoxAscent+s.fontBoundingBoxDescent,{x:d,y:f}=n,p=f,m=f;switch(e.textAlign){case`center`:d-=c/2;break;case`right`:d-=c;break}switch(e.textBaseline){case`top`:m+=u-2*a,p+=u/2-a;break;case`middle`:m+=u/2-a;break;case`alphabetic`:m+=2*a,p-=3*a;break;case`bottom`:m=f,p-=l/2-a/2;break}r&&(e.lineWidth=a,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(d,m),e.lineTo(d+c,m),e.stroke()),i&&(e.lineWidth=a,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(d,p),e.lineTo(d+c,p),e.stroke()),o&&e.restore()}function Hp(e,t,n,r,i=`pt`){if(Ep(e,n,r,i)<=t)return n;let a=Ep(e,`...`,r,i);if(a>=t)return``;let o=1,s=n.length,c;for(;o<=s;){let l=Math.floor((o+s)/2);c=Ep(e,n.slice(0,l),r,i),c+a>t?s=l-1:o=l+1}let l=n.slice(0,Math.max(0,o-1));return l?l+`...`:``}function Up(e,t){if(!t.rotation||t.rotation%(Math.PI*2)==0)return e;let{x:n,y:r}=e,i=Math.cos(-t.rotation),a=Math.sin(-t.rotation),o=e.textWidth-8,s=e.textHeight,c=t.align===`center`,l=t.align===`left`==a<0,u=a*s,d=Math.abs(a*o),f=i*s;return t.verticalAlign===`top`?c?(r+=d/2,n-=u/2):l?n-=u:r+=d:!t.verticalAlign||t.verticalAlign===`bottom`?(r+=s-f,c?(r-=d/2,n-=u/2):l&&(n-=u,r-=d)):c?(n-=u/2,r-=s/2,l?r+=u:r-=u):l?(n-=u,r-=d/2):r+=d/2+f/4,{x:i*n-a*r,y:i*r+a*n}}let Wp={id:`chartColorScalePlugin`,afterDatasetsDraw(e,t,n){if(!n.position||n.position===`none`||!n.colorScale.length)return;let r=e.ctx;r.save(),r.textAlign=`center`,r.textBaseline=`middle`,r.miterLimit=1;let i=(e.chartArea.bottom-e.chartArea.top)/2,a=n.position===`left`?20:r.canvas.width-70,o=e.chartArea.top,s=r.createLinearGradient(0,o+i,0,o),c=1/(n.colorScale.length-1);n.colorScale.forEach((e,t)=>{s.addColorStop(t*c,e)}),r.fillStyle=s,r.fillRect(a,o,10,i),r.fillStyle=n.fontColor??`black`,r.font=wp(12),r.textAlign=`left`;let l=Math.round(n.minValue*100)/100,u=Math.round(n.maxValue*100)/100;n.minValue===n.maxValue&&(--l,u+=1);let d=Fc({value:u,format:void 0},n.locale),f=Fc({value:l,format:void 0},n.locale);r.fillText(f,a+10+5,o+i-6),r.fillText(d,a+10+5,o+6),r.restore()}};function Gp(){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);return class extends globalThis.Chart.BarController{static id=`funnel`;static defaults={...globalThis.Chart?.BarController.defaults,dataElementType:`funnel`,animation:{duration:e=>e.type===`data`?1e3*(e.raw[1]/Math.max(...e.dataset.data.map(e=>e[1]))):1e3}};updateElements(e,t,n,r){super.updateElements(e,t,n,r);for(let i=t;i<t+n;i++){let t=e[i];this.updateElement(t,i,{nextElement:e[i+1]},r)}}}}function Kp(){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);return class extends globalThis.Chart.BarElement{static id=`funnel`;draw(e){e.save();let{x:t,y:n,height:r,nextElement:i,base:a,options:o}=this.getProps([`x`,`y`,`width`,`height`,`nextElement`,`base`,`options`]),s=qp(this),c=(s-(i?qp(i):0))/2,l=Math.min(t,a),u=n-r/2;e.fillStyle=o.backgroundColor,e.beginPath(),e.moveTo(l,u),e.lineTo(l+s,u),e.lineTo(l+s-c,u+r),e.lineTo(l+c,u+r),e.closePath(),e.fill(),o.borderWidth&&(e.strokeStyle=o.borderColor,e.lineWidth=o.borderWidth,e.stroke()),e.restore()}inRange(e,t){let{x:n,y:r,height:i,nextElement:a,base:o}=this.getProps([`x`,`y`,`width`,`height`,`nextElement`,`base`,`options`]),s=qp(this),c=a?qp(a):0,l=Math.min(n,o),u=r-i/2;if(t<u||t>u+i)return!1;let d=(s-c)/2,f=l+d*(t-u)/i,p=l+s-d*(t-u)/i;return!(e<f||e>p)}}}function qp(e){let{x:t,base:n}=e.getProps([`x`,`base`]);return Math.max(t,n)-Math.min(t,n)}let Jp=function(e){if(!e.length)return{x:0,y:0};let{x:t,y:n,base:r,width:i,height:a}=e[0].element.getProps([`x`,`y`,`width`,`height`,`base`]),o=Math.min(t,r),s=n-a/2;return{x:o+i*2/3,y:s+a/2}},Yp={id:`o-spreadsheet-minor-gridlines`,beforeDatasetsDraw(e){let t=e.ctx,n=e.chartArea;if(n)for(let r in e.scales){let i=e.scales[r],a=i.options,o=a?.grid?.minor;if(!o?.display)continue;let s=a?.grid?.display,c=i.ticks;if(!(!c||c.length<2)){t.save(),t.lineWidth=1,t.strokeStyle=o.color??a?.grid?.color??`#e6e6e6`;for(let e=0;e<c.length-1;e++){let r=i.getPixelForTick(e),a=i.getPixelForTick(e+1);if(!(!isFinite(r)||!isFinite(a)))for(let e=+!!s;e<4;e++){let o=e/4,s=Math.round(r+(a-r)*o)+.5;t.beginPath(),i.isHorizontal()?(t.moveTo(s,n.top),t.lineTo(s,n.bottom)):(t.moveTo(n.left,s),t.lineTo(n.right,s)),t.stroke()}}t.restore()}}}},Xp=`000000`,Zp={arrows:`3Arrows`,smiley:`3Symbols`,dots:`3TrafficLights1`},Qp={styleSheet:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,sst:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,Relationships:`http://schemas.openxmlformats.org/package/2006/relationships`,Types:`http://schemas.openxmlformats.org/package/2006/content-types`,worksheet:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,workbook:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,drawing:`http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing`,table:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,revision:`http://schemas.microsoft.com/office/spreadsheetml/2014/revision`,revision3:`http://schemas.microsoft.com/office/spreadsheetml/2016/revision3`,markupCompatibility:`http://schemas.openxmlformats.org/markup-compatibility/2006`},$p=`http://schemas.openxmlformats.org/drawingml/2006/main`,em=`http://schemas.openxmlformats.org/drawingml/2006/chart`,tm={workbook:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml`,macroEnabledWorkbook:`application/vnd.ms-excel.sheet.macroEnabled.main+xml`,templateWorkbook:`application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml`,macroEnabledTemplateWorkbook:`application/vnd.ms-excel.template.macroEnabled.main+xml`,excelAddInWorkbook:`application/vnd.ms-excel.addin.macroEnabled.main+xml`,sheet:`application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml`,metadata:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml`,sharedStrings:`application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml`,styles:`application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml`,drawing:`application/vnd.openxmlformats-officedocument.drawing+xml`,chart:`application/vnd.openxmlformats-officedocument.drawingml.chart+xml`,themes:`application/vnd.openxmlformats-officedocument.theme+xml`,table:`application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml`,pivot:`application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml`,externalLink:`application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml`},nm={document:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument`,sheet:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet`,metadata:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/sheetMetadata`,sharedStrings:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings`,styles:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles`,drawing:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,chart:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart`,theme:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme`,table:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/table`,hyperlink:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink`,image:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/image`},rm=`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,im=.75,am=.143,om=8.43,sm=12.75,cm={FLOOR:[{type:`NUMBER`,value:1}],CEILING:[{type:`NUMBER`,value:1}],ROUND:[{type:`NUMBER`,value:0}],ROUNDUP:[{type:`NUMBER`,value:0}],ROUNDDOWN:[{type:`NUMBER`,value:0}],IFERROR:[{type:`NUMBER`,value:0}]},lm=`ACOT,ACOTH,AGGREGATE,ARABIC,BASE,BETA.DIST,BETA.INV,BINOM.DIST,BINOM.DIST.RANGE,BINOM.INV,BITAND,BITLSHIFT,BITOR,BITRSHIFT,BITXOR,BYCOL,BYROW,CEILING.MATH,CEILING.PRECISE,CHISQ.DIST,CHISQ.DIST.RT,CHISQ.INV,CHISQ.INV.RT,CHISQ.TEST,CHOOSECOLS,CHOOSEROWS,COMBINA,CONCAT,CONFIDENCE.NORM,CONFIDENCE.T,COT,COTH,COVARIANCE.P,COVARIANCE.S,CSC,CSCH,DAYS,DECIMAL,DROP,ERF.PRECISE,ERFC.PRECISE,EXPAND,EXPON.DIST,F.DIST,F.DIST.RT,F.INV,F.INV.RT,F.TEST,FIELDVALUE,FILTERXML,FLOOR.MATH,FLOOR.PRECISE,FORECAST.ETS,FORECAST.ETS.CONFINT,FORECAST.ETS.SEASONALITY,FORECAST.ETS.STAT,FORECAST.LINEAR,FORMULATEXT,GAMMA,GAMMA.DIST,GAMMA.INV,GAMMALN.PRECISE,GAUSS,HSTACK,HYPGEOM.DIST,IFNA,IFS,IMCOSH,IMCOT,IMCSC,IMCSCH,IMSEC,IMSECH,IMSINH,IMTAN,ISFORMULA,ISOMITTED,ISOWEEKNUM,LAMBDA,LET,LOGNORM.DIST,LOGNORM.INV,MAKEARRAY,MAP,MAXIFS,MINIFS,MODE.MULT,MODE.SNGL,MUNIT,NEGBINOM.DIST,NORM.DIST,NORM.INV,NORM.S.DIST,NORM.S.INV,NUMBERVALUE,PDURATION,PERCENTILE.EXC,PERCENTILE.INC,PERCENTRANK.EXC,PERCENTRANK.INC,PERMUTATIONA,PHI,POISSON.DIST,PQSOURCE,PYTHON_STR,PYTHON_TYPE,PYTHON_TYPENAME,QUARTILE.EXC,QUARTILE.INC,QUERYSTRING,RANDARRAY,RANK.AVG,RANK.EQ,REDUCE,RRI,SCAN,SEC,SECH,SEQUENCE,SHEET,SHEETS,SKEW.P,SORTBY,STDEV.P,STDEV.S,SWITCH,T.DIST,T.DIST.2T,T.DIST.RT,T.INV,T.INV.2T,T.TEST,TAKE,TEXTAFTER,TEXTBEFORE,TEXTJOIN,TEXTSPLIT,TOCOL,TOROW,UNICHAR,UNICODE,UNIQUE,VAR.P,VAR.S,VSTACK,WEBSERVICE,WEIBULL.DIST,WRAPCOLS,WRAPROWS,XLOOKUP,XOR,Z.TEST`.split(`,`),um=`xMovingAverage`,dm={exponential:`exp`,logarithmic:`log`,polynomial:`poly`,trailingMovingAverage:`movingAvg`};function fm(e,t,n){return n?Nu(e,t,n):void 0}function pm(e,{applyChange:t}){if(!e)return;let n=t(e);switch(n.changeType){case`REMOVE`:return;default:return n.range}}function mm(e,t,n){let r=[];for(let i of n.dataSets){let{unboundedZone:a,sheetId:o,invalidSheetName:s,invalidXc:c}=e.getRangeFromSheetXC(t,i.dataRange);if(!(s||c))if(a.left!==a.right&&a.top!==a.bottom){if(a.right===void 0)continue;let t=i.dataSetId;for(let i=a.left;i<=a.right;i++){let s={...a,left:i,right:i};r.push({...hm(e,o,s,n.dataSetsHaveTitle?{top:s.top,bottom:s.top,left:s.left,right:s.left}:void 0),dataSetId:t}),t=`${t}_${i}`}}else r.push({...hm(e,o,a,n.dataSetsHaveTitle?{top:a.top,bottom:a.top,left:a.left,right:a.left}:void 0),dataSetId:i.dataSetId})}return r}function hm(e,t,n,r){if(n.left!==n.right&&n.top!==n.bottom)throw Error(`Zone should be a single column or row: ${tr(n)}`);if(r){let i=tr(n),a=tr(r);return{labelCell:e.getRangeFromSheetXC(t,a),dataRange:e.getRangeFromSheetXC(t,i)}}else return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,tr(n))}}function gm(e,t,n){let r=n.labelCell?.zone,i=n.dataRange.zone;if(r){let{numberOfRows:e,numberOfCols:t}=mr(i);e===1?i={...i,left:i.left+1}:t===1&&(i={...i,top:i.top+1})}let a=t[n.dataSetId]??{},o=Du({...n.dataRange,zone:i},e.getSheetSize),s={};a.label?s={text:a.label}:n.labelCell&&(s={reference:e.getRangeString(n.labelCell,`forceSheetReference`,{useBoundedReference:!0})});let c;return a.trend?.type&&(c={type:a.trend.type===`polynomial`&&a.trend.order===1?`linear`:dm[a.trend.type],color:a.trend.color,order:a.trend.order?Math.min(a.trend.order,6):void 0,window:a.trend.window||2}),{label:s,range:e.getRangeString(o,`forceSheetReference`,{useBoundedReference:!0}),backgroundColor:a.backgroundColor,rightYAxis:a.yAxisId===`y1`,trend:c}}function _m(e,t,n){if(!t)return;let r={...t.zone};n&&t.zone.bottom>t.zone.top&&(r.top+=1);let i=Du({...t,zone:r},e.getSheetSize);return e.getRangeString(i,`forceSheetReference`,{useBoundedReference:!0})}function vm(e){return e&&If(e)<.3?`#FFFFFF`:`#000000`}function ym(e){return e&&If(e)<.3?`#C8C8C8`:`#666666`}function bm(e){return e.dataSets.find(e=>!xl.test(e.dataRange))!==void 0||e.dataSets.map(e=>Yn(e.dataRange)).some(e=>e.top!==e.bottom&&Tr(e))?`InvalidDataSet`:`Success`}function xm(e){return e.labelRange&&!xl.test(e.labelRange||``)?`InvalidLabelRange`:`Success`}function Sm(e,t,n){return n&&!!t&&e>=t}function Cm(e){let t=!1,n=!1;if(`horizontal`in e&&e.horizontal)return{useLeftAxis:!0,useRightAxis:!1};let r=`dataSetStyles`in e?e.dataSetStyles??{}:{};for(let e of Object.values(r))e?.yAxisId===`y1`?n=!0:t=!0;return t||=!n,{useLeftAxis:t,useRightAxis:n}}function wm(e,t,n=!1){return(r,i)=>{let a=e?.[i];return Tm({format:a,locale:t},n)(r)}}function Tm(e,t=!1){return n=>{if(n=Number(n),isNaN(n))return n;let{locale:r,format:i}=e;return Om(t?Fc({value:n,format:i},r):B(n,{locale:r,format:!i&&Math.abs(n)>=1e3?`#,##`:i}))}}let Em=[{value:`left`,label:M(`Left`)},{value:`right`,label:M(`Right`)}];function Dm(e,t){let n=[],r=gn(t.map(e=>e.data.length));for(let t=0;t<=r;t++)n.push(e.next());return n}function Om(e,t=20){return e?e.length>t?e.substring(0,t)+`…`:e:``}function km(e){return e===`x1`||e===`xMovingAverage`}function Am({background:e},t){let n=t.getSpreadsheetTheme().backgroundColor;return e||n}function jm(e,t){return e.type===`bar`&&t.type===`line`}let Mm={id:`chartShowValuesPlugin`,afterDatasetsDraw(e,t,n){if(n.showValues&&e._metasets?.[0]?.data)switch(n.type){case`pie`:Hm(e,n);break;case`line`:case`scatter`:Im(e,n);break;case`combo`:case`waterfall`:Lm(e,n);break;case`radar`:Fm(e,n);break;case`bar`:n.horizontal?Bm(e,n):Pm(e,n);break;case`pyramid`:Bm(e,n);break;case`calendar`:Rm(e,n);break;case`bubble`:zm(e,n);break;case`funnel`:Vm(e,n);break}}};function Nm(e){let{chart:t,options:n,getNumberValue:r,direction:i}=e,a=t.ctx;a.save(),a.textAlign=`center`,a.textBaseline=`middle`,a.miterLimit=1;let o={};for(let s of t._metasets)if(!(km(s.xAxisID)||s.hidden))for(let c=0;c<s._parsed.length;c++){let l=r(s,c);if(l===void 0||isNaN(l))continue;let u=s.data[c],d=u.options.backgroundColor;if(!d||zf(d).a!==1)continue;let f=n.callback(l,s,c),p=Um(f,a),m={dataset:s,chartElement:u,numberValue:l,valueIndex:c,textSize:p,options:n,chart:t},h=e.getValuePosition(m);if(e.shouldSkipValue?.(m))continue;if(i===`vertical`){let e=Math.round(h.x);o[e]||(o[e]=[]);for(let t of o[e]||[])Math.abs(t-h.y)<13&&(h.y=t+13*(l<0?1:-1));o[e].push(h.y)}else{let e=Math.round(h.y);o[e]||(o[e]=[]);for(let t of o[e])Math.abs(t-h.x)<p.width&&(h.x=l<0?t-p.width-3:t+p.width+3);o[e].push(h.x)}let{strokeColor:g,textColor:_}=e.getTextColors(m);g&&(a.strokeStyle=g,a.lineWidth=3,a.strokeText(f,h.x,h.y)),a.fillStyle=_,a.lineWidth=1,a.fillText(f,h.x,h.y)}a.restore()}function Pm(e,t){Nm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t].y),getValuePosition:Km,shouldSkipValue:({dataset:e})=>jm(t,e),getTextColors:Wm})}function Fm(e,t){Nm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t].r),getValuePosition:({chartElement:e})=>({x:e.x,y:e.y-10}),shouldSkipValue:()=>!1,getTextColors:Gm})}function Im(e,t){Nm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t].y),getValuePosition:({chartElement:e})=>({x:e.x,y:e.y-10}),shouldSkipValue:()=>!1,getTextColors:Gm})}function Lm(e,t){Nm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t].y),getValuePosition:e=>e.dataset.type===`line`?{x:e.chartElement.x,y:e.chartElement.y-10}:Km(e),shouldSkipValue:()=>!1,getTextColors:e=>e.dataset.type===`line`?Gm(e):Wm(e)})}function Rm(e,t){Nm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>e._parsed[t].y,getValuePosition:({chartElement:e})=>({x:e.x,y:e.y+e.height/2}),shouldSkipValue:({chartElement:e,textSize:t})=>t.height+2>Math.abs(e.height)-2,getTextColors:({chartElement:e})=>({strokeColor:void 0,textColor:vm(e.options.backgroundColor)})})}function zm(e,t){let n=(e,t)=>{let n=e.options.radius??globalThis.Chart?.defaults.elements.point.radius??3;return t.height<n*2};Nm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>e._parsed[t].y,getValuePosition:({chartElement:e,textSize:t})=>({x:e.x,y:n(e,t)?e.y:e.y-10}),shouldSkipValue:()=>!1,getTextColors:e=>n(e.chartElement,e.textSize)?Wm(e):Gm(e)})}function Bm(e,t){Nm({chart:e,options:t,direction:`horizontal`,getNumberValue:(e,t)=>e._parsed[t].x,getValuePosition:({chartElement:t,numberValue:n,textSize:r,dataset:i})=>{let a=e.scales[i.xAxisID].getPixelForValue(0),o=Math.abs(t.x-a),s,c=n<0?-1:1;return s=o<r.width?a+c*(r.width/2+3):t.x-c*(t.width/2),{x:s,y:t.y}},shouldSkipValue:({dataset:e})=>jm(t,e),getTextColors:Wm})}function Vm(e,t){Nm({chart:e,options:t,direction:`horizontal`,getNumberValue:(e,t)=>e._parsed[t].x,getValuePosition:({chartElement:e})=>({x:e.x-e.width/2,y:e.y}),shouldSkipValue:()=>!1,getTextColors:Wm})}function Hm(e,t){let n=e=>{let{startAngle:t,endAngle:n,innerRadius:r,outerRadius:i}=e;return{midAngle:(t+n)/2,midRadius:(r+i)/2}};Nm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t]),getValuePosition:({chartElement:e})=>{let{midAngle:t,midRadius:r}=n(e);return{x:e.x+r*Math.cos(t),y:e.y+r*Math.sin(t)}},shouldSkipValue:({chartElement:e,textSize:t})=>{let{midRadius:r}=n(e),i=e.endAngle-e.startAngle,a=2*r*Math.tan(i/2);return i<Math.PI/2&&(t.width>=a||a<t.height)},getTextColors:Wm})}function Um(e,t){return Ap(t,e,Mp({fontSize:globalThis.Chart?.defaults.font.size??12},`px`))}function Wm(e){let{dataset:t,numberValue:n,valueIndex:r,chartElement:i,options:a}=e;return{strokeColor:i.options.backgroundColor,textColor:a.background(n,t,r)||`#ffffff`}}function Gm(e){let{dataset:t,numberValue:n,valueIndex:r,chartElement:i,options:a}=e;return{strokeColor:a.background(n,t,r)||`#ffffff`,textColor:i.options.backgroundColor}}function Km(e){let{chartElement:t,numberValue:n,dataset:r,textSize:i,chart:a}=e,o=a.scales[r.yAxisID].getPixelForValue(0),s=Math.abs(o-t.y),c=n<0?-1:1,l=0;return l=s<i.height?o-c*(i.height/2):t.y+c*(t.height/2),{x:t.x,y:l}}let qm={showHeaders:!0,headerDesign:{align:`center`,fillColor:`#808080`,bold:!0,fontSize:15},showValues:!0,showLabels:!0,valuesDesign:{align:`left`,verticalAlign:`bottom`,fontSize:12},coloringOptions:{type:`categoryColor`,colors:[],useValueBasedGradient:!0}},Jm={second:1e3,minute:1e3*60,hour:1e3*3600,day:1e3*3600*24,month:1e3*3600*24*30,year:1e3*3600*24*365},Ym={inSeconds:function(e){return Math.floor(e/Jm.second)},inMinutes:function(e){return Math.floor(e/Jm.minute)},inHours:function(e){return Math.floor(e/Jm.hour)},inDays:function(e){return Math.floor(e/Jm.day)},inMonths:function(e){return Math.floor(e/Jm.month)},inYears:function(e){return Math.floor(e/Jm.year)}},Xm=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function Zm(e,t,n){let r=Qm(t),i=eh(e,r,n),a={};return i&&(a[i]=r),{parser:r,displayFormats:a,unit:i??!1,tooltipFormat:r}}function Qm(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 $m(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 eh(e,t,n){let r=e.map(e=>Ua(e,n)?.jsDate);if(r.some(e=>e===void 0)||e.length<2)return;let i=r.map(e=>e.getTime()),a=gn(i)-_n(i),o=$m(t);return Jm.second>=Jm[o]&&Ym.inSeconds(a)<180?`second`:Jm.minute>=Jm[o]&&Ym.inMinutes(a)<180?`minute`:Jm.hour>=Jm[o]&&Ym.inHours(a)<96?`hour`:Jm.day>=Jm[o]&&Ym.inDays(a)<90?`day`:Jm.month>=Jm[o]&&Ym.inMonths(a)<36?`month`:`year`}function th(e,t){let n={},{trendDataSetsValues:r,locale:i,axisFormats:a,axisType:o}=t,s={stacked:e.stacked,locale:i};if(e.horizontal)n.x=gh(e,`bottom`,`values`,o,{...s,format:a?.x}),n.y={...gh(e,`left`,`labels`,`linear`,s),grid:{display:!1}};else{n.x={...gh(e,`bottom`,`labels`,o,s),grid:{display:!1}};let t={...s,format:a?.y};n.y=gh(e,`left`,`values`,`linear`,t);let r={...s,format:a?.y1};n.y1=gh(e,`right`,`values`,`linear`,r)}if(n=tn(n),r&&r.length&&r.some(C)){let e=Math.max(...r.map(e=>e?.length||0));n.x1={...n.x,labels:Array(e).fill(``),offset:!1,display:!1},n[um]={...n.x,offset:!0,display:!1}}return n}function nh(e,t){let n=t.map(e=>e.label||``),r=vm(e.background);return{y:{title:hh(e.axesDesign?.y),stacked:!0,min:0,max:n.length,ticks:{stepSize:.5,color:r,callback:function(e,t,r){if(t%2!=0)return n[Math.floor((t-1)/2)]}},grid:{display:!1},border:{display:!1}},x:{title:hh(e.axesDesign?.x),stacked:!0,grid:{display:!1},position:`top`,ticks:{color:r},border:{display:!1}}}}function rh(e,t){let{dataSetsValues:n}=t;if(!n.length||e.legendPosition===`none`)return;let r=n.flatMap(e=>e.data).filter(pf).map(e=>e.value),i=Math.min(...r),a=Math.max(...r),o=[];return o=typeof e.colorScale==`object`?[e.colorScale.minColor,e.colorScale.midColor,e.colorScale.maxColor].filter(C):[...hp[e.colorScale??`oranges`]],{position:e.legendPosition===`right`?`right`:`left`,colorScale:o,fontColor:vm(e.background),minValue:i,maxValue:a,locale:t.locale}}function ih(e,t){let{locale:n,axisType:r,trendDataSetsValues:i,labels:a,axisFormats:o}=t,s=o?.x,c=e.stacked,l={x:gh(e,`bottom`,`labels`,r,{locale:n}),y:gh(e,`left`,`values`,`linear`,{locale:n,stacked:c,format:o?.y}),y1:gh(e,`right`,`values`,`linear`,{locale:n,stacked:c,format:o?.y1})};if(l=tn(l),r===`time`&&a&&s){let t={type:`time`,time:Zm(a,s,n),min:B(e.axesDesign?.x?.min??``,{format:s,locale:n}),max:B(e.axesDesign?.x?.max??``,{format:s,locale:n})};Object.assign(l.x,t),l.x.ticks.maxTicksLimit=15,delete l?.x?.ticks?.callback}else r===`linear`&&(l.x.type=`linear`,l.x.ticks.callback=e.humanize?e=>Fc({value:e,format:s},n):e=>B(e,{format:s,locale:n}));if(i&&i.length&&i.some(C)&&(l.x1={...l.x,display:!1},l[um]={...l.x,display:!1},r===`category`||r===`time`)){let e=Math.max(...i.map(e=>e?.length||0));l.x1.type=`category`,l.x1.labels=S(0,e).map(e=>e.toString()),l.x1.offset=!1,l[um].type=`category`,l[um].offset=!1}return l}function ah(e){return If(e||`#ffffff`)>.5?`#cccccc`:`#999999`}function oh(e){return If(e||`#ffffff`)>.5?`#e6e6e6`:`#333333`}function sh(e,t){let n=ih(e,t),r=n?.x??{},i=e.axesDesign?.x,a=i?.gridLines!==`none`&&i?.gridLines!==`minor`;return{...n,x:{...r,grid:{...r.grid,color:ah(e.background),display:a}}}}function ch(e,t){let n=sh(e,t),r=e.verticalAxisPosition||`left`;return{...n,y:{...n.y,position:r}}}function lh(e,t){let{locale:n,axisFormats:r,axisType:i}=t,a=r?.y||r?.y1,o=e.axesDesign?.y,s={x:{...gh(e,`bottom`,`labels`,i,{locale:n}),grid:{display:!1}},y:{position:e.verticalAxisPosition,ticks:{color:vm(e.background),callback:Tm({locale:n,format:a},e.humanize)},title:hh(e.axesDesign?.y),min:o?.min,max:o?.max,grid:{lineWidth:e=>e.tick.value===0?2:1,display:o?.gridLines!==`none`&&o?.gridLines!==`minor`,color:ah(e.background)}}};return(o?.gridLines===`minor`||o?.gridLines===`both`)&&(s.y.grid.minor={display:!0,color:oh(e.background)}),s}function uh(e,t){let{dataSetsValues:n}=t,r=th(e,t),i=r.x.ticks.callback;r.x.ticks.callback=e=>i(Math.abs(e));let a=Math.max(...n.map(e=>Math.max(...e.data.filter(pf).map(e=>Math.abs(e.value)))));return r.x.suggestedMin=-a,r.x.suggestedMax=a,r}function dh(e,t){let{locale:n,axisFormats:r,dataSetsValues:i}=t,a=Math.min(...i.map(e=>Math.min(...e.data.filter(pf).map(e=>e.value))));return{r:{beginAtZero:!0,ticks:{callback:Tm({format:r?.r,locale:n},e.humanize),backdropColor:e.background||`#FFFFFF`},pointLabels:{color:vm(e.background),callback:e=>Om(e)},suggestedMin:a<0?a-1:0}}}function fh(e,t){let{locale:n,axisFormats:r,availableRegions:i}=t,a=yh(e.legendPosition),o=e.region?i.find(t=>t.id===e.region):i[0],s=r?.y||r?.y1;return{projection:{projection:mh(o?.defaultProjection||`mercator`),axis:`x`},color:{axis:`x`,display:e.legendPosition!==`none`,border:{color:ze},grid:{color:ze},ticks:{color:vm(e.background),callback:Tm({locale:n,format:s},e.humanize)},legend:{position:a,align:a.includes(`right`)?`left`:`right`,margin:vh(e)},interpolate:_h(e.colorScale??He),missing:e.missingValueColor||`#ffffff`}}}function ph(e,t){let n=t.dataSetsValues[0];return{x:{display:!1},y:{grid:{offset:!1},ticks:{callback:function(e){return Om(this.getLabelForValue(e))}},border:{display:!1}},percentages:{position:`right`,border:{display:!1},ticks:{callback:function(e,r,i){let a=n.data?.[r],o=n.data?.[0];return!o?.value||a?.value===null||!pf(a)||!pf(o)?``:B(a.value/o.value,{format:`0%`,locale:t.locale})}},grid:{display:!1}}}}function mh(e){return globalThis.ChartGeo&&e===`conicConformal`?globalThis.ChartGeo.geoConicConformal().rotate([100,0]):e}function hh(e){if(e?.title?.text){let{text:t,color:n,align:r,italic:i,bold:a}=e.title;return{display:!0,text:t,color:n,font:{style:i?`italic`:`normal`,weight:a?`bold`:`normal`,size:e.title.fontSize??12},align:r===`left`?`start`:r===`right`?`end`:`center`}}}function gh(e,t,n,r,i){let{useLeftAxis:a,useRightAxis:o}=Cm(e);if(t===`left`&&!a||t===`right`&&!o)return;let s=vm(e.background),c;if(c=t===`bottom`?e.axesDesign?.x:t===`left`?e.axesDesign?.y:e.axesDesign?.y1,n===`values`){let n=!(t===`right`&&a),o=c?.gridLines?c?.gridLines===`major`||c?.gridLines===`both`:n,l=!(r===`category`||r===void 0)&&(c?.gridLines===`minor`||c?.gridLines===`both`),u=Tm(i,e.humanize),d={position:t,title:hh(c),beginAtZero:!c?.min,stacked:i?.stacked,ticks:{color:s,callback:u},min:c?.min,max:c?.max,grid:{display:o,color:ah(e.background)}};return l&&(d.grid.minor={display:!0,color:oh(e.background)}),d}else{let t={ticks:{padding:5,color:s,callback:function(e,t,n){return Om(this.getLabelForValue(e))}},min:c?.min,max:c?.max,grid:{display:c?.gridLines===`major`||c?.gridLines===`both`,color:ah(e.background)},stacked:i?.stacked,title:hh(c)};return(c?.gridLines===`minor`||c?.gridLines===`both`)&&(t.grid.minor={display:!0,color:oh(e.background)}),t}}function _h(e,t=0,n=1){if(t===n){let t=e.midColor??e.minColor;return e=>t}let r=[{value:t,color:e.minColor}];return e.midColor&&r.push({value:(t+n)/2,color:e.midColor}),r.push({value:n,color:e.maxColor}),_p(r)}function vh(e){switch(e.legendPosition){case`top`:case`right`:return{top:e.title.text?45:15,left:20,right:20};case`bottom`:case`left`:case`none`:return{left:20,right:20,bottom:10}}}function yh(e){switch(e){case`top`:return`top-left`;case`right`:return`top-right`;case`bottom`:return`bottom-right`;case`left`:return`bottom-left`;case`none`:return`bottom-left`}}let bh=`nullValue`;function xh(e,t){let{dataSetsValues:n,background:r}=t,i=[],a=Wh(e.dataSetStyles,n),o=[];for(let s in n){let{label:c,data:l,hidden:u,dataSetId:d}=n[s];c=e.dataSetStyles?.[d]?.label??c;let f=a.next(),p={label:c,data:l.map(e=>pf(e)?e.value:NaN),hidden:u,borderColor:e.background||r,borderWidth:+!!e.stacked,backgroundColor:f,yAxisID:e.horizontal?`y`:e.dataSetStyles?.[d]?.yAxisId??`y`,xAxisID:`x`,barPercentage:.9,categoryPercentage:n.length>1?.8:1,borderRadius:2};i.push(p);let m=e.dataSetStyles?.[d]?.trend,h=t.trendDataSetsValues?.[s];!m?.display||e.horizontal||!h||o.push(Hh(p,m,h))}i.push(...o);let s=Sh(e,n);return s&&i.push(s),i}function Sh(e,t){let n=t.filter(e=>!e.hidden);if(!e.stacked||!e.showTotalLine||n.length<2)return;let r=S(0,Math.max(...n.map(e=>e.data.length))).map(e=>{let t;for(let r of n){let n=r.data[e];pf(n)&&(t=(t??0)+n.value)}return t??NaN}),i=If(e.background||`#FFFFFF`)<.3?`#e9ecef`:`#343a40`;return{type:`line`,label:M(`Sum`),data:r,order:-1,tension:0,fill:!1,pointRadius:3,borderWidth:2,backgroundColor:i,borderColor:i,pointBackgroundColor:i,xAxisID:`x`,yAxisID:`y`}}function Ch(e,t){let{labels:n,dataSetsValues:r,background:i}=t,a=r.map(e=>e.data).flat().filter(pf).map(e=>e.value),o=Math.max(...a),s=Math.min(...a),c=_h(e.colorScale??He,s,o),l=[];for(let t of r)l.push({label:t.label,data:t.data.map(e=>1),backgroundColor:t.data.map(t=>pf(t)?c(t.value):e.missingValueColor||`#00000000`),borderColor:e.background||i,borderSkipped:!1,borderWidth:1,barPercentage:1,categoryPercentage:1,values:t.data.map(e=>pf(e)?e.value:void 0)});return{labels:n,datasets:l}}function wh(e,t){let{dataSetsValues:n,labels:r}=t,i=e.negativeValuesColor||`#EA6175`,a=e.positiveValuesColor||`#4EA7F2`,o=e.subTotalValuesColor||`#AAAAAA`,s=[],c=[],l={label:``,data:c,backgroundColor:s},u=[],d=0;for(let t of n)if(!t.hidden){for(let l=0;l<t.data.length;l++){let f=t.data[l];if(u.push(r[l]),!pf(f)){c.push([d,d]),s.push(``);continue}c.push([d,f.value+d]);let p=f.value>=0?a:i;l===0&&t===n[0]&&e.firstValueAsSubtotal&&(p=o),s.push(p),d+=f.value}e.showSubTotals&&(u.push(M(`Subtotal`)),c.push([0,d]),s.push(o))}return{datasets:[l],labels:u}}function Th(e,t){let{dataSetsValues:n,axisType:r,labels:i}=t,a=[],o=!!e.fillArea,s=!!e.stacked,c=[],l=Wh(e.dataSetStyles,n);for(let u=0;u<n.length;u++){let{label:d,data:f,hidden:p,dataSetId:m}=n[u];d=e.dataSetStyles?.[m]?.label??d;let h=[],g=l.next();h=r&&[`linear`,`time`].includes(r)?f.map((e,t)=>({x:i[t]===``?NaN:i[t]??NaN,y:pf(e)?e.value:NaN})):f.map(e=>pf(e)?e.value:NaN);let _=e.dataSetStyles?.[m],v={label:d,data:h,hidden:p,tension:0,borderColor:g,backgroundColor:o?qf(g,it):g,pointBackgroundColor:g,fill:o?Uh(u,s):!1,pointRadius:e.hideDataMarkers?0:3,yAxisID:_?.yAxisId||`y`};a.push(v);let ee=_?.trend,y=t.trendDataSetsValues?.[u];!ee?.display||!y||c.push(Hh(v,ee,y))}return a.push(...c),a}function Eh(e,t){let n=Th(e,t);for(let e of n)km(e.xAxisID)||(e.showLine=!1);return n}function Dh(e,t){let n,r;if(e.bubbleColor.color===`multiple`){let i=new fp(t.bubbleSizes.length);r=[];for(let e=0;e<t.bubbleSizes.length;e++)r.push(i.next());n=r.map(t=>qf(t,e.bubbleColor.transparent?.5:1))}else r=e.bubbleColor.color,n=qf(r,e.bubbleColor.transparent?.5:1);let i=Oh(t.bubbleSizes),a=[];for(let e=0;e<t.bubbleSizes.length;e++){let n=t.dataSetsValues[0].data[e];a.push({x:t.labels[e],y:pf(n)?n.value:NaN})}return[{label:t.dataSetsValues[0]?.label,data:a,backgroundColor:n,borderColor:r,hoverBackgroundColor:n,hoverBorderColor:r,yAxisID:`y`,pointRadius:i,pointHoverRadius:i,showLine:!1}]}function Oh(e){if(!e.length)return[];let t=e.filter(e=>Number.isFinite(e)&&e>0),n=t.length?Math.min(...t):0,r=(t.length?Math.max(...t):0)-n;return t.length?e.map(e=>e===void 0||!Number.isFinite(e)||e<0?0:e===0?2:r===0?10:10+x((e-n)/r,0,1)*20):e.map(()=>2)}function kh(e,t){let{dataSetsValues:n}=t,r=[],i=Dm(new fp(Math.max(0,...n.map(e=>e?.data?.length??0)),e.slicesColors),n);for(let{label:t,data:a,hidden:o}of n){if(o)continue;let n={label:t,data:a.map(e=>pf(e)?e.value:NaN),borderColor:e.background||`#FFFFFF`,backgroundColor:i,hoverOffset:10};r.push(n)}return r}function Ah(e,t){let{dataSetsValues:n}=t,r=[],i=Wh(e.dataSetStyles,n),a=[],o=n.filter(({dataSetId:t})=>(e.dataSetStyles?.[t]?.type??`line`)===`bar`);for(let s=0;s<n.length;s++){let{label:c,data:l,hidden:u,dataSetId:d}=n[s];c=e.dataSetStyles?.[d]?.label||c;let f=e.dataSetStyles?.[d],p=i.next(),m=s===0?`bar`:`line`,h=f?.type??m,g={label:c,data:l.map(e=>pf(e)?e.value:null),hidden:u,borderColor:p,backgroundColor:p,yAxisID:e.dataSetStyles?.[d]?.yAxisId||`y`,xAxisID:`x`,type:h,order:h===`bar`?n.length+s:s,pointRadius:e.hideDataMarkers?0:3};g.type===`bar`&&(g.barPercentage=.9,g.categoryPercentage=o.length>1?.8:1,g.borderRadius=2),r.push(g);let _=e.dataSetStyles?.[d]?.trend,v=t.trendDataSetsValues?.[s];!_?.display||!v||a.push(Hh(g,_,v))}return r.push(...a),r}function jh(e,t){let{dataSetsValues:n}=t,r=[],i=e.fillArea??!1,a=Wh(e.dataSetStyles,n);for(let t=0;t<n.length;t++){let{label:o,data:s,hidden:c}=n[t];e.dataSetStyles?.[t]?.label&&(o=e.dataSetStyles[t].label);let l=a.next(),u={label:o,data:s.map(e=>pf(e)?e.value:null),hidden:c,borderColor:l,backgroundColor:l,pointBackgroundColor:l,pointRadius:e.hideDataMarkers?0:3};i&&(u.backgroundColor=qf(l,it),u.fill=`start`),r.push(u)}return r}function Mh(e,t){let{availableRegions:n,dataSetsValues:r,labels:i}=t,a=e.region||n[0]?.id,o=a?t.getGeoJsonFeatures(a):void 0,s={outline:o,showOutline:!!o,data:[]};if(o&&a){let e={};if(r[0])for(let n=0;n<r[0].data.length;n++){let o=r[0].data[n];if(!i[n]||o===void 0)continue;let s=t.geoFeatureNameToId(a,i[n]);s&&(e[s]={value:pf(o)?o.value:0,label:i[n]})}for(let t of o)t.id&&s.data.push({feature:{...t,properties:{name:e[t.id]?.label}},value:e[t.id]?.value})}return[s]}function Nh(e,t){let n=t.dataSetsValues[0],{labels:r,background:i}=t;if(!n)return[];let{label:a,data:o}=n;return a=e.dataSetStyles?.[0]?.label||a,[{label:a,data:o.map(e=>{if(!pf(e))return 0;let t=e.value;return t<=0?[0,0]:[-t,t]}),backgroundColor:Ph(r,e.funnelColors),yAxisID:`y`,xAxisID:`x`,barPercentage:1,categoryPercentage:1,borderColor:e.background||i,borderWidth:3}]}function Ph(e,t){let n=new fp(e.length,t);return e.map(()=>n.next())}function Fh(e,t){let{dataSetsValues:n,labels:r,background:i}=t,a=zh(Lh(n,r)),o=a[0]||[],s=new fp(o.length,e.groupColors||[]),c=o.map(e=>({label:e.label,color:s.next()})),l=[];for(let t=a.length-1;t>=0;t--){let n={groupColors:c,parsing:{key:`value`},data:a[t],borderColor:t=>{let n=t.type===`data`?t.raw:void 0;return!n||n.label===`nullValue`?Ie:e.background||i},backgroundColor:e=>{let t=e.type===`data`?e.raw:void 0;if(!t||t.label===`nullValue`)return Ie;let n=t.groups[0];return c.find(e=>e.label===n)?.color},hoverOffset:10};l.push(n)}return l}function Ih(e,t){let n=[],r=Math.max(...e.map(e=>e.data.length));for(let i=0;i<r;i++){n[i]={};for(let t=0;t<e.length;t++){let r=e[t].data[i]?.value,a=r===null?bh:String(r);n[i][t]=a}n[i].value=Number(t[i])}return n}function Lh(e,t){return Rh(Ih(e,t),0,e.length,[])}function Rh(e,t,n,r){if(t>=n)return[];let i=Object.groupBy(e,e=>e[t]);return Object.keys(i).map(e=>{let a=i[e]?.reduce((e,t)=>e+Number(t.value),0)||0,o=[...r,e];return{label:e,value:a,children:Rh(i[e]||[],t+1,n,[...r,e]),groups:o,depth:t}}).sort((e,t)=>t.value-e.value)}function zh(e){let t=[],n=[...e];for(;n.length>0;){let e=n.shift();e&&(t[e.depth]||(t[e.depth]=[]),t[e.depth].push(e),e.children&&n.push(...e.children))}return t}function Bh(e,t){let{dataSetsValues:n,labels:r,locale:i,axisFormats:a}=t,o={locale:i,format:a?.y};if(n.length===0)return[];let s=Lh(n,r).sort((e,t)=>t.value-e.value),c=Gh(e,s),l=[],u=Math.max(...n.map(e=>e.data.length));for(let e=0;e<u;e++){l[e]={};for(let t=0;t<n.length;t++)l[e][t]=n[t].data[e].value?String(n[t].data[e].value):void 0;l[e].value=Number(r[e])}let d=e.showLabels??qm.showLabels,f=e.showValues??qm.showValues,p=e.coloringOptions||qm.coloringOptions,m;return p?.type===`colorScale`&&(m=Kh(s,p)),[{data:[],tree:l,labels:{display:d||f,overflow:`hidden`,...Vh(e.valuesDesign,qm.valuesDesign),formatter:e=>[d?e.raw.g:void 0,f?B(e.raw.v,o):void 0].filter(C)},captions:{display:e.showHeaders??qm.showHeaders,padding:6,...Vh(e.headerDesign,qm.headerDesign)},key:`value`,groups:S(0,n.length).map(e=>String(e)),borderWidth:0,spacing:1,displayMode:`headerBoxes`,groupColors:c,backgroundColor:t=>{if(t.type!==`data`)return`transparent`;if(!t.raw.isLeaf)return e.headerDesign?.fillColor||qm.headerDesign?.fillColor;if(p.type===`colorScale`)return m?.(t.raw.v)||`#FF0000`;if(p.type===`categoryColor`)return qh(t,s,p,c);throw Error(`Unsupported coloring option type}`)}}]}function Vh(e,t){let n=e=>{let t=e.element.options.backgroundColor;return If(t)>.7?`#666666`:`#FFFFFF`};return{align:e?.align??t?.align,position:e?.verticalAlign??t?.verticalAlign,color:e?.color||n,hoverColor:e?.color||n,font:{weight:e?.bold??t?.bold?`bold`:`normal`,style:e?.italic??t?.italic?`italic`:`normal`,size:e?.fontSize??t?.fontSize}}}function Hh(e,t,n){let r=zf(e.backgroundColor);r.a=1;let i=t.color||Jf(Rf(r),.5);return{type:`line`,xAxisID:t.type===`trailingMovingAverage`?um:`x1`,yAxisID:e.yAxisID,label:e.label?M(`Trend line for %s`,e.label):``,data:n,order:-1,showLine:!0,pointRadius:0,backgroundColor:i,borderColor:i,borderDash:[5,5],borderWidth:void 0,fill:!1,pointBackgroundColor:i}}function Uh(e,t){return t?e===0?`origin`:`-1`:`origin`}function Wh(e,t){let n=t.map(t=>e?.[t.dataSetId]?.backgroundColor),r=t.length;return new fp(r,n)}function Gh(e,t){let n=e.coloringOptions?.type===`categoryColor`?e.coloringOptions.colors:[],r=new fp(t.length,n);return t.map(e=>({label:e.label,color:r.next()}))}function Kh(e,t){if(e.length===0)return;let n=zh(e),r=n[n.length-1],i=Math.min(...r.map(e=>e.value)),a=Math.max(...r.map(e=>e.value));if(Number.isFinite(i)&&Number.isFinite(a)){let e=[{value:i,color:t.minColor}];if(t.midColor){let n=(i+a)/2;e.push({value:n,color:t.midColor})}return e.push({value:a,color:t.maxColor}),_p(e)}}function qh(e,t,n,r){let i=e.raw._data.children[0][0],a=r.find(e=>e.label===i)?.color;if(!a||!n.useValueBasedGradient)return a||`#FF0000`;let o=t.find(e=>e.label===i);if(!o||!o.children.length)return a;let s=zh(o.children),c=s[s.length-1],l=Math.max(...c.map(e=>e.value)),u=Math.min(...c.map(e=>e.value));return u===l||!isFinite(u)||!isFinite(l)?a:Jf(a,((Number(e.raw.v)||0)-l)/(u-l)*.5)}let Jh={id:`sunburstHoverPlugin`,afterEvent(e,t,n){if(!n.enabled)return;let r=e.getActiveElements(),i=r.map(e=>({datasetIndex:e.datasetIndex,index:e.index}));for(let t of r){let n=e.data.datasets[t.datasetIndex].data[t.index];for(let t=0;t<e.data.datasets.length;t++){let r=e.data.datasets[t];for(let e=0;e<r.data.length;e++){let a=r.data[e];Yh(n.groups,a.groups)&&i.push({datasetIndex:t,index:e})}}}i=i.filter(t=>{let{datasetIndex:n,index:r}=t;return e.data.datasets[n].data[r].label!==bh}),e.setActiveElements(i);for(let t of e.getSortedVisibleDatasetMetas())for(let e of t.data){let t=e.$context,{datasetIndex:n,index:r,dataset:a,raw:o}=t;if(o.label===`nullValue`)continue;let s=typeof a.backgroundColor==`function`?a.backgroundColor(t):a.backgroundColor;i.length&&!i.some(e=>e.datasetIndex===n&&e.index===r)?e.options.backgroundColor=Jf(s,.5):e.options.backgroundColor=s}}};function Yh(e,t){return t.length>e.length&&e.every((e,n)=>e===t[n])}let Xh={id:`sunburstLabelsPlugin`,afterDatasetsDraw(e,t,n){if(!n.showValues&&!n.showLabels||e.config.type!==`doughnut`)return;let r=e.ctx;Zh(e,n,r)}};function Zh(e,t,n){let r=t.style,i=r.fontSize||13,a=i+3;for(let o of e._metasets)for(let s=0;s<o._dataset.data.length;s++){let c=o._dataset.data[s];if(c.label===`nullValue`)continue;let l=[t.showLabels?c.label:void 0,t.showValues?t.callback(c.value,`y`):void 0].filter(C),u=o.data[s],{startAngle:d,endAngle:f,innerRadius:p,outerRadius:m,circumference:h}=u,g=u.options.offset/4,_=g*(1-Math.sin(Math.min(Math.PI,h||0)));p+=_,m+=_;let v=(d+f)/2,ee=(p+m)/2,y=(m-p)*.9,te=f-d;if((te>=Math.PI?m:Math.sin(te/2)*p*2)<l.length*a)continue;n.save();let ne={x:Math.cos(v)*g,y:Math.sin(v)*g},re=e.chartArea.left+e.chartArea.width/2+ne.x,ie=e.chartArea.top+e.chartArea.height/2+ne.y;n.translate(re,ie);let ae;v>Math.PI/2?(n.rotate(v-Math.PI),ae=-ee):(ae=ee,n.rotate(v));let oe=u.options.backgroundColor,se=If(oe)>.7?`#666666`:`#FFFFFF`;n.fillStyle=r.textColor||se,n.textAlign=`center`,n.textBaseline=`middle`,n.font=wp(i,r.bold,r.italic);let ce=-((l.length-1)*a)/2;for(let e=0;e<l.length;e++){let t=Hp(n,y,l[e],r,`px`);n.fillText(t,ae,ce+e*a)}n.restore()}}let Qh={id:`waterfallLinesPlugin`,beforeDraw(e,t,n){if(!n.showConnectorLines)return;let r=e._metasets?.[0]?.data;if(!r)return;let i=e.ctx;i.save(),i.setLineDash([3,2]);for(let e=0;e<r.length;e++){let t=r[e];if(t.height===0)continue;let n=eg(r,e);if(!n)break;let a=$h(t),o=$h(n),s=t.$context.raw,c=s[1]-s[0],l=Math.round(c<0?a.bottom-1:a.top),u=Math.round(a.right),d=Math.round(o.left);i.strokeStyle=`#999`,i.beginPath(),i.moveTo(u+1,l+.5),i.lineTo(d,l+.5),i.stroke()}i.restore()}};function $h(e){let t=e.base<e.y;return{left:e.x-e.width/2,right:e.x+e.width/2,bottom:t?e.base+e.height:e.y+e.height,top:t?e.base:e.y}}function eg(e,t){return e.find((e,n)=>n>t&&e.height!==0)}let tg={id:`zoomWindowPlugin`,afterDatasetsDraw:function(e,t,n){if(!n.getLowerBound||!n.getUpperBound)return;let{ctx:r,chartArea:{left:i,right:a,top:o,bottom:s}}=e,c=n.getLowerBound()??i,l=n.getUpperBound()??a;c>l&&([c,l]=[l,c]),c=Math.max(i,c),l=Math.min(a,l),c===i&&--c,l===a&&(l+=1),r.save(),r.fillStyle=`rgba(255,255,255,0.5)`,r.beginPath(),r.rect(i,s,c-i,o-s),r.rect(l,s,a-l,o-s),r.fill(),r.beginPath(),r.strokeStyle=`#bbb`,r.rect(c,s,l-c,o-s),r.stroke(),r.lineWidth=2,r.beginPath(),r.moveTo(c-3,(o+s)/2-7),r.lineTo(c-3,(o+s)/2+7),r.stroke(),r.beginPath(),r.moveTo(l+3,(o+s)/2-7),r.lineTo(l+3,(o+s)/2+7),r.stroke(),r.restore()}};Qr.add(`chartShowValuesPlugin`,{register:e=>e.register(Mm),unregister:e=>e.unregister(Mm)}),Qr.add(`chartMinorGridPlugin`,{register:e=>e.register(Yp),unregister:e=>e.unregister(Yp)}),Qr.add(`waterfallLinesPlugin`,{register:e=>e.register(Qh),unregister:e=>e.unregister(Qh)}),Qr.add(`funnelController`,{register:e=>e.register(Gp()),unregister:e=>e.unregister(Gp())}),Qr.add(`funnelElement`,{register:e=>e.register(Kp()),unregister:e=>e.unregister(Kp())}),Qr.add(`funnelTooltipPositioner`,{register:e=>e.Tooltip.positioners.funnelTooltipPositioner=Jp,unregister:e=>e.Tooltip.positioners.funnelTooltipPositioner=void 0}),Qr.add(`sunburstLabelsPlugin`,{register:e=>e.register(Xh),unregister:e=>e.unregister(Xh)}),Qr.add(`sunburstHoverPlugin`,{register:e=>e.register(Jh),unregister:e=>e.unregister(Jh)}),Qr.add(`chartColorScalePlugin`,{register:e=>e.register(Wp),unregister:e=>e.unregister(Wp)}),Qr.add(`calendarController`,{register:e=>e.register(Ea()),unregister:e=>e.unregister(Ea())}),Qr.add(`zoomWindowPlugin`,{register:e=>e.register(tg),unregister:e=>e.unregister(tg)}),Qr.add(`chartBackgroundPlugin`,{register:e=>e.register(Ta),unregister:e=>e.unregister(Ta)});var ng=class extends O{static template=`o-spreadsheet-ChartJsComponent`;props=(0,t.useProps)({chartId:j.string(),isFullScreen:j.boolean().optional()});canvas=(0,t.signal)(null);chart;currentRuntime;animationStore;currentDevicePixelRatio=window.devicePixelRatio;get chartRuntime(){let e=this.env.model.getters.getChartRuntime(this.props.chartId);if(!(`chartJsConfig`in e))throw Error(`Unsupported chart runtime`);return e}setup(){this.shouldAnimate&&(this.animationStore=k(wa)),(0,t.onMounted)(()=>{ei();let e=this.chartRuntime;this.currentRuntime=e,this.createChart(b(e))}),(0,t.onWillUnmount)(this.unmount.bind(this)),Gi(()=>{let e=this.chartRuntime;e===this.currentRuntime?this.currentDevicePixelRatio!==window.devicePixelRatio&&(this.currentDevicePixelRatio=window.devicePixelRatio,this.updateChartJs(b(this.currentRuntime))):(e.chartJsConfig.type===this.currentRuntime.chartJsConfig.type?this.updateChartJs(b(e)):(this.chart?.destroy(),this.createChart(b(e))),this.currentRuntime=e)})}unmount(){this.chart?.destroy()}get shouldAnimate(){return this.env.model.getters.isDashboard()}createChart(e){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);let t=e.chartJsConfig;if(this.shouldAnimate&&this.animationStore){let e=this.env.model.getters.getChartDefinition(this.props.chartId)?.type;e&&this.animationStore.animationPlayed[this.animationChartId]!==e&&(t=this.enableAnimationInChartData(t),this.animationStore.disableAnimationForChart(this.animationChartId,e))}let n=this.canvas();if(!n)return;let r=n.getContext(`2d`);this.chart=new globalThis.Chart(r,t)}updateChartJs(e){let t=e.chartJsConfig;if(this.shouldAnimate){let e=this.env.model.getters.getChartDefinition(this.props.chartId)?.type;e&&this.hasChartDataChanged()&&this.animationStore&&(t=this.enableAnimationInChartData(t),this.animationStore.disableAnimationForChart(this.animationChartId,e))}t.data&&t.data.datasets?(this.chart.data=t.data,t.options?.plugins?.title&&(this.chart.config.options.plugins.title=t.options.plugins.title)):this.chart.data.datasets=[],this.chart.config.options=t.options,this.chart.update()}hasChartDataChanged(){return!w(this.getChartDataInRuntime(this.currentRuntime),this.getChartDataInRuntime(this.chartRuntime))}enableAnimationInChartData(e){return{...e,options:{...e.options,animation:{animateRotate:!0}}}}getChartDataInRuntime(e){let t=e.chartJsConfig.data;return{labels:t.labels,dataset:t.datasets.map(e=>({data:e.data,label:e.label,tree:e.tree}))}}get animationChartId(){return this.props.isFullScreen?this.props.chartId+`-fullscreen`:this.props.chartId}},rg=class{static commonKeys=[`type`,`title`,`background`,`humanize`,`annotationText`,`annotationLink`]};function ig(e,t,n,r,i){if(!e)return``;if(n===`text`||t?.type!==`number`||e.type!==`number`)return r?Fc(e,i):e.formattedValue;let{value:a,format:o}=e;return n===`progress`?(a=t.value/a,o=`0.0%`):(a=Math.abs(t.value-a),n===`percentage`&&a!==0&&(a/=e.value),n===`percentage`&&(o=`0.0%`),o||(a=Math.round(a*100)/100)),r?Fc({value:a,format:o},i):B(a,{format:o,locale:i})}function ag(e,t,n){return e?t?Fc(e,n):e.formattedValue??String(e.value??``):``}function og(e,t,n,r,i){if(t===`text`||t===`progress`||e?.type!==`number`||n?.type!==`number`)return;let a=n.value-e.value;if(a>0)return r;if(a<0)return i}function sg(e,t,n){if(n===`text`||e?.type!==`number`||t?.type!==`number`)return`neutral`;let r=t.value-e.value;return r>0?`up`:r<0?`down`:`neutral`}function cg(e){return e.keyValue&&!xl.test(e.keyValue)?`InvalidScorecardKeyValue`:`Success`}function lg(e){return e.baseline&&!xl.test(e.baseline)?`InvalidScorecardBaseline`:`Success`}let ug=globalThis.Path2D,dg=ug&&new ug(`M8.6 4.8a.5.5 0 0 1 0 .75l-3.9 3.9a.5 .5 0 0 1 -.75 0l-3.8 -3.9a.5 .5 0 0 1 0 -.75l.4-.4a.5.5 0 0 1 .75 0l2.3 2.4v-5.7c0-.25.25-.5.5-.5h.6c.25 0 .5.25.5.5v5.8l2.3 -2.4a.5.5 0 0 1 .75 0z`),fg=ug&&new ug(`M8.7 5.5a.5.5 0 0 0 0-.75l-3.8-4a.5.5 0 0 0-.75 0l-3.8 4a.5.5 0 0 0 0 .75l.4.4a.5.5 0 0 0 .75 0l2.3-2.4v5.8c0 .25.25.5.5.5h.6c.25 0 .5-.25.5-.5v-5.8l2.2 2.4a.5.5 0 0 0 .75 0z`),pg={sequence:40,allowedDefinitionKeys:[...rg.commonKeys,`keyValue`,`keyDescr`,`baseline`,`baselineMode`,`baselineDescr`,`baselineColorUp`,`baselineColorDown`],fromStrDefinition(e,t,n){let r=Pu(n,t,e.baseline),i=Pu(n,t,e.keyValue);return{...e,baseline:r,keyValue:i}},validateDefinition(e,t){return e.checkValidations(t,cg,lg)},copyInSheetId:e=>e,getDefinitionFromContextCreation(e,t){return{background:e.background,type:`scorecard`,keyValue:e.dataSource?.type===`range`?e.dataSource?.dataSets?.[0]?.dataRange:void 0,title:e.title||{text:``},baselineMode:tt,baselineColorUp:nt,baselineColorDown:rt,baseline:e.auxiliaryRange||``,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},transformDefinition(e,t,{adaptRangeString:n}){let r,i;if(e.baseline){let{changeType:i,range:a}=n(t,e.baseline);i!==`REMOVE`&&(r=a)}if(e.keyValue){let{changeType:r,range:a}=n(t,e.keyValue);r!==`REMOVE`&&(i=a)}return{...e,baseline:r,keyValue:i}},duplicateInDuplicatedSheet(e,t,n){let r=fm(t,n,e.baseline),i=fm(t,n,e.keyValue);return{...e,baseline:r,keyValue:i}},toStrDefinition(e,t,n){return{...e,keyValue:e.keyValue?n.getRangeString(e.keyValue,t):void 0,baseline:e.baseline?n.getRangeString(e.baseline,t):void 0}},getContextCreation(e,t){return{...e,dataSource:{type:`range`,dataSets:e.keyValue?[{dataRange:e.keyValue,dataSetId:`0`}]:[]},auxiliaryRange:e.baseline}},getDefinitionForExcel:()=>void 0,updateRanges(e,t){let n=pm(e.baseline,t),r=pm(e.keyValue,t);return e.baseline===n&&e.keyValue===r?e:{...e,baseline:n,keyValue:r}},getFormulas:()=>[],getRuntime(e,t){let n=``,r,i=e.getLocale();if(t.keyValue){let a={sheetId:t.keyValue.sheetId,col:t.keyValue.zone.left,row:t.keyValue.zone.top};r=e.getEvaluatedCell(a),n=ag(r,t.humanize??!0,i)}let a,o=t.baseline;if(o){let t={sheetId:o.sheetId,col:o.zone.left,row:o.zone.top};a=e.getEvaluatedCell(t)}let{background:s,fontColor:c}=e.getStyleOfSingleCellChart(t.background,t.keyValue),l=ig(a,r,t.baselineMode,t.humanize??!0,i),u=t.baselineMode===`progress`&&bo(l,i)?F(l,i):0,d=t.title;return{title:{...d,text:d.text?e.dynamicTranslate(d.text):``},keyValue:n,keyDescr:t.keyDescr?.text?e.dynamicTranslate(t.keyDescr.text):``,baselineDisplay:l,baselineArrow:sg(a,r,t.baselineMode),baselineColor:og(a,t.baselineMode,r,t.baselineColorUp,t.baselineColorDown),baselineDescr:t.baselineMode!==`progress`&&t.baselineDescr?.text?e.dynamicTranslate(t.baselineDescr.text):``,fontColor:c,background:s,baselineStyle:{...t.baselineMode!==`percentage`&&t.baselineMode!==`progress`&&o?e.getCellComputedStyle({sheetId:o.sheetId,col:o.zone.left,row:o.zone.top}):void 0,fontSize:t.baselineDescr?.fontSize,align:t.baselineDescr?.align},baselineDescrStyle:{textColor:t.baselineDescr?.color,...t.baselineDescr},keyValueStyle:{...t.keyValue?e.getCellComputedStyle({sheetId:t.keyValue.sheetId,col:t.keyValue.zone.left,row:t.keyValue.zone.top}):void 0,fontSize:t.keyDescr?.fontSize,align:t.keyDescr?.align},keyValueDescrStyle:{textColor:t.keyDescr?.color,...t.keyDescr},progressBar:t.baselineMode===`progress`?{value:u,color:u>0?t.baselineColorUp:t.baselineColorDown}:void 0}}};function mg(e,t,n=1){let r=t.getContext(`2d`);if(!r)throw Error(`Unable to retrieve 2D context from canvas`);let i=typeof globalThis.devicePixelRatio==`number`?globalThis.devicePixelRatio:1;t.width=i*e.canvas.width*n,t.height=i*e.canvas.height*n,r.scale(i*n,i*n);let a=e.canvas.width-20;if(r.fillStyle=e.canvas.backgroundColor,r.fillRect(0,0,e.canvas.width,e.canvas.height),e.title){r.font=e.title.style.font,r.fillStyle=e.title.style.color;let t=r.textBaseline;r.textBaseline=`middle`,r.fillText(Bp(r,e.title.text,a-e.title.position.x),e.title.position.x,e.title.position.y),r.textBaseline=t}if(e.baseline&&(r.font=e.baseline.style.font,r.fillStyle=e.baseline.style.color,Vp(r,e.baseline.text,e.baseline.position,e.baseline.style.underline,e.baseline.style.strikethrough,void 0,e.baseline.style.highlightText)),e.baselineArrow&&e.baselineArrow.style.size>0&&ug){r.save(),r.fillStyle=e.baselineArrow.style.highlight?Jf(e.baselineArrow.style.color,Xe):e.baselineArrow.style.color,r.translate(e.baselineArrow.position.x,e.baselineArrow.position.y);let t=e.baselineArrow.style.size/10;switch(r.scale(t,t),e.baselineArrow.direction){case`down`:r.fill(dg);break;case`up`:r.fill(fg);break}r.restore()}if(e.baselineDescr){let t=e.baselineDescr;r.font=t.style.font,r.fillStyle=t.style.color,Vp(r,Bp(r,t.text,a-t.position.x),t.position,void 0,void 0,void 0,e.baseline?.style.highlightText)}if(e.key&&(r.font=e.key.style.font,r.fillStyle=e.key.style.color,Vp(r,Bp(r,e.key.text,a-e.key.position.x),e.key.position,e.key.style.underline,e.key.style.strikethrough,void 0,e.key.style.highlightText)),e.keyDescr){let t=e.keyDescr;r.font=e.keyDescr?.style.font??t.style.font,r.fillStyle=t.style.color,Vp(r,Bp(r,t.text,a-t.position.x),t.position,void 0,void 0,void 0,e.key?.style.highlightText)}if(e.progressBar){if(r.fillStyle=e.progressBar.style.backgroundColor,r.beginPath(),r.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width,e.progressBar.dimension.height,e.progressBar.dimension.height/2),r.fill(),r.fillStyle=e.progressBar.style.color,r.beginPath(),e.progressBar.value>0)r.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width*Math.max(0,Math.min(1,e.progressBar.value)),e.progressBar.dimension.height,e.progressBar.dimension.height/2);else{let t=e.progressBar.dimension.width*Math.max(0,Math.min(1,-e.progressBar.value));r.roundRect(e.progressBar.position.x+e.progressBar.dimension.width-t,e.progressBar.position.y,t,e.progressBar.dimension.height,e.progressBar.dimension.height/2)}r.fill()}}let hg=.05;function gg(e,t){let n=e||``;return t&&n?` `+n:n}function _g({width:e,height:t},n){return new vg({width:e,height:t},n).computeDesign()}var vg=class{runtime;context;width;height;constructor({width:e,height:t},n){if(this.runtime=n,this.width=e,this.height=t,typeof OffscreenCanvas>`u`)throw Error(`OffscreenCanvas is not supported in this environment`);let r=new globalThis.OffscreenCanvas(e,t).getContext(`2d`);if(!r)throw Error(`Unable to create scorecard measurement context`);this.context=r}computeDesign(){let e={canvas:{width:this.width,height:this.height,backgroundColor:this.backgroundColor}},t=this.getTextStyles(),n=0;if(this.title){let r,i;switch({height:n,width:i}=this.getFullTextDimensions(this.title,t.title.font),this.runtime.title.align){case`center`:r=(this.width-i)/2;break;case`right`:r=this.width-i-20;break;default:r=20}e.title={text:this.title,style:t.title,position:{x:r,y:10+n/2}}}let r=t.baselineArrow?.size??0,{height:i,width:a}=this.getTextDimensions(this.baseline,t.baselineValue.font);this.baseline||(i=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).height);let o=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).width,s;switch(this.runtime.baselineStyle?.align){case`right`:s=this.width-20-o-a;break;case`left`:s=20+r;break;default:s=(this.width-a-o+r)/2}if(this.baseline&&(e.baseline={text:this.baseline,style:t.baselineValue,position:{x:s,y:this.keyValue?this.height*(1-hg*(this.runtime.progressBar?1:2)):this.height-(this.height-n-i)/2-10}},t.baselineArrow&&!this.runtime.progressBar&&(e.baselineArrow={direction:this.baselineArrow,style:t.baselineArrow,position:{x:e.baseline.position.x-r,y:e.baseline.position.y-(i+r)/2}})),e.baseline&&this.baselineDescr){let n={x:e.baseline.position.x+a,y:e.baseline.position.y};e.baselineDescr={text:this.baselineDescr,style:t.baselineDescr,position:n}}let c=0;this.runtime.progressBar&&(c=this.height*.05,e.progressBar={position:{x:40,y:this.height*(1-2*hg)-i-c},dimension:{height:c,width:this.width-80},value:this.runtime.progressBar.value,style:{color:this.runtime.progressBar.color,backgroundColor:this.secondaryFontColor}});let{width:l,height:u}=this.getFullTextDimensions(this.keyValue,t.keyValue.font),d=this.getTextDimensions(this.keyDescr,t.keyDescr.font).width,f;switch(this.runtime.keyValueStyle?.align){case`right`:f=this.width-20-d-l;break;case`left`:f=20;break;default:f=(this.width-l-d)/2}if(this.keyValue&&(e.key={text:this.keyValue,style:t.keyValue,position:{x:Math.max(20,f),y:this.height*(.5-hg*2)+10/2+(n+u/2)/2}}),e.key&&this.keyDescr){let n={x:e.key.position.x+l,y:e.key.position.y};e.keyDescr={text:this.keyDescr,style:t.keyDescr,position:n}}return e}get title(){return this.runtime.title.text??``}get keyValue(){return this.runtime.keyValue}get keyDescr(){return gg(this.runtime.keyDescr,this.keyValue)}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){return gg(this.runtime.baselineDescr,this.baseline)}get baselineArrow(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get secondaryFontColor(){return ym(this.backgroundColor)}getTextDimensions(e,t){this.context.font=t;let n=this.context.measureText(e);return{width:n.width,height:n.actualBoundingBoxAscent+n.actualBoundingBoxDescent}}getFullTextDimensions(e,t){this.context.font=t;let n=this.context.measureText(e);return{width:n.width,height:n.fontBoundingBoxAscent+n.fontBoundingBoxDescent}}getTextStyles(){let e=this.runtime.keyValueStyle?.fontSize??32,t=Math.floor(.9*e),n=this.runtime.baselineStyle?.fontSize??16,r=Math.floor(.9*n);return this.runtime.progressBar&&(n/=1.5),{title:{font:wp(this.runtime.title.fontSize??14,this.runtime.title.bold,this.runtime.title.italic),color:this.runtime.title.color??this.secondaryFontColor},keyValue:{color:this.runtime.keyValueStyle?.textColor||this.runtime.fontColor,font:wp(e,this.runtime.keyValueStyle?.bold,this.runtime.keyValueStyle?.italic),strikethrough:this.runtime.keyValueStyle?.strikethrough,underline:this.runtime.keyValueStyle?.underline,highlightText:this.runtime.keyHighlight},keyDescr:{color:this.runtime.keyValueDescrStyle?.textColor||this.runtime.fontColor,font:wp(t,this.runtime.keyValueDescrStyle?.bold,this.runtime.keyValueDescrStyle?.italic),strikethrough:this.runtime.keyValueDescrStyle?.strikethrough,underline:this.runtime.keyValueDescrStyle?.underline,highlightText:this.runtime.keyHighlight},baselineValue:{font:wp(n,this.runtime.baselineStyle?.bold,this.runtime.baselineStyle?.italic),strikethrough:this.runtime.baselineStyle?.strikethrough,underline:this.runtime.baselineStyle?.underline,color:this.runtime.baselineColor||this.runtime.baselineStyle?.textColor||this.secondaryFontColor,highlightText:this.runtime.baselineHighlight},baselineDescr:{font:wp(r,this.runtime.baselineDescrStyle?.bold,this.runtime.baselineDescrStyle?.italic),strikethrough:this.runtime.baselineDescrStyle?.strikethrough,underline:this.runtime.baselineDescrStyle?.underline,color:this.runtime.baselineDescrStyle?.textColor??this.secondaryFontColor,highlightText:this.runtime.baselineHighlight},baselineArrow:this.baselineArrow===`neutral`||this.runtime.progressBar?void 0:{size:this.keyValue?.8*n:0,color:this.runtime.baselineColor||this.runtime.baselineStyle?.textColor||this.secondaryFontColor,highlight:this.runtime.baselineHighlight}}}};function yg(e){return 20+120*Math.exp(-.035*(e-1))}var bg=class{top;bottom;left;right;offsetX;offsetY;canScrollVertically;canScrollHorizontally;viewportWidth;viewportHeight;boundaryLeftX;boundaryTopY;getters;sheetId;boundaries;getFooterSize;constructor(e){if(e.sizeInGrid.width<0||e.sizeInGrid.height<0)throw Error(`Viewport size cannot be negative`);this.getters=e.getters,this.sheetId=e.sheetId,this.boundaries=e.boundaries,this.viewportWidth=e.sizeInGrid.height&&e.sizeInGrid.width,this.viewportHeight=e.sizeInGrid.width&&e.sizeInGrid.height,this.top=e.boundaries.top,this.bottom=e.boundaries.bottom,this.left=e.boundaries.left,this.right=e.boundaries.right,this.offsetX=e.offsets.x,this.offsetY=e.offsets.y,this.canScrollVertically=e.canScrollVertically,this.canScrollHorizontally=e.canScrollHorizontally,this.getFooterSize=e.getFooterSize,this.boundaryLeftX=this.getters.getColDimensions(this.sheetId,this.boundaries.left).start,this.boundaryTopY=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}=this.getters.getColDimensions(this.sheetId,e),{end:r}=this.getters.getRowDimensions(this.sheetId,t),i=n-this.boundaryLeftX;this.canScrollHorizontally&&(i=Math.max(i,this.viewportWidth));let a=r-this.boundaryTopY;return this.canScrollVertically&&(a=Math.max(a,this.viewportHeight),r+this.getFooterSize()>a&&(a+=this.getFooterSize())),{width:i,height:a}}getColIndex(e){return this.searchHeaderIndex(`COL`,e+this.snapCorrection.x,this.left)}getRowIndex(e){return this.searchHeaderIndex(`ROW`,e+this.snapCorrection.y,this.top)}repositionViewport(e){let t=this.sheetId,n=this.getters.getMainCellPosition({sheetId:t,...e}),{col:r,row:i}=this.getters.getNextVisibleCellPosition(n);fr(r,this.boundaries.top,this.boundaries)&&this.repositionViewportX(r),fr(this.boundaries.left,i,this.boundaries)&&this.repositionViewportY(i)}repositionViewportX(e){let t=this.sheetId,{start:n,end:r}=this.getters.getColDimensions(t,e);this.offsetX+this.viewportWidth+this.boundaryLeftX<r?this.offsetX=r-this.viewportWidth-this.boundaryLeftX:this.offsetX+this.boundaryLeftX>n&&(this.offsetX=n-this.boundaryLeftX),this.adjustViewportZoneX()}repositionViewportY(e){let t=this.sheetId,{start:n,end:r}=this.getters.getRowDimensions(t,e);this.offsetY+this.viewportHeight+this.boundaryTopY<r?this.offsetY=r-this.viewportHeight-this.boundaryTopY:this.offsetY+this.boundaryTopY>n&&(this.offsetY=n-this.boundaryTopY),this.adjustViewportZoneY()}willNewOffsetScrollViewport(e,t){return this.canScrollHorizontally&&this.offsetX!==e||this.canScrollVertically&&this.offsetY!==t}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}isZoneVisible(e){return cr(e,this)!==void 0}getVisibleRect(e){let t=cr(e,this),n=this.snapCorrection.x,r=this.snapCorrection.y;if(t)return{x:this.getters.getColRowOffset(`COL`,this.left,t.left,this.sheetId)-(this.left===t.left?0:n),y:this.getters.getColRowOffset(`ROW`,this.top,t.top,this.sheetId)-(this.top===t.top?0:r),width:Math.min(this.getters.getColRowOffset(`COL`,t.left,t.right+1,this.sheetId)-(this.left===t.left?n:0),this.viewportWidth),height:Math.min(this.getters.getColRowOffset(`ROW`,t.top,t.bottom+1,this.sheetId)-(this.top===t.top?r:0),this.viewportHeight)}}getFullRect(e){let t=cr(e,this.boundaries),n=this.snapCorrection.x,r=this.snapCorrection.y;if(t){let t=this.getters.getColRowOffset(`COL`,this.left,e.left,this.sheetId),i=this.getters.getColRowOffset(`ROW`,this.top,e.top,this.sheetId),a=this.getters.getColRowOffset(`COL`,e.left,e.right+1,this.sheetId),o=this.getters.getColRowOffset(`ROW`,e.top,e.bottom+1,this.sheetId);return{x:t-n,y:i-r,width:a,height:o}}}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,this.sheetId),c=this.getters.isHeaderHidden(r,e,i)?0: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}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){let{width:e}=this.getMaxSize();this.viewportWidth+this.offsetX>e&&(this.offsetX=Math.max(0,e-this.viewportWidth))}this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){let{height:e}=this.getMaxSize();this.viewportHeight+this.offsetY>e&&(this.offsetY=Math.max(0,e-this.viewportHeight))}this.adjustViewportZoneY()}adjustViewportZoneX(){this.left=this.searchHeaderIndex(`COL`,this.offsetX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex(`COL`,Math.max(this.viewportWidth+this.snapCorrection.x-.1),this.left)),this.viewportWidth&&(this.left===-1&&(this.left=this.boundaries.left),this.right===-1&&(this.right=this.boundaries.right))}adjustViewportZoneY(){this.top=this.searchHeaderIndex(`ROW`,this.offsetY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex(`ROW`,Math.max(this.viewportHeight+this.snapCorrection.y-.1,0),this.top)),this.viewportHeight&&(this.top===-1&&(this.top=this.boundaries.top),this.bottom===-1&&(this.bottom=this.boundaries.bottom))}get snapCorrection(){return{x:Math.abs(this.offsetX-this.getters.getColRowOffset(`COL`,this.boundaries.left,Math.max(0,this.left),this.sheetId)),y:Math.abs(this.offsetY-this.getters.getColRowOffset(`ROW`,this.boundaries.top,Math.max(0,this.top),this.sheetId))}}},xg=class{getters;viewports={};gridOffsetX=0;gridOffsetY=0;paneDivision;sheetViewWidth;sheetViewHeight;zoomLevel;getFooterSize;zoneToDisplay;constructor(e){this.getters=e.getters,this.paneDivision=e.paneDivision,this.sheetViewWidth=e.sheetViewWidth,this.sheetViewHeight=e.sheetViewHeight,this.zoomLevel=e.zoomLevel,this.getFooterSize=e.getFooterSize,this.zoneToDisplay=e.zoneToDisplay}changeViewportArgs(e){for(let t in e)this[t]=e[t];for(let e of this.getters.getSheetIds())this.resetViewports(e)}getColIndex(e,t){return Math.max(...this.getPositionedViewports(e).map(({viewport:e,viewportX:n})=>t<n||t>n+e.viewportWidth?-1:e.getColIndex(t-n)))}getRowIndex(e,t){return Math.max(...this.getPositionedViewports(e).map(({viewport:e,viewportY:n})=>t<n||t>n+e.viewportHeight?-1:e.getRowIndex(t-n)))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getGridOffset(){return{x:this.gridOffsetX,y:this.gridOffsetY}}getSheetScrollInfo(e){let t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getSheetViewVisibleCols(e){let t=this.getSubViewports(e).map(e=>e);return[...new Set(t.map(e=>S(e.left,e.right+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`COL`,t))}getSheetViewVisibleRows(e){let t=this.getSubViewports(e).map(e=>e);return[...new Set(t.map(e=>S(e.top,e.bottom+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`ROW`,t))}getVisibleCellPositions(e){let t=this.getSheetViewVisibleCols(e),n=this.getSheetViewVisibleRows(e),r=[];for(let i of t)for(let t of n){let n={sheetId:e,col:i,row:t},a=this.getters.getMainCellPosition(n);a.row!==t||a.col!==i||r.push(n)}return r}getMainViewportRect(e){let{width:t,height:n}=this.getMainInternalViewport(e).getMaxSize(),{paneWidth:r,paneHeight:i}=this.getPanesDimensions(e);return{x:r,y:i,width:t,height:n}}getMaximumSheetOffset(e){let{width:t,height:n}=this.getMainViewportRect(e),r=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-r.viewportWidth),maxOffsetY:Math.max(0,n-r.viewportHeight)}}getColRowOffsetInViewport(e,t,n,r){if(r<n)return-this.getColRowOffsetInViewport(e,t,r,n);let i=t===`COL`?this.getSheetViewVisibleCols(e):this.getSheetViewVisibleRows(e),a=i.findIndex(e=>n>=e),o=i.findIndex(e=>r<=e);o=o===-1?i.length:o;let s=i.slice(a,o),c=0;for(let n of s)c+=this.getters.getHeaderSize(e,t,n);return c*this.zoomLevel}isVisibleInViewport({sheetId:e,col:t,row:n}){return this.getSubViewports(e).some(e=>e.isVisible(t,n))}isZoneVisibleInViewport(e,t){return this.getSubViewports(e).some(e=>e.isZoneVisible(t))}getScrollBarWidth(){return 15/this.zoomLevel}getEdgeScrollCol(e,t,n,r){let i=!1,a=0,o=0,{xSplit:s}=this.getPaneDivisions(e),{width:c}=this.getSheetViewDimension(),{x:l}=this.getMainViewportCoordinates(e),u=this.getSheetScrollInfo(e).scrollX;return t>c?(i=!0,o=yg(t-c),a=1):t<l&&r>=l&&u>0?(i=!0,o=yg(l-t),a=-1):s&&n<l&&t>l&&(i=!0,o=yg(t),a=`reset`),{canEdgeScroll:i,direction:a,delay:o}}getEdgeScrollRow(e,t,n,r){let i=!1,a=0,o=0,{ySplit:s}=this.getPaneDivisions(e),{height:c}=this.getSheetViewDimension(),{y:l}=this.getMainViewportCoordinates(e),u=this.getSheetScrollInfo(e).scrollY;return t>c?(i=!0,o=yg(t-c),a=1):t<l&&r>=l&&u>0?(i=!0,o=yg(l-t),a=-1):s&&n<l&&t>l&&(i=!0,o=yg(t),a=`reset`),{canEdgeScroll:i,direction:a,delay:o}}getVisibleRect(e,t){let n=this.getVisibleRectWithoutHeaders(e,t);return{...n,x:n.x+this.gridOffsetX,y:n.y+this.gridOffsetY}}getVisibleRectWithZoom(e,t){let n=this.getViewportZoomLevel(),r=this.getVisibleRectWithoutHeaders(e,t);return r.width*=n,r.height*=n,r.x=r.x*n+this.gridOffsetX*n,r.y=r.y*n+this.gridOffsetY*n,r}getVisibleRectWithoutHeaders(e,t){return this.mapViewportsToRect(e,e=>e.getVisibleRect(t))}getRect(e,t){let n=this.mapViewportsToRect(e,e=>e.getFullRect(t));return{...n,x:n.x+this.gridOffsetX,y:n.y+this.gridOffsetY}}getRectWithoutHeaders(e,t){return this.mapViewportsToRect(e,e=>e.getFullRect(t))}getMainViewportCoordinates(e){let{paneWidth:t,paneHeight:n}=this.getPanesDimensions(e);return{x:t,y:n}}getColDimensionsInViewport(e,t){let{top:n}=this.getMainInternalViewport(e),r={left:t,right:t,top:n,bottom:n},{x:i,width:a}=this.getVisibleRect(e,r),o=i-this.gridOffsetX;return{start:o,size:a,end:o+a}}getRowDimensionsInViewport(e,t){let{left:n}=this.getMainInternalViewport(e),r={left:0,right:n,top:t,bottom:t},{y:i,height:a}=this.getVisibleRect(e,r),o=i-this.gridOffsetY;return{start:o,size:a,end:o+a}}getAllSheetViewportsZonesAndRect(e){return this.getPositionedViewports(e).map(({viewport:e,viewportX:t,viewportY:n})=>({zone:e,rect:{x:t+this.gridOffsetX,y:n+this.gridOffsetY,...e.getMaxSize()}}))}getViewportZoomLevel(){return this.zoomLevel}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getPanesDimensions(e){let t=this.getViewportZones(e),n=0;if(t.bottomLeft){let r=this.getters.getColDimensions(e,t.bottomLeft.left).start;n=this.getters.getColDimensions(e,t.bottomLeft.right).end-r}let r=0;if(t.topRight){let n=this.getters.getRowDimensions(e,t.topRight.top).start;r=this.getters.getRowDimensions(e,t.topRight.bottom).end-n}return{paneWidth:n,paneHeight:r}}getPositionedViewports(e){this.ensureMainViewportExist(e);let t=this.viewports[e],{paneWidth:n,paneHeight:r}=this.getPanesDimensions(e),i=[];return t.topLeft&&i.push({viewport:t.topLeft,viewportX:0,viewportY:0}),t.topRight&&i.push({viewport:t.topRight,viewportX:n,viewportY:0}),t.bottomLeft&&i.push({viewport:t.bottomLeft,viewportX:0,viewportY:r}),i.push({viewport:t.bottomRight,viewportX:n,viewportY:r}),i}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(C)}checkPositiveDimension(e){return!(e.width<0||e.height<0)}checkValuesAreDifferent(e){let{height:t,width:n}=this.getSheetViewDimension();return!(e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===n&&e.height===t)}checkScrollingDirection(e,{offsetX:t,offsetY:n}){let r=this.getMainInternalViewport(e);return!(!r.canScrollHorizontally&&t>0||!r.canScrollVertically&&n>0)}checkIfViewportsWillChange(e,{offsetX:t,offsetY:n}){let{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset(e);return!!this.getSubViewports(e).some(e=>e.willNewOffsetScrollViewport(x(t,0,r),x(n,0,i)))}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){this.sheetViewHeight=e.height,this.sheetViewWidth=e.width,this.gridOffsetX=e.gridOffsetX||0,this.gridOffsetY=e.gridOffsetY||0,this.recomputeViewports()}recomputeViewports(){for(let e of this.getters.getSheetIds())this.resetViewports(e)}setSheetViewOffset(e,t,n){let{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset(e);this.getSubViewports(e).forEach(e=>e.setViewportOffset(x(t,0,r),x(n,0,i)))}getViewportOffset(e){return{x:this.viewports[e]?.bottomRight.offsetX||0,y:this.viewports[e]?.bottomRight.offsetY||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;let{paneWidth:t,paneHeight:n}=this.getPanesDimensions(e),r=Math.min(t,this.sheetViewWidth),i=Math.min(n,this.sheetViewHeight),a=Math.max(this.sheetViewWidth-t,0),o=Math.max(this.sheetViewHeight-n,0),{xRatio:s,yRatio:c}=this.getFrozenSheetViewRatio(e),l=s<1,u=c<1,d=this.getViewportOffset(e),f={},p=this.getViewportZones(e),m=p.topLeft;m&&(f.topLeft=new bg({getters:this.getters,sheetId:e,boundaries:m,sizeInGrid:{width:r,height:i},canScrollHorizontally:!1,canScrollVertically:!1,offsets:{x:0,y:0},getFooterSize:()=>0}));let h=p.topRight;h&&(f.topRight=new bg({getters:this.getters,sheetId:e,boundaries:h,sizeInGrid:{width:a,height:i},canScrollHorizontally:l,canScrollVertically:!1,offsets:{x:l?d.x:0,y:0},getFooterSize:()=>0}));let g=p.bottomLeft;g&&(f.bottomLeft=new bg({getters:this.getters,sheetId:e,boundaries:g,sizeInGrid:{width:r,height:o},canScrollHorizontally:!1,canScrollVertically:u,offsets:{x:0,y:u?d.y:0},getFooterSize:this.getFooterSize}));let _=p.bottomRight;f.bottomRight=new bg({getters:this.getters,sheetId:e,boundaries:_,sizeInGrid:{width:a,height:o},canScrollHorizontally:l,canScrollVertically:u,offsets:{x:l?d.x:0,y:u?d.y:0},getFooterSize:this.getFooterSize}),this.viewports[e]=f}reorganizeViewportZones(e,t){let n=Object.values(t).filter(e=>e!==void 0);if(n.length===1)return{bottomRight:n[0]};if(n.length===4)return t;if(n.length===2){if(t.bottomRight&&(t.topRight||t.bottomLeft))return t;let{topLeft:e,topRight:n,bottomLeft:r}=t;if(e&&n)return{bottomLeft:e,bottomRight:n};if(e&&r)return{topRight:e,bottomRight:r}}throw Error(`ViewportCollection: Malformed viewports for ${e}`)}getViewportZones(e){let{xSplit:t,ySplit:n}=this.getPaneDivisions(e),r=this.getters.getNumberCols(e),i=this.getters.getNumberRows(e),a=this.zoneToDisplay?cr(this.zoneToDisplay,this.getters.getSheetZone(e)):void 0,o={};if(t&&n){let e={left:0,right:t-1,top:0,bottom:n-1};o.topLeft=a?cr(e,a):e}if(n){let e={left:t,right:r-1,top:0,bottom:n-1};o.topRight=a?cr(e,a):e}if(t){let e={left:0,right:t-1,top:n,bottom:i-1};o.bottomLeft=a?cr(e,a):e}let s={left:t,right:r-1,top:n,bottom:i-1};return o.bottomRight=a?cr(s,a):s,this.reorganizeViewportZones(e,o)}refreshViewport(e,t){this.getSubViewports(e).forEach(e=>{e.adjustViewportZone(),e.repositionViewport(t)})}getColIndexLeftOfMainViewport(e,t){if(t>=0)return-1;let n=this.getMainViewport(e).left,r=-this.getSheetScrollInfo(e).scrollX-this.getters.getColRowOffset(`COL`,n,0,e);for(;t<r;n--)r-=this.getters.getColSize(e,n-1);return Math.max(n,0)}getRowIndexTopOfMainViewport(e,t){if(t>=0)return-1;let n=this.getMainViewport(e).top,r=-this.getSheetScrollInfo(e).scrollY-this.getters.getColRowOffset(`ROW`,n,0,e);for(;t<r;n--)r-=this.getters.getRowSize(e,n-1);return Math.max(n,0)}getVisibleFigures(e){let t=[],n=this.getters.getFigures(e),{scrollX:r,scrollY:i}=this.getSheetScrollInfo(e),{x:a,y:o}=this.getMainViewportCoordinates(e),{width:s,height:c}=this.getSheetViewDimensionWithHeaders();for(let l of n){let n=this.getFigureUI(e,l),{x:u,y:d}=n;u>=a&&(u+l.width<r+a||u>s+r+a)||d>=o&&(d+l.height<i+o||d>c+i+o)||t.push(n)}return t}getFigureUI(e,t){let n=t.offset.x+this.getters.getColDimensions(e,t.col).start,r=t.offset.y+this.getters.getRowDimensions(e,t.row).start;return{...t,x:n,y:r}}getPositionAnchorOffset(e,t){let{scrollX:n,scrollY:r}=this.getSheetScrollInfo(e),i=t.x-n,a=t.y-r,o=i>=0?this.getColIndex(e,i):this.getColIndexLeftOfMainViewport(e,i);o<0&&(o=this.getMainInternalViewport(e).searchHeaderIndex(`COL`,i));let s=a>=0?this.getRowIndex(e,a):this.getRowIndexTopOfMainViewport(e,a);s<0&&(s=this.getMainInternalViewport(e).searchHeaderIndex(`ROW`,a));let{x:c,y:l}=this.getRect(e,E({col:o,row:s}));return{col:o,row:s,offset:{x:Math.max(i-c+this.gridOffsetX,0),y:Math.max(a-l+this.gridOffsetY,0)}}}isPixelPositionVisible(e,t){let{scrollX:n,scrollY:r}=this.getSheetScrollInfo(e),{x:i,y:a}=this.getMainViewportCoordinates(e),{width:o,height:s}=this.getSheetViewDimension();return!(t.x>=i&&(t.x<i+n||t.x>o+n+i)||t.y>=a&&(t.y<a+r||t.y>s+r+a))}getFrozenSheetViewRatio(e){let{paneWidth:t,paneHeight:n}=this.getPanesDimensions(e),r=this.sheetViewWidth+this.gridOffsetX,i=this.sheetViewHeight+this.gridOffsetY;return{xRatio:t/r,yRatio:n/i}}mapViewportsToRect(e,t){let n=1/0,r=1/0,i=0,a=0,o=!1;for(let s of this.getPositionedViewports(e)){let e=t(s.viewport);e&&(e.x+=s.viewportX,e.y+=s.viewportY,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}}getGridOffsetX(){return this.gridOffsetX}getGridOffsetY(){return this.gridOffsetY}getZoomLevel(){return this.zoomLevel}setZoomLevel(e){this.zoomLevel=e}getPaneDivisions(e){return this.paneDivision[e]||{xSplit:0,ySplit:0}}setPaneDivision(e,t){this.paneDivision[e]=t}},H=class extends Yr{mutators=[`setViewportOffset`,`resizeSheetView`,`setZoom`,`shiftViewportDown`,`shiftViewportUp`,`scrollToCell`,`setDisplayedSheetId`,`setViewportArgs`,`rebuildViewports`];getHeaderDimensionsCallback=this.getters.getHeaderDimensions;getFooterSizeCallback=this.getFooterSize.bind(this);zoneToDisplay=void 0;viewports=new xg({getters:this.buildViewportGetters(this.getHeaderDimensionsCallback),paneDivision:this.getPaneDivisions(),sheetViewHeight:ct(),sheetViewWidth:ct(),zoomLevel:1,getFooterSize:this.getFooterSizeCallback});sheetsWithDirtyViewports=new Set;shouldRepositionViewports=!1;displayedSheetId=this.model.getters.getActiveSheetId();constructor(e){super(e),this.model.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.onDispose(()=>{this.model.selection.unobserve(this)}),this.viewports.resetViewports(this.displayedSheetId)}handleEvent(e){let t=this.getters.getActiveSheetId();if(e.options.scrollIntoView){let n=e.previousAnchor.zone,r=e.anchor.zone,i=e.mode===`updateAnchor`,a=lr(n,r),{col:o,row:s}=i&&a?e.anchor.cell:Cr(n,r);if(i&&!a){let{top:e,bottom:i,left:a,right:c}=this.viewports.getMainInternalViewport(t);n.left===r.left&&n.right===r.right&&(o=a>o||o>c?a:o),n.top===r.top&&n.bottom===r.bottom&&(s=e>s||s>i?e:s)}o=Math.min(o,this.getters.getNumberCols(t)-1),s=Math.min(s,this.getters.getNumberRows(t)-1),this.sheetsWithDirtyViewports.has(t)||this.viewports.refreshViewport(t,{col:o,row:s})}}handle(e){if(Id.has(e.type))for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);switch(e.type){case`UNDO`:case`REDO`:this.viewports.cleanViewports();for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e),this.syncPaneDivision(e);this.shouldRepositionViewports=!this.getters.getSelectedFigureIds().length;break;case`UNFREEZE_ROWS`:case`UNFREEZE_COLUMNS`:case`FREEZE_COLUMNS`:case`FREEZE_ROWS`:case`UNFREEZE_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:case`ADD_COLUMNS_ROWS`:this.sheetsWithDirtyViewports.add(e.sheetId),this.syncPaneDivision(e.sheetId);break;case`DUPLICATE_SHEET`:this.sheetsWithDirtyViewports.add(e.sheetIdTo),this.syncPaneDivision(e.sheetIdTo);break;case`REMOVE_TABLE`:case`UPDATE_TABLE`:case`UPDATE_FILTER`:case`RESIZE_COLUMNS_ROWS`:case`HIDE_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`:case`SET_FORMATTING`:for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);break;case`DELETE_SHEET`:this.viewports.cleanViewports(),this.sheetsWithDirtyViewports.delete(e.sheetId);break}}finalize(){for(let e of this.sheetsWithDirtyViewports)if(this.viewports.resetViewports(e),this.shouldRepositionViewports){let t=this.getters.getSheetPosition(e);this.viewports.getSubViewports(e).forEach(e=>{e.repositionViewport(t)})}this.sheetsWithDirtyViewports=new Set,this.shouldRepositionViewports=!1,this.setViewports()}setViewports(){let e=this.getters.getSheetIds();for(let t of e)this.viewports.viewports[t]?.bottomRight||this.viewports.resetViewports(t)}syncPaneDivision(e){this.viewports.setPaneDivision(e,this.getters.getPaneDivisions(e))}setDisplayedSheetId(e){this.displayedSheetId=e,this.viewports.resetViewports(e)}setViewportOffset(e){let t=this.displayedSheetId;if(!this.viewports.checkScrollingDirection(t,e)||!this.viewports.checkIfViewportsWillChange(t,e))return`noStateChange`;this.viewports.setSheetViewOffset(t,e.offsetX,e.offsetY)}resizeSheetView(e){if(!this.viewports.checkValuesAreDifferent(e)||!this.viewports.checkPositiveDimension(e))return`noStateChange`;this.viewports.resizeSheetView(e)}setZoom(e){if(e>2||e<.5||e===this.viewports.getZoomLevel())return`noStateChange`;this.viewports.setZoomLevel(e)}shiftViewportDown(){let e=this.displayedSheetId,{top:t,viewportHeight:n,boundaryTopY:r}=this.viewports.getMainInternalViewport(e),i=this.getters.getRowDimensions(e,t);this.shiftVertically(i.start+n-r)}shiftViewportUp(){let e=this.displayedSheetId,{top:t,viewportHeight:n,boundaryTopY:r}=this.viewports.getMainInternalViewport(e),i=this.getters.getRowDimensions(e,t);this.shiftVertically(i.end-r-n)}scrollToCell(e,t,n){this.viewports.refreshViewport(e,{col:t,row:n})}get sheetViewDimensionWithHeaders(){return this.viewports.getSheetViewDimensionWithHeaders()}get sheetViewDimension(){return this.viewports.getSheetViewDimension()}get gridOffset(){return this.viewports.getGridOffset()}get activeMainViewport(){return this.viewports.getMainViewport(this.displayedSheetId)}get activeSheetScrollInfo(){return this.viewports.getSheetScrollInfo(this.displayedSheetId)}get visibleCols(){return this.viewports.getSheetViewVisibleCols(this.displayedSheetId)}get visibleRows(){return this.viewports.getSheetViewVisibleRows(this.displayedSheetId)}get visibleCellPositions(){return this.viewports.getVisibleCellPositions(this.displayedSheetId)}get mainViewportRect(){return this.viewports.getMainViewportRect(this.displayedSheetId)}get maximumSheetOffset(){return this.viewports.getMaximumSheetOffset(this.displayedSheetId)}get scrollBarWidth(){return 15/this.viewports.getZoomLevel()}get mainViewportCoordinates(){return this.viewports.getMainViewportCoordinates(this.displayedSheetId)}get zoomLevel(){return this.viewports.getZoomLevel()}get visibleFigures(){return this.viewports.getVisibleFigures(this.displayedSheetId)}shiftVertically(e){let t=this.displayedSheetId,{top:n}=this.viewports.getMainInternalViewport(t),{scrollX:r}=this.activeSheetScrollInfo;this.viewports.setSheetViewOffset(t,r,e);let{anchor:i}=this.getters.getSelection();if(i.cell.row>=this.getters.getPaneDivisions(t).ySplit){let e=this.viewports.getMainInternalViewport(t).top-n;this.model.selection.selectCell(i.cell.col,i.cell.row+e)}}getPaneDivisions(){let e={};for(let t of this.getters.getSheetIds())e[t]=this.getters.getPaneDivisions(t);return e}getFooterSize(){return this.getters.isReadonly()?0:46}setViewportArgs(e){let t=!1;e.getHeaderDimensions&&(t=!0,this.getHeaderDimensionsCallback=e.getHeaderDimensions),e.getFooterSize&&(t=!0,this.getFooterSizeCallback=e.getFooterSize),e.zoneToDisplay&&!w(e.zoneToDisplay,this.zoneToDisplay)&&(t=!0,this.zoneToDisplay=e.zoneToDisplay),t&&this.rebuildViewports()}rebuildViewports(){this.viewports.changeViewportArgs({getters:this.buildViewportGetters(this.getHeaderDimensionsCallback),paneDivision:this.getPaneDivisions(),sheetViewHeight:this.viewports.getSheetViewDimension().height,sheetViewWidth:this.viewports.getSheetViewDimension().width,zoomLevel:this.viewports.getZoomLevel(),getFooterSize:this.getFooterSizeCallback,zoneToDisplay:this.zoneToDisplay})}buildViewportGetters(e){return{findLastVisibleColRowIndex:this.getters.findLastVisibleColRowIndex,isReadonly:this.getters.isReadonly,getMainCellPosition:this.getters.getMainCellPosition,getNextVisibleCellPosition:this.getters.getNextVisibleCellPosition,isColHidden:this.getters.isColHidden,isRowHidden:this.getters.isRowHidden,isHeaderHidden:this.getters.isHeaderHidden,getNumberHeaders:this.getters.getNumberHeaders,getSheetIds:this.getters.getSheetIds,tryGetSheet:this.getters.tryGetSheet,getNumberCols:this.getters.getNumberCols,getNumberRows:this.getters.getNumberRows,getSheetZone:this.getters.getSheetZone,getFigures:this.getters.getFigures,getColDimensions:(t,n)=>e(t,`COL`,n),getRowDimensions:(t,n)=>e(t,`ROW`,n),getHeaderSize:(t,n,r)=>n===`COL`?e(t,`COL`,r).size:e(t,`ROW`,r).size,getColSize:(t,n)=>e(t,`COL`,n).size,getRowSize:(t,n)=>e(t,`ROW`,n).size,getColRowOffset:(t,n,r,i)=>e(i,t,r).start-e(i,t,n).start}}};function Sg(e,t,n){let r=e.getStore(H).zoomLevel;if(n===void 0&&(n=Tg(t,r)),!n)return Cg(t);let i=t.clientX-n.x,a=t.clientY-n.y,o=i/r,s=a/r;return{ev:t,clientX:t.clientX-i+o,clientY:t.clientY-a+s,offsetX:o,offsetY:s}}function Cg(e){return{ev:e,clientX:e.clientX,clientY:e.clientY,offsetX:e.offsetX,offsetY:e.offsetY}}function wg(e,t){return{height:t.height*e,width:t.width*e,x:t.x*e,y:t.y*e}}function Tg(e,t){let n=e.target;return!n||!(`classList`in n)||!(n instanceof Element)?null:ee(n,t)}var Eg=class extends O{static template=`o-spreadsheet-ScorecardChart`;props=(0,t.useProps)({chartId:j.string(),isFullScreen:j.boolean().optional()});canvas=(0,t.signal)(null);viewStore;get runtime(){return this.env.model.getters.getChartRuntime(this.props.chartId)}get title(){let e=this.env.model.getters.getChartDefinition(this.props.chartId).title.text;return e?this.env.model.getters.dynamicTranslate(e):``}setup(){this.viewStore=k(H),Gi(this.createChart.bind(this),()=>{let e=this.canvas();if(!e)return[];let t=e.getBoundingClientRect();return[t.width,t.height,this.runtime,e,window.devicePixelRatio]});let e=new ResizeObserver(()=>this.createChart());(0,t.onMounted)(()=>{let t=this.canvas();t&&e.observe(t)}),(0,t.onWillUnmount)(()=>e.disconnect())}config(e,t){return _g(wg(1/t,e),this.runtime)}createChart(){let e=this.canvas();if(!e)return;let t=this.viewStore.zoomLevel;mg(this.config(e.getBoundingClientRect(),t),e,t)}};let Dg=new D;function Og(e,t,n){let r=e.model.getters.getFigure(t,n);if(!r)throw Error(`Could not find figure with id ${n} in sheet ${t}`);let i=e.model.getters.getFigureUI(t,r);return e.getStore(H).viewports.getPositionAnchorOffset(t,{x:i.x+50,y:i.y+50})}function kg(e,t){if(t.type===`carouselDataView`)return`o-spreadsheet-Icon.DATA`;let n=e.getChartDefinition(t.chartId);return(Dg.getAll().find(e=>e.matcher?.(n))||Dg.get(n.type)).preview}function Ag(e,t){if(t.title)return t.title;if(t.type===`carouselDataView`)return M(`Data`);let n=e.getChartDefinition(t.chartId);return(Dg.getAll().find(e=>e.matcher?.(n))||Dg.get(n.type)).displayName}let jg=`#F3F2F1`;function Mg(e,t,n=1,r){let i=r??Ng(e),a=typeof globalThis.devicePixelRatio==`number`?globalThis.devicePixelRatio:1;e.width=i.width*a,e.height=i.height*a;let o=e.getContext(`2d`);if(!o)throw Error(`Unable to retrieve 2D context from canvas`);o.scale(a*n,a*n);let s=zg({width:i.width/n,height:i.height/n,x:0,y:0},t,o);Fg(o,s),Pg(o,s),Lg(o,s),Ig(o,s),Rg(o,s)}function Ng(e){if(e instanceof HTMLCanvasElement){let t=e.getBoundingClientRect();return{width:t.width,height:t.height}}return{width:e.width,height:e.height}}function Pg(e,t){e.save();let n=t.gauge,r=n.rect.x+n.rect.width/2,i=n.rect.y+n.rect.height,a=n.rect.height-n.arcWidth/2;if(a<0)return;let o=n.percentage===1?0:Math.PI*(1+n.percentage);e.strokeStyle=jg,e.beginPath(),e.lineWidth=n.arcWidth,e.arc(r,i,a,o,0),e.stroke(),e.strokeStyle=n.color,e.beginPath(),e.arc(r,i,a,Math.PI,o),e.stroke(),e.restore()}function Fg(e,t){e.save(),e.fillStyle=t.backgroundColor,e.fillRect(0,0,t.width,t.height),e.restore()}function Ig(e,t){for(let n of[t.minLabel,t.maxLabel,t.gaugeValue])e.save(),e.textAlign=`center`,e.fillStyle=n.color,e.font=`${n.fontSize}px ${Qe}`,e.fillText(n.label,n.textPosition.x,n.textPosition.y),e.restore()}function Lg(e,t){let{x:n,y:r,width:i,height:a}=t.gauge.rect;for(let o of t.inflectionValues){e.save(),e.translate(n+i/2-.5,r+a-.5),e.rotate(Math.PI/2-o.rotation),e.lineWidth=2,e.strokeStyle=ym(t.backgroundColor)+`aa`,e.beginPath(),e.moveTo(0,-(a-t.gauge.arcWidth)),e.lineTo(0,-a-3),e.stroke(),e.textAlign=`center`,e.font=`${o.fontSize}px ${Qe}`,e.fillStyle=o.color;let s=-a-6-o.offset;e.fillText(o.label,0,s),e.restore()}}function Rg(e,t){e.save();let n=t.title;e.font=wp(n.fontSize,n.bold,n.italic),e.textBaseline=`middle`,e.fillStyle=n.color,e.fillText(n.label,n.textPosition.x,n.textPosition.y),e.restore()}function zg(e,t,n){let r=t.maxValue,i=t.minValue,a=qg(t,`animated`),o=Bg(e,t.title.text),s=o.width/6,c=a?(a-i.value)/(r.value-i.value):0,l={x:e.width/2,y:o.y+o.height-o.height/12},u=80;o.height<300&&(u*=o.height/300);let d=o.width/2,f=t.gaugeValue?.label||`-`;Ep(n,f,{fontSize:u},`px`)>d&&(u=Ip(d,u,e=>Ep(n,f,{fontSize:e},`px`)));let p={x:o.x+s/2,y:o.y+o.height+12},m={x:o.x+o.width-s/2,y:o.y+o.height+12},h=ym(t.background),g=Vg(t,o,h,n),_=0,v=0,ee=0;switch(t.title.text&&({width:v,height:ee}=kp(n,t.title.text,{fontSize:16,...t.title},`px`)),t.title.align){case`right`:_=e.width-v-20;break;case`center`:_=(e.width-v)/2;break;default:_=20;break}return{width:e.width,height:e.height,title:{label:t.title.text??``,fontSize:t.title.fontSize??16,textPosition:{x:_,y:15+ee/2},color:t.title.color??h,bold:t.title.bold,italic:t.title.italic},backgroundColor:t.background,gauge:{rect:o,arcWidth:s,percentage:x(c,0,1),color:Hg(t)},inflectionValues:g,gaugeValue:{label:f,textPosition:l,fontSize:u,color:h},minLabel:{label:t.minValue.label,textPosition:p,fontSize:12,color:h},maxLabel:{label:t.maxValue.label,textPosition:m,fontSize:12,color:h}}}function Bg(e,t){let n=t?25:0,r=e.height-20-n-10,i=e.width-60,a,o;return i>2*r?(a=2*r,o=r):(a=i,o=i/2),{x:30+(i-a)/2,y:n+10+(r-o)/2,width:a,height:o}}function Vg(e,t,n,r){let i=e.maxValue,a=e.minValue,o={x:t.x+t.width/2,y:t.y+t.height},s={fontSize:12},c=[],l=[];for(let u of e.inflectionValues){let e=(u.value-a.value)/(i.value-a.value),d=Ep(r,u.label,s,`px`),f=Math.PI-Math.PI*e,p=Kg(f,t.height+6,o.x,o.y,d+2,12),m=l.some(e=>Gg(e,p))?12:0;l.push(p),c.push({rotation:f,label:u.label,fontSize:12,color:n,offset:m})}return c}function Hg(e){let t=qg(e,`final`);if(t===void 0)return jg;for(let n=0;n<e.inflectionValues.length;n++){let r=e.inflectionValues[n];if(r.operator===`<`&&t<r.value||r.operator===`<=`&&t<=r.value)return e.colors[n]}return e.colors.at(-1)}function Ug(e){return[{start:e.topLeft,end:e.topRight},{start:e.topRight,end:e.bottomRight},{start:e.bottomRight,end:e.bottomLeft},{start:e.bottomLeft,end:e.topLeft}]}function Wg(e,t){let n=e.start,r=e.end,i=t.start,a=t.end;function o(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}return o(n,i,a)!==o(r,i,a)&&o(n,r,i)!==o(n,r,a)}function Gg(e,t){let n=Ug(e),r=Ug(t);for(let e of n)for(let t of r)if(Wg(e,t))return!0;return!1}function Kg(e,t,n,r,i,a){let o=Math.cos(e),s=Math.sin(e),c=o*t,l=s*t,u=i/2*s,d=i/2*o,f={x:c+u+n,y:r-(l-d)},p={x:c-u+n,y:r-(l+d)},m=o*(t+a),h=s*(t+a),g={x:m-u+n,y:r-(h+d)};return{bottomLeft:p,bottomRight:f,topRight:{x:m+u+n,y:r-(h-d)},topLeft:g}}function qg(e,t){return t===`animated`&&e.animationValue!==void 0?e.animationValue:e.gaugeValue?.value}let Jg={responsive:!0,maintainAspectRatio:!1,elements:{line:{fill:!1},point:{hitRadius:15}},animation:!1,events:[`mousemove`,`mouseout`,`click`,`touchstart`,`touchmove`,`mouseup`]};async function Yg(e,t,n){try{let r=Zg(t.width,t.height),i=e_(r,e,t,n),a=await $g(r);return i(),a}catch(e){console.log(`Error exporting chart to image URL: `+e.message)}}async function Xg(e,t,n){try{let r=Zg(t.width,t.height),i=e_(r,e,t,n),a=await Qg(r);return i(),a}catch(e){console.log(`Error exporting chart to image file: `+e.message)}return null}function Zg(e,t){if(!globalThis.OffscreenCanvas)throw Error(`converting a chart to an image using OffscreenCanvas is not supported in this environment`);return new OffscreenCanvas(e,t)}async function Qg(e){return`convertToBlob`in e?e.convertToBlob({type:`image/png`}):new Promise(t=>e.toBlob(t,`image/png`))}async function $g(e){let t=await Qg(e);if(t)return new Promise(e=>{let n=new FileReader;n.addEventListener(`load`,()=>{e(n.result)}),n.readAsDataURL(t)})}function e_(e,t,n,r){if(`chartJsConfig`in t){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);let n=$r();n||ei();let r=b(t.chartJsConfig);if(!globalThis.Chart.registry.controllers.get(r.type))throw console.log(`Chart of type "${r.type}" is not registered in Chart.js library.`),n||ti(),Error(`Chart of type "${r.type}" is not registered in Chart.js library.`);let i=new globalThis.Chart(e,r);return()=>{i.destroy(),n||ti()}}else r===`scorecard`?mg(_g(n,t),e):r===`gauge`&&Mg(e,t,1,n);return()=>{}}let t_=1e3,n_=1e3;function r_(e,t){let n=e.getStore(H),{scrollX:r,scrollY:i}=n.activeSheetScrollInfo,a=n.sheetViewDimension,o=r+Math.max(0,(a.width-t.width)/2),s=i+Math.max(0,(a.height-t.height)/2),c=e.model.getters.getActiveSheetId();return n.viewports.getPositionAnchorOffset(c,{x:o,y:s})}function i_(e){let t=b(e);if(t.width>t_){let e=t_/t.width;t.width=t_,t.height*=e}if(t.height>n_){let e=n_/t.height;t.height=n_,t.width*=e}return t}function a_(e,t,n,r){let i=e.getMaxAnchorOffset(t,r.height,r.width),{col:a,row:o}=n,s={...r.offset};for(let n=e.getColSize(t,a);s.x>n;n=e.getColSize(t,a))a+=1,s.x-=n;a>i.col&&(a=i.col,s.x=i.offset.x);for(let n=e.getRowSize(t,o);s.y>n;n=e.getRowSize(t,o))o+=1,s.y-=n;return o>i.row&&(o=i.row,s.y=i.offset.y),{col:a,row:o,offset:s}}function o_(e,t){return t.model.getters.getChartIdFromFigureId(e)?be([m_(e,t),{id:`edit`,name:M(`Edit`),execute:()=>{t.model.dispatch(`SELECT_FIGURE`,{figureId:e}),t.openSidePanel(`ChartPanel`)},icon:`o-spreadsheet-Icon.EDIT`,isEnabled:e=>!e.isSmall},l_(e,t),u_(e,t),d_(e,t),f_(e,t),p_(e,t)]).filter(e=>t.model.getters.isReadonly()?e.isReadonlyAllowed:!0):[]}function s_(e,t){return be([l_(e,t,M(`Image copied to clipboard`)),u_(e,t),{id:`reset_size`,name:M(`Reset size`),execute:async()=>{let n=t.model.getters.getActiveSheetId(),r=t.model.getters.getFigure(n,e);if(!r)return;let i=t.model.getters.getImagePath(e),a=t.model.getters.getImageSize(e)??await t.imageProvider?.getImageOriginalSize(i);if(!t.model.getters.getImageSize(e)){let n=t.model.getters.getImage(e);n.size=a}let{col:o,row:s}=r,{height:c,width:l}=i_(a);t.model.dispatch(`UPDATE_FIGURE`,{sheetId:n,figureId:e,height:c,width:l,col:o,row:s})},icon:`o-spreadsheet-Icon.REFRESH`},{id:`download`,name:M(`Download`),execute:async()=>{t.model.dispatch(`SELECT_FIGURE`,{figureId:e}),fe(t.model.getters.getImagePath(e),`image`)},icon:`o-spreadsheet-Icon.DOWNLOAD`},p_(e,t)])}function c_(e,t){let n=t=>t.model.getters.getSelectedCarouselItem(e)?.type===`chart`;return be([{id:`edit_carousel`,name:M(`Edit carousel`),execute:()=>{t.model.dispatch(`SELECT_FIGURE`,{figureId:e}),t.openSidePanel(`CarouselPanel`,{figureId:e})},icon:`o-spreadsheet-Icon.EDIT`,isEnabled:e=>!e.isSmall},{...l_(e,t,M(`Carousel copied to clipboard`)),name:M(`Copy carousel`)},{...u_(e,t),name:M(`Cut carousel`)},{...p_(e,t),name:M(`Delete carousel`),separator:!0},{id:`edit_chart`,name:M(`Edit chart`),execute:()=>{t.model.dispatch(`SELECT_FIGURE`,{figureId:e}),t.openSidePanel(`ChartPanel`,{})},icon:`o-spreadsheet-Icon.EDIT`,isEnabled:e=>!e.isSmall,isVisible:n},{...d_(e,t),isVisible:n,name:M(`Copy chart as image`)},{...f_(e,t),isVisible:n,name:M(`Download chart`)},{id:`popout_chart`,name:M(`Pop out chart`),icon:`o-spreadsheet-Icon.EXTERNAL`,execute:()=>{let n=t.model.getters.getSelectedCarouselItem(e);if(!n||n.type!==`chart`)return;let r=t.model.getters.getActiveSheetId(),i=Og(t,r,e);t.model.dispatch(`POPOUT_CHART_FROM_CAROUSEL`,{carouselId:e,chartId:n.chartId,sheetId:r,...i})},isVisible:n},{id:`delete_carousel_item`,name:t=>t.model.getters.getSelectedCarouselItem(e)?.type===`chart`?M(`Delete chart`):M(`Delete data view`),execute:()=>{let n=t.model.getters.getSelectedCarouselItem(e);if(!n)return;let r=t.model.getters.getCarousel(e),i=r.items.filter(e=>!w(e,n));t.model.dispatch(`UPDATE_CAROUSEL`,{figureId:e,sheetId:t.model.getters.getActiveSheetId(),definition:t.model.getters.carouselToCarouselData({...r,items:i})})},icon:`o-spreadsheet-Icon.TRASH`,isVisible:t=>t.model.getters.getCarousel(e).items.length>=1}]).filter(e=>t.model.getters.isReadonly()?e.isReadonlyAllowed:!0)}function l_(e,t,n){return{id:`copy`,name:M(`Copy`),shortcut:`Ctrl+C`,execute:async()=>{t.model.getters.getSelectedFigureIds().includes(e)||t.model.dispatch(`SELECT_FIGURE`,{figureId:e}),t.model.dispatch(`COPY`);let r=await t.model.getters.getClipboardTextAndImageContent();await t.clipboard.write(r),n&&t.notifyUser({sticky:!1,type:`success`,text:n})},icon:`o-spreadsheet-Icon.CLIPBOARD`,isEnabledOnLockedSheet:!0}}function u_(e,t){return{id:`cut`,name:M(`Cut`),shortcut:`Ctrl+X`,execute:async()=>{t.model.getters.getSelectedFigureIds().includes(e)||t.model.dispatch(`SELECT_FIGURE`,{figureId:e}),t.model.dispatch(`CUT`),await t.clipboard.write(await t.model.getters.getClipboardTextAndImageContent())},icon:`o-spreadsheet-Icon.CUT`}}function d_(e,t){return{id:`copy_as_image`,name:M(`Copy as image`),icon:`o-spreadsheet-Icon.COPY_AS_IMAGE`,execute:async()=>{let n=t.model.getters.getFigureSheetId(e),r=t.model.getters.getFigure(n,e),i=t.model.getters.getChartIdFromFigureId(e);if(!i)return;let a=t.model.getters.getChartType(i),o=await Xg(t.model.getters.getChartRuntime(i),r,a);if(!o)return;let s=await new Promise(e=>{let t=new FileReader;t.addEventListener(`loadend`,n=>{let r=t.result;e(r)}),t.readAsArrayBuffer(o)}),c=`<img src="data:image/png;base64,${new Uint8Array(s).toBase64()}" />`;await t.clipboard.write({"text/html":c,"image/png":o}),t.notifyUser({sticky:!1,type:`success`,text:M(`Chart copied to clipboard`)})},isVisible:e=>e.model.getters.getSelectedFigureIds().length<=1,isReadonlyAllowed:!0,isEnabledOnLockedSheet:!0}}function f_(e,t){return{id:`download`,name:M(`Download`),icon:`o-spreadsheet-Icon.DOWNLOAD`,execute:async()=>{let n=t.model.getters.getFigureSheetId(e),r=t.model.getters.getFigure(n,e),i=t.model.getters.getChartIdFromFigureId(e);if(!i)return;let a=t.model.getters.getChartType(i),o=await Yg(t.model.getters.getChartRuntime(i),r,a);o&&fe(o,`chart`)},isVisible:e=>e.model.getters.getSelectedFigureIds().length<=1,isReadonlyAllowed:!0,isEnabledOnLockedSheet:!0}}function p_(e,t){return{id:`delete`,name:M(`Delete`),execute:()=>{let n=t.model.getters.getSelectedFigureIds();n.includes(e)?t.model.dispatch(`DELETE_FIGURES`,{sheetId:t.model.getters.getActiveSheetId(),figureIds:n}):t.model.dispatch(`DELETE_FIGURE`,{sheetId:t.model.getters.getActiveSheetId(),figureId:e})},icon:`o-spreadsheet-Icon.TRASH`}}function m_(e,t){return{id:`mergeCarousel`,name:M(`Create carousel`),isVisible:t=>{let n=t.model.getters.getSelectedFigureIds();if(n.length<2||!n.includes(e))return!1;let r=t.model.getters.getActiveSheetId();return!n.map(e=>t.model.getters.getFigure(r,e)).some(e=>e===void 0||e.tag!==`chart`)},execute:()=>{let n=t.model.getters.getActiveSheetId(),r=t.model.getters.getSelectedFigureIds();t.model.dispatch(`MERGE_CHART_FIGURES_INTO_CAROUSEL`,{sheetId:n,baseFigureId:e,chartFigureIds:r})},icon:`o-spreadsheet-Icon.CAROUSEL`}}function h_({strikethrough:e,underline:t}){return!e&&!t?`none`:`${e?`line-through`:``} ${t?`underline`:``}`}function g_(e){let t=__(e);return e&&e.fillColor&&(t.background=e.fillColor),t}function __(e){let t={};if(!e)return t;if(e.bold&&(t[`font-weight`]=`bold`),e.italic&&(t[`font-style`]=`italic`),e.fontSize&&(t[`font-size`]=`${e.fontSize}px`),e.strikethrough||e.underline){let n=e.strikethrough?`line-through`:``;n=e.underline?n+` underline`:n,t[`text-decoration`]=n}return e.textColor&&(t.color=e.textColor),t}function U(e){let t=``;for(let n in e)e[n]&&(t+=`${n}:${e[n]}; `);return t}function v_(e){let t=window.getComputedStyle(e);return{top:parseInt(t.marginTop,10)||0,bottom:parseInt(t.marginBottom,10)||0,left:parseInt(t.marginLeft,10)||0,right:parseInt(t.marginRight,10)||0}}let y_=[`x1`,um],b_=[`x`,...y_];var x_=class extends Yr{mutators=[`resetAxisLimits`,`updateAxisLimits`,`updateTrendLineConfiguration`,`clearAxisLimits`];originalAxisLimits={};currentAxesLimits={};idConversion={};axisDesignBoundaries={};handle(e){switch(e.type){case`DELETE_FIGURE`:if(e.figureId&&this.idConversion[e.figureId]){for(let t of this.idConversion[e.figureId])delete this.originalAxisLimits[t],delete this.currentAxesLimits[t];delete this.axisDesignBoundaries[e.figureId]}break;case`UPDATE_CHART`:let t=`${e.definition.type}-${e.chartId}`;if(this.idConversion[e.figureId]||(this.idConversion[e.figureId]=new Set),this.idConversion[e.figureId].add(t),!(`zoomable`in e.definition&&e.definition.zoomable))this.clearAxisLimits(t),delete this.axisDesignBoundaries[e.figureId];else{let n=`axesDesign`in e.definition?e.definition.axesDesign:void 0,r=n?.x?.min,i=n?.x?.max,a=this.axisDesignBoundaries[e.figureId];(a?.min!==r||a?.max!==i)&&(this.clearAxisLimits(t),this.axisDesignBoundaries[e.figureId]={min:r,max:i})}break}}clearAxisLimits(e){return delete this.originalAxisLimits[e],delete this.currentAxesLimits[e],`noStateChange`}resetAxisLimits(e,t){for(let n of b_)t[n]?this.originalAxisLimits[e]={...this.originalAxisLimits[e],[n]:{...t[n]}}:this.originalAxisLimits[e]?.[n]&&delete this.originalAxisLimits[e][n];return`noStateChange`}updateAxisLimits(e,t){let{min:n,max:r}=t;return n>r&&([n,r]=[r,n]),this.currentAxesLimits[e]={x:{min:n,max:r}},`noStateChange`}updateTrendLineConfiguration(e){if(!this.originalAxisLimits[e]?.x||!this.currentAxesLimits[e]?.x)return`noStateChange`;let t=this.originalAxisLimits[e].x;for(let n of y_){if(!this.originalAxisLimits[e][n])continue;let r=t.max-t.min,i=this.originalAxisLimits[e][n],a=(i.max-i.min)/r,o=i.min-t.min*a,s=this.currentAxesLimits[e].x.min,c=this.currentAxesLimits[e].x.max;this.currentAxesLimits[e][n]={min:s*a+o,max:c*a+o}}return`noStateChange`}},S_=class extends ng{static template=`o-spreadsheet-ZoomableChartJsComponent`;store;masterChartCanvas=(0,t.signal)(null);masterChart;mode;hasLinearScale;isBarChart;chartId=``;datasetBoundaries={min:0,max:0};removeEventListeners=()=>{};isMasterChartAllowed=!1;setup(){this.store=k(x_),super.setup()}unmount(){super.unmount(),this.masterChart?.destroy(),this.removeEventListeners()}get containerStyle(){return U({height:this.sliceable?`calc(100% - 60px)`:`100%`})}get masterChartContainerStyle(){let e=this.env.model.getters.getChartRuntime(this.props.chartId);return e&&!e.chartJsConfig.data.datasets.some(e=>e.data.length>1)?`opacity: 0.3;`:``}get sliceable(){if(this.props.isFullScreen)return!0;let e=this.env.model.getters.getChartDefinition(this.props.chartId);return(`zoomable`in e&&e.zoomable)??!1}get axisOffset(){return!this.hasLinearScale&&this.isBarChart?.5:0}getMasterChartConfiguration(e){let t=e;return{...t,options:{...t.options,plugins:{...t.options.plugins,zoomWindowPlugin:{getLowerBound:()=>this.lowerBound,getUpperBound:()=>this.upperBound}}}}}getDetailChartConfiguration(e){if(!this.sliceable)return e;let t=e.options.scales.x;return this.store.currentAxesLimits[this.chartId]?.x&&(t={...t,...this.getStoredBoundaries()}),{...e,options:{...e.options,scales:{...e.options.scales,x:t},layout:{...e.options.layout,padding:{...e.options.layout?.padding,bottom:5}}}}}getAxisLimitsFromDataset(e){let t=e.data.datasets.map(e=>e.data).flat().map((e,t)=>typeof e==`object`&&e?e.x:t);return{min:Math.min(...t),max:Math.max(...t)}}setMasterChartCursor(e){let t=this.masterChartCanvas();if(t){if(e&&!e.chartJsConfig.data.datasets.some(e=>e.data.length>1)){t.style.cursor=`not-allowed`,this.isMasterChartAllowed=!1;return}t.style.cursor=`default`,this.isMasterChartAllowed=!0}}createChart(e){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);let t=e.chartJsConfig;if(this.isBarChart=t.type===`bar`,this.chartId=`${t.type}-${this.props.chartId}`,this.datasetBoundaries=this.getAxisLimitsFromDataset(t),this.sliceable&&(e.chartJsConfig=this.getDetailChartConfiguration(t)),super.createChart(e),this.hasLinearScale=this.chart?.scales?.x?.type===`linear`,!this.sliceable||!(`masterChartConfig`in e)){this.isMasterChartAllowed=!1;return}this.masterChart?.destroy();let n=this.masterChartCanvas();if(!n)return;let r=n.getContext(`2d`);this.setMasterChartCursor(e),this.masterChart=new globalThis.Chart(r,this.getMasterChartConfiguration(e.masterChartConfig)),this.resetAxesLimits(),this.chart?.options&&(this.chart.options.animation=!1)}updateChartJs(e){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);let t=e.chartJsConfig,{min:n,max:r}=this.getAxisLimitsFromDataset(t);if((this.datasetBoundaries.min!==n||this.datasetBoundaries.max!==r)&&(this.store.clearAxisLimits(this.chartId),this.datasetBoundaries={min:n,max:r}),this.isBarChart=t?.type===`bar`,this.chartId=`${t.type}-${this.props.chartId}`,this.sliceable&&(e.chartJsConfig=this.getDetailChartConfiguration(t)),super.updateChartJs(e),this.hasLinearScale=this.chart?.scales?.x?.type===`linear`,!this.sliceable||!(`masterChartConfig`in e))this.masterChart=void 0,this.isMasterChartAllowed=!1;else{let t=this.getMasterChartConfiguration(e.masterChartConfig);if(this.masterChart)this.masterChart.data=t.data,this.masterChart.config.options=t.options,this.masterChart.update();else{let e=this.masterChartCanvas();if(!e)return;let n=e.getContext(`2d`);this.masterChart=new globalThis.Chart(n,t)}this.setMasterChartCursor(e)}this.resetAxesLimits(),this.chart?.options&&(this.chart.options.animation=!1)}resetAxesLimits(){if(this.chart){if(!this.store.originalAxisLimits[this.chartId]?.x){let e=this.masterChart?this.masterChart.scales:this.chart.scales;!this.hasLinearScale&&e.x&&(e={...e,x:this.adjustBoundaries(e.x)}),this.store.resetAxisLimits(this.chartId,e);return}this.updateTrendingLineAxes(),this.chart.update(),this.masterChart&&this.masterChart.update()}}updateTrendingLineAxes(){this.store.updateTrendLineConfiguration(this.chartId);let e=this.store.currentAxesLimits[this.chartId];for(let t of[`x1`,um])!this.chart?.config?.options?.scales?.[t]||!e?.[t]||(this.chart.config.options.scales[t].min=e[t].min,this.chart.config.options.scales[t].max=e[t].max)}get upperBound(){return this.computePosition(this.store.currentAxesLimits[this.chartId]?.x?.max)}get lowerBound(){return this.computePosition(this.store.currentAxesLimits[this.chartId]?.x?.min)}computePosition(e){if(e===void 0||!this.masterChart?.scales?.x)return;let t=this.masterChart.scales.x;if(this.hasLinearScale)return t.getPixelForValue(e);if(!this.masterChart.chartArea)return;let{left:n,right:r}=this.masterChart.chartArea,{min:i,max:a}=t,o=this.axisOffset;return n+(r-n)*(o+e-i)/(2*o+a-i)}computeCoordinate(e){if(!this.masterChart)return;let t=this.masterChart.scales.x;if(this.hasLinearScale){let n=t.getValueForPixel(e);return n===void 0?void 0:Math.round(n*100)/100}let{left:n,right:r}=this.masterChart.chartArea,i=this.axisOffset;return t.min-i+(t.max+2*i-t.min)*(e-n)/(r-n)}getStoredBoundaries(){let{min:e,max:t}=this.store.currentAxesLimits[this.chartId].x;return this.hasLinearScale||(e=Math.ceil(e),t=Math.floor(t)),{min:e,max:t}}adjustBoundaries({min:e,max:t}){return this.hasLinearScale||(e=Math.ceil(e)-this.axisOffset,t=Math.floor(t)+this.axisOffset),{min:e,max:t}}updateAxisLimits(e,t){if(e===t||!this.chart)return;this.store.updateAxisLimits(this.chartId,{min:e,max:t});let{min:n,max:r}=this.getStoredBoundaries();(r>n||this.isBarChart&&r===n)&&(this.chart.config.options.scales.x.min=n,this.chart.config.options.scales.x.max=r,this.updateTrendingLineAxes(),this.chart.update()),this.masterChart?.update()}onMasterChartPointerDown(e){this.removeEventListeners();let t=Sg(this.env,e,this.masterChartCanvas()?.getBoundingClientRect()),n=t.offsetX;if(!this.masterChart?.chartArea||!this.chart?.scales?.x)return;let{left:r,right:i,top:a,bottom:o}=this.masterChart.chartArea,s=this.upperBound??i,c=this.lowerBound??r;if(n<r-5||n>i+5||t.offsetY<a||t.offsetY>o)return;e.preventDefault(),e.stopPropagation();let l,u,d,f=n;if((c!==r||s!==i)&&n>c+5&&n<s-5){l=t.offsetX-c,this.mode=`moveInMaster`;let e=this.store.currentAxesLimits[this.chartId]?.x;u=(e?.max??this.chart.scales.x.max)-(e?.min??this.chart.scales.x.min)}else this.mode=`selectInMaster`,l=Math.abs(n-c)<5?s:Math.abs(n-s)<5?c:x(n,r,i),d=this.computeCoordinate(l);let p=this.store.originalAxisLimits[this.chartId].x.min,m=this.store.originalAxisLimits[this.chartId].x.max,h=e=>{if(this.mode===`moveInMaster`){let t=this.computeCoordinate(e-l);return t<p?t=p:t>m-u&&(t=m-u),{min:t,max:t+u}}else if(this.mode===`selectInMaster`){let t=x(e,r,i);if(Math.abs(l-t)>5){let e=this.computeCoordinate(t);return d===void 0||e===void 0?{}:{min:Math.min(d,e),max:Math.max(d,e)}}}return{}},g=e=>{let t=Sg(this.env,e,this.masterChartCanvas()?.getBoundingClientRect()).offsetX;if(Math.abs(t-f)<5)return;let{min:n,max:r}=h(t);n!==void 0&&r!==void 0&&this.updateAxisLimits(n,r)},_=e=>{this.removeEventListeners();let{min:t,max:n}=this.chart.scales.x;this.hasLinearScale||(this.mode===`moveInMaster`?(t=Math.round(t)-this.axisOffset,n=t+u):{min:t,max:n}=this.adjustBoundaries({min:t,max:n})),this.updateAxisLimits(t,n),this.mode=void 0,this.updateMasterChartCursor(e)};this.removeEventListeners=()=>{window.removeEventListener(`pointermove`,g,!0),window.removeEventListener(`pointerup`,_,!0)},window.addEventListener(`pointermove`,g,!0),window.addEventListener(`pointerup`,_,!0)}updateMasterChartCursor(e){let t=e.target,{offsetX:n,offsetY:r}=Sg(this.env,e,t?.getBoundingClientRect());if(!(!t||!this.isMasterChartAllowed)&&this.mode===void 0){if(!this.masterChart?.chartArea){t.style.cursor=`default`;return}let{left:e,right:i,top:a,bottom:o}=this.masterChart.chartArea,s=this.lowerBound??e,c=this.upperBound??i;r<a||r>o?t.style.cursor=`default`:Math.abs(s-n)<5||Math.abs(c-n)<5?t.style.cursor=`ew-resize`:s<n&&n<c&&(s!==e||c!==i)?t.style.cursor=`grab`:t.style.cursor=`crosshair`}}onMasterChartMouseLeave(e){let t=e.target;!t||!this.isMasterChartAllowed||(t.style.cursor=`default`)}onMasterChartDoubleClick(e){this.mode=void 0;let t=Sg(this.env,e,this.masterChartCanvas()?.getBoundingClientRect()),n=t.offsetX;if(!this.masterChart?.chartArea||!this.chart?.scales.x)return;let{left:r,right:i,top:a,bottom:o}=this.masterChart.chartArea,s=this.upperBound??i,c=this.lowerBound??r;if(s<c&&([s,c]=[c,s]),n<r-5||n>i+5||t.offsetY<a||t.offsetY>o)return;e.preventDefault(),e.stopPropagation();let{min:l,max:u}=this.store.currentAxesLimits[this.chartId]?.x??this.chart.scales.x,d=this.store.originalAxisLimits[this.chartId].x;if(d){if(Math.abs(n-c)<5)l=d.min;else if(Math.abs(n-s)<5)u=d.max;else if(c<n&&n<s)l=d.min,u=d.max;else return;this.updateAxisLimits(l,u)}}};let C_=new D;C_.add(`animatedBackgroundColorChange`,{id:`animatedBackgroundColorChange`,easingFn:`easeOutCubic`,hasAnimation:(e,t)=>e?.style?.fillColor!==t?.style?.fillColor,updateAnimation:function(e,t,n,r){let i=_p([{value:0,color:n.style.fillColor||`#ffffff`},{value:1,color:r.style.fillColor||`#ffffff`}]);t.style.fillColor=i(w_[this.easingFn](e))}}),C_.add(`animatedTextColorChange`,{id:`animatedTextColorChange`,easingFn:`easeOutCubic`,hasAnimation:(e,t)=>e?.style?.textColor!==t?.style?.textColor,updateAnimation:function(e,t,n,r){let i=_p([{value:0,color:n.style.textColor||`#000000`},{value:1,color:r.style.textColor||`#000000`}]);t.style.textColor=i(w_[this.easingFn](e))}}),C_.add(`animatedDataBar`,{id:`animatedDataBar`,easingFn:`easeOutCubic`,hasAnimation:(e,t)=>e?.dataBarFill?.percentage!==t?.dataBarFill?.percentage,updateAnimation:function(e,t,n,r){let i=n?.dataBarFill?.percentage||0,a=r?.dataBarFill?.percentage||0,o=w_[this.easingFn](e),s=i+(a-i)*o;t.dataBarFill={color:r.dataBarFill?.color||n.dataBarFill?.color||`#ffffff`,percentage:s}}}),C_.add(`textFadeIn`,{id:`textFadeIn`,easingFn:`easeInCubic`,hasAnimation:(e,t)=>{let n=e?.content?.textLines?.join(`
|
|
17
|
+
`):[t];for(let t of a){let a=t.includes(` `)?t.split(` `):[t];if(!r){i.push(t);continue}let o=``,s=r;for(let t of a){let a=Pp(e,t,r,n),c=a.pop(),l=Ep(e,c,n);if(a.length)o!==``&&(i.push(o),o=``,s=r),a.forEach(e=>{i.push(e)}),o=c,s=r-l;else{let t=o===``?c:` `+c,a=Ep(e,t,n);a<=s?(o+=t,s-=a):(i.push(o),o=c,s=r-l)}}o!==``&&i.push(o)}return i}function Ip(e,t,n,r=.25){let i=1;if(n(i)>e)return i;if(n(t)<e)return t;let a=(i+t)/2,o=n(a),s=0;for(;Math.abs(o-e)>r&&s<20;)o>=e?t=(i+t)/2:i=(i+t)/2,a=(i+t)/2,o=n(a),s++;return a}function Lp(e){return e?e.toLowerCase().trim():``}let Rp=/([0-9\.]*)px/;function zp(e){return Number(e.match(Rp)?.[1])}function Bp(e,t,n){let r=Dp(e,t,e.font);if(r<=n)return t;let i=Dp(e,`…`,e.font);if(r<=i)return t;let a=t.length;for(;r>=n-i&&a-->0;)t=t.substring(0,a),r=Dp(e,t,e.font);return t+`…`}function Vp(e,t,n,r=!1,i=!1,a=zp(e.font)/10,o=!1){if(o&&(e.save(),e.fillStyle=Jf(e.fillStyle,Xe)),e.fillText(t,n.x,n.y),!r&&!i)return;let s=e.measureText(t),c=s.width,l=s.actualBoundingBoxAscent+s.actualBoundingBoxDescent,u=s.fontBoundingBoxAscent+s.fontBoundingBoxDescent,{x:d,y:f}=n,p=f,m=f;switch(e.textAlign){case`center`:d-=c/2;break;case`right`:d-=c;break}switch(e.textBaseline){case`top`:m+=u-2*a,p+=u/2-a;break;case`middle`:m+=u/2-a;break;case`alphabetic`:m+=2*a,p-=3*a;break;case`bottom`:m=f,p-=l/2-a/2;break}r&&(e.lineWidth=a,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(d,m),e.lineTo(d+c,m),e.stroke()),i&&(e.lineWidth=a,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(d,p),e.lineTo(d+c,p),e.stroke()),o&&e.restore()}function Hp(e,t,n,r,i=`pt`){if(Ep(e,n,r,i)<=t)return n;let a=Ep(e,`...`,r,i);if(a>=t)return``;let o=1,s=n.length,c;for(;o<=s;){let l=Math.floor((o+s)/2);c=Ep(e,n.slice(0,l),r,i),c+a>t?s=l-1:o=l+1}let l=n.slice(0,Math.max(0,o-1));return l?l+`...`:``}function Up(e,t){if(!t.rotation||t.rotation%(Math.PI*2)==0)return e;let{x:n,y:r}=e,i=Math.cos(-t.rotation),a=Math.sin(-t.rotation),o=e.textWidth-8,s=e.textHeight,c=t.align===`center`,l=t.align===`left`==a<0,u=a*s,d=Math.abs(a*o),f=i*s;return t.verticalAlign===`top`?c?(r+=d/2,n-=u/2):l?n-=u:r+=d:!t.verticalAlign||t.verticalAlign===`bottom`?(r+=s-f,c?(r-=d/2,n-=u/2):l&&(n-=u,r-=d)):c?(n-=u/2,r-=s/2,l?r+=u:r-=u):l?(n-=u,r-=d/2):r+=d/2+f/4,{x:i*n-a*r,y:i*r+a*n}}let Wp={id:`chartColorScalePlugin`,afterDatasetsDraw(e,t,n){if(!n.position||n.position===`none`||!n.colorScale.length)return;let r=e.ctx;r.save(),r.textAlign=`center`,r.textBaseline=`middle`,r.miterLimit=1;let i=(e.chartArea.bottom-e.chartArea.top)/2,a=n.position===`left`?20:r.canvas.width-70,o=e.chartArea.top,s=r.createLinearGradient(0,o+i,0,o),c=1/(n.colorScale.length-1);n.colorScale.forEach((e,t)=>{s.addColorStop(t*c,e)}),r.fillStyle=s,r.fillRect(a,o,10,i),r.fillStyle=n.fontColor??`black`,r.font=wp(12),r.textAlign=`left`;let l=Math.round(n.minValue*100)/100,u=Math.round(n.maxValue*100)/100;n.minValue===n.maxValue&&(--l,u+=1);let d=Fc({value:u,format:void 0},n.locale),f=Fc({value:l,format:void 0},n.locale);r.fillText(f,a+10+5,o+i-6),r.fillText(d,a+10+5,o+6),r.restore()}};function Gp(){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);return class extends globalThis.Chart.BarController{static id=`funnel`;static defaults={...globalThis.Chart?.BarController.defaults,dataElementType:`funnel`,animation:{duration:e=>e.type===`data`?1e3*(e.raw[1]/Math.max(...e.dataset.data.map(e=>e[1]))):1e3}};updateElements(e,t,n,r){super.updateElements(e,t,n,r);for(let i=t;i<t+n;i++){let t=e[i];this.updateElement(t,i,{nextElement:e[i+1]},r)}}}}function Kp(){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);return class extends globalThis.Chart.BarElement{static id=`funnel`;draw(e){e.save();let{x:t,y:n,height:r,nextElement:i,base:a,options:o}=this.getProps([`x`,`y`,`width`,`height`,`nextElement`,`base`,`options`]),s=qp(this),c=(s-(i?qp(i):0))/2,l=Math.min(t,a),u=n-r/2;e.fillStyle=o.backgroundColor,e.beginPath(),e.moveTo(l,u),e.lineTo(l+s,u),e.lineTo(l+s-c,u+r),e.lineTo(l+c,u+r),e.closePath(),e.fill(),o.borderWidth&&(e.strokeStyle=o.borderColor,e.lineWidth=o.borderWidth,e.stroke()),e.restore()}inRange(e,t){let{x:n,y:r,height:i,nextElement:a,base:o}=this.getProps([`x`,`y`,`width`,`height`,`nextElement`,`base`,`options`]),s=qp(this),c=a?qp(a):0,l=Math.min(n,o),u=r-i/2;if(t<u||t>u+i)return!1;let d=(s-c)/2,f=l+d*(t-u)/i,p=l+s-d*(t-u)/i;return!(e<f||e>p)}}}function qp(e){let{x:t,base:n}=e.getProps([`x`,`base`]);return Math.max(t,n)-Math.min(t,n)}let Jp=function(e){if(!e.length)return{x:0,y:0};let{x:t,y:n,base:r,width:i,height:a}=e[0].element.getProps([`x`,`y`,`width`,`height`,`base`]),o=Math.min(t,r),s=n-a/2;return{x:o+i*2/3,y:s+a/2}},Yp={id:`o-spreadsheet-minor-gridlines`,beforeDatasetsDraw(e){let t=e.ctx,n=e.chartArea;if(n)for(let r in e.scales){let i=e.scales[r],a=i.options,o=a?.grid?.minor;if(!o?.display)continue;let s=a?.grid?.display,c=i.ticks;if(!(!c||c.length<2)){t.save(),t.lineWidth=1,t.strokeStyle=o.color??a?.grid?.color??`#e6e6e6`;for(let e=0;e<c.length-1;e++){let r=i.getPixelForTick(e),a=i.getPixelForTick(e+1);if(!(!isFinite(r)||!isFinite(a)))for(let e=+!!s;e<4;e++){let o=e/4,s=Math.round(r+(a-r)*o)+.5;t.beginPath(),i.isHorizontal()?(t.moveTo(s,n.top),t.lineTo(s,n.bottom)):(t.moveTo(n.left,s),t.lineTo(n.right,s)),t.stroke()}}t.restore()}}}},Xp=`000000`,Zp={arrows:`3Arrows`,smiley:`3Symbols`,dots:`3TrafficLights1`},Qp={styleSheet:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,sst:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,Relationships:`http://schemas.openxmlformats.org/package/2006/relationships`,Types:`http://schemas.openxmlformats.org/package/2006/content-types`,worksheet:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,workbook:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,drawing:`http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing`,table:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,revision:`http://schemas.microsoft.com/office/spreadsheetml/2014/revision`,revision3:`http://schemas.microsoft.com/office/spreadsheetml/2016/revision3`,markupCompatibility:`http://schemas.openxmlformats.org/markup-compatibility/2006`},$p=`http://schemas.openxmlformats.org/drawingml/2006/main`,em=`http://schemas.openxmlformats.org/drawingml/2006/chart`,tm={workbook:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml`,macroEnabledWorkbook:`application/vnd.ms-excel.sheet.macroEnabled.main+xml`,templateWorkbook:`application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml`,macroEnabledTemplateWorkbook:`application/vnd.ms-excel.template.macroEnabled.main+xml`,excelAddInWorkbook:`application/vnd.ms-excel.addin.macroEnabled.main+xml`,sheet:`application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml`,metadata:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml`,sharedStrings:`application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml`,styles:`application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml`,drawing:`application/vnd.openxmlformats-officedocument.drawing+xml`,chart:`application/vnd.openxmlformats-officedocument.drawingml.chart+xml`,themes:`application/vnd.openxmlformats-officedocument.theme+xml`,table:`application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml`,pivot:`application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml`,externalLink:`application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml`},nm={document:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument`,sheet:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet`,metadata:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/sheetMetadata`,sharedStrings:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings`,styles:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles`,drawing:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,chart:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart`,theme:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme`,table:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/table`,hyperlink:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink`,image:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/image`},rm=`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,im=.75,am=.143,om=8.43,sm=12.75,cm={FLOOR:[{type:`NUMBER`,value:1}],CEILING:[{type:`NUMBER`,value:1}],ROUND:[{type:`NUMBER`,value:0}],ROUNDUP:[{type:`NUMBER`,value:0}],ROUNDDOWN:[{type:`NUMBER`,value:0}],IFERROR:[{type:`NUMBER`,value:0}]},lm=`ACOT,ACOTH,AGGREGATE,ARABIC,BASE,BETA.DIST,BETA.INV,BINOM.DIST,BINOM.DIST.RANGE,BINOM.INV,BITAND,BITLSHIFT,BITOR,BITRSHIFT,BITXOR,BYCOL,BYROW,CEILING.MATH,CEILING.PRECISE,CHISQ.DIST,CHISQ.DIST.RT,CHISQ.INV,CHISQ.INV.RT,CHISQ.TEST,CHOOSECOLS,CHOOSEROWS,COMBINA,CONCAT,CONFIDENCE.NORM,CONFIDENCE.T,COT,COTH,COVARIANCE.P,COVARIANCE.S,CSC,CSCH,DAYS,DECIMAL,DROP,ERF.PRECISE,ERFC.PRECISE,EXPAND,EXPON.DIST,F.DIST,F.DIST.RT,F.INV,F.INV.RT,F.TEST,FIELDVALUE,FILTERXML,FLOOR.MATH,FLOOR.PRECISE,FORECAST.ETS,FORECAST.ETS.CONFINT,FORECAST.ETS.SEASONALITY,FORECAST.ETS.STAT,FORECAST.LINEAR,FORMULATEXT,GAMMA,GAMMA.DIST,GAMMA.INV,GAMMALN.PRECISE,GAUSS,HSTACK,HYPGEOM.DIST,IFNA,IFS,IMCOSH,IMCOT,IMCSC,IMCSCH,IMSEC,IMSECH,IMSINH,IMTAN,ISFORMULA,ISOMITTED,ISOWEEKNUM,LAMBDA,LET,LOGNORM.DIST,LOGNORM.INV,MAKEARRAY,MAP,MAXIFS,MINIFS,MODE.MULT,MODE.SNGL,MUNIT,NEGBINOM.DIST,NORM.DIST,NORM.INV,NORM.S.DIST,NORM.S.INV,NUMBERVALUE,PDURATION,PERCENTILE.EXC,PERCENTILE.INC,PERCENTRANK.EXC,PERCENTRANK.INC,PERMUTATIONA,PHI,POISSON.DIST,PQSOURCE,PYTHON_STR,PYTHON_TYPE,PYTHON_TYPENAME,QUARTILE.EXC,QUARTILE.INC,QUERYSTRING,RANDARRAY,RANK.AVG,RANK.EQ,REDUCE,RRI,SCAN,SEC,SECH,SEQUENCE,SHEET,SHEETS,SKEW.P,SORTBY,STDEV.P,STDEV.S,SWITCH,T.DIST,T.DIST.2T,T.DIST.RT,T.INV,T.INV.2T,T.TEST,TAKE,TEXTAFTER,TEXTBEFORE,TEXTJOIN,TEXTSPLIT,TOCOL,TOROW,UNICHAR,UNICODE,UNIQUE,VAR.P,VAR.S,VSTACK,WEBSERVICE,WEIBULL.DIST,WRAPCOLS,WRAPROWS,XLOOKUP,XOR,Z.TEST`.split(`,`),um=`xMovingAverage`,dm={exponential:`exp`,logarithmic:`log`,polynomial:`poly`,trailingMovingAverage:`movingAvg`};function fm(e,t,n){return n?Nu(e,t,n):void 0}function pm(e,{applyChange:t}){if(!e)return;let n=t(e);switch(n.changeType){case`REMOVE`:return;default:return n.range}}function mm(e,t,n){let r=[];for(let i of n.dataSets){let{unboundedZone:a,sheetId:o,invalidSheetName:s,invalidXc:c}=e.getRangeFromSheetXC(t,i.dataRange);if(!(s||c))if(a.left!==a.right&&a.top!==a.bottom){if(a.right===void 0)continue;let t=i.dataSetId;for(let i=a.left;i<=a.right;i++){let s={...a,left:i,right:i};r.push({...hm(e,o,s,n.dataSetsHaveTitle?{top:s.top,bottom:s.top,left:s.left,right:s.left}:void 0),dataSetId:t}),t=`${t}_${i}`}}else r.push({...hm(e,o,a,n.dataSetsHaveTitle?{top:a.top,bottom:a.top,left:a.left,right:a.left}:void 0),dataSetId:i.dataSetId})}return r}function hm(e,t,n,r){if(n.left!==n.right&&n.top!==n.bottom)throw Error(`Zone should be a single column or row: ${tr(n)}`);if(r){let i=tr(n),a=tr(r);return{labelCell:e.getRangeFromSheetXC(t,a),dataRange:e.getRangeFromSheetXC(t,i)}}else return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,tr(n))}}function gm(e,t,n){let r=n.labelCell?.zone,i=n.dataRange.zone;if(r){let{numberOfRows:e,numberOfCols:t}=mr(i);e===1?i={...i,left:i.left+1}:t===1&&(i={...i,top:i.top+1})}let a=t[n.dataSetId]??{},o=Du({...n.dataRange,zone:i},e.getSheetSize),s={};a.label?s={text:a.label}:n.labelCell&&(s={reference:e.getRangeString(n.labelCell,`forceSheetReference`,{useBoundedReference:!0})});let c;return a.trend?.type&&(c={type:a.trend.type===`polynomial`&&a.trend.order===1?`linear`:dm[a.trend.type],color:a.trend.color,order:a.trend.order?Math.min(a.trend.order,6):void 0,window:a.trend.window||2}),{label:s,range:e.getRangeString(o,`forceSheetReference`,{useBoundedReference:!0}),backgroundColor:a.backgroundColor,rightYAxis:a.yAxisId===`y1`,trend:c}}function _m(e,t,n){if(!t)return;let r={...t.zone};n&&t.zone.bottom>t.zone.top&&(r.top+=1);let i=Du({...t,zone:r},e.getSheetSize);return e.getRangeString(i,`forceSheetReference`,{useBoundedReference:!0})}function vm(e){return e&&If(e)<.3?`#FFFFFF`:`#000000`}function ym(e){return e&&If(e)<.3?`#C8C8C8`:`#666666`}function bm(e){return e.dataSets.find(e=>!xl.test(e.dataRange))!==void 0||e.dataSets.map(e=>Yn(e.dataRange)).some(e=>e.top!==e.bottom&&Tr(e))?`InvalidDataSet`:`Success`}function xm(e){return e.labelRange&&!xl.test(e.labelRange||``)?`InvalidLabelRange`:`Success`}function Sm(e,t,n){return n&&!!t&&e>=t}function Cm(e){let t=!1,n=!1;if(`horizontal`in e&&e.horizontal)return{useLeftAxis:!0,useRightAxis:!1};let r=`dataSetStyles`in e?e.dataSetStyles??{}:{};for(let e of Object.values(r))e?.yAxisId===`y1`?n=!0:t=!0;return t||=!n,{useLeftAxis:t,useRightAxis:n}}function wm(e,t,n=!1){return(r,i)=>{let a=e?.[i];return Tm({format:a,locale:t},n)(r)}}function Tm(e,t=!1){return n=>{if(n=Number(n),isNaN(n))return n;let{locale:r,format:i}=e;return Om(t?Fc({value:n,format:i},r):B(n,{locale:r,format:!i&&Math.abs(n)>=1e3?`#,##`:i}))}}let Em=[{value:`left`,label:M(`Left`)},{value:`right`,label:M(`Right`)}];function Dm(e,t){let n=[],r=gn(t.map(e=>e.data.length));for(let t=0;t<=r;t++)n.push(e.next());return n}function Om(e,t=20){return e?e.length>t?e.substring(0,t)+`…`:e:``}function km(e){return e===`x1`||e===`xMovingAverage`}function Am({background:e},t){let n=t.getSpreadsheetTheme().backgroundColor;return e||n}function jm(e,t){return e.type===`bar`&&t.type===`line`}let Mm={id:`chartShowValuesPlugin`,afterDatasetsDraw(e,t,n){if(n.showValues&&e._metasets?.[0]?.data)switch(n.type){case`pie`:Hm(e,n);break;case`line`:case`scatter`:Im(e,n);break;case`combo`:case`waterfall`:Lm(e,n);break;case`radar`:Fm(e,n);break;case`bar`:n.horizontal?Bm(e,n):Pm(e,n);break;case`pyramid`:Bm(e,n);break;case`calendar`:Rm(e,n);break;case`bubble`:zm(e,n);break;case`funnel`:Vm(e,n);break}}};function Nm(e){let{chart:t,options:n,getNumberValue:r,direction:i}=e,a=t.ctx;a.save(),a.textAlign=`center`,a.textBaseline=`middle`,a.miterLimit=1;let o={};for(let s of t._metasets)if(!(km(s.xAxisID)||s.hidden))for(let c=0;c<s._parsed.length;c++){let l=r(s,c);if(l===void 0||isNaN(l))continue;let u=s.data[c],d=u.options.backgroundColor;if(!d||zf(d).a!==1)continue;let f=n.callback(l,s,c),p=Um(f,a),m={dataset:s,chartElement:u,numberValue:l,valueIndex:c,textSize:p,options:n,chart:t},h=e.getValuePosition(m);if(e.shouldSkipValue?.(m))continue;if(i===`vertical`){let e=Math.round(h.x);o[e]||(o[e]=[]);for(let t of o[e]||[])Math.abs(t-h.y)<13&&(h.y=t+13*(l<0?1:-1));o[e].push(h.y)}else{let e=Math.round(h.y);o[e]||(o[e]=[]);for(let t of o[e])Math.abs(t-h.x)<p.width&&(h.x=l<0?t-p.width-3:t+p.width+3);o[e].push(h.x)}let{strokeColor:g,textColor:_}=e.getTextColors(m);g&&(a.strokeStyle=g,a.lineWidth=3,a.strokeText(f,h.x,h.y)),a.fillStyle=_,a.lineWidth=1,a.fillText(f,h.x,h.y)}a.restore()}function Pm(e,t){Nm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t].y),getValuePosition:Km,shouldSkipValue:({dataset:e})=>jm(t,e),getTextColors:Wm})}function Fm(e,t){Nm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t].r),getValuePosition:({chartElement:e})=>({x:e.x,y:e.y-10}),shouldSkipValue:()=>!1,getTextColors:Gm})}function Im(e,t){Nm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t].y),getValuePosition:({chartElement:e})=>({x:e.x,y:e.y-10}),shouldSkipValue:()=>!1,getTextColors:Gm})}function Lm(e,t){Nm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t].y),getValuePosition:e=>e.dataset.type===`line`?{x:e.chartElement.x,y:e.chartElement.y-10}:Km(e),shouldSkipValue:()=>!1,getTextColors:e=>e.dataset.type===`line`?Gm(e):Wm(e)})}function Rm(e,t){Nm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>e._parsed[t].y,getValuePosition:({chartElement:e})=>({x:e.x,y:e.y+e.height/2}),shouldSkipValue:({chartElement:e,textSize:t})=>t.height+2>Math.abs(e.height)-2,getTextColors:({chartElement:e})=>({strokeColor:void 0,textColor:vm(e.options.backgroundColor)})})}function zm(e,t){let n=(e,t)=>{let n=e.options.radius??globalThis.Chart?.defaults.elements.point.radius??3;return t.height<n*2};Nm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>e._parsed[t].y,getValuePosition:({chartElement:e,textSize:t})=>({x:e.x,y:n(e,t)?e.y:e.y-10}),shouldSkipValue:()=>!1,getTextColors:e=>n(e.chartElement,e.textSize)?Wm(e):Gm(e)})}function Bm(e,t){Nm({chart:e,options:t,direction:`horizontal`,getNumberValue:(e,t)=>e._parsed[t].x,getValuePosition:({chartElement:t,numberValue:n,textSize:r,dataset:i})=>{let a=e.scales[i.xAxisID].getPixelForValue(0),o=Math.abs(t.x-a),s,c=n<0?-1:1;return s=o<r.width?a+c*(r.width/2+3):t.x-c*(t.width/2),{x:s,y:t.y}},shouldSkipValue:({dataset:e})=>jm(t,e),getTextColors:Wm})}function Vm(e,t){Nm({chart:e,options:t,direction:`horizontal`,getNumberValue:(e,t)=>e._parsed[t].x,getValuePosition:({chartElement:e})=>({x:e.x-e.width/2,y:e.y}),shouldSkipValue:()=>!1,getTextColors:Wm})}function Hm(e,t){let n=e=>{let{startAngle:t,endAngle:n,innerRadius:r,outerRadius:i}=e;return{midAngle:(t+n)/2,midRadius:(r+i)/2}};Nm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t]),getValuePosition:({chartElement:e})=>{let{midAngle:t,midRadius:r}=n(e);return{x:e.x+r*Math.cos(t),y:e.y+r*Math.sin(t)}},shouldSkipValue:({chartElement:e,textSize:t})=>{let{midRadius:r}=n(e),i=e.endAngle-e.startAngle,a=2*r*Math.tan(i/2);return i<Math.PI/2&&(t.width>=a||a<t.height)},getTextColors:Wm})}function Um(e,t){return Ap(t,e,Mp({fontSize:globalThis.Chart?.defaults.font.size??12},`px`))}function Wm(e){let{dataset:t,numberValue:n,valueIndex:r,chartElement:i,options:a}=e;return{strokeColor:i.options.backgroundColor,textColor:a.background(n,t,r)||`#ffffff`}}function Gm(e){let{dataset:t,numberValue:n,valueIndex:r,chartElement:i,options:a}=e;return{strokeColor:a.background(n,t,r)||`#ffffff`,textColor:i.options.backgroundColor}}function Km(e){let{chartElement:t,numberValue:n,dataset:r,textSize:i,chart:a}=e,o=a.scales[r.yAxisID].getPixelForValue(0),s=Math.abs(o-t.y),c=n<0?-1:1,l=0;return l=s<i.height?o-c*(i.height/2):t.y+c*(t.height/2),{x:t.x,y:l}}let qm={showHeaders:!0,headerDesign:{align:`center`,fillColor:`#808080`,bold:!0,fontSize:15},showValues:!0,showLabels:!0,valuesDesign:{align:`left`,verticalAlign:`bottom`,fontSize:12},coloringOptions:{type:`categoryColor`,colors:[],useValueBasedGradient:!0}},Jm={second:1e3,minute:1e3*60,hour:1e3*3600,day:1e3*3600*24,month:1e3*3600*24*30,year:1e3*3600*24*365},Ym={inSeconds:function(e){return Math.floor(e/Jm.second)},inMinutes:function(e){return Math.floor(e/Jm.minute)},inHours:function(e){return Math.floor(e/Jm.hour)},inDays:function(e){return Math.floor(e/Jm.day)},inMonths:function(e){return Math.floor(e/Jm.month)},inYears:function(e){return Math.floor(e/Jm.year)}},Xm=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function Zm(e,t,n){let r=Qm(t),i=eh(e,r,n),a={};return i&&(a[i]=r),{parser:r,displayFormats:a,unit:i??!1,tooltipFormat:r}}function Qm(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 $m(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 eh(e,t,n){let r=e.map(e=>Ua(e,n)?.jsDate);if(r.some(e=>e===void 0)||e.length<2)return;let i=r.map(e=>e.getTime()),a=gn(i)-_n(i),o=$m(t);return Jm.second>=Jm[o]&&Ym.inSeconds(a)<180?`second`:Jm.minute>=Jm[o]&&Ym.inMinutes(a)<180?`minute`:Jm.hour>=Jm[o]&&Ym.inHours(a)<96?`hour`:Jm.day>=Jm[o]&&Ym.inDays(a)<90?`day`:Jm.month>=Jm[o]&&Ym.inMonths(a)<36?`month`:`year`}function th(e,t){let n={},{trendDataSetsValues:r,locale:i,axisFormats:a,axisType:o}=t,s={stacked:e.stacked,locale:i};if(e.horizontal)n.x=gh(e,`bottom`,`values`,o,{...s,format:a?.x}),n.y={...gh(e,`left`,`labels`,`linear`,s),grid:{display:!1}};else{n.x={...gh(e,`bottom`,`labels`,o,s),grid:{display:!1}};let t={...s,format:a?.y};n.y=gh(e,`left`,`values`,`linear`,t);let r={...s,format:a?.y1};n.y1=gh(e,`right`,`values`,`linear`,r)}if(n=tn(n),r&&r.length&&r.some(C)){let e=Math.max(...r.map(e=>e?.length||0));n.x1={...n.x,labels:Array(e).fill(``),offset:!1,display:!1},n[um]={...n.x,offset:!0,display:!1}}return n}function nh(e,t){let n=t.map(e=>e.label||``),r=vm(e.background);return{y:{title:hh(e.axesDesign?.y),stacked:!0,min:0,max:n.length,ticks:{stepSize:.5,color:r,callback:function(e,t,r){if(t%2!=0)return n[Math.floor((t-1)/2)]}},grid:{display:!1},border:{display:!1}},x:{title:hh(e.axesDesign?.x),stacked:!0,grid:{display:!1},position:`top`,ticks:{color:r},border:{display:!1}}}}function rh(e,t){let{dataSetsValues:n}=t;if(!n.length||e.legendPosition===`none`)return;let r=n.flatMap(e=>e.data).filter(pf).map(e=>e.value),i=Math.min(...r),a=Math.max(...r),o=[];return o=typeof e.colorScale==`object`?[e.colorScale.minColor,e.colorScale.midColor,e.colorScale.maxColor].filter(C):[...hp[e.colorScale??`oranges`]],{position:e.legendPosition===`right`?`right`:`left`,colorScale:o,fontColor:vm(e.background),minValue:i,maxValue:a,locale:t.locale}}function ih(e,t){let{locale:n,axisType:r,trendDataSetsValues:i,labels:a,axisFormats:o}=t,s=o?.x,c=e.stacked,l={x:gh(e,`bottom`,`labels`,r,{locale:n}),y:gh(e,`left`,`values`,`linear`,{locale:n,stacked:c,format:o?.y}),y1:gh(e,`right`,`values`,`linear`,{locale:n,stacked:c,format:o?.y1})};if(l=tn(l),r===`time`&&a&&s){let t={type:`time`,time:Zm(a,s,n),min:B(e.axesDesign?.x?.min??``,{format:s,locale:n}),max:B(e.axesDesign?.x?.max??``,{format:s,locale:n})};Object.assign(l.x,t),l.x.ticks.maxTicksLimit=15,delete l?.x?.ticks?.callback}else r===`linear`&&(l.x.type=`linear`,l.x.ticks.callback=e.humanize?e=>Fc({value:e,format:s},n):e=>B(e,{format:s,locale:n}));if(i&&i.length&&i.some(C)&&(l.x1={...l.x,display:!1},l[um]={...l.x,display:!1},r===`category`||r===`time`)){let e=Math.max(...i.map(e=>e?.length||0));l.x1.type=`category`,l.x1.labels=S(0,e).map(e=>e.toString()),l.x1.offset=!1,l[um].type=`category`,l[um].offset=!1}return l}function ah(e){return If(e||`#ffffff`)>.5?`#cccccc`:`#999999`}function oh(e){return If(e||`#ffffff`)>.5?`#e6e6e6`:`#333333`}function sh(e,t){let n=ih(e,t),r=n?.x??{},i=e.axesDesign?.x,a=i?.gridLines!==`none`&&i?.gridLines!==`minor`;return{...n,x:{...r,grid:{...r.grid,color:ah(e.background),display:a}}}}function ch(e,t){let n=sh(e,t),r=e.verticalAxisPosition||`left`;return{...n,y:{...n.y,position:r}}}function lh(e,t){let{locale:n,axisFormats:r,axisType:i}=t,a=r?.y||r?.y1,o=e.axesDesign?.y,s={x:{...gh(e,`bottom`,`labels`,i,{locale:n}),grid:{display:!1}},y:{position:e.verticalAxisPosition,ticks:{color:vm(e.background),callback:Tm({locale:n,format:a},e.humanize)},title:hh(e.axesDesign?.y),min:o?.min,max:o?.max,grid:{lineWidth:e=>e.tick.value===0?2:1,display:o?.gridLines!==`none`&&o?.gridLines!==`minor`,color:ah(e.background)}}};return(o?.gridLines===`minor`||o?.gridLines===`both`)&&(s.y.grid.minor={display:!0,color:oh(e.background)}),s}function uh(e,t){let{dataSetsValues:n}=t,r=th(e,t),i=r.x.ticks.callback;r.x.ticks.callback=e=>i(Math.abs(e));let a=Math.max(...n.map(e=>Math.max(...e.data.filter(pf).map(e=>Math.abs(e.value)))));return r.x.suggestedMin=-a,r.x.suggestedMax=a,r}function dh(e,t){let{locale:n,axisFormats:r,dataSetsValues:i}=t,a=Math.min(...i.map(e=>Math.min(...e.data.filter(pf).map(e=>e.value))));return{r:{beginAtZero:!0,ticks:{callback:Tm({format:r?.r,locale:n},e.humanize),backdropColor:e.background||`#FFFFFF`},pointLabels:{color:vm(e.background),callback:e=>Om(e)},suggestedMin:a<0?a-1:0}}}function fh(e,t){let{locale:n,axisFormats:r,availableRegions:i}=t,a=yh(e.legendPosition),o=e.region?i.find(t=>t.id===e.region):i[0],s=r?.y||r?.y1;return{projection:{projection:mh(o?.defaultProjection||`mercator`),axis:`x`},color:{axis:`x`,display:e.legendPosition!==`none`,border:{color:ze},grid:{color:ze},ticks:{color:vm(e.background),callback:Tm({locale:n,format:s},e.humanize)},legend:{position:a,align:a.includes(`right`)?`left`:`right`,margin:vh(e)},interpolate:_h(e.colorScale??He),missing:e.missingValueColor||`#ffffff`}}}function ph(e,t){let n=t.dataSetsValues[0];return{x:{display:!1},y:{grid:{offset:!1},ticks:{callback:function(e){return Om(this.getLabelForValue(e))}},border:{display:!1}},percentages:{position:`right`,border:{display:!1},ticks:{callback:function(e,r,i){let a=n.data?.[r],o=n.data?.[0];return!o?.value||a?.value===null||!pf(a)||!pf(o)?``:B(a.value/o.value,{format:`0%`,locale:t.locale})}},grid:{display:!1}}}}function mh(e){return globalThis.ChartGeo&&e===`conicConformal`?globalThis.ChartGeo.geoConicConformal().rotate([100,0]):e}function hh(e){if(e?.title?.text){let{text:t,color:n,align:r,italic:i,bold:a}=e.title;return{display:!0,text:t,color:n,font:{style:i?`italic`:`normal`,weight:a?`bold`:`normal`,size:e.title.fontSize??12},align:r===`left`?`start`:r===`right`?`end`:`center`}}}function gh(e,t,n,r,i){let{useLeftAxis:a,useRightAxis:o}=Cm(e);if(t===`left`&&!a||t===`right`&&!o)return;let s=vm(e.background),c;if(c=t===`bottom`?e.axesDesign?.x:t===`left`?e.axesDesign?.y:e.axesDesign?.y1,n===`values`){let n=!(t===`right`&&a),o=c?.gridLines?c?.gridLines===`major`||c?.gridLines===`both`:n,l=!(r===`category`||r===void 0)&&(c?.gridLines===`minor`||c?.gridLines===`both`),u=Tm(i,e.humanize),d={position:t,title:hh(c),beginAtZero:!c?.min,stacked:i?.stacked,ticks:{color:s,callback:u},min:c?.min,max:c?.max,grid:{display:o,color:ah(e.background)}};return l&&(d.grid.minor={display:!0,color:oh(e.background)}),d}else{let t={ticks:{padding:5,color:s,callback:function(e,t,n){return Om(this.getLabelForValue(e))}},min:c?.min,max:c?.max,grid:{display:c?.gridLines===`major`||c?.gridLines===`both`,color:ah(e.background)},stacked:i?.stacked,title:hh(c)};return(c?.gridLines===`minor`||c?.gridLines===`both`)&&(t.grid.minor={display:!0,color:oh(e.background)}),t}}function _h(e,t=0,n=1){if(t===n){let t=e.midColor??e.minColor;return e=>t}let r=[{value:t,color:e.minColor}];return e.midColor&&r.push({value:(t+n)/2,color:e.midColor}),r.push({value:n,color:e.maxColor}),_p(r)}function vh(e){switch(e.legendPosition){case`top`:case`right`:return{top:e.title.text?45:15,left:20,right:20};case`bottom`:case`left`:case`none`:return{left:20,right:20,bottom:10}}}function yh(e){switch(e){case`top`:return`top-left`;case`right`:return`top-right`;case`bottom`:return`bottom-right`;case`left`:return`bottom-left`;case`none`:return`bottom-left`}}let bh=`nullValue`;function xh(e,t){let{dataSetsValues:n,background:r}=t,i=[],a=Wh(e.dataSetStyles,n),o=[];for(let s in n){let{label:c,data:l,hidden:u,dataSetId:d}=n[s];c=e.dataSetStyles?.[d]?.label??c;let f=a.next(),p={label:c,data:l.map(e=>pf(e)?e.value:NaN),hidden:u,borderColor:e.background||r,borderWidth:+!!e.stacked,backgroundColor:f,yAxisID:e.horizontal?`y`:e.dataSetStyles?.[d]?.yAxisId??`y`,xAxisID:`x`,barPercentage:.9,categoryPercentage:n.length>1?.8:1,borderRadius:2};i.push(p);let m=e.dataSetStyles?.[d]?.trend,h=t.trendDataSetsValues?.[s];!m?.display||e.horizontal||!h||o.push(Hh(p,m,h))}i.push(...o);let s=Sh(e,n);return s&&i.push(s),i}function Sh(e,t){let n=t.filter(e=>!e.hidden);if(!e.stacked||!e.showTotalLine||n.length<2)return;let r=S(0,Math.max(...n.map(e=>e.data.length))).map(e=>{let t;for(let r of n){let n=r.data[e];pf(n)&&(t=(t??0)+n.value)}return t??NaN}),i=If(e.background||`#FFFFFF`)<.3?`#e9ecef`:`#343a40`;return{type:`line`,label:M(`Sum`),data:r,order:-1,tension:0,fill:!1,pointRadius:3,borderWidth:2,backgroundColor:i,borderColor:i,pointBackgroundColor:i,xAxisID:`x`,yAxisID:`y`}}function Ch(e,t){let{labels:n,dataSetsValues:r,background:i}=t,a=r.map(e=>e.data).flat().filter(pf).map(e=>e.value),o=Math.max(...a),s=Math.min(...a),c=_h(e.colorScale??He,s,o),l=[];for(let t of r)l.push({label:t.label,data:t.data.map(e=>1),backgroundColor:t.data.map(t=>pf(t)?c(t.value):e.missingValueColor||`#00000000`),borderColor:e.background||i,borderSkipped:!1,borderWidth:1,barPercentage:1,categoryPercentage:1,values:t.data.map(e=>pf(e)?e.value:void 0)});return{labels:n,datasets:l}}function wh(e,t){let{dataSetsValues:n,labels:r}=t,i=e.negativeValuesColor||`#EA6175`,a=e.positiveValuesColor||`#4EA7F2`,o=e.subTotalValuesColor||`#AAAAAA`,s=[],c=[],l={label:``,data:c,backgroundColor:s},u=[],d=0;for(let t of n)if(!t.hidden){for(let l=0;l<t.data.length;l++){let f=t.data[l];if(u.push(r[l]),!pf(f)){c.push([d,d]),s.push(``);continue}c.push([d,f.value+d]);let p=f.value>=0?a:i;l===0&&t===n[0]&&e.firstValueAsSubtotal&&(p=o),s.push(p),d+=f.value}e.showSubTotals&&(u.push(M(`Subtotal`)),c.push([0,d]),s.push(o))}return{datasets:[l],labels:u}}function Th(e,t){let{dataSetsValues:n,axisType:r,labels:i}=t,a=[],o=!!e.fillArea,s=!!e.stacked,c=[],l=Wh(e.dataSetStyles,n);for(let u=0;u<n.length;u++){let{label:d,data:f,hidden:p,dataSetId:m}=n[u];d=e.dataSetStyles?.[m]?.label??d;let h=[],g=l.next();h=r&&[`linear`,`time`].includes(r)?f.map((e,t)=>({x:i[t]===``?NaN:i[t]??NaN,y:pf(e)?e.value:NaN})):f.map(e=>pf(e)?e.value:NaN);let _=e.dataSetStyles?.[m],v={label:d,data:h,hidden:p,tension:0,borderColor:g,backgroundColor:o?qf(g,it):g,pointBackgroundColor:g,fill:o?Uh(u,s):!1,pointRadius:e.hideDataMarkers?0:3,yAxisID:_?.yAxisId||`y`};a.push(v);let ee=_?.trend,y=t.trendDataSetsValues?.[u];!ee?.display||!y||c.push(Hh(v,ee,y))}return a.push(...c),a}function Eh(e,t){let n=Th(e,t);for(let e of n)km(e.xAxisID)||(e.showLine=!1);return n}function Dh(e,t){let n,r;if(e.bubbleColor.color===`multiple`){let i=new fp(t.bubbleSizes.length);r=[];for(let e=0;e<t.bubbleSizes.length;e++)r.push(i.next());n=r.map(t=>qf(t,e.bubbleColor.transparent?.5:1))}else r=e.bubbleColor.color,n=qf(r,e.bubbleColor.transparent?.5:1);let i=Oh(t.bubbleSizes),a=[];for(let e=0;e<t.bubbleSizes.length;e++){let n=t.dataSetsValues[0].data[e];a.push({x:t.labels[e],y:pf(n)?n.value:NaN})}return[{label:t.dataSetsValues[0]?.label,data:a,backgroundColor:n,borderColor:r,hoverBackgroundColor:n,hoverBorderColor:r,yAxisID:`y`,pointRadius:i,pointHoverRadius:i,showLine:!1}]}function Oh(e){if(!e.length)return[];let t=e.filter(e=>Number.isFinite(e)&&e>0),n=t.length?Math.min(...t):0,r=(t.length?Math.max(...t):0)-n;return t.length?e.map(e=>e===void 0||!Number.isFinite(e)||e<0?0:e===0?2:r===0?10:10+x((e-n)/r,0,1)*20):e.map(()=>2)}function kh(e,t){let{dataSetsValues:n}=t,r=[],i=Dm(new fp(Math.max(0,...n.map(e=>e?.data?.length??0)),e.slicesColors),n);for(let{label:t,data:a,hidden:o}of n){if(o)continue;let n={label:t,data:a.map(e=>pf(e)?e.value:NaN),borderColor:e.background||`#FFFFFF`,backgroundColor:i,hoverOffset:10};r.push(n)}return r}function Ah(e,t){let{dataSetsValues:n}=t,r=[],i=Wh(e.dataSetStyles,n),a=[],o=n.filter(({dataSetId:t})=>(e.dataSetStyles?.[t]?.type??`line`)===`bar`);for(let s=0;s<n.length;s++){let{label:c,data:l,hidden:u,dataSetId:d}=n[s];c=e.dataSetStyles?.[d]?.label||c;let f=e.dataSetStyles?.[d],p=i.next(),m=s===0?`bar`:`line`,h=f?.type??m,g={label:c,data:l.map(e=>pf(e)?e.value:null),hidden:u,borderColor:p,backgroundColor:p,yAxisID:e.dataSetStyles?.[d]?.yAxisId||`y`,xAxisID:`x`,type:h,order:h===`bar`?n.length+s:s,pointRadius:e.hideDataMarkers?0:3};g.type===`bar`&&(g.barPercentage=.9,g.categoryPercentage=o.length>1?.8:1,g.borderRadius=2),r.push(g);let _=e.dataSetStyles?.[d]?.trend,v=t.trendDataSetsValues?.[s];!_?.display||!v||a.push(Hh(g,_,v))}return r.push(...a),r}function jh(e,t){let{dataSetsValues:n}=t,r=[],i=e.fillArea??!1,a=Wh(e.dataSetStyles,n);for(let t=0;t<n.length;t++){let{label:o,data:s,hidden:c}=n[t];e.dataSetStyles?.[t]?.label&&(o=e.dataSetStyles[t].label);let l=a.next(),u={label:o,data:s.map(e=>pf(e)?e.value:null),hidden:c,borderColor:l,backgroundColor:l,pointBackgroundColor:l,pointRadius:e.hideDataMarkers?0:3};i&&(u.backgroundColor=qf(l,it),u.fill=`start`),r.push(u)}return r}function Mh(e,t){let{availableRegions:n,dataSetsValues:r,labels:i}=t,a=e.region||n[0]?.id,o=a?t.getGeoJsonFeatures(a):void 0,s={outline:o,showOutline:!!o,data:[]};if(o&&a){let e={};if(r[0])for(let n=0;n<r[0].data.length;n++){let o=r[0].data[n];if(!i[n]||o===void 0)continue;let s=t.geoFeatureNameToId(a,i[n]);s&&(e[s]={value:pf(o)?o.value:0,label:i[n]})}for(let t of o)t.id&&s.data.push({feature:{...t,properties:{name:e[t.id]?.label}},value:e[t.id]?.value})}return[s]}function Nh(e,t){let n=t.dataSetsValues[0],{labels:r,background:i}=t;if(!n)return[];let{label:a,data:o}=n;return a=e.dataSetStyles?.[0]?.label||a,[{label:a,data:o.map(e=>{if(!pf(e))return 0;let t=e.value;return t<=0?[0,0]:[-t,t]}),backgroundColor:Ph(r,e.funnelColors),yAxisID:`y`,xAxisID:`x`,barPercentage:1,categoryPercentage:1,borderColor:e.background||i,borderWidth:3}]}function Ph(e,t){let n=new fp(e.length,t);return e.map(()=>n.next())}function Fh(e,t){let{dataSetsValues:n,labels:r,background:i}=t,a=zh(Lh(n,r)),o=a[0]||[],s=new fp(o.length,e.groupColors||[]),c=o.map(e=>({label:e.label,color:s.next()})),l=[];for(let t=a.length-1;t>=0;t--){let n={groupColors:c,parsing:{key:`value`},data:a[t],borderColor:t=>{let n=t.type===`data`?t.raw:void 0;return!n||n.label===`nullValue`?Ie:e.background||i},backgroundColor:e=>{let t=e.type===`data`?e.raw:void 0;if(!t||t.label===`nullValue`)return Ie;let n=t.groups[0];return c.find(e=>e.label===n)?.color},hoverOffset:10};l.push(n)}return l}function Ih(e,t){let n=[],r=Math.max(...e.map(e=>e.data.length));for(let i=0;i<r;i++){n[i]={};for(let t=0;t<e.length;t++){let r=e[t].data[i]?.value,a=r===null?bh:String(r);n[i][t]=a}n[i].value=Number(t[i])}return n}function Lh(e,t){return Rh(Ih(e,t),0,e.length,[])}function Rh(e,t,n,r){if(t>=n)return[];let i=Object.groupBy(e,e=>e[t]);return Object.keys(i).map(e=>{let a=i[e]?.reduce((e,t)=>e+Number(t.value),0)||0,o=[...r,e];return{label:e,value:a,children:Rh(i[e]||[],t+1,n,[...r,e]),groups:o,depth:t}}).sort((e,t)=>t.value-e.value)}function zh(e){let t=[],n=[...e];for(;n.length>0;){let e=n.shift();e&&(t[e.depth]||(t[e.depth]=[]),t[e.depth].push(e),e.children&&n.push(...e.children))}return t}function Bh(e,t){let{dataSetsValues:n,labels:r,locale:i,axisFormats:a}=t,o={locale:i,format:a?.y};if(n.length===0)return[];let s=Lh(n,r).sort((e,t)=>t.value-e.value),c=Gh(e,s),l=[],u=Math.max(...n.map(e=>e.data.length));for(let e=0;e<u;e++){l[e]={};for(let t=0;t<n.length;t++)l[e][t]=n[t].data[e].value?String(n[t].data[e].value):void 0;l[e].value=Number(r[e])}let d=e.showLabels??qm.showLabels,f=e.showValues??qm.showValues,p=e.coloringOptions||qm.coloringOptions,m;return p?.type===`colorScale`&&(m=Kh(s,p)),[{data:[],tree:l,labels:{display:d||f,overflow:`hidden`,...Vh(e.valuesDesign,qm.valuesDesign),formatter:e=>[d?e.raw.g:void 0,f?B(e.raw.v,o):void 0].filter(C)},captions:{display:e.showHeaders??qm.showHeaders,padding:6,...Vh(e.headerDesign,qm.headerDesign)},key:`value`,groups:S(0,n.length).map(e=>String(e)),borderWidth:0,spacing:1,displayMode:`headerBoxes`,groupColors:c,backgroundColor:t=>{if(t.type!==`data`)return`transparent`;if(!t.raw.isLeaf)return e.headerDesign?.fillColor||qm.headerDesign?.fillColor;if(p.type===`colorScale`)return m?.(t.raw.v)||`#FF0000`;if(p.type===`categoryColor`)return qh(t,s,p,c);throw Error(`Unsupported coloring option type}`)}}]}function Vh(e,t){let n=e=>{let t=e.element.options.backgroundColor;return If(t)>.7?`#666666`:`#FFFFFF`};return{align:e?.align??t?.align,position:e?.verticalAlign??t?.verticalAlign,color:e?.color||n,hoverColor:e?.color||n,font:{weight:e?.bold??t?.bold?`bold`:`normal`,style:e?.italic??t?.italic?`italic`:`normal`,size:e?.fontSize??t?.fontSize}}}function Hh(e,t,n){let r=zf(e.backgroundColor);r.a=1;let i=t.color||Jf(Rf(r),.5);return{type:`line`,xAxisID:t.type===`trailingMovingAverage`?um:`x1`,yAxisID:e.yAxisID,label:e.label?M(`Trend line for %s`,e.label):``,data:n,order:-1,showLine:!0,pointRadius:0,backgroundColor:i,borderColor:i,borderDash:[5,5],borderWidth:void 0,fill:!1,pointBackgroundColor:i}}function Uh(e,t){return t?e===0?`origin`:`-1`:`origin`}function Wh(e,t){let n=t.map(t=>e?.[t.dataSetId]?.backgroundColor),r=t.length;return new fp(r,n)}function Gh(e,t){let n=e.coloringOptions?.type===`categoryColor`?e.coloringOptions.colors:[],r=new fp(t.length,n);return t.map(e=>({label:e.label,color:r.next()}))}function Kh(e,t){if(e.length===0)return;let n=zh(e),r=n[n.length-1],i=Math.min(...r.map(e=>e.value)),a=Math.max(...r.map(e=>e.value));if(Number.isFinite(i)&&Number.isFinite(a)){let e=[{value:i,color:t.minColor}];if(t.midColor){let n=(i+a)/2;e.push({value:n,color:t.midColor})}return e.push({value:a,color:t.maxColor}),_p(e)}}function qh(e,t,n,r){let i=e.raw._data.children[0][0],a=r.find(e=>e.label===i)?.color;if(!a||!n.useValueBasedGradient)return a||`#FF0000`;let o=t.find(e=>e.label===i);if(!o||!o.children.length)return a;let s=zh(o.children),c=s[s.length-1],l=Math.max(...c.map(e=>e.value)),u=Math.min(...c.map(e=>e.value));return u===l||!isFinite(u)||!isFinite(l)?a:Jf(a,((Number(e.raw.v)||0)-l)/(u-l)*.5)}let Jh={id:`sunburstHoverPlugin`,afterEvent(e,t,n){if(!n.enabled)return;let r=e.getActiveElements(),i=r.map(e=>({datasetIndex:e.datasetIndex,index:e.index}));for(let t of r){let n=e.data.datasets[t.datasetIndex].data[t.index];for(let t=0;t<e.data.datasets.length;t++){let r=e.data.datasets[t];for(let e=0;e<r.data.length;e++){let a=r.data[e];Yh(n.groups,a.groups)&&i.push({datasetIndex:t,index:e})}}}i=i.filter(t=>{let{datasetIndex:n,index:r}=t;return e.data.datasets[n].data[r].label!==bh}),e.setActiveElements(i);for(let t of e.getSortedVisibleDatasetMetas())for(let e of t.data){let t=e.$context,{datasetIndex:n,index:r,dataset:a,raw:o}=t;if(o.label===`nullValue`)continue;let s=typeof a.backgroundColor==`function`?a.backgroundColor(t):a.backgroundColor;i.length&&!i.some(e=>e.datasetIndex===n&&e.index===r)?e.options.backgroundColor=Jf(s,.5):e.options.backgroundColor=s}}};function Yh(e,t){return t.length>e.length&&e.every((e,n)=>e===t[n])}let Xh={id:`sunburstLabelsPlugin`,afterDatasetsDraw(e,t,n){if(!n.showValues&&!n.showLabels||e.config.type!==`doughnut`)return;let r=e.ctx;Zh(e,n,r)}};function Zh(e,t,n){let r=t.style,i=r.fontSize||13,a=i+3;for(let o of e._metasets)for(let s=0;s<o._dataset.data.length;s++){let c=o._dataset.data[s];if(c.label===`nullValue`)continue;let l=[t.showLabels?c.label:void 0,t.showValues?t.callback(c.value,`y`):void 0].filter(C),u=o.data[s],{startAngle:d,endAngle:f,innerRadius:p,outerRadius:m,circumference:h}=u,g=u.options.offset/4,_=g*(1-Math.sin(Math.min(Math.PI,h||0)));p+=_,m+=_;let v=(d+f)/2,ee=(p+m)/2,y=(m-p)*.9,te=f-d;if((te>=Math.PI?m:Math.sin(te/2)*p*2)<l.length*a)continue;n.save();let ne={x:Math.cos(v)*g,y:Math.sin(v)*g},re=e.chartArea.left+e.chartArea.width/2+ne.x,ie=e.chartArea.top+e.chartArea.height/2+ne.y;n.translate(re,ie);let ae;v>Math.PI/2?(n.rotate(v-Math.PI),ae=-ee):(ae=ee,n.rotate(v));let oe=u.options.backgroundColor,se=If(oe)>.7?`#666666`:`#FFFFFF`;n.fillStyle=r.textColor||se,n.textAlign=`center`,n.textBaseline=`middle`,n.font=wp(i,r.bold,r.italic);let ce=-((l.length-1)*a)/2;for(let e=0;e<l.length;e++){let t=Hp(n,y,l[e],r,`px`);n.fillText(t,ae,ce+e*a)}n.restore()}}let Qh={id:`waterfallLinesPlugin`,beforeDraw(e,t,n){if(!n.showConnectorLines)return;let r=e._metasets?.[0]?.data;if(!r)return;let i=e.ctx;i.save(),i.setLineDash([3,2]);for(let e=0;e<r.length;e++){let t=r[e];if(t.height===0)continue;let n=eg(r,e);if(!n)break;let a=$h(t),o=$h(n),s=t.$context.raw,c=s[1]-s[0],l=Math.round(c<0?a.bottom-1:a.top),u=Math.round(a.right),d=Math.round(o.left);i.strokeStyle=`#999`,i.beginPath(),i.moveTo(u+1,l+.5),i.lineTo(d,l+.5),i.stroke()}i.restore()}};function $h(e){let t=e.base<e.y;return{left:e.x-e.width/2,right:e.x+e.width/2,bottom:t?e.base+e.height:e.y+e.height,top:t?e.base:e.y}}function eg(e,t){return e.find((e,n)=>n>t&&e.height!==0)}let tg={id:`zoomWindowPlugin`,afterDatasetsDraw:function(e,t,n){if(!n.getLowerBound||!n.getUpperBound)return;let{ctx:r,chartArea:{left:i,right:a,top:o,bottom:s}}=e,c=n.getLowerBound()??i,l=n.getUpperBound()??a;c>l&&([c,l]=[l,c]),c=Math.max(i,c),l=Math.min(a,l),c===i&&--c,l===a&&(l+=1),r.save(),r.fillStyle=`rgba(255,255,255,0.5)`,r.beginPath(),r.rect(i,s,c-i,o-s),r.rect(l,s,a-l,o-s),r.fill(),r.beginPath(),r.strokeStyle=`#bbb`,r.rect(c,s,l-c,o-s),r.stroke(),r.lineWidth=2,r.beginPath(),r.moveTo(c-3,(o+s)/2-7),r.lineTo(c-3,(o+s)/2+7),r.stroke(),r.beginPath(),r.moveTo(l+3,(o+s)/2-7),r.lineTo(l+3,(o+s)/2+7),r.stroke(),r.restore()}};Qr.add(`chartShowValuesPlugin`,{register:e=>e.register(Mm),unregister:e=>e.unregister(Mm)}),Qr.add(`chartMinorGridPlugin`,{register:e=>e.register(Yp),unregister:e=>e.unregister(Yp)}),Qr.add(`waterfallLinesPlugin`,{register:e=>e.register(Qh),unregister:e=>e.unregister(Qh)}),Qr.add(`funnelController`,{register:e=>e.register(Gp()),unregister:e=>e.unregister(Gp())}),Qr.add(`funnelElement`,{register:e=>e.register(Kp()),unregister:e=>e.unregister(Kp())}),Qr.add(`funnelTooltipPositioner`,{register:e=>e.Tooltip.positioners.funnelTooltipPositioner=Jp,unregister:e=>e.Tooltip.positioners.funnelTooltipPositioner=void 0}),Qr.add(`sunburstLabelsPlugin`,{register:e=>e.register(Xh),unregister:e=>e.unregister(Xh)}),Qr.add(`sunburstHoverPlugin`,{register:e=>e.register(Jh),unregister:e=>e.unregister(Jh)}),Qr.add(`chartColorScalePlugin`,{register:e=>e.register(Wp),unregister:e=>e.unregister(Wp)}),Qr.add(`calendarController`,{register:e=>e.register(Ea()),unregister:e=>e.unregister(Ea())}),Qr.add(`zoomWindowPlugin`,{register:e=>e.register(tg),unregister:e=>e.unregister(tg)}),Qr.add(`chartBackgroundPlugin`,{register:e=>e.register(Ta),unregister:e=>e.unregister(Ta)});var ng=class extends O{static template=`o-spreadsheet-ChartJsComponent`;props=(0,t.useProps)({chartId:j.string(),isFullScreen:j.boolean().optional()});canvas=(0,t.signal)(null);chart;currentRuntime;animationStore;currentDevicePixelRatio=window.devicePixelRatio;get chartRuntime(){let e=this.env.model.getters.getChartRuntime(this.props.chartId);if(!(`chartJsConfig`in e))throw Error(`Unsupported chart runtime`);return e}setup(){this.shouldAnimate&&(this.animationStore=k(wa)),(0,t.onMounted)(()=>{ei();let e=this.chartRuntime;this.currentRuntime=e,this.createChart(b(e))}),(0,t.onWillUnmount)(this.unmount.bind(this)),Gi(()=>{let e=this.chartRuntime;e===this.currentRuntime?this.currentDevicePixelRatio!==window.devicePixelRatio&&(this.currentDevicePixelRatio=window.devicePixelRatio,this.updateChartJs(b(this.currentRuntime))):(e.chartJsConfig.type===this.currentRuntime.chartJsConfig.type?this.updateChartJs(b(e)):(this.chart?.destroy(),this.createChart(b(e))),this.currentRuntime=e)})}unmount(){this.chart?.destroy()}get shouldAnimate(){return this.env.model.getters.isDashboard()}createChart(e){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);let t=e.chartJsConfig;if(this.shouldAnimate&&this.animationStore){let e=this.env.model.getters.getChartDefinition(this.props.chartId)?.type;e&&this.animationStore.animationPlayed[this.animationChartId]!==e&&(t=this.enableAnimationInChartData(t),this.animationStore.disableAnimationForChart(this.animationChartId,e))}let n=this.canvas();if(!n)return;let r=n.getContext(`2d`);this.chart=new globalThis.Chart(r,t)}updateChartJs(e){let t=e.chartJsConfig;if(this.shouldAnimate){let e=this.env.model.getters.getChartDefinition(this.props.chartId)?.type;e&&this.hasChartDataChanged()&&this.animationStore&&(t=this.enableAnimationInChartData(t),this.animationStore.disableAnimationForChart(this.animationChartId,e))}t.data&&t.data.datasets?(this.chart.data=t.data,t.options?.plugins?.title&&(this.chart.config.options.plugins.title=t.options.plugins.title)):this.chart.data.datasets=[],this.chart.config.options=t.options,this.chart.update()}hasChartDataChanged(){return!w(this.getChartDataInRuntime(this.currentRuntime),this.getChartDataInRuntime(this.chartRuntime))}enableAnimationInChartData(e){return{...e,options:{...e.options,animation:{animateRotate:!0}}}}getChartDataInRuntime(e){let t=e.chartJsConfig.data;return{labels:t.labels,dataset:t.datasets.map(e=>({data:e.data,label:e.label,tree:e.tree}))}}get animationChartId(){return this.props.isFullScreen?this.props.chartId+`-fullscreen`:this.props.chartId}},rg=class{static commonKeys=[`type`,`title`,`background`,`humanize`,`annotationText`,`annotationLink`]};function ig(e,t,n,r,i){if(!e)return``;if(n===`text`||t?.type!==`number`||e.type!==`number`)return r?Fc(e,i):e.formattedValue;let{value:a,format:o}=e;return n===`progress`?(a=t.value/a,o=`0.0%`):(a=Math.abs(t.value-a),n===`percentage`&&a!==0&&(a/=e.value),n===`percentage`&&(o=`0.0%`),o||(a=Math.round(a*100)/100)),r?Fc({value:a,format:o},i):B(a,{format:o,locale:i})}function ag(e,t,n){return e?t?Fc(e,n):e.formattedValue??String(e.value??``):``}function og(e,t,n,r,i){if(t===`text`||t===`progress`||e?.type!==`number`||n?.type!==`number`)return;let a=n.value-e.value;if(a>0)return r;if(a<0)return i}function sg(e,t,n){if(n===`text`||e?.type!==`number`||t?.type!==`number`)return`neutral`;let r=t.value-e.value;return r>0?`up`:r<0?`down`:`neutral`}function cg(e){return e.keyValue&&!xl.test(e.keyValue)?`InvalidScorecardKeyValue`:`Success`}function lg(e){return e.baseline&&!xl.test(e.baseline)?`InvalidScorecardBaseline`:`Success`}let ug=globalThis.Path2D,dg=ug&&new ug(`M8.6 4.8a.5.5 0 0 1 0 .75l-3.9 3.9a.5 .5 0 0 1 -.75 0l-3.8 -3.9a.5 .5 0 0 1 0 -.75l.4-.4a.5.5 0 0 1 .75 0l2.3 2.4v-5.7c0-.25.25-.5.5-.5h.6c.25 0 .5.25.5.5v5.8l2.3 -2.4a.5.5 0 0 1 .75 0z`),fg=ug&&new ug(`M8.7 5.5a.5.5 0 0 0 0-.75l-3.8-4a.5.5 0 0 0-.75 0l-3.8 4a.5.5 0 0 0 0 .75l.4.4a.5.5 0 0 0 .75 0l2.3-2.4v5.8c0 .25.25.5.5.5h.6c.25 0 .5-.25.5-.5v-5.8l2.2 2.4a.5.5 0 0 0 .75 0z`),pg={sequence:40,allowedDefinitionKeys:[...rg.commonKeys,`keyValue`,`keyDescr`,`baseline`,`baselineMode`,`baselineDescr`,`baselineColorUp`,`baselineColorDown`],fromStrDefinition(e,t,n){let r=Pu(n,t,e.baseline),i=Pu(n,t,e.keyValue);return{...e,baseline:r,keyValue:i}},validateDefinition(e,t){return e.checkValidations(t,cg,lg)},copyInSheetId:e=>e,getDefinitionFromContextCreation(e,t){return{background:e.background,type:`scorecard`,keyValue:e.dataSource?.type===`range`?e.dataSource?.dataSets?.[0]?.dataRange:void 0,title:e.title||{text:``},baselineMode:tt,baselineColorUp:nt,baselineColorDown:rt,baseline:e.auxiliaryRange||``,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},transformDefinition(e,t,{adaptRangeString:n}){let r,i;if(e.baseline){let{changeType:i,range:a}=n(t,e.baseline);i!==`REMOVE`&&(r=a)}if(e.keyValue){let{changeType:r,range:a}=n(t,e.keyValue);r!==`REMOVE`&&(i=a)}return{...e,baseline:r,keyValue:i}},duplicateInDuplicatedSheet(e,t,n){let r=fm(t,n,e.baseline),i=fm(t,n,e.keyValue);return{...e,baseline:r,keyValue:i}},toStrDefinition(e,t,n){return{...e,keyValue:e.keyValue?n.getRangeString(e.keyValue,t):void 0,baseline:e.baseline?n.getRangeString(e.baseline,t):void 0}},getContextCreation(e,t){return{...e,dataSource:{type:`range`,dataSets:e.keyValue?[{dataRange:e.keyValue,dataSetId:`0`}]:[]},auxiliaryRange:e.baseline}},getDefinitionForExcel:()=>void 0,updateRanges(e,t){let n=pm(e.baseline,t),r=pm(e.keyValue,t);return e.baseline===n&&e.keyValue===r?e:{...e,baseline:n,keyValue:r}},getFormulas:()=>[],getRuntime(e,t){let n=``,r,i=e.getLocale();if(t.keyValue){let a={sheetId:t.keyValue.sheetId,col:t.keyValue.zone.left,row:t.keyValue.zone.top};r=e.getEvaluatedCell(a),n=ag(r,t.humanize??!0,i)}let a,o=t.baseline;if(o){let t={sheetId:o.sheetId,col:o.zone.left,row:o.zone.top};a=e.getEvaluatedCell(t)}let{background:s,fontColor:c}=e.getStyleOfSingleCellChart(t.background,t.keyValue),l=ig(a,r,t.baselineMode,t.humanize??!0,i),u=t.baselineMode===`progress`&&bo(l,i)?F(l,i):0,d=t.title;return{title:{...d,text:d.text?e.dynamicTranslate(d.text):``},keyValue:n,keyDescr:t.keyDescr?.text?e.dynamicTranslate(t.keyDescr.text):``,baselineDisplay:l,baselineArrow:sg(a,r,t.baselineMode),baselineColor:og(a,t.baselineMode,r,t.baselineColorUp,t.baselineColorDown),baselineDescr:t.baselineMode!==`progress`&&t.baselineDescr?.text?e.dynamicTranslate(t.baselineDescr.text):``,fontColor:c,background:s,baselineStyle:{...t.baselineMode!==`percentage`&&t.baselineMode!==`progress`&&o?e.getCellComputedStyle({sheetId:o.sheetId,col:o.zone.left,row:o.zone.top}):void 0,fontSize:t.baselineDescr?.fontSize,align:t.baselineDescr?.align},baselineDescrStyle:{textColor:t.baselineDescr?.color,...t.baselineDescr},keyValueStyle:{...t.keyValue?e.getCellComputedStyle({sheetId:t.keyValue.sheetId,col:t.keyValue.zone.left,row:t.keyValue.zone.top}):void 0,fontSize:t.keyDescr?.fontSize,align:t.keyDescr?.align},keyValueDescrStyle:{textColor:t.keyDescr?.color,...t.keyDescr},progressBar:t.baselineMode===`progress`?{value:u,color:u>0?t.baselineColorUp:t.baselineColorDown}:void 0}}};function mg(e,t,n=1){let r=t.getContext(`2d`);if(!r)throw Error(`Unable to retrieve 2D context from canvas`);let i=typeof globalThis.devicePixelRatio==`number`?globalThis.devicePixelRatio:1;t.width=i*e.canvas.width*n,t.height=i*e.canvas.height*n,r.scale(i*n,i*n);let a=e.canvas.width-20;if(r.fillStyle=e.canvas.backgroundColor,r.fillRect(0,0,e.canvas.width,e.canvas.height),e.title){r.font=e.title.style.font,r.fillStyle=e.title.style.color;let t=r.textBaseline;r.textBaseline=`middle`,r.fillText(Bp(r,e.title.text,a-e.title.position.x),e.title.position.x,e.title.position.y),r.textBaseline=t}if(e.baseline&&(r.font=e.baseline.style.font,r.fillStyle=e.baseline.style.color,Vp(r,e.baseline.text,e.baseline.position,e.baseline.style.underline,e.baseline.style.strikethrough,void 0,e.baseline.style.highlightText)),e.baselineArrow&&e.baselineArrow.style.size>0&&ug){r.save(),r.fillStyle=e.baselineArrow.style.highlight?Jf(e.baselineArrow.style.color,Xe):e.baselineArrow.style.color,r.translate(e.baselineArrow.position.x,e.baselineArrow.position.y);let t=e.baselineArrow.style.size/10;switch(r.scale(t,t),e.baselineArrow.direction){case`down`:r.fill(dg);break;case`up`:r.fill(fg);break}r.restore()}if(e.baselineDescr){let t=e.baselineDescr;r.font=t.style.font,r.fillStyle=t.style.color,Vp(r,Bp(r,t.text,a-t.position.x),t.position,void 0,void 0,void 0,e.baseline?.style.highlightText)}if(e.key&&(r.font=e.key.style.font,r.fillStyle=e.key.style.color,Vp(r,Bp(r,e.key.text,a-e.key.position.x),e.key.position,e.key.style.underline,e.key.style.strikethrough,void 0,e.key.style.highlightText)),e.keyDescr){let t=e.keyDescr;r.font=e.keyDescr?.style.font??t.style.font,r.fillStyle=t.style.color,Vp(r,Bp(r,t.text,a-t.position.x),t.position,void 0,void 0,void 0,e.key?.style.highlightText)}if(e.progressBar){if(r.fillStyle=e.progressBar.style.backgroundColor,r.beginPath(),r.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width,e.progressBar.dimension.height,e.progressBar.dimension.height/2),r.fill(),r.fillStyle=e.progressBar.style.color,r.beginPath(),e.progressBar.value>0)r.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width*Math.max(0,Math.min(1,e.progressBar.value)),e.progressBar.dimension.height,e.progressBar.dimension.height/2);else{let t=e.progressBar.dimension.width*Math.max(0,Math.min(1,-e.progressBar.value));r.roundRect(e.progressBar.position.x+e.progressBar.dimension.width-t,e.progressBar.position.y,t,e.progressBar.dimension.height,e.progressBar.dimension.height/2)}r.fill()}}let hg=.05;function gg(e,t){let n=e||``;return t&&n?` `+n:n}function _g({width:e,height:t},n){return new vg({width:e,height:t},n).computeDesign()}var vg=class{runtime;context;width;height;constructor({width:e,height:t},n){if(this.runtime=n,this.width=e,this.height=t,typeof OffscreenCanvas>`u`)throw Error(`OffscreenCanvas is not supported in this environment`);let r=new globalThis.OffscreenCanvas(e,t).getContext(`2d`);if(!r)throw Error(`Unable to create scorecard measurement context`);this.context=r}computeDesign(){let e={canvas:{width:this.width,height:this.height,backgroundColor:this.backgroundColor}},t=this.getTextStyles(),n=0;if(this.title){let r,i;switch({height:n,width:i}=this.getFullTextDimensions(this.title,t.title.font),this.runtime.title.align){case`center`:r=(this.width-i)/2;break;case`right`:r=this.width-i-20;break;default:r=20}e.title={text:this.title,style:t.title,position:{x:r,y:10+n/2}}}let r=t.baselineArrow?.size??0,{height:i,width:a}=this.getTextDimensions(this.baseline,t.baselineValue.font);this.baseline||(i=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).height);let o=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).width,s;switch(this.runtime.baselineStyle?.align){case`right`:s=this.width-20-o-a;break;case`left`:s=20+r;break;default:s=(this.width-a-o+r)/2}if(this.baseline&&(e.baseline={text:this.baseline,style:t.baselineValue,position:{x:s,y:this.keyValue?this.height*(1-hg*(this.runtime.progressBar?1:2)):this.height-(this.height-n-i)/2-10}},t.baselineArrow&&!this.runtime.progressBar&&(e.baselineArrow={direction:this.baselineArrow,style:t.baselineArrow,position:{x:e.baseline.position.x-r,y:e.baseline.position.y-(i+r)/2}})),e.baseline&&this.baselineDescr){let n={x:e.baseline.position.x+a,y:e.baseline.position.y};e.baselineDescr={text:this.baselineDescr,style:t.baselineDescr,position:n}}let c=0;this.runtime.progressBar&&(c=this.height*.05,e.progressBar={position:{x:40,y:this.height*(1-2*hg)-i-c},dimension:{height:c,width:this.width-80},value:this.runtime.progressBar.value,style:{color:this.runtime.progressBar.color,backgroundColor:this.secondaryFontColor}});let{width:l,height:u}=this.getFullTextDimensions(this.keyValue,t.keyValue.font),d=this.getTextDimensions(this.keyDescr,t.keyDescr.font).width,f;switch(this.runtime.keyValueStyle?.align){case`right`:f=this.width-20-d-l;break;case`left`:f=20;break;default:f=(this.width-l-d)/2}if(this.keyValue&&(e.key={text:this.keyValue,style:t.keyValue,position:{x:Math.max(20,f),y:this.height*(.5-hg*2)+10/2+(n+u/2)/2}}),e.key&&this.keyDescr){let n={x:e.key.position.x+l,y:e.key.position.y};e.keyDescr={text:this.keyDescr,style:t.keyDescr,position:n}}return e}get title(){return this.runtime.title.text??``}get keyValue(){return this.runtime.keyValue}get keyDescr(){return gg(this.runtime.keyDescr,this.keyValue)}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){return gg(this.runtime.baselineDescr,this.baseline)}get baselineArrow(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get secondaryFontColor(){return ym(this.backgroundColor)}getTextDimensions(e,t){this.context.font=t;let n=this.context.measureText(e);return{width:n.width,height:n.actualBoundingBoxAscent+n.actualBoundingBoxDescent}}getFullTextDimensions(e,t){this.context.font=t;let n=this.context.measureText(e);return{width:n.width,height:n.fontBoundingBoxAscent+n.fontBoundingBoxDescent}}getTextStyles(){let e=this.runtime.keyValueStyle?.fontSize??32,t=Math.floor(.9*e),n=this.runtime.baselineStyle?.fontSize??16,r=Math.floor(.9*n);return this.runtime.progressBar&&(n/=1.5),{title:{font:wp(this.runtime.title.fontSize??14,this.runtime.title.bold,this.runtime.title.italic),color:this.runtime.title.color??this.secondaryFontColor},keyValue:{color:this.runtime.keyValueStyle?.textColor||this.runtime.fontColor,font:wp(e,this.runtime.keyValueStyle?.bold,this.runtime.keyValueStyle?.italic),strikethrough:this.runtime.keyValueStyle?.strikethrough,underline:this.runtime.keyValueStyle?.underline,highlightText:this.runtime.keyHighlight},keyDescr:{color:this.runtime.keyValueDescrStyle?.textColor||this.runtime.fontColor,font:wp(t,this.runtime.keyValueDescrStyle?.bold,this.runtime.keyValueDescrStyle?.italic),strikethrough:this.runtime.keyValueDescrStyle?.strikethrough,underline:this.runtime.keyValueDescrStyle?.underline,highlightText:this.runtime.keyHighlight},baselineValue:{font:wp(n,this.runtime.baselineStyle?.bold,this.runtime.baselineStyle?.italic),strikethrough:this.runtime.baselineStyle?.strikethrough,underline:this.runtime.baselineStyle?.underline,color:this.runtime.baselineColor||this.runtime.baselineStyle?.textColor||this.secondaryFontColor,highlightText:this.runtime.baselineHighlight},baselineDescr:{font:wp(r,this.runtime.baselineDescrStyle?.bold,this.runtime.baselineDescrStyle?.italic),strikethrough:this.runtime.baselineDescrStyle?.strikethrough,underline:this.runtime.baselineDescrStyle?.underline,color:this.runtime.baselineDescrStyle?.textColor??this.secondaryFontColor,highlightText:this.runtime.baselineHighlight},baselineArrow:this.baselineArrow===`neutral`||this.runtime.progressBar?void 0:{size:this.keyValue?.8*n:0,color:this.runtime.baselineColor||this.runtime.baselineStyle?.textColor||this.secondaryFontColor,highlight:this.runtime.baselineHighlight}}}};function yg(e){return 20+120*Math.exp(-.035*(e-1))}var bg=class{top;bottom;left;right;offsetX;offsetY;canScrollVertically;canScrollHorizontally;viewportWidth;viewportHeight;boundaryLeftX;boundaryTopY;getters;sheetId;boundaries;getFooterSize;constructor(e){if(e.sizeInGrid.width<0||e.sizeInGrid.height<0)throw Error(`Viewport size cannot be negative`);this.getters=e.getters,this.sheetId=e.sheetId,this.boundaries=e.boundaries,this.viewportWidth=e.sizeInGrid.height&&e.sizeInGrid.width,this.viewportHeight=e.sizeInGrid.width&&e.sizeInGrid.height,this.top=e.boundaries.top,this.bottom=e.boundaries.bottom,this.left=e.boundaries.left,this.right=e.boundaries.right,this.offsetX=e.offsets.x,this.offsetY=e.offsets.y,this.canScrollVertically=e.canScrollVertically,this.canScrollHorizontally=e.canScrollHorizontally,this.getFooterSize=e.getFooterSize,this.boundaryLeftX=this.getters.getColDimensions(this.sheetId,this.boundaries.left).start,this.boundaryTopY=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}=this.getters.getColDimensions(this.sheetId,e),{end:r}=this.getters.getRowDimensions(this.sheetId,t),i=n-this.boundaryLeftX;this.canScrollHorizontally&&(i=Math.max(i,this.viewportWidth));let a=r-this.boundaryTopY;return this.canScrollVertically&&(a=Math.max(a,this.viewportHeight),r+this.getFooterSize()>a&&(a+=this.getFooterSize())),{width:i,height:a}}getColIndex(e){return this.searchHeaderIndex(`COL`,e+this.snapCorrection.x,this.left)}getRowIndex(e){return this.searchHeaderIndex(`ROW`,e+this.snapCorrection.y,this.top)}repositionViewport(e){let t=this.sheetId,n=this.getters.getMainCellPosition({sheetId:t,...e}),{col:r,row:i}=this.getters.getNextVisibleCellPosition(n);fr(r,this.boundaries.top,this.boundaries)&&this.repositionViewportX(r),fr(this.boundaries.left,i,this.boundaries)&&this.repositionViewportY(i)}repositionViewportX(e){let t=this.sheetId,{start:n,end:r}=this.getters.getColDimensions(t,e);this.offsetX+this.viewportWidth+this.boundaryLeftX<r?this.offsetX=r-this.viewportWidth-this.boundaryLeftX:this.offsetX+this.boundaryLeftX>n&&(this.offsetX=n-this.boundaryLeftX),this.adjustViewportZoneX()}repositionViewportY(e){let t=this.sheetId,{start:n,end:r}=this.getters.getRowDimensions(t,e);this.offsetY+this.viewportHeight+this.boundaryTopY<r?this.offsetY=r-this.viewportHeight-this.boundaryTopY:this.offsetY+this.boundaryTopY>n&&(this.offsetY=n-this.boundaryTopY),this.adjustViewportZoneY()}willNewOffsetScrollViewport(e,t){return this.canScrollHorizontally&&this.offsetX!==e||this.canScrollVertically&&this.offsetY!==t}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}isZoneVisible(e){return cr(e,this)!==void 0}getVisibleRect(e){let t=cr(e,this),n=this.snapCorrection.x,r=this.snapCorrection.y;if(t)return{x:this.getters.getColRowOffset(`COL`,this.left,t.left,this.sheetId)-(this.left===t.left?0:n),y:this.getters.getColRowOffset(`ROW`,this.top,t.top,this.sheetId)-(this.top===t.top?0:r),width:Math.min(this.getters.getColRowOffset(`COL`,t.left,t.right+1,this.sheetId)-(this.left===t.left?n:0),this.viewportWidth),height:Math.min(this.getters.getColRowOffset(`ROW`,t.top,t.bottom+1,this.sheetId)-(this.top===t.top?r:0),this.viewportHeight)}}getFullRect(e){let t=cr(e,this.boundaries),n=this.snapCorrection.x,r=this.snapCorrection.y;if(t){let t=this.getters.getColRowOffset(`COL`,this.left,e.left,this.sheetId),i=this.getters.getColRowOffset(`ROW`,this.top,e.top,this.sheetId),a=this.getters.getColRowOffset(`COL`,e.left,e.right+1,this.sheetId),o=this.getters.getColRowOffset(`ROW`,e.top,e.bottom+1,this.sheetId);return{x:t-n,y:i-r,width:a,height:o}}}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,this.sheetId),c=this.getters.isHeaderHidden(r,e,i)?0: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}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){let{width:e}=this.getMaxSize();this.viewportWidth+this.offsetX>e&&(this.offsetX=Math.max(0,e-this.viewportWidth))}this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){let{height:e}=this.getMaxSize();this.viewportHeight+this.offsetY>e&&(this.offsetY=Math.max(0,e-this.viewportHeight))}this.adjustViewportZoneY()}adjustViewportZoneX(){this.left=this.searchHeaderIndex(`COL`,this.offsetX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex(`COL`,Math.max(this.viewportWidth+this.snapCorrection.x-.1),this.left)),this.viewportWidth&&(this.left===-1&&(this.left=this.boundaries.left),this.right===-1&&(this.right=this.boundaries.right))}adjustViewportZoneY(){this.top=this.searchHeaderIndex(`ROW`,this.offsetY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex(`ROW`,Math.max(this.viewportHeight+this.snapCorrection.y-.1,0),this.top)),this.viewportHeight&&(this.top===-1&&(this.top=this.boundaries.top),this.bottom===-1&&(this.bottom=this.boundaries.bottom))}get snapCorrection(){return{x:Math.abs(this.offsetX-this.getters.getColRowOffset(`COL`,this.boundaries.left,Math.max(0,this.left),this.sheetId)),y:Math.abs(this.offsetY-this.getters.getColRowOffset(`ROW`,this.boundaries.top,Math.max(0,this.top),this.sheetId))}}},xg=class{getters;viewports={};gridOffsetX=0;gridOffsetY=0;paneDivision;sheetViewWidth;sheetViewHeight;zoomLevel;getFooterSize;zoneToDisplay;constructor(e){this.getters=e.getters,this.paneDivision=e.paneDivision,this.sheetViewWidth=e.sheetViewWidth,this.sheetViewHeight=e.sheetViewHeight,this.zoomLevel=e.zoomLevel,this.getFooterSize=e.getFooterSize,this.zoneToDisplay=e.zoneToDisplay}changeViewportArgs(e){for(let t in e)this[t]=e[t];for(let e of this.getters.getSheetIds())this.resetViewports(e)}getColIndex(e,t){return Math.max(...this.getPositionedViewports(e).map(({viewport:e,viewportX:n})=>t<n||t>n+e.viewportWidth?-1:e.getColIndex(t-n)))}getRowIndex(e,t){return Math.max(...this.getPositionedViewports(e).map(({viewport:e,viewportY:n})=>t<n||t>n+e.viewportHeight?-1:e.getRowIndex(t-n)))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getGridOffset(){return{x:this.gridOffsetX,y:this.gridOffsetY}}getSheetScrollInfo(e){let t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getSheetViewVisibleCols(e){let t=this.getSubViewports(e).map(e=>e);return[...new Set(t.map(e=>S(e.left,e.right+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`COL`,t))}getSheetViewVisibleRows(e){let t=this.getSubViewports(e).map(e=>e);return[...new Set(t.map(e=>S(e.top,e.bottom+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`ROW`,t))}getVisibleCellPositions(e){let t=this.getSheetViewVisibleCols(e),n=this.getSheetViewVisibleRows(e),r=[];for(let i of t)for(let t of n){let n={sheetId:e,col:i,row:t},a=this.getters.getMainCellPosition(n);a.row!==t||a.col!==i||r.push(n)}return r}getMainViewportRect(e){let{width:t,height:n}=this.getMainInternalViewport(e).getMaxSize(),{paneWidth:r,paneHeight:i}=this.getPanesDimensions(e);return{x:r,y:i,width:t,height:n}}getMaximumSheetOffset(e){let{width:t,height:n}=this.getMainViewportRect(e),r=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-r.viewportWidth),maxOffsetY:Math.max(0,n-r.viewportHeight)}}getColRowOffsetInViewport(e,t,n,r){if(r<n)return-this.getColRowOffsetInViewport(e,t,r,n);let i=t===`COL`?this.getSheetViewVisibleCols(e):this.getSheetViewVisibleRows(e),a=i.findIndex(e=>n>=e),o=i.findIndex(e=>r<=e);o=o===-1?i.length:o;let s=i.slice(a,o),c=0;for(let n of s)c+=this.getters.getHeaderSize(e,t,n);return c*this.zoomLevel}isVisibleInViewport({sheetId:e,col:t,row:n}){return this.getSubViewports(e).some(e=>e.isVisible(t,n))}isZoneVisibleInViewport(e,t){return this.getSubViewports(e).some(e=>e.isZoneVisible(t))}getScrollBarWidth(){return 15/this.zoomLevel}getEdgeScrollCol(e,t,n,r){let i=!1,a=0,o=0,{xSplit:s}=this.getPaneDivisions(e),{width:c}=this.getSheetViewDimension(),{x:l}=this.getMainViewportCoordinates(e),u=this.getSheetScrollInfo(e).scrollX;return t>c?(i=!0,o=yg(t-c),a=1):t<l&&r>=l&&u>0?(i=!0,o=yg(l-t),a=-1):s&&n<l&&t>l&&(i=!0,o=yg(t),a=`reset`),{canEdgeScroll:i,direction:a,delay:o}}getEdgeScrollRow(e,t,n,r){let i=!1,a=0,o=0,{ySplit:s}=this.getPaneDivisions(e),{height:c}=this.getSheetViewDimension(),{y:l}=this.getMainViewportCoordinates(e),u=this.getSheetScrollInfo(e).scrollY;return t>c?(i=!0,o=yg(t-c),a=1):t<l&&r>=l&&u>0?(i=!0,o=yg(l-t),a=-1):s&&n<l&&t>l&&(i=!0,o=yg(t),a=`reset`),{canEdgeScroll:i,direction:a,delay:o}}getVisibleRect(e,t){let n=this.getVisibleRectWithoutHeaders(e,t);return{...n,x:n.x+this.gridOffsetX,y:n.y+this.gridOffsetY}}getVisibleRectWithZoom(e,t){let n=this.getViewportZoomLevel(),r=this.getVisibleRectWithoutHeaders(e,t);return r.width*=n,r.height*=n,r.x=r.x*n+this.gridOffsetX*n,r.y=r.y*n+this.gridOffsetY*n,r}getVisibleRectWithoutHeaders(e,t){return this.mapViewportsToRect(e,e=>e.getVisibleRect(t))}getRect(e,t){let n=this.mapViewportsToRect(e,e=>e.getFullRect(t));return{...n,x:n.x+this.gridOffsetX,y:n.y+this.gridOffsetY}}getRectWithoutHeaders(e,t){return this.mapViewportsToRect(e,e=>e.getFullRect(t))}getMainViewportCoordinates(e){let{paneWidth:t,paneHeight:n}=this.getPanesDimensions(e);return{x:t,y:n}}getColDimensionsInViewport(e,t){let{top:n}=this.getMainInternalViewport(e),r={left:t,right:t,top:n,bottom:n},{x:i,width:a}=this.getVisibleRect(e,r),o=i-this.gridOffsetX;return{start:o,size:a,end:o+a}}getRowDimensionsInViewport(e,t){let{left:n}=this.getMainInternalViewport(e),r={left:0,right:n,top:t,bottom:t},{y:i,height:a}=this.getVisibleRect(e,r),o=i-this.gridOffsetY;return{start:o,size:a,end:o+a}}getAllSheetViewportsZonesAndRect(e){return this.getPositionedViewports(e).map(({viewport:e,viewportX:t,viewportY:n})=>({zone:e,rect:{x:t+this.gridOffsetX,y:n+this.gridOffsetY,...e.getMaxSize()}}))}getViewportZoomLevel(){return this.zoomLevel}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getPanesDimensions(e){let t=this.getViewportZones(e),n=0;if(t.bottomLeft){let r=this.getters.getColDimensions(e,t.bottomLeft.left).start;n=this.getters.getColDimensions(e,t.bottomLeft.right).end-r}let r=0;if(t.topRight){let n=this.getters.getRowDimensions(e,t.topRight.top).start;r=this.getters.getRowDimensions(e,t.topRight.bottom).end-n}return{paneWidth:n,paneHeight:r}}getPositionedViewports(e){this.ensureMainViewportExist(e);let t=this.viewports[e],{paneWidth:n,paneHeight:r}=this.getPanesDimensions(e),i=[];return t.topLeft&&i.push({viewport:t.topLeft,viewportX:0,viewportY:0}),t.topRight&&i.push({viewport:t.topRight,viewportX:n,viewportY:0}),t.bottomLeft&&i.push({viewport:t.bottomLeft,viewportX:0,viewportY:r}),i.push({viewport:t.bottomRight,viewportX:n,viewportY:r}),i}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(C)}checkPositiveDimension(e){return!(e.width<0||e.height<0)}checkValuesAreDifferent(e){let{height:t,width:n}=this.getSheetViewDimension();return!(e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===n&&e.height===t)}checkScrollingDirection(e,{offsetX:t,offsetY:n}){let r=this.getMainInternalViewport(e);return!(!r.canScrollHorizontally&&t>0||!r.canScrollVertically&&n>0)}checkIfViewportsWillChange(e,{offsetX:t,offsetY:n}){let{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset(e);return!!this.getSubViewports(e).some(e=>e.willNewOffsetScrollViewport(x(t,0,r),x(n,0,i)))}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){this.sheetViewHeight=e.height,this.sheetViewWidth=e.width,this.gridOffsetX=e.gridOffsetX||0,this.gridOffsetY=e.gridOffsetY||0,this.recomputeViewports()}recomputeViewports(){for(let e of this.getters.getSheetIds())this.resetViewports(e)}setSheetViewOffset(e,t,n){let{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset(e);this.getSubViewports(e).forEach(e=>e.setViewportOffset(x(t,0,r),x(n,0,i)))}getViewportOffset(e){return{x:this.viewports[e]?.bottomRight.offsetX||0,y:this.viewports[e]?.bottomRight.offsetY||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;let{paneWidth:t,paneHeight:n}=this.getPanesDimensions(e),r=Math.min(t,this.sheetViewWidth),i=Math.min(n,this.sheetViewHeight),a=Math.max(this.sheetViewWidth-t,0),o=Math.max(this.sheetViewHeight-n,0),{xRatio:s,yRatio:c}=this.getFrozenSheetViewRatio(e),l=s<1,u=c<1,d=this.getViewportOffset(e),f={},p=this.getViewportZones(e),m=p.topLeft;m&&(f.topLeft=new bg({getters:this.getters,sheetId:e,boundaries:m,sizeInGrid:{width:r,height:i},canScrollHorizontally:!1,canScrollVertically:!1,offsets:{x:0,y:0},getFooterSize:()=>0}));let h=p.topRight;h&&(f.topRight=new bg({getters:this.getters,sheetId:e,boundaries:h,sizeInGrid:{width:a,height:i},canScrollHorizontally:l,canScrollVertically:!1,offsets:{x:l?d.x:0,y:0},getFooterSize:()=>0}));let g=p.bottomLeft;g&&(f.bottomLeft=new bg({getters:this.getters,sheetId:e,boundaries:g,sizeInGrid:{width:r,height:o},canScrollHorizontally:!1,canScrollVertically:u,offsets:{x:0,y:u?d.y:0},getFooterSize:this.getFooterSize}));let _=p.bottomRight;f.bottomRight=new bg({getters:this.getters,sheetId:e,boundaries:_,sizeInGrid:{width:a,height:o},canScrollHorizontally:l,canScrollVertically:u,offsets:{x:l?d.x:0,y:u?d.y:0},getFooterSize:this.getFooterSize}),this.viewports[e]=f}reorganizeViewportZones(e,t){let n=Object.values(t).filter(e=>e!==void 0);if(n.length===1)return{bottomRight:n[0]};if(n.length===4)return t;if(n.length===2){if(t.bottomRight&&(t.topRight||t.bottomLeft))return t;let{topLeft:e,topRight:n,bottomLeft:r}=t;if(e&&n)return{bottomLeft:e,bottomRight:n};if(e&&r)return{topRight:e,bottomRight:r}}throw Error(`ViewportCollection: Malformed viewports for ${e}`)}getViewportZones(e){let{xSplit:t,ySplit:n}=this.getPaneDivisions(e),r=this.getters.getNumberCols(e),i=this.getters.getNumberRows(e),a=this.zoneToDisplay?cr(this.zoneToDisplay,this.getters.getSheetZone(e)):void 0,o={};if(t&&n){let e={left:0,right:t-1,top:0,bottom:n-1};o.topLeft=a?cr(e,a):e}if(n){let e={left:t,right:r-1,top:0,bottom:n-1};o.topRight=a?cr(e,a):e}if(t){let e={left:0,right:t-1,top:n,bottom:i-1};o.bottomLeft=a?cr(e,a):e}let s={left:t,right:r-1,top:n,bottom:i-1};return o.bottomRight=a?cr(s,a):s,this.reorganizeViewportZones(e,o)}refreshViewport(e,t){this.getSubViewports(e).forEach(e=>{e.adjustViewportZone(),e.repositionViewport(t)})}getColIndexLeftOfMainViewport(e,t){if(t>=0)return-1;let n=this.getMainViewport(e).left,r=-this.getSheetScrollInfo(e).scrollX-this.getters.getColRowOffset(`COL`,n,0,e);for(;t<r;n--)r-=this.getters.getColSize(e,n-1);return Math.max(n,0)}getRowIndexTopOfMainViewport(e,t){if(t>=0)return-1;let n=this.getMainViewport(e).top,r=-this.getSheetScrollInfo(e).scrollY-this.getters.getColRowOffset(`ROW`,n,0,e);for(;t<r;n--)r-=this.getters.getRowSize(e,n-1);return Math.max(n,0)}getVisibleFigures(e){let t=[],n=this.getters.getFigures(e),{scrollX:r,scrollY:i}=this.getSheetScrollInfo(e),{x:a,y:o}=this.getMainViewportCoordinates(e),{width:s,height:c}=this.getSheetViewDimensionWithHeaders();for(let l of n){let n=this.getFigureUI(e,l),{x:u,y:d}=n;u>=a&&(u+l.width<r+a||u>s+r+a)||d>=o&&(d+l.height<i+o||d>c+i+o)||t.push(n)}return t}getFigureUI(e,t){let n=t.offset.x+this.getters.getColDimensions(e,t.col).start,r=t.offset.y+this.getters.getRowDimensions(e,t.row).start;return{...t,x:n,y:r}}getPositionAnchorOffset(e,t){let{scrollX:n,scrollY:r}=this.getSheetScrollInfo(e),i=t.x-n,a=t.y-r,o=i>=0?this.getColIndex(e,i):this.getColIndexLeftOfMainViewport(e,i);o<0&&(o=this.getMainInternalViewport(e).searchHeaderIndex(`COL`,i));let s=a>=0?this.getRowIndex(e,a):this.getRowIndexTopOfMainViewport(e,a);s<0&&(s=this.getMainInternalViewport(e).searchHeaderIndex(`ROW`,a));let{x:c,y:l}=this.getRect(e,E({col:o,row:s}));return{col:o,row:s,offset:{x:Math.max(i-c+this.gridOffsetX,0),y:Math.max(a-l+this.gridOffsetY,0)}}}isPixelPositionVisible(e,t){let{scrollX:n,scrollY:r}=this.getSheetScrollInfo(e),{x:i,y:a}=this.getMainViewportCoordinates(e),{width:o,height:s}=this.getSheetViewDimension();return!(t.x>=i&&(t.x<i+n||t.x>o+n+i)||t.y>=a&&(t.y<a+r||t.y>s+r+a))}getFrozenSheetViewRatio(e){let{paneWidth:t,paneHeight:n}=this.getPanesDimensions(e),r=this.sheetViewWidth+this.gridOffsetX,i=this.sheetViewHeight+this.gridOffsetY;return{xRatio:t/r,yRatio:n/i}}mapViewportsToRect(e,t){let n=1/0,r=1/0,i=0,a=0,o=!1;for(let s of this.getPositionedViewports(e)){let e=t(s.viewport);e&&(e.x+=s.viewportX,e.y+=s.viewportY,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}}getGridOffsetX(){return this.gridOffsetX}getGridOffsetY(){return this.gridOffsetY}getZoomLevel(){return this.zoomLevel}setZoomLevel(e){this.zoomLevel=e}getPaneDivisions(e){return this.paneDivision[e]||{xSplit:0,ySplit:0}}setPaneDivision(e,t){this.paneDivision[e]=t}},H=class extends Yr{mutators=[`setViewportOffset`,`resizeSheetView`,`setZoom`,`shiftViewportDown`,`shiftViewportUp`,`scrollToCell`,`setDisplayedSheetId`,`setViewportArgs`,`rebuildViewports`];getHeaderDimensionsCallback=this.getters.getHeaderDimensions;getFooterSizeCallback=this.getFooterSize.bind(this);zoneToDisplay=void 0;viewports=new xg({getters:this.buildViewportGetters(this.getHeaderDimensionsCallback),paneDivision:this.getPaneDivisions(),sheetViewHeight:ct(),sheetViewWidth:ct(),zoomLevel:1,getFooterSize:this.getFooterSizeCallback});sheetsWithDirtyViewports=new Set;shouldRepositionViewports=!1;displayedSheetId=this.model.getters.getActiveSheetId();constructor(e){super(e),this.model.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.onDispose(()=>{this.model.selection.unobserve(this)}),this.viewports.resetViewports(this.displayedSheetId)}handleEvent(e){let t=this.getters.getActiveSheetId();if(e.options.scrollIntoView){let n=e.previousAnchor.zone,r=e.anchor.zone,i=e.mode===`updateAnchor`,a=lr(n,r),{col:o,row:s}=i&&a?e.anchor.cell:Cr(n,r);if(i&&!a){let{top:e,bottom:i,left:a,right:c}=this.viewports.getMainInternalViewport(t);n.left===r.left&&n.right===r.right&&(o=a>o||o>c?a:o),n.top===r.top&&n.bottom===r.bottom&&(s=e>s||s>i?e:s)}o=Math.min(o,this.getters.getNumberCols(t)-1),s=Math.min(s,this.getters.getNumberRows(t)-1),this.sheetsWithDirtyViewports.has(t)||this.viewports.refreshViewport(t,{col:o,row:s})}}handle(e){if(Id.has(e.type))for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);switch(e.type){case`UNDO`:case`REDO`:this.viewports.cleanViewports();for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e),this.syncPaneDivision(e);this.shouldRepositionViewports=!this.getters.getSelectedFigureIds().length;break;case`UNFREEZE_ROWS`:case`UNFREEZE_COLUMNS`:case`FREEZE_COLUMNS`:case`FREEZE_ROWS`:case`UNFREEZE_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:case`ADD_COLUMNS_ROWS`:this.sheetsWithDirtyViewports.add(e.sheetId),this.syncPaneDivision(e.sheetId);break;case`DUPLICATE_SHEET`:this.sheetsWithDirtyViewports.add(e.sheetIdTo),this.syncPaneDivision(e.sheetIdTo);break;case`REMOVE_TABLE`:case`UPDATE_TABLE`:case`UPDATE_FILTER`:case`RESIZE_COLUMNS_ROWS`:case`HIDE_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`:case`SET_FORMATTING`:for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);break;case`DELETE_SHEET`:this.viewports.cleanViewports(),this.sheetsWithDirtyViewports.delete(e.sheetId);break}}finalize(){for(let e of this.sheetsWithDirtyViewports)if(this.viewports.resetViewports(e),this.shouldRepositionViewports){let t=this.getters.getSheetPosition(e);this.viewports.getSubViewports(e).forEach(e=>{e.repositionViewport(t)})}this.sheetsWithDirtyViewports=new Set,this.shouldRepositionViewports=!1,this.setViewports()}setViewports(){let e=this.getters.getSheetIds();for(let t of e)this.viewports.viewports[t]?.bottomRight||this.viewports.resetViewports(t)}syncPaneDivision(e){this.viewports.setPaneDivision(e,this.getters.getPaneDivisions(e))}setDisplayedSheetId(e){this.displayedSheetId=e,this.viewports.resetViewports(e)}setViewportOffset(e){let t=this.displayedSheetId;if(!this.viewports.checkScrollingDirection(t,e)||!this.viewports.checkIfViewportsWillChange(t,e))return`noStateChange`;this.viewports.setSheetViewOffset(t,e.offsetX,e.offsetY)}resizeSheetView(e){if(!this.viewports.checkValuesAreDifferent(e)||!this.viewports.checkPositiveDimension(e))return`noStateChange`;this.viewports.resizeSheetView(e)}setZoom(e){if(e>2||e<.5||e===this.viewports.getZoomLevel())return`noStateChange`;this.viewports.setZoomLevel(e)}shiftViewportDown(){let e=this.displayedSheetId,{top:t,viewportHeight:n,boundaryTopY:r}=this.viewports.getMainInternalViewport(e),i=this.getters.getRowDimensions(e,t);this.shiftVertically(i.start+n-r)}shiftViewportUp(){let e=this.displayedSheetId,{top:t,viewportHeight:n,boundaryTopY:r}=this.viewports.getMainInternalViewport(e),i=this.getters.getRowDimensions(e,t);this.shiftVertically(i.end-r-n)}scrollToCell(e,t,n){this.viewports.refreshViewport(e,{col:t,row:n})}get sheetViewDimensionWithHeaders(){return this.viewports.getSheetViewDimensionWithHeaders()}get sheetViewDimension(){return this.viewports.getSheetViewDimension()}get gridOffset(){return this.viewports.getGridOffset()}get activeMainViewport(){return this.viewports.getMainViewport(this.displayedSheetId)}get activeSheetScrollInfo(){return this.viewports.getSheetScrollInfo(this.displayedSheetId)}get visibleCols(){return this.viewports.getSheetViewVisibleCols(this.displayedSheetId)}get visibleRows(){return this.viewports.getSheetViewVisibleRows(this.displayedSheetId)}get visibleCellPositions(){return this.viewports.getVisibleCellPositions(this.displayedSheetId)}get mainViewportRect(){return this.viewports.getMainViewportRect(this.displayedSheetId)}get maximumSheetOffset(){return this.viewports.getMaximumSheetOffset(this.displayedSheetId)}get scrollBarWidth(){return 15/this.viewports.getZoomLevel()}get mainViewportCoordinates(){return this.viewports.getMainViewportCoordinates(this.displayedSheetId)}get zoomLevel(){return this.viewports.getZoomLevel()}get visibleFigures(){return this.viewports.getVisibleFigures(this.displayedSheetId)}shiftVertically(e){let t=this.displayedSheetId,{top:n}=this.viewports.getMainInternalViewport(t),{scrollX:r}=this.activeSheetScrollInfo;this.viewports.setSheetViewOffset(t,r,e);let{anchor:i}=this.getters.getSelection();if(i.cell.row>=this.getters.getPaneDivisions(t).ySplit){let e=this.viewports.getMainInternalViewport(t).top-n;this.model.selection.selectCell(i.cell.col,i.cell.row+e)}}getPaneDivisions(){let e={};for(let t of this.getters.getSheetIds())e[t]=this.getters.getPaneDivisions(t);return e}getFooterSize(){return this.getters.isReadonly()?0:46}setViewportArgs(e){let t=!1;e.getHeaderDimensions&&(t=!0,this.getHeaderDimensionsCallback=e.getHeaderDimensions),e.getFooterSize&&(t=!0,this.getFooterSizeCallback=e.getFooterSize),e.zoneToDisplay&&!w(e.zoneToDisplay,this.zoneToDisplay)&&(t=!0,this.zoneToDisplay=e.zoneToDisplay),t&&this.rebuildViewports()}rebuildViewports(){this.viewports.changeViewportArgs({getters:this.buildViewportGetters(this.getHeaderDimensionsCallback),paneDivision:this.getPaneDivisions(),sheetViewHeight:this.viewports.getSheetViewDimension().height,sheetViewWidth:this.viewports.getSheetViewDimension().width,zoomLevel:this.viewports.getZoomLevel(),getFooterSize:this.getFooterSizeCallback,zoneToDisplay:this.zoneToDisplay})}buildViewportGetters(e){return{findLastVisibleColRowIndex:this.getters.findLastVisibleColRowIndex,isReadonly:this.getters.isReadonly,getMainCellPosition:this.getters.getMainCellPosition,getNextVisibleCellPosition:this.getters.getNextVisibleCellPosition,isColHidden:this.getters.isColHidden,isRowHidden:this.getters.isRowHidden,isHeaderHidden:this.getters.isHeaderHidden,getNumberHeaders:this.getters.getNumberHeaders,getSheetIds:this.getters.getSheetIds,tryGetSheet:this.getters.tryGetSheet,getNumberCols:this.getters.getNumberCols,getNumberRows:this.getters.getNumberRows,getSheetZone:this.getters.getSheetZone,getFigures:this.getters.getFigures,getColDimensions:(t,n)=>e(t,`COL`,n),getRowDimensions:(t,n)=>e(t,`ROW`,n),getHeaderSize:(t,n,r)=>n===`COL`?e(t,`COL`,r).size:e(t,`ROW`,r).size,getColSize:(t,n)=>e(t,`COL`,n).size,getRowSize:(t,n)=>e(t,`ROW`,n).size,getColRowOffset:(t,n,r,i)=>e(i,t,r).start-e(i,t,n).start}}};function Sg(e,t,n){let r=e.getStore(H).zoomLevel;if(n===void 0&&(n=Tg(t,r)),!n)return Cg(t);let i=t.clientX-n.x,a=t.clientY-n.y,o=i/r,s=a/r;return{ev:t,clientX:t.clientX-i+o,clientY:t.clientY-a+s,offsetX:o,offsetY:s}}function Cg(e){return{ev:e,clientX:e.clientX,clientY:e.clientY,offsetX:e.offsetX,offsetY:e.offsetY}}function wg(e,t){return{height:t.height*e,width:t.width*e,x:t.x*e,y:t.y*e}}function Tg(e,t){let n=e.target;return!n||!(`classList`in n)||!(n instanceof Element)?null:ee(n,t)}var Eg=class extends O{static template=`o-spreadsheet-ScorecardChart`;props=(0,t.useProps)({chartId:j.string(),isFullScreen:j.boolean().optional()});canvas=(0,t.signal)(null);viewStore;get runtime(){return this.env.model.getters.getChartRuntime(this.props.chartId)}get title(){let e=this.env.model.getters.getChartDefinition(this.props.chartId).title.text;return e?this.env.model.getters.dynamicTranslate(e):``}setup(){this.viewStore=k(H),Gi(this.createChart.bind(this),()=>{let e=this.canvas();if(!e)return[];let t=e.getBoundingClientRect();return[t.width,t.height,this.runtime,e,window.devicePixelRatio]});let e=new ResizeObserver(()=>this.createChart());(0,t.onMounted)(()=>{let t=this.canvas();t&&e.observe(t)}),(0,t.onWillUnmount)(()=>e.disconnect())}config(e,t){return _g(wg(1/t,e),this.runtime)}createChart(){let e=this.canvas();if(!e)return;let t=this.viewStore.zoomLevel;mg(this.config(e.getBoundingClientRect(),t),e,t)}};let Dg=new D;function Og(e,t,n){let r=e.model.getters.getFigure(t,n);if(!r)throw Error(`Could not find figure with id ${n} in sheet ${t}`);let i=e.model.getters.getFigureUI(t,r);return e.getStore(H).viewports.getPositionAnchorOffset(t,{x:i.x+50,y:i.y+50})}function kg(e,t){if(t.type===`carouselDataView`)return`o-spreadsheet-Icon.DATA`;let n=e.getChartDefinition(t.chartId);return(Dg.getAll().find(e=>e.matcher?.(n))||Dg.get(n.type)).preview}function Ag(e,t){if(t.title)return e.dynamicTranslate(t.title);if(t.type===`carouselDataView`)return M(`Data`);let n=e.getChartDefinition(t.chartId);return(Dg.getAll().find(e=>e.matcher?.(n))||Dg.get(n.type)).displayName}let jg=`#F3F2F1`;function Mg(e,t,n=1,r){let i=r??Ng(e),a=typeof globalThis.devicePixelRatio==`number`?globalThis.devicePixelRatio:1;e.width=i.width*a,e.height=i.height*a;let o=e.getContext(`2d`);if(!o)throw Error(`Unable to retrieve 2D context from canvas`);o.scale(a*n,a*n);let s=zg({width:i.width/n,height:i.height/n,x:0,y:0},t,o);Fg(o,s),Pg(o,s),Lg(o,s),Ig(o,s),Rg(o,s)}function Ng(e){if(e instanceof HTMLCanvasElement){let t=e.getBoundingClientRect();return{width:t.width,height:t.height}}return{width:e.width,height:e.height}}function Pg(e,t){e.save();let n=t.gauge,r=n.rect.x+n.rect.width/2,i=n.rect.y+n.rect.height,a=n.rect.height-n.arcWidth/2;if(a<0)return;let o=n.percentage===1?0:Math.PI*(1+n.percentage);e.strokeStyle=jg,e.beginPath(),e.lineWidth=n.arcWidth,e.arc(r,i,a,o,0),e.stroke(),e.strokeStyle=n.color,e.beginPath(),e.arc(r,i,a,Math.PI,o),e.stroke(),e.restore()}function Fg(e,t){e.save(),e.fillStyle=t.backgroundColor,e.fillRect(0,0,t.width,t.height),e.restore()}function Ig(e,t){for(let n of[t.minLabel,t.maxLabel,t.gaugeValue])e.save(),e.textAlign=`center`,e.fillStyle=n.color,e.font=`${n.fontSize}px ${Qe}`,e.fillText(n.label,n.textPosition.x,n.textPosition.y),e.restore()}function Lg(e,t){let{x:n,y:r,width:i,height:a}=t.gauge.rect;for(let o of t.inflectionValues){e.save(),e.translate(n+i/2-.5,r+a-.5),e.rotate(Math.PI/2-o.rotation),e.lineWidth=2,e.strokeStyle=ym(t.backgroundColor)+`aa`,e.beginPath(),e.moveTo(0,-(a-t.gauge.arcWidth)),e.lineTo(0,-a-3),e.stroke(),e.textAlign=`center`,e.font=`${o.fontSize}px ${Qe}`,e.fillStyle=o.color;let s=-a-6-o.offset;e.fillText(o.label,0,s),e.restore()}}function Rg(e,t){e.save();let n=t.title;e.font=wp(n.fontSize,n.bold,n.italic),e.textBaseline=`middle`,e.fillStyle=n.color,e.fillText(n.label,n.textPosition.x,n.textPosition.y),e.restore()}function zg(e,t,n){let r=t.maxValue,i=t.minValue,a=qg(t,`animated`),o=Bg(e,t.title.text),s=o.width/6,c=a?(a-i.value)/(r.value-i.value):0,l={x:e.width/2,y:o.y+o.height-o.height/12},u=80;o.height<300&&(u*=o.height/300);let d=o.width/2,f=t.gaugeValue?.label||`-`;Ep(n,f,{fontSize:u},`px`)>d&&(u=Ip(d,u,e=>Ep(n,f,{fontSize:e},`px`)));let p={x:o.x+s/2,y:o.y+o.height+12},m={x:o.x+o.width-s/2,y:o.y+o.height+12},h=ym(t.background),g=Vg(t,o,h,n),_=0,v=0,ee=0;switch(t.title.text&&({width:v,height:ee}=kp(n,t.title.text,{fontSize:16,...t.title},`px`)),t.title.align){case`right`:_=e.width-v-20;break;case`center`:_=(e.width-v)/2;break;default:_=20;break}return{width:e.width,height:e.height,title:{label:t.title.text??``,fontSize:t.title.fontSize??16,textPosition:{x:_,y:15+ee/2},color:t.title.color??h,bold:t.title.bold,italic:t.title.italic},backgroundColor:t.background,gauge:{rect:o,arcWidth:s,percentage:x(c,0,1),color:Hg(t)},inflectionValues:g,gaugeValue:{label:f,textPosition:l,fontSize:u,color:h},minLabel:{label:t.minValue.label,textPosition:p,fontSize:12,color:h},maxLabel:{label:t.maxValue.label,textPosition:m,fontSize:12,color:h}}}function Bg(e,t){let n=t?25:0,r=e.height-20-n-10,i=e.width-60,a,o;return i>2*r?(a=2*r,o=r):(a=i,o=i/2),{x:30+(i-a)/2,y:n+10+(r-o)/2,width:a,height:o}}function Vg(e,t,n,r){let i=e.maxValue,a=e.minValue,o={x:t.x+t.width/2,y:t.y+t.height},s={fontSize:12},c=[],l=[];for(let u of e.inflectionValues){let e=(u.value-a.value)/(i.value-a.value),d=Ep(r,u.label,s,`px`),f=Math.PI-Math.PI*e,p=Kg(f,t.height+6,o.x,o.y,d+2,12),m=l.some(e=>Gg(e,p))?12:0;l.push(p),c.push({rotation:f,label:u.label,fontSize:12,color:n,offset:m})}return c}function Hg(e){let t=qg(e,`final`);if(t===void 0)return jg;for(let n=0;n<e.inflectionValues.length;n++){let r=e.inflectionValues[n];if(r.operator===`<`&&t<r.value||r.operator===`<=`&&t<=r.value)return e.colors[n]}return e.colors.at(-1)}function Ug(e){return[{start:e.topLeft,end:e.topRight},{start:e.topRight,end:e.bottomRight},{start:e.bottomRight,end:e.bottomLeft},{start:e.bottomLeft,end:e.topLeft}]}function Wg(e,t){let n=e.start,r=e.end,i=t.start,a=t.end;function o(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}return o(n,i,a)!==o(r,i,a)&&o(n,r,i)!==o(n,r,a)}function Gg(e,t){let n=Ug(e),r=Ug(t);for(let e of n)for(let t of r)if(Wg(e,t))return!0;return!1}function Kg(e,t,n,r,i,a){let o=Math.cos(e),s=Math.sin(e),c=o*t,l=s*t,u=i/2*s,d=i/2*o,f={x:c+u+n,y:r-(l-d)},p={x:c-u+n,y:r-(l+d)},m=o*(t+a),h=s*(t+a),g={x:m-u+n,y:r-(h+d)};return{bottomLeft:p,bottomRight:f,topRight:{x:m+u+n,y:r-(h-d)},topLeft:g}}function qg(e,t){return t===`animated`&&e.animationValue!==void 0?e.animationValue:e.gaugeValue?.value}let Jg={responsive:!0,maintainAspectRatio:!1,elements:{line:{fill:!1},point:{hitRadius:15}},animation:!1,events:[`mousemove`,`mouseout`,`click`,`touchstart`,`touchmove`,`mouseup`]};async function Yg(e,t,n){try{let r=Zg(t.width,t.height),i=e_(r,e,t,n),a=await $g(r);return i(),a}catch(e){console.log(`Error exporting chart to image URL: `+e.message)}}async function Xg(e,t,n){try{let r=Zg(t.width,t.height),i=e_(r,e,t,n),a=await Qg(r);return i(),a}catch(e){console.log(`Error exporting chart to image file: `+e.message)}return null}function Zg(e,t){if(!globalThis.OffscreenCanvas)throw Error(`converting a chart to an image using OffscreenCanvas is not supported in this environment`);return new OffscreenCanvas(e,t)}async function Qg(e){return`convertToBlob`in e?e.convertToBlob({type:`image/png`}):new Promise(t=>e.toBlob(t,`image/png`))}async function $g(e){let t=await Qg(e);if(t)return new Promise(e=>{let n=new FileReader;n.addEventListener(`load`,()=>{e(n.result)}),n.readAsDataURL(t)})}function e_(e,t,n,r){if(`chartJsConfig`in t){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);let n=$r();n||ei();let r=b(t.chartJsConfig);if(!globalThis.Chart.registry.controllers.get(r.type))throw console.log(`Chart of type "${r.type}" is not registered in Chart.js library.`),n||ti(),Error(`Chart of type "${r.type}" is not registered in Chart.js library.`);let i=new globalThis.Chart(e,r);return()=>{i.destroy(),n||ti()}}else r===`scorecard`?mg(_g(n,t),e):r===`gauge`&&Mg(e,t,1,n);return()=>{}}let t_=1e3,n_=1e3;function r_(e,t){let n=e.getStore(H),{scrollX:r,scrollY:i}=n.activeSheetScrollInfo,a=n.sheetViewDimension,o=r+Math.max(0,(a.width-t.width)/2),s=i+Math.max(0,(a.height-t.height)/2),c=e.model.getters.getActiveSheetId();return n.viewports.getPositionAnchorOffset(c,{x:o,y:s})}function i_(e){let t=b(e);if(t.width>t_){let e=t_/t.width;t.width=t_,t.height*=e}if(t.height>n_){let e=n_/t.height;t.height=n_,t.width*=e}return t}function a_(e,t,n,r){let i=e.getMaxAnchorOffset(t,r.height,r.width),{col:a,row:o}=n,s={...r.offset};for(let n=e.getColSize(t,a);s.x>n;n=e.getColSize(t,a))a+=1,s.x-=n;a>i.col&&(a=i.col,s.x=i.offset.x);for(let n=e.getRowSize(t,o);s.y>n;n=e.getRowSize(t,o))o+=1,s.y-=n;return o>i.row&&(o=i.row,s.y=i.offset.y),{col:a,row:o,offset:s}}function o_(e,t){return t.model.getters.getChartIdFromFigureId(e)?be([m_(e,t),{id:`edit`,name:M(`Edit`),execute:()=>{t.model.dispatch(`SELECT_FIGURE`,{figureId:e}),t.openSidePanel(`ChartPanel`)},icon:`o-spreadsheet-Icon.EDIT`,isEnabled:e=>!e.isSmall},l_(e,t),u_(e,t),d_(e,t),f_(e,t),p_(e,t)]).filter(e=>t.model.getters.isReadonly()?e.isReadonlyAllowed:!0):[]}function s_(e,t){return be([l_(e,t,M(`Image copied to clipboard`)),u_(e,t),{id:`reset_size`,name:M(`Reset size`),execute:async()=>{let n=t.model.getters.getActiveSheetId(),r=t.model.getters.getFigure(n,e);if(!r)return;let i=t.model.getters.getImagePath(e),a=t.model.getters.getImageSize(e)??await t.imageProvider?.getImageOriginalSize(i);if(!t.model.getters.getImageSize(e)){let n=t.model.getters.getImage(e);n.size=a}let{col:o,row:s}=r,{height:c,width:l}=i_(a);t.model.dispatch(`UPDATE_FIGURE`,{sheetId:n,figureId:e,height:c,width:l,col:o,row:s})},icon:`o-spreadsheet-Icon.REFRESH`},{id:`download`,name:M(`Download`),execute:async()=>{t.model.dispatch(`SELECT_FIGURE`,{figureId:e}),fe(t.model.getters.getImagePath(e),`image`)},icon:`o-spreadsheet-Icon.DOWNLOAD`},p_(e,t)])}function c_(e,t){let n=t=>t.model.getters.getSelectedCarouselItem(e)?.type===`chart`;return be([{id:`edit_carousel`,name:M(`Edit carousel`),execute:()=>{t.model.dispatch(`SELECT_FIGURE`,{figureId:e}),t.openSidePanel(`CarouselPanel`,{figureId:e})},icon:`o-spreadsheet-Icon.EDIT`,isEnabled:e=>!e.isSmall},{...l_(e,t,M(`Carousel copied to clipboard`)),name:M(`Copy carousel`)},{...u_(e,t),name:M(`Cut carousel`)},{...p_(e,t),name:M(`Delete carousel`),separator:!0},{id:`edit_chart`,name:M(`Edit chart`),execute:()=>{t.model.dispatch(`SELECT_FIGURE`,{figureId:e}),t.openSidePanel(`ChartPanel`,{})},icon:`o-spreadsheet-Icon.EDIT`,isEnabled:e=>!e.isSmall,isVisible:n},{...d_(e,t),isVisible:n,name:M(`Copy chart as image`)},{...f_(e,t),isVisible:n,name:M(`Download chart`)},{id:`popout_chart`,name:M(`Pop out chart`),icon:`o-spreadsheet-Icon.EXTERNAL`,execute:()=>{let n=t.model.getters.getSelectedCarouselItem(e);if(!n||n.type!==`chart`)return;let r=t.model.getters.getActiveSheetId(),i=Og(t,r,e);t.model.dispatch(`POPOUT_CHART_FROM_CAROUSEL`,{carouselId:e,chartId:n.chartId,sheetId:r,...i})},isVisible:n},{id:`delete_carousel_item`,name:t=>t.model.getters.getSelectedCarouselItem(e)?.type===`chart`?M(`Delete chart`):M(`Delete data view`),execute:()=>{let n=t.model.getters.getSelectedCarouselItem(e);if(!n)return;let r=t.model.getters.getCarousel(e),i=r.items.filter(e=>!w(e,n));t.model.dispatch(`UPDATE_CAROUSEL`,{figureId:e,sheetId:t.model.getters.getActiveSheetId(),definition:t.model.getters.carouselToCarouselData({...r,items:i})})},icon:`o-spreadsheet-Icon.TRASH`,isVisible:t=>t.model.getters.getCarousel(e).items.length>=1}]).filter(e=>t.model.getters.isReadonly()?e.isReadonlyAllowed:!0)}function l_(e,t,n){return{id:`copy`,name:M(`Copy`),shortcut:`Ctrl+C`,execute:async()=>{t.model.getters.getSelectedFigureIds().includes(e)||t.model.dispatch(`SELECT_FIGURE`,{figureId:e}),t.model.dispatch(`COPY`);let r=await t.model.getters.getClipboardTextAndImageContent();await t.clipboard.write(r),n&&t.notifyUser({sticky:!1,type:`success`,text:n})},icon:`o-spreadsheet-Icon.CLIPBOARD`,isEnabledOnLockedSheet:!0}}function u_(e,t){return{id:`cut`,name:M(`Cut`),shortcut:`Ctrl+X`,execute:async()=>{t.model.getters.getSelectedFigureIds().includes(e)||t.model.dispatch(`SELECT_FIGURE`,{figureId:e}),t.model.dispatch(`CUT`),await t.clipboard.write(await t.model.getters.getClipboardTextAndImageContent())},icon:`o-spreadsheet-Icon.CUT`}}function d_(e,t){return{id:`copy_as_image`,name:M(`Copy as image`),icon:`o-spreadsheet-Icon.COPY_AS_IMAGE`,execute:async()=>{let n=t.model.getters.getFigureSheetId(e),r=t.model.getters.getFigure(n,e),i=t.model.getters.getChartIdFromFigureId(e);if(!i)return;let a=t.model.getters.getChartType(i),o=await Xg(t.model.getters.getChartRuntime(i),r,a);if(!o)return;let s=await new Promise(e=>{let t=new FileReader;t.addEventListener(`loadend`,n=>{let r=t.result;e(r)}),t.readAsArrayBuffer(o)}),c=`<img src="data:image/png;base64,${new Uint8Array(s).toBase64()}" />`;await t.clipboard.write({"text/html":c,"image/png":o}),t.notifyUser({sticky:!1,type:`success`,text:M(`Chart copied to clipboard`)})},isVisible:e=>e.model.getters.getSelectedFigureIds().length<=1,isReadonlyAllowed:!0,isEnabledOnLockedSheet:!0}}function f_(e,t){return{id:`download`,name:M(`Download`),icon:`o-spreadsheet-Icon.DOWNLOAD`,execute:async()=>{let n=t.model.getters.getFigureSheetId(e),r=t.model.getters.getFigure(n,e),i=t.model.getters.getChartIdFromFigureId(e);if(!i)return;let a=t.model.getters.getChartType(i),o=await Yg(t.model.getters.getChartRuntime(i),r,a);o&&fe(o,`chart`)},isVisible:e=>e.model.getters.getSelectedFigureIds().length<=1,isReadonlyAllowed:!0,isEnabledOnLockedSheet:!0}}function p_(e,t){return{id:`delete`,name:M(`Delete`),execute:()=>{let n=t.model.getters.getSelectedFigureIds();n.includes(e)?t.model.dispatch(`DELETE_FIGURES`,{sheetId:t.model.getters.getActiveSheetId(),figureIds:n}):t.model.dispatch(`DELETE_FIGURE`,{sheetId:t.model.getters.getActiveSheetId(),figureId:e})},icon:`o-spreadsheet-Icon.TRASH`}}function m_(e,t){return{id:`mergeCarousel`,name:M(`Create carousel`),isVisible:t=>{let n=t.model.getters.getSelectedFigureIds();if(n.length<2||!n.includes(e))return!1;let r=t.model.getters.getActiveSheetId();return!n.map(e=>t.model.getters.getFigure(r,e)).some(e=>e===void 0||e.tag!==`chart`)},execute:()=>{let n=t.model.getters.getActiveSheetId(),r=t.model.getters.getSelectedFigureIds();t.model.dispatch(`MERGE_CHART_FIGURES_INTO_CAROUSEL`,{sheetId:n,baseFigureId:e,chartFigureIds:r})},icon:`o-spreadsheet-Icon.CAROUSEL`}}function h_({strikethrough:e,underline:t}){return!e&&!t?`none`:`${e?`line-through`:``} ${t?`underline`:``}`}function g_(e){let t=__(e);return e&&e.fillColor&&(t.background=e.fillColor),t}function __(e){let t={};if(!e)return t;if(e.bold&&(t[`font-weight`]=`bold`),e.italic&&(t[`font-style`]=`italic`),e.fontSize&&(t[`font-size`]=`${e.fontSize}px`),e.strikethrough||e.underline){let n=e.strikethrough?`line-through`:``;n=e.underline?n+` underline`:n,t[`text-decoration`]=n}return e.textColor&&(t.color=e.textColor),t}function U(e){let t=``;for(let n in e)e[n]&&(t+=`${n}:${e[n]}; `);return t}function v_(e){let t=window.getComputedStyle(e);return{top:parseInt(t.marginTop,10)||0,bottom:parseInt(t.marginBottom,10)||0,left:parseInt(t.marginLeft,10)||0,right:parseInt(t.marginRight,10)||0}}let y_=[`x1`,um],b_=[`x`,...y_];var x_=class extends Yr{mutators=[`resetAxisLimits`,`updateAxisLimits`,`updateTrendLineConfiguration`,`clearAxisLimits`];originalAxisLimits={};currentAxesLimits={};idConversion={};axisDesignBoundaries={};handle(e){switch(e.type){case`DELETE_FIGURE`:if(e.figureId&&this.idConversion[e.figureId]){for(let t of this.idConversion[e.figureId])delete this.originalAxisLimits[t],delete this.currentAxesLimits[t];delete this.axisDesignBoundaries[e.figureId]}break;case`UPDATE_CHART`:let t=`${e.definition.type}-${e.chartId}`;if(this.idConversion[e.figureId]||(this.idConversion[e.figureId]=new Set),this.idConversion[e.figureId].add(t),!(`zoomable`in e.definition&&e.definition.zoomable))this.clearAxisLimits(t),delete this.axisDesignBoundaries[e.figureId];else{let n=`axesDesign`in e.definition?e.definition.axesDesign:void 0,r=n?.x?.min,i=n?.x?.max,a=this.axisDesignBoundaries[e.figureId];(a?.min!==r||a?.max!==i)&&(this.clearAxisLimits(t),this.axisDesignBoundaries[e.figureId]={min:r,max:i})}break}}clearAxisLimits(e){return delete this.originalAxisLimits[e],delete this.currentAxesLimits[e],`noStateChange`}resetAxisLimits(e,t){for(let n of b_)t[n]?this.originalAxisLimits[e]={...this.originalAxisLimits[e],[n]:{...t[n]}}:this.originalAxisLimits[e]?.[n]&&delete this.originalAxisLimits[e][n];return`noStateChange`}updateAxisLimits(e,t){let{min:n,max:r}=t;return n>r&&([n,r]=[r,n]),this.currentAxesLimits[e]={x:{min:n,max:r}},`noStateChange`}updateTrendLineConfiguration(e){if(!this.originalAxisLimits[e]?.x||!this.currentAxesLimits[e]?.x)return`noStateChange`;let t=this.originalAxisLimits[e].x;for(let n of y_){if(!this.originalAxisLimits[e][n])continue;let r=t.max-t.min,i=this.originalAxisLimits[e][n],a=(i.max-i.min)/r,o=i.min-t.min*a,s=this.currentAxesLimits[e].x.min,c=this.currentAxesLimits[e].x.max;this.currentAxesLimits[e][n]={min:s*a+o,max:c*a+o}}return`noStateChange`}},S_=class extends ng{static template=`o-spreadsheet-ZoomableChartJsComponent`;store;masterChartCanvas=(0,t.signal)(null);masterChart;mode;hasLinearScale;isBarChart;chartId=``;datasetBoundaries={min:0,max:0};removeEventListeners=()=>{};isMasterChartAllowed=!1;setup(){this.store=k(x_),super.setup()}unmount(){super.unmount(),this.masterChart?.destroy(),this.removeEventListeners()}get containerStyle(){return U({height:this.sliceable?`calc(100% - 60px)`:`100%`})}get masterChartContainerStyle(){let e=this.env.model.getters.getChartRuntime(this.props.chartId);return e&&!e.chartJsConfig.data.datasets.some(e=>e.data.length>1)?`opacity: 0.3;`:``}get sliceable(){if(this.props.isFullScreen)return!0;let e=this.env.model.getters.getChartDefinition(this.props.chartId);return(`zoomable`in e&&e.zoomable)??!1}get axisOffset(){return!this.hasLinearScale&&this.isBarChart?.5:0}getMasterChartConfiguration(e){let t=e;return{...t,options:{...t.options,plugins:{...t.options.plugins,zoomWindowPlugin:{getLowerBound:()=>this.lowerBound,getUpperBound:()=>this.upperBound}}}}}getDetailChartConfiguration(e){if(!this.sliceable)return e;let t=e.options.scales.x;return this.store.currentAxesLimits[this.chartId]?.x&&(t={...t,...this.getStoredBoundaries()}),{...e,options:{...e.options,scales:{...e.options.scales,x:t},layout:{...e.options.layout,padding:{...e.options.layout?.padding,bottom:5}}}}}getAxisLimitsFromDataset(e){let t=e.data.datasets.map(e=>e.data).flat().map((e,t)=>typeof e==`object`&&e?e.x:t);return{min:Math.min(...t),max:Math.max(...t)}}setMasterChartCursor(e){let t=this.masterChartCanvas();if(t){if(e&&!e.chartJsConfig.data.datasets.some(e=>e.data.length>1)){t.style.cursor=`not-allowed`,this.isMasterChartAllowed=!1;return}t.style.cursor=`default`,this.isMasterChartAllowed=!0}}createChart(e){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);let t=e.chartJsConfig;if(this.isBarChart=t.type===`bar`,this.chartId=`${t.type}-${this.props.chartId}`,this.datasetBoundaries=this.getAxisLimitsFromDataset(t),this.sliceable&&(e.chartJsConfig=this.getDetailChartConfiguration(t)),super.createChart(e),this.hasLinearScale=this.chart?.scales?.x?.type===`linear`,!this.sliceable||!(`masterChartConfig`in e)){this.isMasterChartAllowed=!1;return}this.masterChart?.destroy();let n=this.masterChartCanvas();if(!n)return;let r=n.getContext(`2d`);this.setMasterChartCursor(e),this.masterChart=new globalThis.Chart(r,this.getMasterChartConfiguration(e.masterChartConfig)),this.resetAxesLimits(),this.chart?.options&&(this.chart.options.animation=!1)}updateChartJs(e){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);let t=e.chartJsConfig,{min:n,max:r}=this.getAxisLimitsFromDataset(t);if((this.datasetBoundaries.min!==n||this.datasetBoundaries.max!==r)&&(this.store.clearAxisLimits(this.chartId),this.datasetBoundaries={min:n,max:r}),this.isBarChart=t?.type===`bar`,this.chartId=`${t.type}-${this.props.chartId}`,this.sliceable&&(e.chartJsConfig=this.getDetailChartConfiguration(t)),super.updateChartJs(e),this.hasLinearScale=this.chart?.scales?.x?.type===`linear`,!this.sliceable||!(`masterChartConfig`in e))this.masterChart=void 0,this.isMasterChartAllowed=!1;else{let t=this.getMasterChartConfiguration(e.masterChartConfig);if(this.masterChart)this.masterChart.data=t.data,this.masterChart.config.options=t.options,this.masterChart.update();else{let e=this.masterChartCanvas();if(!e)return;let n=e.getContext(`2d`);this.masterChart=new globalThis.Chart(n,t)}this.setMasterChartCursor(e)}this.resetAxesLimits(),this.chart?.options&&(this.chart.options.animation=!1)}resetAxesLimits(){if(this.chart){if(!this.store.originalAxisLimits[this.chartId]?.x){let e=this.masterChart?this.masterChart.scales:this.chart.scales;!this.hasLinearScale&&e.x&&(e={...e,x:this.adjustBoundaries(e.x)}),this.store.resetAxisLimits(this.chartId,e);return}this.updateTrendingLineAxes(),this.chart.update(),this.masterChart&&this.masterChart.update()}}updateTrendingLineAxes(){this.store.updateTrendLineConfiguration(this.chartId);let e=this.store.currentAxesLimits[this.chartId];for(let t of[`x1`,um])!this.chart?.config?.options?.scales?.[t]||!e?.[t]||(this.chart.config.options.scales[t].min=e[t].min,this.chart.config.options.scales[t].max=e[t].max)}get upperBound(){return this.computePosition(this.store.currentAxesLimits[this.chartId]?.x?.max)}get lowerBound(){return this.computePosition(this.store.currentAxesLimits[this.chartId]?.x?.min)}computePosition(e){if(e===void 0||!this.masterChart?.scales?.x)return;let t=this.masterChart.scales.x;if(this.hasLinearScale)return t.getPixelForValue(e);if(!this.masterChart.chartArea)return;let{left:n,right:r}=this.masterChart.chartArea,{min:i,max:a}=t,o=this.axisOffset;return n+(r-n)*(o+e-i)/(2*o+a-i)}computeCoordinate(e){if(!this.masterChart)return;let t=this.masterChart.scales.x;if(this.hasLinearScale){let n=t.getValueForPixel(e);return n===void 0?void 0:Math.round(n*100)/100}let{left:n,right:r}=this.masterChart.chartArea,i=this.axisOffset;return t.min-i+(t.max+2*i-t.min)*(e-n)/(r-n)}getStoredBoundaries(){let{min:e,max:t}=this.store.currentAxesLimits[this.chartId].x;return this.hasLinearScale||(e=Math.ceil(e),t=Math.floor(t)),{min:e,max:t}}adjustBoundaries({min:e,max:t}){return this.hasLinearScale||(e=Math.ceil(e)-this.axisOffset,t=Math.floor(t)+this.axisOffset),{min:e,max:t}}updateAxisLimits(e,t){if(e===t||!this.chart)return;this.store.updateAxisLimits(this.chartId,{min:e,max:t});let{min:n,max:r}=this.getStoredBoundaries();(r>n||this.isBarChart&&r===n)&&(this.chart.config.options.scales.x.min=n,this.chart.config.options.scales.x.max=r,this.updateTrendingLineAxes(),this.chart.update()),this.masterChart?.update()}onMasterChartPointerDown(e){this.removeEventListeners();let t=Sg(this.env,e,this.masterChartCanvas()?.getBoundingClientRect()),n=t.offsetX;if(!this.masterChart?.chartArea||!this.chart?.scales?.x)return;let{left:r,right:i,top:a,bottom:o}=this.masterChart.chartArea,s=this.upperBound??i,c=this.lowerBound??r;if(n<r-5||n>i+5||t.offsetY<a||t.offsetY>o)return;e.preventDefault(),e.stopPropagation();let l,u,d,f=n;if((c!==r||s!==i)&&n>c+5&&n<s-5){l=t.offsetX-c,this.mode=`moveInMaster`;let e=this.store.currentAxesLimits[this.chartId]?.x;u=(e?.max??this.chart.scales.x.max)-(e?.min??this.chart.scales.x.min)}else this.mode=`selectInMaster`,l=Math.abs(n-c)<5?s:Math.abs(n-s)<5?c:x(n,r,i),d=this.computeCoordinate(l);let p=this.store.originalAxisLimits[this.chartId].x.min,m=this.store.originalAxisLimits[this.chartId].x.max,h=e=>{if(this.mode===`moveInMaster`){let t=this.computeCoordinate(e-l);return t<p?t=p:t>m-u&&(t=m-u),{min:t,max:t+u}}else if(this.mode===`selectInMaster`){let t=x(e,r,i);if(Math.abs(l-t)>5){let e=this.computeCoordinate(t);return d===void 0||e===void 0?{}:{min:Math.min(d,e),max:Math.max(d,e)}}}return{}},g=e=>{let t=Sg(this.env,e,this.masterChartCanvas()?.getBoundingClientRect()).offsetX;if(Math.abs(t-f)<5)return;let{min:n,max:r}=h(t);n!==void 0&&r!==void 0&&this.updateAxisLimits(n,r)},_=e=>{this.removeEventListeners();let{min:t,max:n}=this.chart.scales.x;this.hasLinearScale||(this.mode===`moveInMaster`?(t=Math.round(t)-this.axisOffset,n=t+u):{min:t,max:n}=this.adjustBoundaries({min:t,max:n})),this.updateAxisLimits(t,n),this.mode=void 0,this.updateMasterChartCursor(e)};this.removeEventListeners=()=>{window.removeEventListener(`pointermove`,g,!0),window.removeEventListener(`pointerup`,_,!0)},window.addEventListener(`pointermove`,g,!0),window.addEventListener(`pointerup`,_,!0)}updateMasterChartCursor(e){let t=e.target,{offsetX:n,offsetY:r}=Sg(this.env,e,t?.getBoundingClientRect());if(!(!t||!this.isMasterChartAllowed)&&this.mode===void 0){if(!this.masterChart?.chartArea){t.style.cursor=`default`;return}let{left:e,right:i,top:a,bottom:o}=this.masterChart.chartArea,s=this.lowerBound??e,c=this.upperBound??i;r<a||r>o?t.style.cursor=`default`:Math.abs(s-n)<5||Math.abs(c-n)<5?t.style.cursor=`ew-resize`:s<n&&n<c&&(s!==e||c!==i)?t.style.cursor=`grab`:t.style.cursor=`crosshair`}}onMasterChartMouseLeave(e){let t=e.target;!t||!this.isMasterChartAllowed||(t.style.cursor=`default`)}onMasterChartDoubleClick(e){this.mode=void 0;let t=Sg(this.env,e,this.masterChartCanvas()?.getBoundingClientRect()),n=t.offsetX;if(!this.masterChart?.chartArea||!this.chart?.scales.x)return;let{left:r,right:i,top:a,bottom:o}=this.masterChart.chartArea,s=this.upperBound??i,c=this.lowerBound??r;if(s<c&&([s,c]=[c,s]),n<r-5||n>i+5||t.offsetY<a||t.offsetY>o)return;e.preventDefault(),e.stopPropagation();let{min:l,max:u}=this.store.currentAxesLimits[this.chartId]?.x??this.chart.scales.x,d=this.store.originalAxisLimits[this.chartId].x;if(d){if(Math.abs(n-c)<5)l=d.min;else if(Math.abs(n-s)<5)u=d.max;else if(c<n&&n<s)l=d.min,u=d.max;else return;this.updateAxisLimits(l,u)}}};let C_=new D;C_.add(`animatedBackgroundColorChange`,{id:`animatedBackgroundColorChange`,easingFn:`easeOutCubic`,hasAnimation:(e,t)=>e?.style?.fillColor!==t?.style?.fillColor,updateAnimation:function(e,t,n,r){let i=_p([{value:0,color:n.style.fillColor||`#ffffff`},{value:1,color:r.style.fillColor||`#ffffff`}]);t.style.fillColor=i(w_[this.easingFn](e))}}),C_.add(`animatedTextColorChange`,{id:`animatedTextColorChange`,easingFn:`easeOutCubic`,hasAnimation:(e,t)=>e?.style?.textColor!==t?.style?.textColor,updateAnimation:function(e,t,n,r){let i=_p([{value:0,color:n.style.textColor||`#000000`},{value:1,color:r.style.textColor||`#000000`}]);t.style.textColor=i(w_[this.easingFn](e))}}),C_.add(`animatedDataBar`,{id:`animatedDataBar`,easingFn:`easeOutCubic`,hasAnimation:(e,t)=>e?.dataBarFill?.percentage!==t?.dataBarFill?.percentage,updateAnimation:function(e,t,n,r){let i=n?.dataBarFill?.percentage||0,a=r?.dataBarFill?.percentage||0,o=w_[this.easingFn](e),s=i+(a-i)*o;t.dataBarFill={color:r.dataBarFill?.color||n.dataBarFill?.color||`#ffffff`,percentage:s}}}),C_.add(`textFadeIn`,{id:`textFadeIn`,easingFn:`easeInCubic`,hasAnimation:(e,t)=>{let n=e?.content?.textLines?.join(`
|
|
18
18
|
`).trim(),r=t?.content?.textLines?.join(`
|
|
19
19
|
`).trim();return!!(!n&&r)},updateAnimation:function(e,t,n,r){t.textOpacity=w_[this.easingFn](e)}}),C_.add(`textFadeOut`,{id:`textFadeOut`,easingFn:`easeOutCubic`,hasAnimation:(e,t)=>{let n=e?.content?.textLines?.join(`
|
|
20
20
|
`).trim(),r=t?.content?.textLines?.join(`
|
|
@@ -24,7 +24,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
24
24
|
(value for the item) / (value for the parent item on rows)`),"%_of_parent_col_total":M(`Calculates values as follows:
|
|
25
25
|
(value for the item) / (value for the parent item on columns)`),"%_of_parent_total":M(`Calculates values as follows:
|
|
26
26
|
(value for the item) / (value for the parent item of the selected Base field)`),difference_from:M(`Displays values as the difference from the value of the Base item in the Base field.`),"%_difference_from":M(`Displays values as the percentage difference from the value of the Base item in the Base field.`),running_total:M(`Displays the value for successive items in the Base field as a running total.`),"%_running_total":M(`Calculates the value as a percentage for successive items in the Base field that are displayed as a running total.`),rank_asc:M(`Displays the rank of selected values in a specific field, listing the smallest item in the field as 1, and each larger value with a higher rank value.`),rank_desc:M(`Displays the rank of selected values in a specific field, listing the largest item in the field as 1, and each smaller value with a higher rank value.`),index:M(`Calculates values as follows:
|
|
27
|
-
((value in cell) x (Grand Total of Grand Totals)) / ((Grand Row Total) x (Grand Column Total))`)}};function ub(e,t){return M(`Oops—this pivot table is quite large (%s cells). Try simplifying it using the side panel.`,B(e,{format:`0,00`,locale:t}))}function db(e){let t=Da.now();switch(e){case`today`:return Math.floor(to(t));case`yesterday`:return t.setDate(t.getDate()-1),Math.floor(to(t));case`tomorrow`:return t.setDate(t.getDate()+1),Math.floor(to(t));case`lastWeek`:return t.setDate(t.getDate()-6),Math.floor(to(t));case`lastMonth`:{let e=t.getMonth()===0?11:t.getMonth()-1,n=new Da(t.getFullYear(),e,1);return t.getDate()>no(n)?t.setDate(1):(t.setDate(t.getDate()+1),t.setMonth(t.getMonth()-1)),Math.floor(to(t))}case`lastYear`:return t.getMonth()===1&&t.getDate()===29?(t.setDate(28),t.setFullYear(t.getFullYear()-1)):(t.setDate(t.getDate()+1),t.setFullYear(t.getFullYear()-1)),Math.floor(to(t))}}function fb(e,t){return`dateValue`in e&&e.dateValue!==`exactDate`?[db(e.dateValue)]:e.values.map(e=>Ba(e,t))}function pb(e,t){return e.map(e=>{if(e.startsWith(`=`))return e;let n=uf(e,z);return typeof n==`number`?B(n,{format:t.dateFormat,locale:t}):``})}function mb(e){if(!e||typeof e!=`object`||!(!e.thousandsSeparator||typeof e.thousandsSeparator==`string`))return!1;for(let t of[`code`,`name`,`decimalSeparator`,`dateFormat`,`timeFormat`,`formulaArgSeparator`])if(!e[t]||typeof e[t]!=`string`)return!1;if(e.formulaArgSeparator===e.decimalSeparator||e.thousandsSeparator===e.decimalSeparator)return!1;try{B(1,{locale:e,format:`#,##0.00`}),B(1,{locale:e,format:e.dateFormat}),B(1,{locale:e,format:e.timeFormat})}catch{return!1}return!0}function hb(e,t){return Sn(e)?yb(e,t):Sb(e,t)}function gb(e,t){return Sn(e)?yb(e,t):Cb(e,t)}function _b(e,t){return e.startsWith(`=`)?bb(e,t):Tb(e,t)}function vb(e,t){return Sn(e)?yb(e,t):Sb(e,t)}function yb(e,t){return xb(e.startsWith(`+`)?`=`+e.slice(1):e,t,z)}function bb(e,t){return xb(e,z,t)}function xb(e,t,n){if(t.formulaArgSeparator===n.formulaArgSeparator&&t.decimalSeparator===n.decimalSeparator)return e;let r=zl(e,t),i=``;for(let e of r)e.type===`NUMBER`?i+=e.value.replace(t.decimalSeparator,n.decimalSeparator):e.type===`ARG_SEPARATOR`?i+=n.formulaArgSeparator:e.type===`ARRAY_ROW_SEPARATOR`?i+=n.formulaArgSeparator===`;`?`\\`:`;`:i+=e.value;return i}function Sb(e,t){return t.decimalSeparator===`.`||!bo(e,t)?e:(t.thousandsSeparator&&(e=e.replaceAll(t.thousandsSeparator,``)),e.replace(t.decimalSeparator,`.`))}function Cb(e,t){if(Va(e,t)){let n=F(e,t),r=z.dateFormat;return Number.isInteger(n)||(r+=` `+z.timeFormat),B(n,{locale:z,format:r})}return Sb(e,t)}function wb(e,t){if(t.decimalSeparator===`.`||!bo(e,z))return e;let n=Tc(z);return e.replace(n,e=>e.replace(`.`,t.decimalSeparator))}function Tb(e,t){if(Va(e,z)){let n=F(e,z),r=t.dateFormat;return Number.isInteger(n)||(r+=` `+t.timeFormat),B(n,{locale:t,format:r})}return wb(e,t)}function Eb(e){return e.dateFormat+` `+e.timeFormat}let G=new D;G.add(`containsText`,{type:`containsText`,isValueValid:(e,t)=>String(e).toLowerCase().includes(String(t.values[0]).toLowerCase()),getErrorString:e=>M(`The value must be a text that contains "%s"`,String(e.values[0])),isCriterionValueValid:e=>!!e,criterionValueErrorString:sb.CriterionError.notEmptyValue,numberOfValues:()=>1,name:M(`Text contains`),getPreview:e=>M(`Text contains "%s"`,e.values[0])}),G.add(`notContainsText`,{type:`notContainsText`,isValueValid:(e,t)=>!String(e).toLowerCase().includes(String(t.values[0]).toLowerCase()),getErrorString:e=>M(`The value must be a text that does not contain "%s"`,String(e.values[0])),isCriterionValueValid:e=>!!e,criterionValueErrorString:sb.CriterionError.notEmptyValue,numberOfValues:()=>1,name:M(`Text does not contain`),getPreview:e=>M(`Text does not contain "%s"`,e.values[0])}),G.add(`isEqualText`,{type:`isEqualText`,isValueValid:(e,t)=>String(e).toLowerCase()===String(t.values[0]).toLowerCase(),getErrorString:e=>M(`The value must be exactly "%s"`,String(e.values[0])),isCriterionValueValid:e=>!!e,criterionValueErrorString:sb.CriterionError.notEmptyValue,numberOfValues:()=>1,name:M(`Text is exactly`),getPreview:e=>M(`Text is exactly "%s"`,e.values[0])});let Db=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$/;G.add(`isEmail`,{type:`isEmail`,isValueValid:(e,t)=>typeof e==`string`&&Db.test(e),getErrorString:()=>M(`The value must be a valid email address`),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>0,name:M(`Text is valid email`),getPreview:()=>M(`Text is valid email`)}),G.add(`isLink`,{type:`isLink`,isValueValid:(e,t)=>rf(e)!==void 0,getErrorString:()=>M(`The value must be a valid link`),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>0,name:M(`Text is valid link`),getPreview:()=>M(`Text is valid link`)}),G.add(`dateIs`,{type:`dateIs`,isValueValid:(e,t)=>{let n=fb(t,z)[0],r=Ba(e,z);return r===void 0||n===void 0?!1:[`lastWeek`,`lastMonth`,`lastYear`].includes(t.dateValue)?po(r,Math.floor(to(Da.now())),n):fo(r,n)},getErrorString:(e,t)=>{let n=t.getLocale();return e.dateValue===`exactDate`?M(`The value must be the date %s`,kb(e,n)[0]):M(`The value must be %s`,sb.DateIs[e.dateValue])},isCriterionValueValid:e=>Ab(e),criterionValueErrorString:sb.CriterionError.dateValue,numberOfValues:e=>+(e.dateValue===`exactDate`),name:M(`Date is`),getPreview:(e,t)=>e.dateValue===`exactDate`?M(`Date is %s`,pb(e.values,t.getLocale())[0]):M(`Date is %s`,sb.DateIs[e.dateValue])}),G.add(`dateIsBefore`,{type:`dateIsBefore`,isValueValid:(e,t)=>{let n=fb(t,z)[0],r=Ba(e,z);return r!==void 0&&n!==void 0&&mo(r,n)},getErrorString:(e,t)=>{let n=t.getLocale();return e.dateValue===`exactDate`?M(`The value must be a date before %s`,kb(e,n)[0]):M(`The value must be a date before %s`,sb.DateIsBefore[e.dateValue])},isCriterionValueValid:e=>Ab(e),criterionValueErrorString:sb.CriterionError.dateValue,numberOfValues:e=>+(e.dateValue===`exactDate`),name:M(`Date is before`),getPreview:(e,t)=>e.dateValue===`exactDate`?M(`Date is before %s`,pb(e.values,t.getLocale())[0]):M(`Date is before %s`,sb.DateIsBefore[e.dateValue])}),G.add(`dateIsOnOrBefore`,{type:`dateIsOnOrBefore`,isValueValid:(e,t)=>{let n=fb(t,z)[0],r=Ba(e,z);return r!==void 0&&n!==void 0&&ho(r,n)},getErrorString:(e,t)=>{let n=t.getLocale();return e.dateValue===`exactDate`?M(`The value must be a date on or before %s`,kb(e,n)[0]):M(`The value must be a date on or before %s`,sb.DateIsBefore[e.dateValue])},isCriterionValueValid:e=>Ab(e),criterionValueErrorString:sb.CriterionError.dateValue,numberOfValues:e=>+(e.dateValue===`exactDate`),name:M(`Date is on or before`),getPreview:(e,t)=>e.dateValue===`exactDate`?M(`Date is on or before %s`,pb(e.values,t.getLocale())[0]):M(`Date is on or before %s`,sb.DateIsBefore[e.dateValue])}),G.add(`dateIsAfter`,{type:`dateIsAfter`,isValueValid:(e,t)=>{let n=fb(t,z)[0],r=Ba(e,z);return r!==void 0&&n!==void 0&&go(r,n)},getErrorString:(e,t)=>{let n=t.getLocale();return e.dateValue===`exactDate`?M(`The value must be a date after %s`,kb(e,n)[0]):M(`The value must be a date after %s`,sb.DateIsBefore[e.dateValue])},isCriterionValueValid:e=>Ab(e),criterionValueErrorString:sb.CriterionError.dateValue,numberOfValues:e=>+(e.dateValue===`exactDate`),name:M(`Date is after`),getPreview:(e,t)=>e.dateValue===`exactDate`?M(`Date is after %s`,pb(e.values,t.getLocale())[0]):M(`Date is after %s`,sb.DateIsBefore[e.dateValue])}),G.add(`dateIsOnOrAfter`,{type:`dateIsOnOrAfter`,isValueValid:(e,t)=>{let n=fb(t,z)[0],r=Ba(e,z);return r!==void 0&&n!==void 0&&_o(r,n)},getErrorString:(e,t)=>{let n=t.getLocale();return e.dateValue===`exactDate`?M(`The value must be a date on or after %s`,kb(e,n)[0]):M(`The value must be a date on or after %s`,sb.DateIsBefore[e.dateValue])},isCriterionValueValid:e=>Ab(e),criterionValueErrorString:sb.CriterionError.dateValue,numberOfValues:e=>+(e.dateValue===`exactDate`),name:M(`Date is on or after`),getPreview:(e,t)=>e.dateValue===`exactDate`?M(`Date is on or after %s`,pb(e.values,t.getLocale())[0]):M(`Date is on or after %s`,sb.DateIsBefore[e.dateValue])}),G.add(`dateIsBetween`,{type:`dateIsBetween`,isValueValid:(e,t)=>{let n=fb(t,z),r=Ba(e,z);return r===void 0||n[0]===void 0||n[1]===void 0?!1:po(r,n[0],n[1])},getErrorString:(e,t)=>{let n=kb(e,t.getLocale());return M(`The value must be a date between %s and %s`,n[0],n[1])},isCriterionValueValid:e=>Ab(e),criterionValueErrorString:sb.CriterionError.dateValue,numberOfValues:()=>2,name:M(`Date is between`),getPreview:(e,t)=>{let n=pb(e.values,t.getLocale());return M(`Date is between %s and %s`,n[0],n[1])}}),G.add(`dateIsNotBetween`,{type:`dateIsNotBetween`,isValueValid:(e,t)=>{let n=fb(t,z),r=Ba(e,z);return r===void 0||n[0]===void 0||n[1]===void 0?!1:!po(r,n[0],n[1])},getErrorString:(e,t)=>{let n=kb(e,t.getLocale());return M(`The value must be a date not between %s and %s`,n[0],n[1])},isCriterionValueValid:e=>Ab(e),criterionValueErrorString:sb.CriterionError.dateValue,numberOfValues:()=>2,name:M(`Date is not between`),getPreview:(e,t)=>{let n=pb(e.values,t.getLocale());return M(`Date is not between %s and %s`,n[0],n[1])}}),G.add(`dateIsValid`,{type:`dateIsValid`,isValueValid:(e,t)=>Ba(e,z)!==void 0,getErrorString:()=>M(`The value must be a valid date`),isCriterionValueValid:e=>Ab(e),criterionValueErrorString:``,numberOfValues:()=>0,name:M(`Is valid date`),getPreview:()=>M(`Date is valid`)}),G.add(`isEqual`,{type:`isEqual`,isValueValid:(e,t)=>e===t.values[0],getErrorString:(e,t)=>M(`The value must be equal to %s`,Ob(e,t.getLocale())[0]),isCriterionValueValid:e=>jb(e),criterionValueErrorString:sb.CriterionError.numberValue,numberOfValues:()=>1,name:M(`Is equal to`),getPreview:(e,t)=>M(`Value is equal to %s`,Ob(e,t.getLocale())[0])}),G.add(`isNotEqual`,{type:`isNotEqual`,isValueValid:(e,t)=>e!==t.values[0],getErrorString:(e,t)=>M(`The value must not be equal to %s`,Ob(e,t.getLocale())[0]),isCriterionValueValid:e=>jb(e),criterionValueErrorString:sb.CriterionError.numberValue,numberOfValues:()=>1,name:M(`Is not equal to`),getPreview:(e,t)=>M(`Value is not equal to %s`,Ob(e,t.getLocale())[0])}),G.add(`isGreaterThan`,{type:`isGreaterThan`,isValueValid:(e,t)=>{if(typeof e!=`number`)return!1;let n=t.values[0];return typeof n==`number`?e>n:!1},getErrorString:(e,t)=>M(`The value must be greater than %s`,Ob(e,t.getLocale())[0]),isCriterionValueValid:e=>jb(e),criterionValueErrorString:sb.CriterionError.numberValue,numberOfValues:()=>1,name:M(`Is greater than`),getPreview:(e,t)=>M(`Value is greater than %s`,Ob(e,t.getLocale())[0])}),G.add(`isGreaterOrEqualTo`,{type:`isGreaterOrEqualTo`,isValueValid:(e,t)=>{if(typeof e!=`number`)return!1;let n=t.values[0];return typeof n==`number`?e>=n:!1},getErrorString:(e,t)=>M(`The value must be greater or equal to %s`,Ob(e,t.getLocale())[0]),isCriterionValueValid:e=>jb(e),criterionValueErrorString:sb.CriterionError.numberValue,numberOfValues:()=>1,name:M(`Is greater or equal to`),getPreview:(e,t)=>M(`Value is greater or equal to %s`,Ob(e,t.getLocale())[0])}),G.add(`isLessThan`,{type:`isLessThan`,isValueValid:(e,t)=>{if(typeof e!=`number`)return!1;let n=t.values[0];return typeof n==`number`?e<n:!1},getErrorString:(e,t)=>M(`The value must be less than %s`,Ob(e,t.getLocale())[0]),isCriterionValueValid:e=>jb(e),criterionValueErrorString:sb.CriterionError.numberValue,numberOfValues:()=>1,name:M(`Is less than`),getPreview:(e,t)=>M(`Value is less than %s`,Ob(e,t.getLocale())[0])}),G.add(`isLessOrEqualTo`,{type:`isLessOrEqualTo`,isValueValid:(e,t)=>{if(typeof e!=`number`)return!1;let n=t.values[0];return typeof n==`number`?e<=n:!1},getErrorString:(e,t)=>M(`The value must be less or equal to %s`,Ob(e,t.getLocale())[0]),isCriterionValueValid:e=>jb(e),criterionValueErrorString:sb.CriterionError.numberValue,numberOfValues:()=>1,name:M(`Is less or equal to`),getPreview:(e,t)=>M(`Value is less or equal to %s`,Ob(e,t.getLocale())[0])}),G.add(`isBetween`,{type:`isBetween`,isValueValid:(e,t)=>typeof e!=`number`||typeof t.values[0]!=`number`||typeof t.values[1]!=`number`?!1:mn(e,t.values[0],t.values[1]),getErrorString:(e,t)=>{let n=Ob(e,t.getLocale());return M(`The value must be between %s and %s`,n[0],n[1])},isCriterionValueValid:e=>jb(e),criterionValueErrorString:sb.CriterionError.numberValue,numberOfValues:()=>2,name:M(`Is between`),getPreview:(e,t)=>{let n=Ob(e,t.getLocale());return M(`Value is between %s and %s`,n[0],n[1])}}),G.add(`isNotBetween`,{type:`isNotBetween`,isValueValid:(e,t)=>typeof e!=`number`||typeof t.values[0]!=`number`||typeof t.values[1]!=`number`?!1:!mn(e,t.values[0],t.values[1]),getErrorString:(e,t)=>{let n=Ob(e,t.getLocale());return M(`The value must not be between %s and %s`,n[0],n[1])},isCriterionValueValid:e=>jb(e),criterionValueErrorString:sb.CriterionError.numberValue,numberOfValues:()=>2,name:M(`Is not between`),getPreview:(e,t)=>{let n=Ob(e,t.getLocale());return M(`Value is not between %s and %s`,n[0],n[1])}}),G.add(`isBoolean`,{type:`isBoolean`,isValueValid:(e,t)=>e===``||typeof e==`boolean`,getErrorString:()=>M(`The value must be a boolean`),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>0,name:M(`Checkbox`),getPreview:()=>M(`Checkbox`)}),G.add(`isValueInList`,{type:`isValueInList`,isValueValid:(e,t)=>e===null?!1:t.values.map(e=>String(e).toLowerCase()).includes(e.toString().toLowerCase()),getErrorString:e=>M(`The value must be one of: %s`,e.values.join(`, `)),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>void 0,allowedValues:`onlyLiterals`,name:M(`Value in list`),getPreview:e=>M(`Value one of: %s`,e.values.join(`, `))}),G.add(`isValueInRange`,{type:`isValueInRange`,preComputeCriterion:(e,t,n)=>{if(t.length===0)return new Set;let r=t[0].sheetId,i=n.getDataValidationRangeValues(r,e);return new Set(i.map(e=>e.value.toString().toLowerCase()))},isValueValid:(e,t,n)=>e?n.has(e.toString().toLowerCase()):!1,getErrorString:e=>M(`The value must be a value in the range %s`,String(e.values[0])),isCriterionValueValid:e=>xl.test(e),criterionValueErrorString:sb.CriterionError.validRange,numberOfValues:()=>1,allowedValues:`onlyLiterals`,name:M(`Value in range`),getPreview:e=>M(`Value in range %s`,e.values[0])}),G.add(`customFormula`,{type:`customFormula`,isValueValid:(e,t)=>{let n=t.values[0];return typeof n==`number`||typeof n==`boolean`?!!n:!1},getErrorString:()=>M(`The value does not match the custom formula data validation rule`),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>1,allowedValues:`onlyFormulas`,name:M(`Custom formula`),getPreview:e=>M(`Custom formula %s`,e.values[0])}),G.add(`beginsWithText`,{type:`beginsWithText`,isValueValid:(e,t)=>String(e).toLowerCase().startsWith(String(t.values[0]).toLowerCase()),getErrorString:e=>M(`The value must be a text that begins with "%s"`,String(e.values[0])),isCriterionValueValid:e=>!!e,criterionValueErrorString:sb.CriterionError.notEmptyValue,numberOfValues:()=>1,name:M(`Text begins with`),getPreview:e=>M(`Text begins with "%s"`,e.values[0])}),G.add(`endsWithText`,{type:`endsWithText`,isValueValid:(e,t)=>String(e).toLowerCase().endsWith(String(t.values[0]).toLowerCase()),getErrorString:e=>M(`The value must be a text that ends with "%s"`,String(e.values[0])),isCriterionValueValid:e=>!!e,criterionValueErrorString:sb.CriterionError.notEmptyValue,numberOfValues:()=>1,name:M(`Text ends with`),getPreview:e=>M(`Text ends with "%s"`,e.values[0])}),G.add(`isEmpty`,{type:`isEmpty`,isValueValid:(e,t)=>(e??``).toString().trim()===``,getErrorString:()=>M(`The value must be empty`),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>0,name:M(`Is empty`),getPreview:()=>M(`Is empty`)}),G.add(`isNotEmpty`,{type:`isNotEmpty`,isValueValid:(e,t)=>(e??``).toString().trim()!==``,getErrorString:()=>M(`The value must not be empty`),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>0,name:M(`Is not empty`),getPreview:()=>M(`Is not empty`)}),G.add(`top10`,{type:`top10`,preComputeCriterion:(e,t,n)=>{let r=Yo(e.values[0],z);if(r===void 0||r<=0)return;let i=[];for(let e of t)for(let{value:t}of n.getVisibleRangeValues(e))typeof t==`number`&&i.push(t);let a=i.sort((e,t)=>e-t);e.isPercent&&(r=x(r,1,100));let o=0;return o=e.isBottom&&!e.isPercent?r-1:e.isBottom&&e.isPercent?Math.floor(a.length*r/100)-1:!e.isBottom&&e.isPercent?a.length-Math.floor(a.length*r/100):a.length-r,o=x(o,0,a.length-1),a[o]},isValueValid:(e,t,n)=>typeof e!=`number`||n===void 0?!1:t.isBottom?e<=n:e>=n,getErrorString:e=>{let t={value:String(e.values[0]),percentSymbol:e.isPercent?`%`:``};return e.isBottom?M(`The value must be in bottom %(value)s%(percentSymbol)s`,t):M(`The value must be in top %(value)s%(percentSymbol)s`,t)},isCriterionValueValid:e=>Mb(e),criterionValueErrorString:sb.CriterionError.positiveNumber,numberOfValues:()=>1,name:M(`Is in Top/Bottom ranking`),getPreview:e=>{let t={value:e.values[0],percentSymbol:e.isPercent?`%`:``};return e.isBottom?M(`Value is in bottom %(value)s%(percentSymbol)s`,t):M(`Value is in top %(value)s%(percentSymbol)s`,t)}}),G.add(`uniqueValues`,{type:`uniqueValues`,preComputeCriterion:(e,t,n)=>{let r=Nb(t,n);return new Set(Object.keys(r).filter(e=>r[e]===1))},isValueValid:(e,t,n)=>e===null||n===void 0?!1:n.has(String(e).toLowerCase()),getErrorString:()=>M(`The value must be unique`),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>0,name:M(`Is value unique`),getPreview:()=>M(`Value is unique`)}),G.add(`duplicateValues`,{type:`duplicateValues`,preComputeCriterion:(e,t,n)=>{let r=Nb(t,n);return new Set(Object.keys(r).filter(e=>r[e]!==1))},isValueValid:(e,t,n)=>e===null||n===void 0?!1:n.has(String(e).toLowerCase()),getErrorString:()=>M(`The value must not be unique`),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>0,name:M(`Is value duplicate`),getPreview:()=>M(`Value is duplicate`)});function Ob(e,t){return e.values.map(e=>e===void 0?N.InvalidReference:_b(String(e),t))}function kb(e,t){return fb(e,z).map(e=>e===void 0?N.InvalidReference:B(e,{locale:t,format:t.dateFormat}))}function Ab(e){return Ba(e,z)!==void 0}function jb(e){return Yo(e,z)!==void 0}function Mb(e){let t=Yo(e,z);return t!==void 0&&t>0}function Nb(e,t){let n={};for(let r of e)for(let e of t.getVisibleRangeValues(r)){let t=I(e).toLowerCase();t&&(n[t]=(n[t]||0)+1)}return n}function Pb(e,t,n,r,i){if(r.filterType===`values`){let e=r.hiddenValues?.map(Lp);if(!e)return!1;if(new Set(e).has(Lp(n.formattedValue)))return!0}else{if(r.type===`none`)return!1;let a=G.get(r.type),o=r.values.map(n=>n.startsWith(`=`)?e.evaluateFormula(t,n)??``:uf(n,z));if(o.some(Nv))return!1;let s={type:r.type,values:o.map(jv),dateValue:r.dateValue};if(!a.isValueValid(n.value,s,i))return!0}return!1}var Fb=class{columns;rows;rowFields;measures;fieldsType;maxIndent;pivotCells={};rowTree;colTree;isSorted=!1;constructor(e,t,n,r,i={COL:[],ROW:[]}){this.measures=n,this.fieldsType=r,i.COL.length&&(e=this.removeCollapsedColumns(e,n,i.COL)),this.columns=e.map(e=>{let t=0;return e.map(e=>(e={...e,offset:t},t+=e.width,e))}),this.rows=t.filter(e=>!this.isParentCollapsed(i.ROW,e));let a=Math.max(...t.map(e=>e.fields.length)),o=t.find(e=>e.fields.length===a);this.rowFields=o?[...o.fields]:[],this.maxIndent=Math.max(...this.rows.map(e=>e.indent)),this.rowTree=Yt(()=>this.buildRowsTree()),this.colTree=Yt(()=>this.buildColumnsTree())}removeCollapsedColumns(e,t,n){let r=(n,r)=>{let i=this.getDomain(n),a=e[r],o=a.findIndex(e=>_v(this.getDomain(e),i)),s=a.findLastIndex(e=>_v(this.getDomain(e),i)),c=r===e.length-1,l=t.map(e=>({fields:c?[...n.fields,`measure`]:[],values:c?[...n.values,e]:[],width:1,offset:0,collapsedHeader:!c}));a.splice(o,s-o+1,...l)};return e.map((i,a)=>{for(let o of i){if(a>=e.length-2)return i;let s=this.getDomain(o);if(n.some(e=>w(s,e))){o.width=t.length;for(let t=a+1;t<e.length;t++)r(o,t)}}return i})}isParentCollapsed(e,t){let n=this.getDomain(t);return e.some(e=>_v(n,e))}getNumberOfDataColumns(){return this.columns.at(-1)?.length||0}getSkippedRows(e){let t=new Set,n=this.getColHeadersHeight();if(!e.displayColumnHeaders)for(let e=0;e<n-1;e++)t.add(e);if(e.displayMeasuresRow||t.add(n-1),e.tabularForm)for(let e=0;e<this.rows.length;e++){let r=this.rows[e].indent;r!==0&&r!==this.maxIndent&&t.add(e+n)}return t}getPivotCells(e=yy){let t=JSON.stringify(e);if(!this.pivotCells[t]){let{displayTotals:n}=e,r=this.rows.length,i=this.getNumberOfDataColumns(),a=r+this.getColHeadersHeight(),o=i+this.getRowHeadersWidth(e);!n&&r!==1&&--a,!n&&i!==this.measures.length&&(o-=this.measures.length);let s=[],c=this.getSkippedRows(e);for(let t=0;t<o;t++){s.push([]);for(let n=0;n<a;n++){if(c.has(n))continue;let r=this.getPivotCell(t,n,e);s[t].push(r)}}this.pivotCells[t]=s}return this.pivotCells[t]}getRowTree(){return this.rowTree()}getColTree(){return this.colTree()}isTotalRow(e){return this.rows[e].indent!==this.maxIndent}getPivotCell(e,t,n){let r=this.getColHeadersHeight(),i=this.getRowHeadersWidth(n),a=n.tabularForm,o=t<r-1&&e>=i,s=t===r-1&&e>=i,c=t>r-1&&e<i,l=t>r-1&&e>=i,u=a&&t===r-1&&e<i;if(a&&c){let n=t-r,i=this.getDomain(this.rows[n]).slice(0,e+1);return i.length===0&&e!==0?Ib:{type:`HEADER`,domain:i,dimension:`ROW`}}else if(a&&u)return{type:`ROW_GROUP_NAME`,rowField:this.rowFields[e]};else if(s){let n=e-i,r=this.getColHeaderDomain(n,t);if(!r)return Ib;let a=r.at(-1)?.value?.toString()||``;return{type:`MEASURE_HEADER`,domain:r.slice(0,-1),measure:a}}else if(o){let n=e-i,r=this.getColHeaderDomain(n,t);return r?{type:`HEADER`,domain:r,dimension:`COL`}:Ib}else if(c){let e=t-r;return{type:`HEADER`,domain:this.getDomain(this.rows[e]),dimension:`ROW`}}else if(l){let a=t-r,o=e-i;return!n.displayTotals&&this.isTotalRow(a)?Ib:{type:`VALUE`,domain:[...this.getDomain(this.rows[a]),...this.getColDomain(o)],measure:this.getColMeasure(o)}}return Ib}getColHeaderDomain(e,t){let n=this.columns[t].find(t=>t.offset===e);if(!(!n||n.collapsedHeader))return this.getDomain(n)}getDomain(e){return e.fields.map((t,n)=>{if(t===`measure`)return{type:`char`,field:t,value:Ny({displayName:`measure`,type:`char`},e.values[n])};{let{fieldName:r,granularity:i}=Oy(t),a=this.fieldsType[r]||`char`;return{type:a,field:t,value:Ny({displayName:r,type:a,granularity:i},e.values[n])}}})}getColDomain(e){let t=this.getColHeaderDomain(e,this.getColHeadersHeight()-1);return t?t.slice(0,-1):[]}getColMeasure(e){let t=this.getColHeaderDomain(e,this.getColHeadersHeight()-1)?.at(-1)?.value;if(t==null)throw Error(`Measure is missing`);return t.toString()}getRowHeadersWidth(e){return e.tabularForm?this.rowFields.length:1}getColHeadersHeight(){return this.columns.length}buildRowsTree(){let e=[],t=0,n={};n[0]=e;for(let r of this.rows){if(r.fields.length===0||r.values.length===0)return e;let i=r.fields.length-1,a=r.fields[i],{fieldName:o,granularity:s}=Oy(a),c=Ny({displayName:o,type:this.fieldsType[o]??`char`,granularity:s},r.values[i]);if(i>t){t=i,n[t]=[];let e=n[t-1].at(-1);e&&(e.children=n[t])}t=i;let l={value:c,field:r.fields[i],children:[],type:this.fieldsType[o]||`char`,width:0};n[t].push(l)}return e}buildColumnsTree(){let e=[],t=this.columns.at(-2)||[],n={};n[0]=e;for(let e of t)for(let t=0;t<e.fields.length;t++){let r=e.fields[t],{fieldName:i,granularity:a}=Oy(r),o=Ny({displayName:i,type:this.fieldsType[i]??`char`,granularity:a},e.values[t]),s={value:o,field:e.fields[t],children:[],width:e.width,type:this.fieldsType[i]||`char`};n[t]?.at(-1)?.value!==o&&(n[t+1]=[],s.children=n[t+1],n[t].push(s))}return e}export(){return{cols:this.columns,rows:this.rows,measures:this.measures,fieldsType:this.fieldsType}}sort(e,t,n){if(this.isSorted)return;let r=(e,t)=>{let r=n(e,t).value;return typeof r==`number`?r:-1/0},i=t.domain,a=gv(this.rowTree(),[],(n,a)=>{let o=r(e,[...n,...i]),s=r(e,[...a,...i]);return t.order===`asc`?o-s:s-o});this.rowTree=Yt(a),this.rows=[...this.rowTreeToRows(a),this.rows[this.rows.length-1]],this.isSorted=!0}rowTreeToRows(e,t){return e.flatMap(e=>{let n={indent:t?t.indent+1:1,fields:[...t?.fields||[],e.field],values:[...t?.values||[],e.value]};return[n,...this.rowTreeToRows(e.children,n)]})}get numberOfCells(){return this.rows.length*this.getNumberOfDataColumns()}getColumnDomainsAtDepth(e){return e<0||e>=this.getColHeadersHeight()-1?[]:this.columns[e].map(e=>this.getDomain(e)).filter(e=>e.length)}getRowDomainsAtDepth(e){return e<0||e>this.maxIndent?[]:this.rows.filter(t=>t.indent===e+1).map(e=>this.getDomain(e))}getPivotTableDimensions(e){let t=this.getPivotCells(e),n=0;return e.displayColumnHeaders&&(n=this.getColHeadersHeight()-1),e.displayMeasuresRow&&n++,{numberOfCols:Math.min(this.getRowHeadersWidth(e)+e.numberOfColumns,t.length),numberOfRows:Math.min(n+e.numberOfRows,t[0].length),numberOfHeaderRows:n}}getNumberOfRowGroupBys(){return Math.max(...this.rows.map(e=>e.fields.length))}};let Ib={type:`EMPTY`};function Lb(e,t,n){let r=t.measures.filter(e=>!e.isHidden).map(e=>e.id),i=zb(e,t.columns,0);Bb(i,r.length);let a=Vb(i,t),o=Rb(e,0,t.rows,[],[]);o.push({fields:[],values:[],indent:0});let s={};for(let e of t.columns)s[e.fieldName]=e.type;for(let e of t.rows)s[e.fieldName]=e.type;return new Fb(a,o,r,s,n===`collapsed`?t.collapsedDomains:void 0)}function Rb(e,t,n,r,i){if(t>=n.length)return[];let a=n[t],o=a.nameWithGranularity,s=Hb(e,a),c=Wb(s,a),l=[],u=r.concat(o);for(let e of c){let r=i.concat(e);l.push({fields:u,values:r,indent:t+1});let a=s[e];a&&l.push(...Rb(a,t+1,n,u,r))}return l}function zb(e,t,n){if(n>=t.length)return[];let r=t[n],i=t[n].nameWithGranularity,a=Hb(e,r);return Wb(a,t[n]).map(e=>({value:a[e]?.[0]?.[r.nameWithGranularity]?.value??null,field:i,children:zb(a[e]||[],t,n+1),type:r.type,width:0}))}function Bb(e,t){for(let n in e){let r=e[n];r.children.length===0?r.width=t:(Bb(r.children,t),r.width=r.children.reduce((e,t)=>e+t.width,0))}}function Vb(e,t){let n=t.columns.map(e=>e.nameWithGranularity),r=n.length,i=t.measures.filter(e=>!e.isHidden),a=i.length,o=Array(r).fill(0).map(()=>[]);function s(e,t,i){let a=o[t];for(let o of e){let e=i.concat([o.value]),c={fields:n.slice(0,t+1),values:e,width:o.width,offset:0};a.push(c),t<=r-1&&s(o.children,t+1,e)}}s(e,0,[]);let c=n.length>0,l=[];return c&&o[o.length-1].forEach(e=>{i.forEach(t=>{let n={fields:[...e.fields,`measure`],values:[...e.values,t.id],width:1,offset:0};l.push(n)})}),i.forEach(e=>{let t={fields:[`measure`],values:[e.id],width:1,offset:0};l.push(t)}),o.push(l),o.length===1&&o.unshift([]),o[o.length-2].push({fields:[],values:[],width:a,offset:0}),o}function Hb(e,t){return Object.groupBy(e,Ub(t))}function Ub(e){let t=e.nameWithGranularity;return e=>`${e[t]?.value??null}`}function Wb(e,t){let n=t.order,r=t.customGroups?.find(e=>e.isOtherGroup);return!n&&!r?Object.keys(e):Object.keys(e).sort((e,i)=>r&&e===r.name?1:r&&i===r.name?-1:n?Gb(t,e,i):0)}function Gb(e,t,n){return t===`null`?e.order===`asc`?1:-1:n===`null`?e.order===`asc`?-1:1:e.type===`integer`||e.type===`datetime`?e.order===`asc`?F(t,z)-F(n,z):F(n,z)-F(t,z):e.order===`asc`?t.localeCompare(n):n.localeCompare(t)}let Kb=Symbol(`NULL`);function qb(e,t,n){let r=e.granularity||`month`;if(!(r in Jb))throw Error(`Unknown date granularity: ${r}`);let i=typeof t==`number`||typeof t==`string`?t:Kb;if(!Jb[r].set.has(t)){Jb[r].set.add(t);let a=null;if(typeof t==`number`||typeof t==`string`){let e=rs(t,n);switch(r){case`year`:a=e.getFullYear();break;case`quarter_number`:a=Math.floor(e.getMonth()/3)+1;break;case`month_number`:a=e.getMonth()+1;break;case`month`:a=Math.floor(F(t,n));break;case`iso_week_number`:a=e.getIsoWeek();break;case`day_of_month`:a=e.getDate();break;case`day`:a=Math.floor(F(t,n));break;case`day_of_week`:a=(e.getDay()+7-n.weekStart)%7+1;break;case`hour_number`:a=e.getHours();break;case`minute_number`:a=e.getMinutes();break;case`second_number`:a=e.getSeconds();break}}Jb[r].values[i]=Ny(e,a)}return Jb[r].values[i]}let Jb={year:{set:new Set,values:{}},quarter_number:{set:new Set,values:{}},month_number:{set:new Set,values:{}},month:{set:new Set,values:{}},iso_week_number:{set:new Set,values:{}},day_of_month:{set:new Set,values:{}},day:{set:new Set,values:{}},day_of_week:{set:new Set,values:{}},hour_number:{set:new Set,values:{}},minute_number:{set:new Set,values:{}},second_number:{set:new Set,values:{}}};function Yb(){for(let e in Jb)Jb[e].set.clear(),Jb[e].values={}}var Xb=class{type=`SPREADSHEET`;getters;_definition;coreDefinition;metaData={fields:{},fieldKeys:[]};unfilteredDataEntries=[];filteredDataEntries=[];collapsedTable;expandedTable;invalidRangeError;needsReevaluation=!0;constructor(e,t){this.getters=t.getters,this.coreDefinition=t.definition}init(e={}){(!this._definition||e.reload)&&(this.reload(4),this.needsReevaluation=!1)}reload(e){e===4&&(this.metaData=this.loadMetaData()),e>=3&&(this._definition=this.loadRuntimeDefinition()),e>=2&&(this.unfilteredDataEntries=this.loadDataEntries(),this.filteredDataEntries=this.loadFilteredDataEntries(this.unfilteredDataEntries)),e>=1&&(this.collapsedTable=void 0,this.expandedTable=void 0)}onDefinitionChange(e){let t=this.coreDefinition;if(this.coreDefinition=e,this._definition){let n=Math.max(this.computeShouldReload(t,e),0);this.reload(n)}}computeShouldReload(e,t){return w(e.dataSet,t.dataSet)?3:4}get isInvalidRange(){return!!this.invalidRangeError}get invalidRangeMessage(){return this.invalidRangeError?.message}get definition(){if(this._definition||this.init(),!this._definition)throw Error(`Pivot definition should be defined at this point.`);return this._definition}isValid(){if(this.invalidRangeError||!this.definition)return!1;for(let e of this.definition.measures)if(!e.isValid)return!1;for(let e of this.definition.columns)if(!e.isValid)return!1;for(let e of this.definition.rows)if(!e.isValid)return!1;for(let e of this.definition.filters??[])if(!e.isValid)return!1;return!0}assertIsValid({throwOnError:e}){if(!this.isValid()){if(e)throw this.invalidRangeError?this.invalidRangeError:new P(M(`At least one measure/dimension and/or filter is not correct.`));return{value:N.GenericError,message:this.invalidRangeError?.message??M(`At least one measure/dimension and/or filter is not correct.`)}}}areDomainArgsFieldsValid(e){let t=e.filter((e,t)=>t%2==0).map(I);return t.length&&t.at(-1)===`measure`&&(t=t.slice(0,-1)),jy(t,this.definition)}parseArgsToPivotDomain(e){let t=[];for(let n=0;n<e.length-1;n+=2){let r=I(e[n]),i=this.getTypeOfDimension(r),a=r===`measure`?I(e[n+1]):Ny(this.getDimension(r),e[n+1]);t.push({field:r,value:a,type:i})}return t}markAsDirtyForEvaluation(){this.needsReevaluation=!0}getMeasure(e){return this.definition.getMeasure(e)}getPivotMeasureValue(e){return{value:this.getMeasure(e).displayName}}getPivotHeaderValueAndFormat(e){let t=e.at(-1);if(!t)return{value:M(`Total`)};let n=this.getDimension(t.field),r=this.filterDataEntriesFromDomain(this.filteredDataEntries,e)[0]?.[n.nameWithGranularity];return n.type===`datetime`?oy(n.granularity||`month`).toValueAndFormat(t.value,this.getters.getLocale()):r?r.value===null?{value:M(`(Undefined)`)}:r:{value:``}}getPivotCellValueAndFormat(e,t){let n=this.filterDataEntriesFromDomain(this.filteredDataEntries,t);if(n.length===0)return{value:``};let r=this.getMeasure(e),i=n.map(e=>e[r.fieldName]).filter(C),a=i.filter(e=>e.type!==`empty`),o=r.aggregator,s=wy[o];if(!s)throw Error(`Aggregator ${o} does not exist`);try{let e=s([i],this.getters.getLocale());return a.length===0?{...e,value:``}:e}catch(e){return cl(e,o.toUpperCase())}}getDataEntries(){return this.unfilteredDataEntries}getPossibleFieldValues(e){let t=[],n=Hb(this.filteredDataEntries,e),r=Wb(n,e);for(let i of r)t.push({value:n[i]?.[0]?.[e.nameWithGranularity]?.value??``,label:n[i]?.[0]?.[e.nameWithGranularity]?.formattedValue||``});return t}getCollapsedTableStructure(){if(!this.isValid())throw Error(`Pivot is not valid !`);return this.coreDefinition.style?.tabularForm?this.getExpandedTableStructure():(this.collapsedTable||=Lb(this.filteredDataEntries,this.definition,`collapsed`),this.collapsedTable)}getExpandedTableStructure(){if(!this.isValid())throw Error(`Pivot is not valid !`);return this.expandedTable||=Lb(this.filteredDataEntries,this.definition,`expanded`),this.expandedTable}getFields(){return this.metaData.fields}get fields(){return this.getFields()}loadMetaData(){if(this.invalidRangeError=void 0,this.coreDefinition.dataSet){let{zone:e,sheetId:t}=this.coreDefinition.dataSet,n=this.getters.getRangeFromZone(t,e);try{let e=this.extractFieldsFromRange(n),t=Wy(this.coreDefinition,e.fields);return{...e,fields:{...e.fields,...t}}}catch(e){return this.invalidRangeError=e,{fields:{},fieldKeys:[]}}}else return this.invalidRangeError=new P(M(`The pivot cannot be created because the dataset is missing.`)),{fields:{},fieldKeys:[]}}loadRuntimeDefinition(){return new $y(this.coreDefinition,this.fields,this.getters)}loadDataEntries(){let e=this._definition?.range;return this.isValid()&&e?this.extractDataEntriesFromRange(e):[]}loadFilteredDataEntries(e){let t=this._definition?.range?.sheetId;return t?(this._definition&&this._definition.filters&&(e=e.filter(e=>{let n=!0;for(let r of this._definition?.filters??[]){let i=e[r.fieldName];if(i&&Pb(this.getters,t,i,r)){n=!1;break}}return n})),e):[]}getTypeOfDimension(e){if(e===`measure`)return`char`;let{fieldName:t}=Oy(e),n=this.fields[t]?.type;if(!n)throw Error(`Field ${t} does not exist`);return n}filterDataEntriesFromDomain(e,t){return t.reduce((e,t)=>this.filterDataEntriesFromDomainNode(e,t),e)}filterDataEntriesFromDomainNode(e,t){let{field:n,value:r,type:i}=t,{nameWithGranularity:a}=this.getDimension(n);return e.filter(e=>{let t=e[a]?.value;return i===`char`?String(t)===String(r):t===r})}getDimension(e){return this.definition.getDimension(e)}getTypeFromZone(e,t){let n=this.getters.getEvaluatedCellsInZone(e,t).filter(e=>!(e.type===`empty`||e.value===``));return n.length===0?`integer`:n.every(e=>e.type===`number`&&e.format&&Sc(e.format))?`datetime`:n.every(e=>e.type===`boolean`)?`boolean`:n.every(e=>e.type===`number`)?`integer`:`char`}assertCellIsValidField(e,t,n){if(n.type===`error`)throw new P(M(`The pivot cannot be created because cell %s contains an error`,T(e,t)));if(n.type===`empty`||n.value===``)throw new P(M(`The pivot cannot be created because cell %s is empty`,T(e,t)));if(n.value===`__count`)throw new P(M(`The pivot cannot be created because cell %s contains a reserved value`,T(e,t)))}extractFieldsFromRange(e){let t={},n=[],r=e.sheetId,i=e.zone.top;for(let a=e.zone.left;a<=e.zone.right;a++){let o=this.getters.getEvaluatedCell({sheetId:r,col:a,row:i});this.assertCellIsValidField(a,i,o);let s=o.value?.toString();if(s){let i=this.getTypeFromZone(r,{top:e.zone.top+1,left:a,bottom:e.zone.bottom,right:a}),o=Uy(s,t);t[o]={name:o,type:i,string:o,aggregator:i===`integer`?`sum`:`count`},n.push(o)}}return{fields:t,fieldKeys:n}}extractDataEntriesFromRange(e){let t=[];for(let n=e.zone.top+1;n<=e.zone.bottom;n++){let r={top:n,bottom:n,left:e.zone.left,right:e.zone.right},i=this.getters.getEvaluatedCellsInZone(e.sheetId,r),a={},o=!0;for(let e in i){let t=i[e],n=this.fields[this.metaData.fieldKeys[e]];if(!n)throw Error(`Field ${this.metaData.fieldKeys[e]} does not exist`);t.value===``?a[n.name]={value:null,type:`empty`,formattedValue:``}:(a[n.name]=t,t.type!==`empty`&&(o=!1))}for(let e in this.definition.customFields||{}){let t=this.definition.customFields?.[e];if(!t)continue;let n=a[t.parentField],r=this.fields[t.parentField];if(!n||!r){a[e]={value:null,type:`empty`,formattedValue:``};continue}let i=t.groups.find(e=>e.values.some(e=>e===n?.value))||t.groups.find(e=>e.isOtherGroup);a[e]={...n,value:i?i.name:n.value}}o||(a.__count={value:1,type:`number`,formattedValue:`1`},t.push(a))}let n=this.definition.columns.concat(this.definition.rows).filter(e=>e.type===`datetime`);if(n.length){let e=this.getters.getLocale();for(let r of t)for(let t of n){let n=qb(t,r[t.fieldName]?.value||null,this.getters.getLocale()),{format:i,value:a}=oy(t.granularity||`month`).toValueAndFormat(n,e);r[t.nameWithGranularity]={value:n,type:r[t.fieldName]?.type||`empty`,format:r[t.fieldName]?.format,formattedValue:B(a,{locale:e,format:i})}}}return t}};let Zb=new D,Qb=[`year`,`quarter_number`,`month_number`,`month`,`iso_week_number`,`day_of_month`,`day`,`day_of_week`],$b=[...Qb,`hour_number`,`minute_number`,`second_number`];Zb.add(`SPREADSHEET`,{ui:Xb,definition:$y,dateGranularities:[...Qb],isMeasureCandidate:e=>e.type!==`boolean`,datetimeGranularities:[...$b],isGroupable:()=>!0,canHaveCustomGroup:e=>e.type===`char`&&!e.isCustomField,isPivotUnused:()=>!0,adaptRanges:(e,t,n)=>{if(t.type!==`SPREADSHEET`||!t.dataSet)return t;let{sheetId:r,zone:i}=t.dataSet,a=e.getRangeFromZone(r,i),o=ex(a,n);if(o===a)return t;let s=o&&{sheetId:o.sheetId,zone:o.zone};return{...t,dataSet:s}}});function ex(e,t){if(!e)return;let n=t(e);switch(n.changeType){case`REMOVE`:return;default:return n.range}}let tx={name:M(`See pivot properties`),execute(e){let t=e.model.getters.getActivePosition(),n=e.model.getters.getPivotIdFromPosition(t);e.openSidePanel(`PivotSidePanel`,{pivotId:n})},isVisible:e=>{let t=e.model.getters.getActivePosition(),n=e.model.getters.getPivotIdFromPosition(t);return!e.isSmall&&n&&e.model.getters.isExistingPivot(n)||!1},isReadonlyAllowed:!0,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.PIVOT`},nx={name:M(`Ascending`),execute:e=>mx(e,e.model.getters.getActivePosition(),`asc`),isActive:e=>e.model.getters.getPivotCellSortDirection(e.model.getters.getActivePosition())===`asc`},rx={name:M(`Descending`),execute:e=>mx(e,e.model.getters.getActivePosition(),`desc`),isActive:e=>e.model.getters.getPivotCellSortDirection(e.model.getters.getActivePosition())===`desc`},ix={name:M(`No sorting`),execute:e=>mx(e,e.model.getters.getActivePosition(),`none`),isActive:e=>e.model.getters.getPivotCellSortDirection(e.model.getters.getActivePosition())===`none`},ax={name:M(`Convert to individual formulas`),execute(e){let t=e.model.getters.getActivePosition(),n=e.model.getters.getCorrespondingFormulaCell(t),r=e.model.getters.getPivotIdFromPosition(t);if(!n||!r)return;let{sheetId:i,col:a,row:o}=e.model.getters.getCellPosition(n.id),s=e.model.getters.getPivot(r);s.init(),s.isValid()&&e.model.dispatch(`SPLIT_PIVOT_FORMULA`,{sheetId:i,col:a,row:o,pivotId:r})},isVisible:e=>{let t=e.model.getters.getActivePosition(),n=e.model.getters.getPivotIdFromPosition(t);if(!n)return!1;let r=e.model.getters.getPivot(n),i=e.model.getters.getEvaluatedCell(t);return r.isValid()&&e.model.getters.isSpillPivotFormula(t)&&i.type!==`error`},icon:`o-spreadsheet-Icon.PIVOT`},ox={name:M(`Group pivot dimensions`),execute:e=>{let t=hx(e);if(!t)return;let{pivotId:n,values:r,field:i}=t,a=e.model.getters.getPivot(n),o=b(e.model.getters.getPivotCoreDefinition(n));if(!i.isCustomField)gx(o,r,i,a.getFields());else{let e=(o.customFields||{})[i.name];if(!e)return;_x(e,r)}e.model.dispatch(`UPDATE_PIVOT`,{pivotId:n,pivot:o})},isVisible:e=>{let t=hx(e);if(!t)return!1;let{pivotId:n,values:r,field:i}=t,a=e.model.getters.getPivot(n);return r.length>1&&(i.isCustomField||Zb.get(a.type).canHaveCustomGroup(i))}},sx={name:M(`Group all remaining dimensions`),execute:e=>{let t=hx(e);if(!t)return;let{pivotId:n,field:r}=t,i=e.model.getters.getPivot(n),a=b(e.model.getters.getPivotCoreDefinition(n)),o=r.isCustomField?(a.customFields||{})[r.name]:qy(a,r,i.getFields());o&&(o.groups.push({name:Hy(M(`Others`),o),values:[],isOtherGroup:!0}),Ky(a,r.name,o.name),e.model.dispatch(`UPDATE_PIVOT`,{pivotId:n,pivot:a}))},isVisible:e=>{let t=hx(e);if(!t)return!1;let{pivotId:n,field:r,values:i}=t;return bx(e,n,i,r)}},cx={name:M(`Ungroup pivot dimensions`),execute:e=>{let t=hx(e);if(!t)return;let{pivotId:n,values:r,field:i}=t,a=e.model.getters.getPivot(n),o=b(e.model.getters.getPivotCoreDefinition(n));vx(o,r,i,a.getFields()),e.model.dispatch(`UPDATE_PIVOT`,{pivotId:n,pivot:o})},isVisible:e=>{let t=hx(e);if(!t)return!1;let{pivotId:n,values:r,field:i}=t,a=e.model.getters.getPivot(n),o=e.model.getters.getPivotCoreDefinition(n);if(!i.isCustomField){let e=qy(o,i,a.getFields());if(![...o.rows,...o.columns].some(t=>t.fieldName===e.name))return!1}return yx(o,r,i,a.getFields())}},lx={name:e=>{let t=e.model.getters.getActivePosition(),n=fx(e.model.getters,t);return n.isPivotGroup?n.isCollapsed?M(`Expand`):M(`Collapse`):``},execute(e){Jy(e.model.getters.getActivePosition(),e)},isVisible:e=>{let t=e.model.getters.getActivePosition(),n=fx(e.model.getters,t),r=e.model.getters.getPivotStyleAtPosition(t);return n.isPivotGroup&&!r?.pivotStyle.tabularForm}},ux={name:M(`Collapse all`),execute(e){let t=e.model.getters.getActivePosition(),n=fx(e.model.getters,t);if(!n.isPivotGroup)return;let{pivotCell:r,pivotId:i,siblingDomains:a}=n,o=b(e.model.getters.getPivotCoreDefinition(i));o.collapsedDomains=o.collapsedDomains||{COL:[],ROW:[]};let s=[...o.collapsedDomains[r.dimension]||[],...a],c=s.filter((e,t)=>t===s.findIndex(t=>w(t,e)));o.collapsedDomains[r.dimension]=c,e.model.dispatch(`UPDATE_PIVOT`,{pivotId:i,pivot:o})},isVisible:e=>{let t=e.model.getters.getActivePosition(),n=fx(e.model.getters,t),r=e.model.getters.getPivotStyleAtPosition(t);if(!n.isPivotGroup||r?.pivotStyle.tabularForm)return!1;let{pivotCell:i,pivotId:a,siblingDomains:o}=n,s=e.model.getters.getPivotCoreDefinition(a);return!o.every(e=>(s.collapsedDomains?.[i.dimension]||[]).some(t=>w(t,e)))}},dx={name:M(`Expand all`),execute(e){let t=e.model.getters.getActivePosition(),n=fx(e.model.getters,t);if(!n.isPivotGroup)return;let{pivotCell:r,pivotId:i,siblingDomains:a}=n,o=b(e.model.getters.getPivotCoreDefinition(i));o.collapsedDomains=o.collapsedDomains||{COL:[],ROW:[]};let s=(o.collapsedDomains[r.dimension]||[]).filter(e=>!a.find(t=>w(t,e)));o.collapsedDomains[r.dimension]=s,e.model.dispatch(`UPDATE_PIVOT`,{pivotId:i,pivot:o})},isVisible:e=>{let t=e.model.getters.getActivePosition(),n=fx(e.model.getters,t),r=e.model.getters.getPivotStyleAtPosition(t);if(!n.isPivotGroup||r?.pivotStyle.tabularForm)return!1;let{pivotCell:i,pivotId:a,siblingDomains:o}=n;return(e.model.getters.getPivotCoreDefinition(a).collapsedDomains?.[i.dimension]||[]).some(e=>o.some(t=>w(t,e)))}};function fx(e,t){if(!e.isSpillPivotFormula(t))return{isPivotGroup:!1};let n=e.getPivotCellFromPosition(t),r=e.getPivotIdFromPosition(t);if(n.type!==`HEADER`||!r||!n.domain.length)return{isPivotGroup:!1};let i=e.getPivotCoreDefinition(r),a=e.isDashboard(),o=n.dimension===`COL`?i.columns:i.rows;if(!(!a&&n.domain.length!==o.length))return{isPivotGroup:!1};let s=(i.collapsedDomains?.[n.dimension]??[]).some(e=>w(e,n.domain)),c=e.getPivot(r).getExpandedTableStructure(),l=n.domain.length-1;return{isPivotGroup:!0,isCollapsed:s,pivotCell:n,pivotId:r,siblingDomains:n.dimension===`ROW`?c.getRowDomainsAtDepth(l):c.getColumnDomainsAtDepth(l)}}function px(e,t){let n=e.getPivotIdFromPosition(t);if(!n||!e.isExistingPivot(n)||!e.isSpillPivotFormula(t)||!e.getPivot(n).isValid())return!1;let r=e.getPivotCellFromPosition(t);return r.type===`VALUE`||r.type===`MEASURE_HEADER`}function mx(e,t,n){let r=e.model.getters.getPivotIdFromPosition(t),i=e.model.getters.getPivotCellFromPosition(t);if(i.type===`EMPTY`||i.type===`HEADER`||i.type===`ROW_GROUP_NAME`||!r)return;if(n===`none`){e.model.dispatch(`UPDATE_PIVOT`,{pivotId:r,pivot:{...e.model.getters.getPivotCoreDefinition(r),sortedColumn:void 0}});return}let a=tv(e.model.getters.getPivot(r),i.domain).colDomain;e.model.dispatch(`UPDATE_PIVOT`,{pivotId:r,pivot:{...e.model.getters.getPivotCoreDefinition(r),sortedColumn:{domain:a,order:n,measure:i.measure}}})}function hx(e){let t,n,r=[];for(let i of e.model.getters.getSelectedZones()){let a=e.model.getters.getActiveSheetId();for(let o of vr(a,i)){let i=e.model.getters.getPivotIdFromPosition(o);if(!t)t=i;else if(i&&t!==i)return;if(!t)continue;let a=e.model.getters.getPivotCellFromPosition(o);if(a.type!==`HEADER`||!e.model.getters.isSpillPivotFormula(o))continue;let s=a.domain.at(-1)?.field;if(!n&&s)n=s;else if(n&&s&&n!==s)return;r.push(a)}}if(!t||!n||r.length===0)return;let i=e.model.getters.getPivot(t).getFields()[n];if(!i)return;let a=r.map(e=>e.domain.at(-1)?.value).filter(e=>e!==void 0);return{pivotId:t,values:a,field:i}}function gx(e,t,n,r){let i=qy(e,n,r);Gy(t,i);let a={name:Hy(M(`Group`),i),values:t};i.groups.push(a),e.customFields||={},e.customFields[i.name]=i,Ky(e,n.name,i.name)}function _x(e,t){let n=new Set,r=[];for(let i of t){let t=e.groups.find(e=>e.name===i);t?(r.push(t),t.values.forEach(e=>n.add(e))):n.add(i)}if(r.some(e=>e.isOtherGroup))e.groups=e.groups.filter(e=>e.isOtherGroup||!r.includes(e));else if(r.length===0){let n={name:Hy(M(`Group`),e),values:t};e.groups.push(n)}else{let t=r.slice(1);e.groups=e.groups.filter(e=>!t.includes(e)),r[0].values=Array.from(n)}}function vx(e,t,n,r){let i;if(!n.isCustomField)i=qy(e,n,r),i.groups.some(e=>e.isOtherGroup)&&t.some(e=>!i?.groups.some(t=>t.values.includes(e)))&&(i.groups=i.groups.filter(e=>!e.isOtherGroup)),Gy(t,i);else{if(i=(e.customFields||{})[n.name],!i)return;i.groups=i.groups.filter(e=>!t.includes(e.name))}i.groups.every(e=>e.values.length===0&&!e.isOtherGroup)&&(xx(e,i.name),delete e.customFields?.[i.name])}function yx(e,t,n,r){if(n.isCustomField){let r=(e.customFields||{})[n.name];return r?r.groups.some(e=>t.includes(e.name)):!1}else return qy(e,n,r).groups.some(e=>e.isOtherGroup||t.some(t=>e.values.includes(t)))}function bx(e,t,n,r){let i=e.model.getters.getPivot(t),a=e.model.getters.getPivotCoreDefinition(t),o=r.isCustomField?(a.customFields||{})[r.name]:Object.values(a.customFields||{}).find(e=>e.parentField===r.name),s=i.definition.getDimension(r.name);if(!s||!o||yx(a,n,r,i.getFields()))return!1;let c=new Set(i.getPossibleFieldValues(s).map(e=>e.value)),l=r.isCustomField?o.groups.map(e=>e.name):o.groups.flatMap(e=>e.values);for(let e of[...n,...l])c.delete(e);return c.size===0}function xx(e,t){let n=e.customFields?.[t];if(!n)return;let r=[...e.rows,...e.columns].some(e=>e.fieldName===n.parentField);for(let i of[e.rows,e.columns]){let e=i.findIndex(e=>e.fieldName===t);e!==-1&&(r?i.splice(e,1):i.splice(e,1,{fieldName:n.parentField}))}}let Sx=new D;Sx.add(`link`,{condition:(e,t)=>!!t.getEvaluatedCell(e).link,execute:(e,t,n)=>nf(t.model.getters.getEvaluatedCell(e).link,t,n),title:(e,t)=>{let n=t.getEvaluatedCell(e).link;return n?n.isExternal?M(`Go to url: %(url)s`,{url:n.url}):M(`Go to %(label)s`,{label:n.label}):``},sequence:5}),Sx.add(`dashboard_pivot_sorting`,{condition:(e,t)=>{if(!t.isDashboard())return!1;let n=t.getPivotCellFromPosition(e);return px(t,e)&&n.type===`MEASURE_HEADER`},execute:(e,t)=>{mx(t,e,wx(t.model.getters,e))},component:X_,componentProps:(e,t)=>({position:e,sortDirection:t.getPivotCellSortDirection(e)}),sequence:2});let Cx={none:`asc`,asc:`desc`,desc:`none`};function wx(e,t){return Cx[e.getPivotCellSortDirection(t)??`none`]}var Tx=class extends Yr{viewStore=this.get(H);_clickableCells=(0,t.markRaw)({});_registryItems=(0,t.markRaw)(Sx.getAll().sort((e,t)=>e.sequence-t.sequence));handle(e){(Id.has(e.type)||e.type===`EVALUATE_CELLS`||e.type===`UPDATE_CELL`&&(`content`in e||`format`in e))&&(this._clickableCells=(0,t.markRaw)({}),this._registryItems=(0,t.markRaw)(Sx.getAll().sort((e,t)=>e.sequence-t.sequence)))}getClickableItem(e){let{sheetId:t,col:n,row:r}=e,i=this._clickableCells,a=T(n,r);if(i[t]||(i[t]={}),!(a in i[t])){let n=this.findClickableItem(e);i[t][a]=n}return i[t][a]}findClickableItem(e){let t=this.getters;for(let n of this._registryItems)if(n.condition(e,t))return n}get clickableCells(){let e=[],t=this.getters;for(let n of this.viewStore.visibleCellPositions){let r=this.getClickableItem(n);if(!r)continue;let i=typeof r.title==`function`?r.title(n,t):r.title,a=this.getClickableCellRect(n);a&&e.push({coordinates:a,position:n,action:r.execute,title:i||``,component:r.component,componentProps:r.componentProps?.(n,t)??{}})}return e}getClickableCellRect(e){let t=this.getters.expandZone(e.sheetId,E(e)),n=this.viewStore.viewports.getVisibleRect(e.sheetId,t),r=this.getters.getCellIcons(e),i={center:r.find(e=>e.horizontalAlign===`center`),left:r.find(e=>e.horizontalAlign===`left`),right:r.find(e=>e.horizontalAlign===`right`)};if(!i.center?.onClick){if(i.right?.onClick){let r=this.viewStore.viewports.getRect(e.sheetId,t),a=this.getters.getCellIconRect(i.right,r);n.width-=a.width+i.right.margin}if(i.left?.onClick){let r=this.viewStore.viewports.getRect(e.sheetId,t),a=this.getters.getCellIconRect(i.left,r);n.x+=a.width+i.left.margin,n.width-=a.width+i.left.margin}return n}}},Ex=class extends O{static template=`o-spreadsheet-ClickableCellsOverlay`;static components={};clickableCellsStore;setup(){this.clickableCellsStore=k(Tx)}getCellClickableStyle(e){return U({top:`${e.y}px`,left:`${e.x}px`,width:`${e.width}px`,height:`${e.height}px`})}getClickableCells(){return(0,t.toRaw)(this.clickableCellsStore.clickableCells)}selectClickableCell(e,t){if(![0,1].includes(e.button))return;let{position:n,action:r}=t;r(n,this.env,de(e))}},Dx=class extends Yr{mutators=[`clear`,`hover`];col;row;handle(e){switch(e.type){case`ACTIVATE_SHEET`:this.clear()}}hover(e){if(e.col===this.col&&e.row===this.row)return`noStateChange`;this.col=e.col,this.row=e.row}clear(){if(this.col===void 0&&this.row===void 0)return`noStateChange`;this.col=void 0,this.row=void 0}},Ox=class extends O{static template=`o-spreadsheet-ValidationMessages`;props=(0,t.useProps)({messages:j.array(j.string()).optional(),msgType:j.or([j.literal(`warning`),j.literal(`error`),j.literal(`info`)]),slots:j.object().optional()});get divClasses(){return this.props.msgType===`warning`?`o-validation-warning`:this.props.msgType===`info`?`o-validation-info`:`o-validation-error`}},kx=class extends O{static template=`o-spreadsheet-GridAddRowsFooter`;static components={ValidationMessages:Ox};DOMFocusableElementStore;viewStore;inputRef=t.signal.ref(HTMLInputElement);state=(0,t.proxy)({inputValue:`100`,errorFlag:!1});setup(){this.DOMFocusableElementStore=k(M_),this.viewStore=k(H),Wi(window,`click`,this.onExternalClick,{capture:!0})}get addRowsPosition(){let{scrollY:e}=this.viewStore.activeSheetScrollInfo,{y:t,height:n}=this.viewStore.mainViewportRect;return U({top:`${t+n-e-46}px`,height:`46px`})}get errorMessages(){return[M(`Please enter a number between 0 and 10000.`)]}onKeydown(e){e.key.toUpperCase()===`ESCAPE`?this.focusDefaultElement():e.key.toUpperCase()===`ENTER`&&this.onConfirm()}onInput(e){let t=e.target.value;this.state.inputValue=t;let n=Number(t);this.state.errorFlag=Number.isNaN(n)||n<=0||n>1e4}onConfirm(){if(this.state.errorFlag)return;let e=Number(this.state.inputValue),t=this.viewStore.displayedSheetId,n=this.env.model.getters.getNumberRows(t);this.env.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:t,sheetName:this.env.model.getters.getSheetName(t),position:`after`,base:n-1,quantity:e,dimension:`ROW`}),this.focusDefaultElement();let{scrollX:r}=this.viewStore.activeSheetScrollInfo,{end:i}=this.env.model.getters.getRowDimensions(t,n+e-1);this.viewStore.setViewportOffset({offsetX:r,offsetY:i})}onExternalClick(e){let t=this.inputRef();t!==document.activeElement||e.target===t||this.focusDefaultElement()}focusDefaultElement(){document.activeElement===this.inputRef()&&this.DOMFocusableElementStore.focus()}};let Ax=function(e){return e.PlainText=`text/plain`,e.Html=`text/html`,e.Image=`image`,e}({}),jx=[`image/avif`,`image/bmp`,`image/gif`,`image/vnd.microsoft.icon`,`image/jpeg`,`image/png`,`image/tiff`,`image/webp`];function Mx(e,t){let n=new Set(t.map(e=>e.left)),r=new Set(t.map(e=>e.right)),i=new Set(t.map(e=>e.top)),a=new Set(t.map(e=>e.bottom)),o=i.size===1&&a.size===1||n.size===1&&r.size===1?Sr(t):[t[t.length-1]],s=o.map(e=>_r(e)).flat();return{sheetId:e,zones:t,clippedZones:o,columnsIndexes:[...new Set(s.map(e=>e.col))].sort((e,t)=>e-t),rowsIndexes:[...new Set(s.map(e=>e.row))].sort((e,t)=>e-t)}}function Nx(e,t,n){let r=Math.max(e.right-t+1,e.left),i=Math.max(e.bottom-n+1,e.top),a=[];for(let o=e.left;o<=r;o+=t)for(let r=e.top;r<=i;r+=n)a.push({left:o,top:r,bottom:r+n-1,right:o+t-1});return a}function Px(e,t){if(!t.length||!t[0].length)return e;let n=t[0].length,r=t.length;return e.map(e=>Nx(e,n,r)).flat()}function Fx(e){let t;e[`text/html`]&&(t=Lx(new DOMParser().parseFromString(e[`text/html`],`text/html`)));let n=e[`text/plain`]||``,r;if(!n.trim()){for(let t of jx)if(e[t]){r=e[t];break}}return{text:n,data:t,imageBlob:r}}function Ix(e){return e?.match(/<div data-osheet-clipboard-id=(['"])([^'"]+)\1/)?.[2]}function Lx(e){if([...e.documentElement.attributes].some(e=>e.value.includes(`microsoft`)))return;let t=e.querySelector(`div`)?.getAttribute(`data-osheet-clipboard`);return t&&JSON.parse(t)}let Rx=(e,t,n,r)=>{e.forEach(({handlerName:e,handler:i})=>{let a=t[e];a&&i.paste(n,a,r)})};function zx(e,t,n,r,i){let a,o=[],s={sheetId:e,zones:t};for(let{handlerName:c,handler:l}of r){let r=n[c];if(!r)continue;let u=l.getPasteTarget(e,t,r,i);u.figureIds&&(s.figureIds={...s.figureIds,...u.figureIds});for(let e of u.zones){if(o.push(e),a===void 0){a=e;continue}a=or(a,e)}}return{target:s,zone:a,selectedZones:o}}let Bx=(e,t,n)=>{let r={col:t[0].left,row:t[0].top};e.getBackToDefault(),e.selectZone({cell:r,zone:or(...n)},{scrollIntoView:!1})},Vx={figureHandlers:new D,cellHandlers:new D};function Hx(e,t,n){let{x:r,y:i,width:a,height:o}=n;if(a<0||o<0)return;let s=t.color||`#017E84`,{ctx:c}=e;c.save(),t.noBorder||(t.dashed&&c.setLineDash([5,3]),c.strokeStyle=s,t.thinLine?(c.lineWidth=1,c.strokeRect(r,i,a,o)):(c.lineWidth=2,c.strokeRect(r+.5,i+.5,a,o))),t.noFill||(c.fillStyle=qf(jf(s),t.fillAlpha??.12),c.fillRect(r,i,a,o)),c.restore()}var Ux=class extends Yr{mutators=[`register`,`unRegister`];providers=[];constructor(e){super(e),this.onDispose(()=>{this.providers=[]})}get renderingLayers(){return[`Highlights`]}get highlights(){let e=this.getters.getActiveSheetId();return this.providers.flatMap(e=>e.highlights).filter(t=>t.range.sheetId===e).map(e=>{let{numberOfRows:t,numberOfCols:n}=mr(e.range.zone),r=t*n===1?this.getters.expandZone(e.range.sheetId,e.range.zone):e.range.unboundedZone;return{...e,range:this.model.getters.getRangeFromZone(e.range.sheetId,r)}})}register(e){this.providers.push(e)}unRegister(e){this.providers=this.providers.filter(t=>t!==e)}drawLayer(e,t){if(t===`Highlights`)for(let t of this.highlights)Hx(e,t,e.viewports.getVisibleRect(e.sheetId,t.range.zone))}};let Wx=[`cell`,`border`,`table`,`conditionalFormat`,`merge`];var Gx=class extends Yr{mutators=[`activate`,`cancel`,`pasteFormat`];highlightStore=this.get(Ux);status=`inactive`;copiedData;constructor(e){super(e),this.highlightStore.register(this),this.onDispose(()=>{this.highlightStore.unRegister(this)})}handle(e){switch(e.type){case`PAINT_FORMAT`:this.paintFormat(e.sheetId,e.target);break}}activate(e){this.copiedData=this.copyFormats(),this.status=e.persistent?`persistent`:`oneOff`}cancel(){this.status=`inactive`,this.copiedData=void 0}pasteFormat(e){this.model.dispatch(`PAINT_FORMAT`,{target:e,sheetId:this.getters.getActiveSheetId()})}get isActive(){return this.status!==`inactive`}get clipboardHandlers(){return Wx.map(e=>({handlerName:e,handler:new(Vx.cellHandlers.get(e))(this.getters,this.model.dispatch)}))}copyFormats(){let e=this.getters.getActiveSheetId(),t=this.getters.getSelectedZones(),n={zones:t,sheetId:e};for(let{handlerName:r,handler:i}of this.clipboardHandlers){let a=i.copy(Mx(e,t),!1);a!==void 0&&(n[r]=a)}return n}paintFormat(e,t){if(!this.copiedData)return;let n={isCutOperation:!1,pasteOption:`onlyFormat`},{target:r,selectedZones:i}=zx(e,t,this.copiedData,this.clipboardHandlers,n);Rx(this.clipboardHandlers,this.copiedData,r,n),Bx(this.model.selection,t,i),this.status===`oneOff`&&this.cancel()}get highlights(){let e=this.copiedData;return e?e.zones.map(t=>({range:this.model.getters.getRangeFromZone(e.sheetId,t),color:je,dashed:!0,sheetId:e.sheetId,noFill:!0,thinLine:!0,interactive:!1})):[]}};let Kx=new D;var qx=class extends Yr{mutators=[`open`,`close`];persistentPopover;hoveredCell=this.get(Dx);viewStore=this.get(H);handle(e){switch(e.type){case`ACTIVATE_SHEET`:this.close()}}open({col:e,row:t},n){let r=this.viewStore.displayedSheetId;Kx.contains(n)&&(this.persistentPopover={col:e,row:t,sheetId:r,type:n})}close(){if(!this.persistentPopover)return`noStateChange`;this.persistentPopover=void 0}get persistentCellPopover(){return this.persistentPopover&&{isOpen:!0,...this.persistentPopover}||{isOpen:!1}}get isOpen(){return this.persistentPopover!==void 0}get cellPopover(){let e=this.viewStore.displayedSheetId;if(this.persistentPopover&&this.persistentPopover.sheetId===e&&this.viewStore.viewports.isVisibleInViewport(this.persistentPopover)){let e=this.getters.getMainCellPosition(this.persistentPopover),t=Kx.get(this.persistentPopover.type).onOpen?.(e,this.getters);return t?.isOpen?{...t,anchorRect:this.computePopoverAnchorRect(this.persistentPopover)}:{isOpen:!1}}let{col:t,row:n}=this.hoveredCell;if(t===void 0||n===void 0||!this.viewStore.viewports.isVisibleInViewport({sheetId:e,col:t,row:n}))return{isOpen:!1};let r=this.getters.getMainCellPosition({sheetId:e,col:t,row:n}),i=Kx.getAll().map(e=>e.onHover?.(r,this.getters)).find(e=>e?.isOpen);return i?.isOpen?{...i,anchorRect:this.computePopoverAnchorRect(r)}:{isOpen:!1}}computePopoverAnchorRect({col:e,row:t}){let n=this.viewStore.displayedSheetId,r=this.getters.getMerge({sheetId:n,col:e,row:t});return r?this.viewStore.viewports.getVisibleRect(n,r):this.viewStore.viewports.getVisibleRect(n,E({col:e,row:t}))}},Jx=class extends Yr{mutators=[`setHoveredIcon`];hoveredIcon=void 0;setHoveredIcon(e){this.hoveredIcon=e}};function Yx(e,n){let r=k(Dx),i=k(Y_),a=k(H),o={col:void 0,row:void 0},{Date:s}=window,c,l,u=0;function d(){let e=a.displayedSheetId;return c===void 0||l===void 0?{sheetId:e,col:-1,row:-1}:{sheetId:e,col:a.viewports.getColIndex(e,c),row:a.viewports.getRowIndex(e,l)}}function f(e){let t=y(n());return{x:e.clientX-t.x,y:e.clientY-t.y}}let{pause:p,resume:m}=N_(h,200);function h(){let{col:e,row:t}=d(),n=s.now()-u;if(n>300&&(e!==o.col||t!==o.row)&&ne(void 0,void 0),n>300){if(e<0||t<0)return;ne(e,t)}}function g(e){_(n(),e.ev)&&({x:c,y:l}=f(e),u=s.now(),i.hover(d()))}function v(){let{col:e,row:t}=d();(e!==o.col||t!==o.row)&&ne(void 0,void 0)}function ee(t){let r=Sg(e,t),{x:i,y:a}=f(r),o=y(n());return a<0||a>o.height||i<0||i>o.width?g(r):p()}(0,t.useListener)(n,`pointermove`,t=>!e.isMobile()&&g(Sg(e,t))),(0,t.useListener)(n,`mouseleave`,ee),(0,t.useListener)(n,`mouseenter`,m),(0,t.useListener)(n,`pointerdown`,v),(0,t.useListener)(n,`pointerdown`,t=>e.isMobile()&&g(Sg(e,t))),Wi(window,`click`,te);function te(e){let t=e.target,r=n();r&&!r.contains(t)&&ne(void 0,void 0)}function ne(e,t){(e!==o.col||t!==o.row)&&(o.col=e,o.row=t,r.hover({col:e,row:t}))}return o}var Xx=class extends O{static template=`o-spreadsheet-GridOverlay`;static components={GridAddRowsFooter:kx};props=(0,t.useProps)({onCellDoubleClicked:j.function().optional(()=>()=>{}),onCellClicked:j.function().optional(()=>()=>{}),onCellRightClicked:j.function().optional(()=>()=>{}),onGridResized:j.function().optional(()=>()=>{}),gridOverlayDimensions:j.string(),hasFooter:j.boolean().optional(()=>!0)});gridOverlayRef=(0,t.signal)(null);cellPopovers;paintFormatStore;hoveredIconStore;viewStore;setup(){Yx(this.env,this.gridOverlayRef);let e=new ResizeObserver(()=>{this.props.onGridResized()});(0,t.onMounted)(()=>{e.observe(this.gridOverlayEl)}),(0,t.onWillUnmount)(()=>{e.disconnect()}),this.cellPopovers=k(qx),this.paintFormatStore=k(Gx),this.hoveredIconStore=k(Jx),this.viewStore=k(H)}get gridOverlayEl(){let e=this.gridOverlayRef();if(!e)throw Error(`GridOverlay el is not defined.`);return e}get style(){return this.props.gridOverlayDimensions+U({cursor:this.hoveredIconStore.hoveredIcon?`pointer`:`default`})}get isPaintingFormat(){return this.paintFormatStore.isActive}onPointerMove(e){if(this.env.isMobile())return;let t=this.getInteractiveIconAtEvent(Sg(this.env,e)),n=t?.type?{id:t.type,position:t.position}:void 0;w(n,this.hoveredIconStore.hoveredIcon)||this.hoveredIconStore.setHoveredIcon(n)}onPointerDown(e){e.button>0||this.env.isMobile()||this.onCellClicked(Sg(this.env,e))}onClick(e){e.button>0||!this.env.isMobile()||this.onCellClicked(Sg(this.env,e))}onCellClicked(e){let t=this.cellPopovers.persistentCellPopover,[n,r]=this.getCartesianCoordinates(e),i=this.getInteractiveIconAtEvent(e);if(i&&this.env.model.selection.getBackToDefault(),this.props.onCellClicked(n,r,{expandZone:e.ev.shiftKey,addZone:ue(e.ev)},e),i?.onClick&&i.onClick(i.position,this.env),e.ev.target===this.gridOverlayRef()&&this.cellPopovers.isOpen&&w(t,this.cellPopovers.persistentCellPopover)){this.cellPopovers.close();return}}onDoubleClick(e){let t=Sg(this.env,e);if(this.getInteractiveIconAtEvent(t))return;let[n,r]=this.getCartesianCoordinates(t);this.props.onCellDoubleClicked(n,r,e)}onContextMenu(e){let[t,n]=this.getCartesianCoordinates(Sg(this.env,e));this.props.onCellRightClicked(t,n,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){let t=this.viewStore.displayedSheetId;return[this.viewStore.viewports.getColIndex(t,e.offsetX),this.viewStore.viewports.getRowIndex(t,e.offsetY)]}getInteractiveIconAtEvent(e){let t=y(this.gridOverlayRef()),n=this.viewStore.viewports.getGridOffset(),r=e.clientX-t.x+n.x,i=e.clientY-t.y+n.y,[a,o]=this.getCartesianCoordinates(e),s=this.viewStore.displayedSheetId,c={col:a,row:o,sheetId:s},l=this.env.model.getters.getMerge(c);l&&(c={col:l.left,row:l.top,sheetId:s});let u=this.env.model.getters.getCellIcons(c).find(e=>{let t=this.env.model.getters.getMerge(c)||E(c),n=this.viewStore.viewports.getRect(s,t);return B_(r,i,this.env.model.getters.getCellIconRect(e,n))});return u?.onClick?u:void 0}},Zx=class extends O{static template=`o-spreadsheet-GridPopover`;static components={Popover:U_};props=(0,t.useProps)({onClosePopover:j.function(),onMouseWheel:j.function(),gridRect:j.Rect()});cellPopovers;viewStore;setup(){this.cellPopovers=k(qx),this.viewStore=k(H)}get cellPopover(){let e=this.cellPopovers.cellPopover;if(!e.isOpen)return{isOpen:!1};let t=this.viewStore.zoomLevel,n=wg(t,e.anchorRect);return{...e,anchorRect:{...n,x:n.x+this.props.gridRect.x,y:n.y+this.props.gridRect.y}}}};function Qx(e,t){let n=()=>{window.removeEventListener(`pointerup`,r,{capture:!0}),window.removeEventListener(`dragstart`,i),window.removeEventListener(`pointermove`,e),window.removeEventListener(`wheel`,e)},r=e=>{t(e),n()};function i(e){e.preventDefault()}return window.addEventListener(`pointerup`,r,{capture:!0}),window.addEventListener(`dragstart`,i),window.addEventListener(`pointermove`,e),window.addEventListener(`wheel`,e,{passive:!1}),n}let $x={name:`ARROW_DOWN`,width:448,height:512,paths:[{fillColor:`#E06666`,path:`M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z`}]},eS={name:`ARROW_UP`,width:448,height:512,paths:[{fillColor:`#6AA84F`,path:`M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z`}]},tS={name:`ARROW_RIGHT`,width:448,height:512,paths:[{fillColor:`#F0AD4E`,path:`M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z`}]},nS={name:`SMILE`,width:496,height:512,paths:[{fillColor:`#6AA84F`,path:`M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm4 72.6c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.7-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.1-8.4-25.3-7.1-33.8 3.1z`}]},rS={name:`MEH`,width:496,height:512,paths:[{fillColor:`#F0AD4E`,path:`M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm8 144H160c-13.2 0-24 10.8-24 24s10.8 24 24 24h176c13.2 0 24-10.8 24-24s-10.8-24-24-24z`}]},iS={name:`FROWN`,width:496,height:512,paths:[{fillColor:`#E06666`,path:`M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-80 128c-40.2 0-78 17.7-103.8 48.6-8.5 10.2-7.1 25.3 3.1 33.8 10.2 8.4 25.3 7.1 33.8-3.1 16.6-19.9 41-31.4 66.9-31.4s50.3 11.4 66.9 31.4c8.1 9.7 23.1 11.9 33.8 3.1 10.2-8.5 11.5-23.6 3.1-33.8C326 321.7 288.2 304 248 304z`}]},aS=`M256 9 a247 247 0 1 0.1 0 0`,oS={name:`GREEN_DOT`,width:512,height:512,paths:[{fillColor:`#6AA84F`,path:aS}]},sS={name:`YELLOW_DOT`,width:512,height:512,paths:[{fillColor:`#F0AD4E`,path:aS}]},cS={name:`RED_DOT`,width:512,height:512,paths:[{fillColor:`#E06666`,path:aS}]},lS=`M40 160 h320 l-160 160`;function uS(e){return{name:`CARET_DOWN`,width:512,height:512,paths:[{fillColor:e.textColor||`#374151C2`,path:lS}]}}function dS(e){return{name:`CARET_UP`,width:512,height:512,paths:[{fillColor:e.textColor||`#374151C2`,path:`M40 320 h320 l-160 -160`}]}}function fS(e){return{name:`CARET_DOWN`,width:512,height:512,paths:[{fillColor:e.textColor||`#374151C2`,path:`M200 32a200 200 0 1 1 0 400 200 200 0 1 1 0-400`},{fillColor:e.fillColor||`#fff`,path:lS}]}}let pS=e=>({name:`CHECKBOX_UNCHECKED`,width:512,height:512,paths:[{fillColor:e?ze:`#91959d`,path:`M45,45 h422 v422 h-422 v-422 m30,30 v362 h362 v-362`}]}),mS=e=>({name:`CHECKBOX_UNCHECKED`,width:512,height:512,paths:[{fillColor:e?`#82d1d5`:Ve,path:`M45,45 h422 v422 h-422 v-422 m30,30 v362 h362 v-362`}]}),hS=e=>({name:`CHECKBOX_CHECKED`,width:512,height:512,paths:[{fillColor:e?`#82d1d5`:Ve,path:`M45,45 h422 v422 h-422 v-422`},{fillColor:e?`#505050`:`#FFF`,path:`M165,240 l45,45 l135,-135 h60 l-195,195 l-105,-105`}]});function gS(e,t){return{name:`PIVOT_ICON`,width:512,height:512,paths:[{path:`M21,21 h469 v469 h-469`,fillColor:t?Le:`#777`},{path:`M64,64 v384 h384 v-384`,fillColor:t?`#E7E9ED`:`#eee`},{path:e?`M149,235 h213 v43 h-213 M235,149 h43 v213 h-43`:`M149,235 h213 v43 h-213`,fillColor:t?Le:`#777`}]}}function _S(e,t,n){let r=e?`M18.6 3.5H4.29c-.7 0-1.06.85-.56 1.35l6.1 6.1v6.8c0 .26.13.5.34.65l2.64 1.85a.79.79 0 0 0 1.25-.65v-8.64l6.1-6.1a.79.79 0 0 0-.56-1.35`:`M 339.667 681 L 510.333 681 L 510.333 595.667 L 339.667 595.667 L 339.667 681 Z M 41 169 L 41 254.333 L 809 254.333 L 809 169 L 41 169 Z M 169 467.667 L 681 467.667 L 681 382.333 L 169 382.333 L 169 467.667 Z`,i=e?`M0,0 h24 v24 h-24`:`M0,0 h850 v850 h-850`,a={iconColor:Pe,hoverBackgroundColor:Pe};return n&&!t?a.iconColor=`#fff`:!n&&t?a.iconColor=`#defade`:n&&t&&(a.iconColor=Pe,a.hoverBackgroundColor=`#fff`),{name:`DATA_FILTER_ICON`,width:e?24:850,height:e?24:850,paths:[n?{path:i,fillColor:a.hoverBackgroundColor}:void 0,{path:r,fillColor:a.iconColor}].filter(C)}}let vS={arrowGood:{template:`ARROW_UP`,svg:eS},arrowNeutral:{template:`ARROW_RIGHT`,svg:tS},arrowBad:{template:`ARROW_DOWN`,svg:$x},smileyGood:{template:`SMILE`,svg:nS},smileyNeutral:{template:`MEH`,svg:rS},smileyBad:{template:`FROWN`,svg:iS},dotGood:{template:`GREEN_DOT`,svg:oS},dotNeutral:{template:`YELLOW_DOT`,svg:sS},dotBad:{template:`RED_DOT`,svg:cS}},yS={arrows:{good:`arrowGood`,neutral:`arrowNeutral`,bad:`arrowBad`},smiley:{good:`smileyGood`,neutral:`smileyNeutral`,bad:`smileyBad`},dots:{good:`dotGood`,neutral:`dotNeutral`,bad:`dotBad`}},bS={};function xS(e){if(bS[e])return bS[e];let t=new Path2D(e);return bS[e]=t,t}var SS=class{static getters=[];history;constructor(e){this.history=Object.assign(Object.create(e),{update:e.addChange.bind(e,this),selectCell:()=>{}})}exportForExcel(e){}allowDispatch(e){return`Success`}beforeHandle(e){}handle(e){}finalize(){}batchValidations(...e){return t=>e.map(e=>e.call(this,t)).flat()}chainValidations(...e){return t=>{for(let n of e){let e=n.call(this,t);Array.isArray(e)||(e=[e]);let r=e.filter(e=>e!==`Success`);if(r.length)return r}return`Success`}}checkValidations(e,...t){return this.batchValidations(...t)(e)}},CS=class extends SS{getters;constructor({getters:e,stateObserver:t}){super(t),this.getters=e}},wS=class extends CS{static getters=[`getCellFingerprint`];getCellFingerprint(e){let t=this.getters.getCellPosition(e.id);return e.isFormula?this.computeFormulaFingerprint(t,e):this.getLiteralFingerprint(t)}computeFormulaFingerprint(e,t){let n=t.compiledFormula.rangeDependencies,r=e.col,i=e.row,a=this.getters.getSheetIds().indexOf(e.sheetId),o={dx:0,dy:0,dSheet:0};for(let e of n){let t=e.zone,[n,s]=e.parts;o.dSheet=this.getters.getSheetIds().indexOf(e.sheetId)-a;let c=ju(e)&&!e.unboundedZone.hasHeader,l=Au(e)&&!e.unboundedZone.hasHeader,u=c||n?.colFixed?0:r,d=l||n?.rowFixed?0:i,f=!s&&n?.colFixed||s?.colFixed,p=!s&&n?.rowFixed||s?.rowFixed,m=e.unboundedZone.right===void 0,h=e.unboundedZone.bottom===void 0,g=m||f?0:r,_=h||p?0:i,v=yr({top:t.top-d,left:t.left-u,right:t.right-g,bottom:t.bottom-_});for(let e=v.top;e<=v.bottom;e++)for(let t=v.left;t<=v.right;t++)o.dx+=t,o.dy+=e}let s=t.compiledFormula.normalizedFormula;return TS(o)+s}getLiteralFingerprint(e){switch(this.getters.getEvaluatedCell(e).type){case`number`:case`boolean`:return ES;case`text`:case`empty`:case`error`:return}}};function TS(e){return Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>t).join(`,`)}let ES=`DATA_FINGERPRINT`;var DS=class extends Yr{mutators=[`enable`,`disable`];isInvalidated=!1;fingerprintColors={[ES]:`#D9D9D9`};isEnabled=!1;colors=new J_;handle(e){switch(Gd(e)&&this.isEnabled&&(this.isInvalidated=!0),e.type){case`UNDO`:case`REDO`:case`ACTIVATE_SHEET`:this.isEnabled&&(this.isInvalidated=!0);break}}finalize(){this.isInvalidated&&(this.isInvalidated=!1,this.computeFingerprints())}enable(){this.isEnabled=!0,this.computeFingerprints()}disable(){this.isEnabled=!1,this.colors=new J_}computeFingerprints(){this.colors=new J_;let e=new J_,t=new Set,n=this.getters.getActiveSheetId(),r=this.getters.getCells(n);for(let n in r){let i=r[n],a=this.getters.getCellFingerprint(i);if(!a)continue;t.add(a);let o=this.getters.getCellPosition(i.id);e.set(o,a)}this.assignColors(t);for(let[t,n]of e.entries()){let e=this.fingerprintColors[n];this.colors.set(t,e),this.colorSpreadZone(t,e)}}colorSpreadZone(e,t){let n=this.getters.getSpreadZone(e);if(!n)return;let r=e.sheetId;for(let e=n.top;e<=n.bottom;e++)for(let i=n.left;i<=n.right;i++){let n={sheetId:r,col:i,row:e};this.colors.set(n,t)}}assignColors(e){let t=new pp(e.size);Object.keys(this.fingerprintColors).forEach(()=>t.next());for(let n of e)this.fingerprintColors[n]||(this.fingerprintColors[n]=qf(t.next(),.8))}},OS=class extends Ur{renderer;fingerprints;hoveredTables;hoveredIcon;lastRenderSheetId=void 0;lastRenderBoxes=new Map;preventNewAnimationsInNextFrame=!1;zonesWithPreventedAnimationsInNextFrame={};animations=new Map;getters;constructor(e,t=e(Jr)){super(e),this.renderer=t;let n=e(Wr);this.getters=n.getters,this.fingerprints=e(DS),this.hoveredTables=e(Y_),this.hoveredIcon=e(Jx),n.on(`command-dispatched`,this,this.handle),n.on(`command-finalized`,this,this.finalize),this.renderer.register(this),this.onDispose(()=>{n.off(`command-dispatched`,this),n.off(`command-finalized`,this),this.renderer.unRegister(this)})}handle(e){switch(e.type){case`START`:case`ACTIVATE_SHEET`:case`ADD_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:this.animations.clear(),this.preventNewAnimationsInNextFrame=!0;break;case`RESIZE_COLUMNS_ROWS`:this.preventNewAnimationsInNextFrame=!0;break;case`REDO`:this.zonesWithPreventedAnimationsInNextFrame={};break;case`UNDO`:for(let t of e.commands)if(t.type===`ADD_COLUMNS_ROWS`||t.type===`REMOVE_COLUMNS_ROWS`||t.type===`RESIZE_COLUMNS_ROWS`){this.animations.clear(),this.preventNewAnimationsInNextFrame=!0;break}break;case`PASTE`:this.preventNewAnimationsInNextFrame=!0;break;case`UPDATE_CELL`:let t=this.getters.getCommandZones(e);this.zonesWithPreventedAnimationsInNextFrame[e.sheetId]||(this.zonesWithPreventedAnimationsInNextFrame[e.sheetId]=[]),this.zonesWithPreventedAnimationsInNextFrame[e.sheetId].push(...t);break}}finalize(){for(let e in this.zonesWithPreventedAnimationsInNextFrame)this.zonesWithPreventedAnimationsInNextFrame[e]=zn(this.zonesWithPreventedAnimationsInNextFrame[e])}get renderingLayers(){return[`Background`,`Headers`]}drawLayer(e,t,n){switch(t){case`Background`:this.drawGlobalBackground(e);let t=e.sheetId===this.lastRenderSheetId?this.lastRenderBoxes:new Map;this.lastRenderSheetId=e.sheetId,this.lastRenderBoxes=new Map;let{sheetId:r,viewports:i}=e;for(let{zone:a,rect:o}of i.getAllSheetViewportsZonesAndRect(r)){let{ctx:s}=e;s.save(),s.beginPath(),s.rect(o.x,o.y,o.width,o.height),s.clip();let c=this.getGridBoxes(i,r,a),l=this.getBoxesWithAnimations(c,t,n);this.drawBackground(e,l),this.drawOverflowingCellBackground(e,l),this.drawCellBackground(e,l),this.drawBorders(e,l),this.drawTexts(e,l),this.drawIcon(e,l),s.restore()}this.drawFrozenPanes(e),this.preventNewAnimationsInNextFrame=!1,this.zonesWithPreventedAnimationsInNextFrame={};break;case`Headers`:this.drawHeaders(e),this.drawFrozenPanesHeaders(e);break}}drawGlobalBackground(e){let{ctx:t,viewports:n}=e,{width:r,height:i}=n.getSheetViewDimensionWithHeaders();t.fillStyle=this.getBackgroundColor(e),t.fillRect(0,0,r+ke,i+ke)}drawBackground(e,t){let{ctx:n,thinLineWidth:r}=e,i=!e.hideGridLines&&this.getters.getGridLinesVisibility(e.sheetId),a=i?.1*r:0;if(i){let i=this.getters.getSpreadsheetTheme(),o=this.getBackgroundColor(e);n.strokeStyle=qf(Wf(i.gridBorderColor+`aa`,o+`50`),1),n.lineWidth=r;for(let e of t)e.style.hideGridLines||n.strokeRect(e.x+a,e.y+a,e.width-2*a,e.height-2*a)}}drawCellBackground(e,t){let{ctx:n}=e;for(let r of t){let t=r.style;if(t.fillColor&&jf(t.fillColor)!==jf(this.getBackgroundColor(e))&&(n.fillStyle=jf(t.fillColor),n.fillRect(r.x-ke,r.y-ke,r.width+ke*2,r.height+ke*2)),r.dataBarFill){n.fillStyle=r.dataBarFill.color;let e=r.dataBarFill.percentage,t=r.width*(e/100);n.fillRect(r.x,r.y,t,r.height)}if(r.overlayColor&&(n.fillStyle=Wf(t.fillColor||this.getBackgroundColor(e),r.overlayColor),n.fillRect(r.x-ke,r.y-ke,r.width+ke*2,r.height+ke*2)),r?.chip){n.save(),n.beginPath(),n.rect(r.x,r.y,r.width,r.height),n.clip();let e=r.chip;n.fillStyle=r.overlayColor?Wf(e.color,r.overlayColor):e.color,n.beginPath(),n.roundRect(e.x,e.y,e.width,e.height,10),n.fill(),n.restore()}r.isError&&(n.fillStyle=`red`,n.beginPath(),n.moveTo(r.x+r.width-5,r.y),n.lineTo(r.x+r.width,r.y),n.lineTo(r.x+r.width,r.y+5),n.fill())}}drawOverflowingCellBackground(e,t){let{ctx:n,thinLineWidth:r}=e;for(let i of t)if(i.content&&i.isOverflow){let t=i.content.align||`left`,a,o,s=i.y+r/2,c=i.height-r,l=Math.min(i.clipRect?.width||1/0,i.content.width);t===`left`?(a=i.x+r/2,o=l-2*r):t===`right`?(a=i.x+i.width-r/2,o=-l+2*r):(a=(i.clipRect?.x||i.x+i.width/2-i.content.width/2)+r/2,o=l-2*r),n.fillStyle=this.getBackgroundColor(e),n.fillRect(a,s,o,c)}}drawBorders(e,t){let{ctx:n}=e;for(let e of t){let t=e.border;if(t){let{x:n,y:i,width:a,height:o}=e;t.left&&r(t.left,n,i,n,i+o),t.top&&r(t.top,n,i,n+a,i),t.right&&r(t.right,n+a,i,n+a,i+o),t.bottom&&r(t.bottom,n,i+o,n+a,i+o)}}function r({color:e,style:t,opacity:r},i,a,o,s){switch(n.globalAlpha=r??1,n.strokeStyle=e,t){case`medium`:n.lineWidth=2,i+=a===s?-.5:.5,o+=a===s?1.5:.5,a+=i===o?-.5:.5,s+=i===o?1.5:.5;break;case`thick`:n.lineWidth=3,a===s&&(i--,o++),i===o&&(a--,s++);break;case`dashed`:n.lineWidth=1,n.setLineDash([1,3]);break;case`dotted`:n.lineWidth=1,a===s&&(i+=.5,o+=.5),i===o&&(a+=.5,s+=.5),n.setLineDash([1,1]);break;default:n.lineWidth=1;break}n.beginPath(),n.moveTo(i,a),n.lineTo(o,s),n.stroke(),n.lineWidth=1,n.setLineDash([]),n.globalAlpha=1}}drawTexts(e,t){let{ctx:n}=e;n.textBaseline=`top`;let r;for(let e of t)if(e.content){n.globalAlpha=e.textOpacity??1;let t=e.content.align||`left`,i=e.chip?0:e.style.rotation,a={...e.style,align:t,rotation:i},o=Mp(a);if(o!==r&&(r=o,n.font=o),n.fillStyle=a.textColor||`#000`,n.textAlign=t,e.clipRect){n.save(),n.beginPath();let{x:t,y:r,width:i,height:a}=e.clipRect;n.rect(t,r,i,a),n.clip()}let s=e.content.x,c=e.content.y;a.rotation&&(n.save(),n.rotate(a.rotation),{x:s,y:c}=Up(e.content,a));for(let t of e.content.textLines)Vp(n,t,{x:s,y:c},a.underline,a.strikethrough),c+=4+e.content.fontSizePx;a.rotation&&n.restore(),e.clipRect&&n.restore(),n.globalAlpha=1}}drawIcon(e,t){let{ctx:n}=e;for(let e of t)for(let t of Object.values(e.icons)){if(!t)continue;let r=w({id:t.type,position:t.position},this.hoveredIcon.hoveredIcon)&&t.hoverSvg||t.svg;if(!r)continue;n.save(),n.globalAlpha=t.opacity??1,n.beginPath();let i=t.clipRect||e;n.rect(i.x,i.y,i.width,i.height),n.clip();let a=t.size,{x:o,y:s}=this.getters.getCellIconRect(t,e);n.translate(o,s),n.scale(a/r.width,a/r.height);for(let e of r.paths)n.fillStyle=e.fillColor,n.fill(xS(e.path));n.restore()}}drawHeaders(e){let{ctx:t,thinLineWidth:n,viewports:r,sheetId:i}=e,a=r.getSheetViewVisibleCols(i),o=a[0],s=r.getSheetViewVisibleRows(i),c=s[0],{width:l,height:u}=r.getSheetViewDimensionWithHeaders(),d=e.selectedZones,f=Mr(d),p=Pr(d),m=this.getters.getNumberCols(i),h=this.getters.getNumberRows(i),g=e.activeCols,_=e.activeRows,v=this.getters.getSpreadsheetTheme();t.font=`400 11px ${Qe}`,t.textAlign=`center`,t.textBaseline=`middle`,t.lineWidth=n,t.strokeStyle=v.headerTextColor,t.fillStyle=this.getters.getSpreadsheetTheme().backgroundColor,t.fillRect(0,0,48,u),t.fillRect(0,0,l,26);for(let e of a){let n={left:e,right:e,top:0,bottom:h-1},{x:a,width:o}=r.getVisibleRect(i,n),s=g.has(e),c=f.has(e);s?t.fillStyle=v.headerActiveBackgroundColor:c?t.fillStyle=v.headerSelectedBackgroundColor:t.fillStyle=v.headerBackgroundColor,t.fillRect(a,0,o,26)}for(let e of s){let n={top:e,bottom:e,left:0,right:m-1},{y:a,height:o}=r.getVisibleRect(i,n),s=_.has(e),c=p.has(e);s?t.fillStyle=v.headerActiveBackgroundColor:c?t.fillStyle=v.headerSelectedBackgroundColor:t.fillStyle=v.headerBackgroundColor,t.fillRect(0,a,48,o)}t.beginPath(),t.moveTo(48,0),t.lineTo(48,u),t.moveTo(0,26),t.lineTo(l,26),t.strokeStyle=v.headerBorderColor,t.stroke();for(let e of a){let n=kn(e);t.fillStyle=g.has(e)?`#fff`:v.headerTextColor;let a={left:e,right:e,top:c,bottom:c},{x:o,width:s}=r.getRect(i,a),{x:l,width:u}=r.getVisibleRect(i,a);t.save(),t.beginPath(),t.rect(l,0,u,26),t.clip(),t.fillText(n,o+s/2,26/2),t.restore(),t.beginPath(),t.moveTo(o+s,0),t.lineTo(o+s,26),t.stroke()}for(let e of s){t.fillStyle=_.has(e)?`#fff`:v.headerTextColor;let n={top:e,bottom:e,left:o,right:o},{y:a,height:s}=r.getRect(i,n),{y:c,height:l}=r.getVisibleRect(i,n);t.save(),t.beginPath(),t.rect(0,c,48,l),t.clip(),t.fillText(String(e+1),48/2,a+s/2),t.restore(),t.beginPath(),t.moveTo(0,a+s),t.lineTo(48,a+s),t.stroke()}}drawFrozenPanesHeaders(e){let{ctx:t,thinLineWidth:n,sheetId:r,viewports:i}=e,{paneWidth:a,paneHeight:o}=i.getPanesDimensions(r),s=i.getGridOffsetX(),c=i.getGridOffsetY();t.lineWidth=6*n,t.strokeStyle=this.getters.getSpreadsheetTheme().frozenPaneHeaderBorderColor,t.beginPath(),a&&(t.moveTo(s+a,0),t.lineTo(s+a,c)),o&&(t.moveTo(0,c+o),t.lineTo(s,c+o)),t.stroke()}drawFrozenPanes(e){let{ctx:t,thinLineWidth:n,sheetId:r,viewports:i}=e,{x:a,y:o}=i.getMainViewportCoordinates(r),s=i.getSheetViewVisibleCols(r),c=s[0],l=s[s.length-1],u=i.getSheetViewVisibleRows(r),d={left:c,right:l,top:u[0],bottom:u[u.length-1]},f=e.viewports.getVisibleRect(e.sheetId,d),p=i.getGridOffsetX(),m=i.getGridOffsetY();t.lineWidth=6*n,t.strokeStyle=this.getters.getSpreadsheetTheme().frozenPaneBorderColor,t.beginPath(),a&&(t.moveTo(p+a,m),t.lineTo(p+a,f.height+m)),o&&(t.moveTo(p,m+o),t.lineTo(f.width+p,m+o)),t.stroke()}findNextEmptyCol(e,t,n,r){let i=t;for(;i<n;){let t={sheetId:e,col:i+1,row:r},n=this.getters.getEvaluatedCell(t),a=this.getters.getCellComputedBorder(t),o=this.getters.doesCellHaveGridIcon(t);if(n.type!==`empty`||this.getters.isInMerge(t)||a?.left||o)return i;i++}return i}findPreviousEmptyCol(e,t,n,r){let i=t;for(;i>n;){let t={sheetId:e,col:i-1,row:r},n=this.getters.getEvaluatedCell(t),a=this.getters.getCellComputedBorder(t),o=this.getters.doesCellHaveGridIcon(t);if(n.type!==`empty`||this.getters.isInMerge(t)||a?.right||o)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!n&&Gc(r.value,r.format)?`left`:t&&r.type===`number`?n===`center`?n:`left`:!n||n==="default"?r.defaultAlign:n}createZoneBox(e,t,n,r){let{left:i,right:a}=r,o=n.left,s=n.top,c={sheetId:t,col:o,row:s},l=this.getters.getEvaluatedCell(c),u=this.getters.shouldShowFormulas(),{x:d,y:f,width:p,height:m}=e.getRect(t,n),h=this.getters.getDataValidationChipStyle(c),g=this.getters.getCellComputedStyle(c);if(this.fingerprints.isEnabled){let e=this.fingerprints.colors.get(c);g={...g,fillColor:e}}h?.textColor&&(g={...g,textColor:h.textColor});let _=this.fingerprints.isEnabled?void 0:this.getters.getConditionalDataBar(c),v=this.getters.getCellIcons(c),ee={left:v.find(e=>e?.horizontalAlign===`left`),right:v.find(e=>e?.horizontalAlign===`right`),center:v.find(e=>e?.horizontalAlign===`center`)},y={id:tr(n),x:d,y:f,width:p,height:m,border:this.getters.getCellComputedBorder(c)||void 0,style:g,dataBarFill:_,overlayColor:this.hoveredTables.overlayColors.get(c),isError:l.type===`error`&&!!l.message||this.getters.isDataValidationInvalid(c),icons:ee,disabledAnimation:this.zonesWithPreventedAnimationsInNextFrame[t]?.some(e=>pr(n,e)||ur(n,e))},te=Np(y.style);if(l.type===`empty`||y.icons.center)return y;let ne=g.wrapping||`overflow`,re=ne===`wrap`&&!u,ie=p-8,ae=g.align?0:ie,oe=re?ie:void 0,se=this.getters.getCellMultiLineText(c,{maxWidth:ae,wrapWidth:oe}),ce={...g,align:`left`,rotation:0},le=Math.max(...se.map(e=>this.getters.getTextWidth(e,ce)))+4,ue=this.getters.getMultilineTextSize(se,g),de=h?5:0,fe=(y.icons.left?y.icons.left.size+y.icons.left.margin:0)+de,pe=(y.icons.right?y.icons.right.size+y.icons.right.margin:0)+de,me=fe+ue.width+pe+4,he=this.computeCellAlignment(c,me>p),ge=se.length,_e=Math.round(this.getters.computeTextYCoordinate(y,te,g.verticalAlign,ge)),ve=y.x;he===`left`?ve+=4+fe:he===`right`?ve+=y.width-4-pe:ve+=y.width/2,ve=Math.round(ve);let ye=bp(te,ge);if(y.content={textLines:se,width:ne===`overflow`?le:p,textHeight:ye,textWidth:le,align:he,x:ve,y:_e,fontSizePx:te},h?.fillColor){let e=fe;y.chip={color:h.fillColor,width:y.width-e-5,height:ye+2,x:y.x+e,y:_e-2}}let be=me>p||ue.height>m;if(y.icons.left||y.icons.right||y.chip)y.clipRect={x:y.x+fe,y:y.y,width:Math.max(0,p-fe-pe),height:m};else if(be&&ne===`overflow`){let r,l;switch(this.getters.isInMerge(c)?(r=this.getters.getMerge(c).right,l=o):(r=y.border?.right?n.right:this.findNextEmptyCol(t,o,a,s),l=y.border?.left?n.left:this.findPreviousEmptyCol(t,o,i,s),y.isOverflow=!0),he){case`left`:{let i=E({col:r,row:s}),{x:a,y:o,width:c,height:l}=e.getVisibleRect(t,or(n,i));(c<me||te>l||se.length>1)&&(y.clipRect={x:a,y:o,width:c,height:l});break}case`right`:{let r=E({col:l,row:s}),{x:i,y:a,width:o,height:c}=e.getVisibleRect(t,or(n,r));(o<me||te>c||se.length>1)&&(y.clipRect={x:i,y:a,width:o,height:c});break}case`center`:{let i={...n,left:l,right:r},{x:a,y:o,height:s,width:c}=e.getVisibleRect(t,i),u=me/2,d=y.x+y.width/2;if(a+c<d+u||a>d-u||te>s||se.length>1){let e=a>d-u?a:d-u;y.clipRect={x:e,y:o,width:a+c-e,height:s}}break}}}else(ne===`clip`||ne===`wrap`||se.length>1)&&(y.clipRect={x:y.x,y:y.y,width:p,height:m});return y}getGridBoxes(e,t,n){let r=[],i=e.getSheetViewVisibleCols(t).filter(e=>e>=n.left&&e<=n.right),a=i[0],o=i[i.length-1],s=e.getSheetViewVisibleRows(t).filter(e=>e>=n.top&&e<=n.bottom),c={left:a,right:o,top:s[0],bottom:s[s.length-1]};for(let n of s)for(let a of i){let i={sheetId:t,col:a,row:n};this.getters.isInMerge(i)||r.push(this.createZoneBox(e,t,E(i),c))}for(let n of this.getters.getMerges(t))if(!this.getters.isMergeHidden(t,n)&&ur(n,c)){let i=this.createZoneBox(e,t,n,c),a=this.getters.getCellComputedBorder({sheetId:t,col:n.right,row:n.bottom});i.border={...i.border,bottom:a?a.bottom:void 0,right:a?a.right:void 0},i.isMerge=!0,r.push(i)}return r}getBoxesWithAnimations(e,t,n){return this.updateAnimationsProgress(n),this.addNewAnimations(e,t,n),this.animations.size>0?(this.renderer.startAnimation(`grid_renderer_animation`),this.updateBoxesWithAnimations(e)):(this.renderer.stopAnimation(`grid_renderer_animation`),e)}updateBoxesWithAnimations(e){let t=[];for(let n of e){let e=this.animations.get(n.id);if(!e){t.push(n);continue}let r=b(n);t.push(r);for(let i of e.animationTypes){let a=C_.get(i).updateAnimation(e.progress,r,e.oldBox,n);a&&t.push(...a.newBoxes)}}return t}updateAnimationsProgress(e){if(e!==void 0)for(let t of this.animations.keys()){let n=this.animations.get(t);if(n.startTime===void 0){n.startTime=e;continue}let r=e-n.startTime,i=Math.min(1,r/200);i>=1&&this.animations.delete(t),n.progress=i}}addNewAnimations(e,t,n){for(let r of e){this.lastRenderBoxes.set(r.id,r);let e=t.get(r.id);if(this.preventNewAnimationsInNextFrame||!e||r.disabledAnimation)continue;let i=[];for(let t of C_.getAll())t.hasAnimation(e,r)&&i.push(t.id);let a=i.length>0?{animationTypes:i,oldBox:e,progress:0,startTime:n}:void 0;a&&this.animations.set(r.id,a)}}getBackgroundColor(e){return this.getters.getSheet(e.sheetId).backgroundColor||this.getters.getSpreadsheetTheme().backgroundColor}};function kS({canvasRef:e,renderingCtx:t,rendererStore:n,changeCanvasSizeOnZoom:r}){Gi(a);let i=n||k(Jr);ra(OS,i);function a(){let n=e(),a=n.getContext(`2d`,{alpha:!1}),o={ctx:a,thinLineWidth:.4,...t()},s=o.dpr,c=o.viewports.getZoomLevel();r||(c=Math.max(c,1));let{width:l,height:u}=o.viewports.getSheetViewDimensionWithHeaders();n.width=l*s*c,n.height=u*s*c;let d=U({width:r?`${l*c}px`:`${l}px`,height:r?`${u*c}px`:`${u}px`});n.setAttribute(`style`,d),!(l===0||u===0)&&(a.translate(-.5,-.5),a.scale(s*c,s*c),i.draw(o))}}function AS(e){function t(e,t){return e*(t===0?1:23)}return n=>{e(t(n.shiftKey&&!le()?n.deltaY:n.deltaX,n.deltaMode),t(n.shiftKey&&!le()?n.deltaX:n.deltaY,n.deltaMode),n)}}var jS=class{direction;el;constructor(e,t){this.el=e,this.direction=t}get scroll(){return this.direction===`horizontal`?this.el.scrollLeft:this.el.scrollTop}set scroll(e){this.direction===`horizontal`?this.el.scrollLeft=e:this.el.scrollTop=e}},MS=class extends O{static template=t.xml`
|
|
27
|
+
((value in cell) x (Grand Total of Grand Totals)) / ((Grand Row Total) x (Grand Column Total))`)}};function ub(e,t){return M(`Oops—this pivot table is quite large (%s cells). Try simplifying it using the side panel.`,B(e,{format:`0,00`,locale:t}))}function db(e){let t=Da.now();switch(e){case`today`:return Math.floor(to(t));case`yesterday`:return t.setDate(t.getDate()-1),Math.floor(to(t));case`tomorrow`:return t.setDate(t.getDate()+1),Math.floor(to(t));case`lastWeek`:return t.setDate(t.getDate()-6),Math.floor(to(t));case`lastMonth`:{let e=t.getMonth()===0?11:t.getMonth()-1,n=new Da(t.getFullYear(),e,1);return t.getDate()>no(n)?t.setDate(1):(t.setDate(t.getDate()+1),t.setMonth(t.getMonth()-1)),Math.floor(to(t))}case`lastYear`:return t.getMonth()===1&&t.getDate()===29?(t.setDate(28),t.setFullYear(t.getFullYear()-1)):(t.setDate(t.getDate()+1),t.setFullYear(t.getFullYear()-1)),Math.floor(to(t))}}function fb(e,t){return`dateValue`in e&&e.dateValue!==`exactDate`?[db(e.dateValue)]:e.values.map(e=>Ba(e,t))}function pb(e,t){return e.map(e=>{if(e.startsWith(`=`))return e;let n=uf(e,z);return typeof n==`number`?B(n,{format:t.dateFormat,locale:t}):``})}function mb(e){if(!e||typeof e!=`object`||!(!e.thousandsSeparator||typeof e.thousandsSeparator==`string`))return!1;for(let t of[`code`,`name`,`decimalSeparator`,`dateFormat`,`timeFormat`,`formulaArgSeparator`])if(!e[t]||typeof e[t]!=`string`)return!1;if(e.formulaArgSeparator===e.decimalSeparator||e.thousandsSeparator===e.decimalSeparator)return!1;try{B(1,{locale:e,format:`#,##0.00`}),B(1,{locale:e,format:e.dateFormat}),B(1,{locale:e,format:e.timeFormat})}catch{return!1}return!0}function hb(e,t){return Sn(e)?yb(e,t):Sb(e,t)}function gb(e,t){return Sn(e)?yb(e,t):Cb(e,t)}function _b(e,t){return e.startsWith(`=`)?bb(e,t):Tb(e,t)}function vb(e,t){return Sn(e)?yb(e,t):Sb(e,t)}function yb(e,t){return xb(e.startsWith(`+`)?`=`+e.slice(1):e,t,z)}function bb(e,t){return xb(e,z,t)}function xb(e,t,n){if(t.formulaArgSeparator===n.formulaArgSeparator&&t.decimalSeparator===n.decimalSeparator)return e;let r=zl(e,t),i=``;for(let e of r)e.type===`NUMBER`?i+=e.value.replace(t.decimalSeparator,n.decimalSeparator):e.type===`ARG_SEPARATOR`?i+=n.formulaArgSeparator:e.type===`ARRAY_ROW_SEPARATOR`?i+=n.formulaArgSeparator===`;`?`\\`:`;`:i+=e.value;return i}function Sb(e,t){return t.decimalSeparator===`.`||!bo(e,t)?e:(t.thousandsSeparator&&(e=e.replaceAll(t.thousandsSeparator,``)),e.replace(t.decimalSeparator,`.`))}function Cb(e,t){if(Va(e,t)){let n=F(e,t),r=z.dateFormat;return Number.isInteger(n)||(r+=` `+z.timeFormat),B(n,{locale:z,format:r})}return Sb(e,t)}function wb(e,t){if(t.decimalSeparator===`.`||!bo(e,z))return e;let n=Tc(z);return e.replace(n,e=>e.replace(`.`,t.decimalSeparator))}function Tb(e,t){if(Va(e,z)){let n=F(e,z),r=t.dateFormat;return Number.isInteger(n)||(r+=` `+t.timeFormat),B(n,{locale:t,format:r})}return wb(e,t)}function Eb(e){return e.dateFormat+` `+e.timeFormat}let G=new D;G.add(`containsText`,{type:`containsText`,isValueValid:(e,t)=>String(e).toLowerCase().includes(String(t.values[0]).toLowerCase()),getErrorString:e=>M(`The value must be a text that contains "%s"`,String(e.values[0])),isCriterionValueValid:e=>!!e,criterionValueErrorString:sb.CriterionError.notEmptyValue,numberOfValues:()=>1,name:M(`Text contains`),getPreview:e=>M(`Text contains "%s"`,e.values[0])}),G.add(`notContainsText`,{type:`notContainsText`,isValueValid:(e,t)=>!String(e).toLowerCase().includes(String(t.values[0]).toLowerCase()),getErrorString:e=>M(`The value must be a text that does not contain "%s"`,String(e.values[0])),isCriterionValueValid:e=>!!e,criterionValueErrorString:sb.CriterionError.notEmptyValue,numberOfValues:()=>1,name:M(`Text does not contain`),getPreview:e=>M(`Text does not contain "%s"`,e.values[0])}),G.add(`isEqualText`,{type:`isEqualText`,isValueValid:(e,t)=>String(e).toLowerCase()===String(t.values[0]).toLowerCase(),getErrorString:e=>M(`The value must be exactly "%s"`,String(e.values[0])),isCriterionValueValid:e=>!!e,criterionValueErrorString:sb.CriterionError.notEmptyValue,numberOfValues:()=>1,name:M(`Text is exactly`),getPreview:e=>M(`Text is exactly "%s"`,e.values[0])});let Db=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$/;G.add(`isEmail`,{type:`isEmail`,isValueValid:(e,t)=>typeof e==`string`&&Db.test(e),getErrorString:()=>M(`The value must be a valid email address`),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>0,name:M(`Text is valid email`),getPreview:()=>M(`Text is valid email`)}),G.add(`isLink`,{type:`isLink`,isValueValid:(e,t)=>rf(e)!==void 0,getErrorString:()=>M(`The value must be a valid link`),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>0,name:M(`Text is valid link`),getPreview:()=>M(`Text is valid link`)}),G.add(`dateIs`,{type:`dateIs`,isValueValid:(e,t)=>{let n=fb(t,z)[0],r=Ba(e,z);return r===void 0||n===void 0?!1:[`lastWeek`,`lastMonth`,`lastYear`].includes(t.dateValue)?po(r,Math.floor(to(Da.now())),n):fo(r,n)},getErrorString:(e,t)=>{let n=t.getLocale();return e.dateValue===`exactDate`?M(`The value must be the date %s`,kb(e,n)[0]):M(`The value must be %s`,sb.DateIs[e.dateValue])},isCriterionValueValid:e=>Ab(e),criterionValueErrorString:sb.CriterionError.dateValue,numberOfValues:e=>+(e.dateValue===`exactDate`),name:M(`Date is`),getPreview:(e,t)=>e.dateValue===`exactDate`?M(`Date is %s`,pb(e.values,t.getLocale())[0]):M(`Date is %s`,sb.DateIs[e.dateValue])}),G.add(`dateIsBefore`,{type:`dateIsBefore`,isValueValid:(e,t)=>{let n=fb(t,z)[0],r=Ba(e,z);return r!==void 0&&n!==void 0&&mo(r,n)},getErrorString:(e,t)=>{let n=t.getLocale();return e.dateValue===`exactDate`?M(`The value must be a date before %s`,kb(e,n)[0]):M(`The value must be a date before %s`,sb.DateIsBefore[e.dateValue])},isCriterionValueValid:e=>Ab(e),criterionValueErrorString:sb.CriterionError.dateValue,numberOfValues:e=>+(e.dateValue===`exactDate`),name:M(`Date is before`),getPreview:(e,t)=>e.dateValue===`exactDate`?M(`Date is before %s`,pb(e.values,t.getLocale())[0]):M(`Date is before %s`,sb.DateIsBefore[e.dateValue])}),G.add(`dateIsOnOrBefore`,{type:`dateIsOnOrBefore`,isValueValid:(e,t)=>{let n=fb(t,z)[0],r=Ba(e,z);return r!==void 0&&n!==void 0&&ho(r,n)},getErrorString:(e,t)=>{let n=t.getLocale();return e.dateValue===`exactDate`?M(`The value must be a date on or before %s`,kb(e,n)[0]):M(`The value must be a date on or before %s`,sb.DateIsBefore[e.dateValue])},isCriterionValueValid:e=>Ab(e),criterionValueErrorString:sb.CriterionError.dateValue,numberOfValues:e=>+(e.dateValue===`exactDate`),name:M(`Date is on or before`),getPreview:(e,t)=>e.dateValue===`exactDate`?M(`Date is on or before %s`,pb(e.values,t.getLocale())[0]):M(`Date is on or before %s`,sb.DateIsBefore[e.dateValue])}),G.add(`dateIsAfter`,{type:`dateIsAfter`,isValueValid:(e,t)=>{let n=fb(t,z)[0],r=Ba(e,z);return r!==void 0&&n!==void 0&&go(r,n)},getErrorString:(e,t)=>{let n=t.getLocale();return e.dateValue===`exactDate`?M(`The value must be a date after %s`,kb(e,n)[0]):M(`The value must be a date after %s`,sb.DateIsBefore[e.dateValue])},isCriterionValueValid:e=>Ab(e),criterionValueErrorString:sb.CriterionError.dateValue,numberOfValues:e=>+(e.dateValue===`exactDate`),name:M(`Date is after`),getPreview:(e,t)=>e.dateValue===`exactDate`?M(`Date is after %s`,pb(e.values,t.getLocale())[0]):M(`Date is after %s`,sb.DateIsBefore[e.dateValue])}),G.add(`dateIsOnOrAfter`,{type:`dateIsOnOrAfter`,isValueValid:(e,t)=>{let n=fb(t,z)[0],r=Ba(e,z);return r!==void 0&&n!==void 0&&_o(r,n)},getErrorString:(e,t)=>{let n=t.getLocale();return e.dateValue===`exactDate`?M(`The value must be a date on or after %s`,kb(e,n)[0]):M(`The value must be a date on or after %s`,sb.DateIsBefore[e.dateValue])},isCriterionValueValid:e=>Ab(e),criterionValueErrorString:sb.CriterionError.dateValue,numberOfValues:e=>+(e.dateValue===`exactDate`),name:M(`Date is on or after`),getPreview:(e,t)=>e.dateValue===`exactDate`?M(`Date is on or after %s`,pb(e.values,t.getLocale())[0]):M(`Date is on or after %s`,sb.DateIsBefore[e.dateValue])}),G.add(`dateIsBetween`,{type:`dateIsBetween`,isValueValid:(e,t)=>{let n=fb(t,z),r=Ba(e,z);return r===void 0||n[0]===void 0||n[1]===void 0?!1:po(r,n[0],n[1])},getErrorString:(e,t)=>{let n=kb(e,t.getLocale());return M(`The value must be a date between %s and %s`,n[0],n[1])},isCriterionValueValid:e=>Ab(e),criterionValueErrorString:sb.CriterionError.dateValue,numberOfValues:()=>2,name:M(`Date is between`),getPreview:(e,t)=>{let n=pb(e.values,t.getLocale());return M(`Date is between %s and %s`,n[0],n[1])}}),G.add(`dateIsNotBetween`,{type:`dateIsNotBetween`,isValueValid:(e,t)=>{let n=fb(t,z),r=Ba(e,z);return r===void 0||n[0]===void 0||n[1]===void 0?!1:!po(r,n[0],n[1])},getErrorString:(e,t)=>{let n=kb(e,t.getLocale());return M(`The value must be a date not between %s and %s`,n[0],n[1])},isCriterionValueValid:e=>Ab(e),criterionValueErrorString:sb.CriterionError.dateValue,numberOfValues:()=>2,name:M(`Date is not between`),getPreview:(e,t)=>{let n=pb(e.values,t.getLocale());return M(`Date is not between %s and %s`,n[0],n[1])}}),G.add(`dateIsValid`,{type:`dateIsValid`,isValueValid:(e,t)=>Ba(e,z)!==void 0,getErrorString:()=>M(`The value must be a valid date`),isCriterionValueValid:e=>Ab(e),criterionValueErrorString:``,numberOfValues:()=>0,name:M(`Is valid date`),getPreview:()=>M(`Date is valid`)}),G.add(`isEqual`,{type:`isEqual`,isValueValid:(e,t)=>e===t.values[0],getErrorString:(e,t)=>M(`The value must be equal to %s`,Ob(e,t.getLocale())[0]),isCriterionValueValid:e=>jb(e),criterionValueErrorString:sb.CriterionError.numberValue,numberOfValues:()=>1,name:M(`Is equal to`),getPreview:(e,t)=>M(`Value is equal to %s`,Ob(e,t.getLocale())[0])}),G.add(`isNotEqual`,{type:`isNotEqual`,isValueValid:(e,t)=>e!==t.values[0],getErrorString:(e,t)=>M(`The value must not be equal to %s`,Ob(e,t.getLocale())[0]),isCriterionValueValid:e=>jb(e),criterionValueErrorString:sb.CriterionError.numberValue,numberOfValues:()=>1,name:M(`Is not equal to`),getPreview:(e,t)=>M(`Value is not equal to %s`,Ob(e,t.getLocale())[0])}),G.add(`isGreaterThan`,{type:`isGreaterThan`,isValueValid:(e,t)=>{if(typeof e!=`number`)return!1;let n=t.values[0];return typeof n==`number`?e>n:!1},getErrorString:(e,t)=>M(`The value must be greater than %s`,Ob(e,t.getLocale())[0]),isCriterionValueValid:e=>jb(e),criterionValueErrorString:sb.CriterionError.numberValue,numberOfValues:()=>1,name:M(`Is greater than`),getPreview:(e,t)=>M(`Value is greater than %s`,Ob(e,t.getLocale())[0])}),G.add(`isGreaterOrEqualTo`,{type:`isGreaterOrEqualTo`,isValueValid:(e,t)=>{if(typeof e!=`number`)return!1;let n=t.values[0];return typeof n==`number`?e>=n:!1},getErrorString:(e,t)=>M(`The value must be greater or equal to %s`,Ob(e,t.getLocale())[0]),isCriterionValueValid:e=>jb(e),criterionValueErrorString:sb.CriterionError.numberValue,numberOfValues:()=>1,name:M(`Is greater or equal to`),getPreview:(e,t)=>M(`Value is greater or equal to %s`,Ob(e,t.getLocale())[0])}),G.add(`isLessThan`,{type:`isLessThan`,isValueValid:(e,t)=>{if(typeof e!=`number`)return!1;let n=t.values[0];return typeof n==`number`?e<n:!1},getErrorString:(e,t)=>M(`The value must be less than %s`,Ob(e,t.getLocale())[0]),isCriterionValueValid:e=>jb(e),criterionValueErrorString:sb.CriterionError.numberValue,numberOfValues:()=>1,name:M(`Is less than`),getPreview:(e,t)=>M(`Value is less than %s`,Ob(e,t.getLocale())[0])}),G.add(`isLessOrEqualTo`,{type:`isLessOrEqualTo`,isValueValid:(e,t)=>{if(typeof e!=`number`)return!1;let n=t.values[0];return typeof n==`number`?e<=n:!1},getErrorString:(e,t)=>M(`The value must be less or equal to %s`,Ob(e,t.getLocale())[0]),isCriterionValueValid:e=>jb(e),criterionValueErrorString:sb.CriterionError.numberValue,numberOfValues:()=>1,name:M(`Is less or equal to`),getPreview:(e,t)=>M(`Value is less or equal to %s`,Ob(e,t.getLocale())[0])}),G.add(`isBetween`,{type:`isBetween`,isValueValid:(e,t)=>typeof e!=`number`||typeof t.values[0]!=`number`||typeof t.values[1]!=`number`?!1:mn(e,t.values[0],t.values[1]),getErrorString:(e,t)=>{let n=Ob(e,t.getLocale());return M(`The value must be between %s and %s`,n[0],n[1])},isCriterionValueValid:e=>jb(e),criterionValueErrorString:sb.CriterionError.numberValue,numberOfValues:()=>2,name:M(`Is between`),getPreview:(e,t)=>{let n=Ob(e,t.getLocale());return M(`Value is between %s and %s`,n[0],n[1])}}),G.add(`isNotBetween`,{type:`isNotBetween`,isValueValid:(e,t)=>typeof e!=`number`||typeof t.values[0]!=`number`||typeof t.values[1]!=`number`?!1:!mn(e,t.values[0],t.values[1]),getErrorString:(e,t)=>{let n=Ob(e,t.getLocale());return M(`The value must not be between %s and %s`,n[0],n[1])},isCriterionValueValid:e=>jb(e),criterionValueErrorString:sb.CriterionError.numberValue,numberOfValues:()=>2,name:M(`Is not between`),getPreview:(e,t)=>{let n=Ob(e,t.getLocale());return M(`Value is not between %s and %s`,n[0],n[1])}}),G.add(`isBoolean`,{type:`isBoolean`,isValueValid:(e,t)=>e===``||typeof e==`boolean`,getErrorString:()=>M(`The value must be a boolean`),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>0,name:M(`Checkbox`),getPreview:()=>M(`Checkbox`)}),G.add(`isValueInList`,{type:`isValueInList`,isValueValid:(e,t)=>e===null?!1:t.values.map(e=>String(e).toLowerCase()).includes(e.toString().toLowerCase()),getErrorString:e=>M(`The value must be one of: %s`,e.values.join(`, `)),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>void 0,allowedValues:`onlyLiterals`,name:M(`Value in list`),getPreview:e=>M(`Value one of: %s`,e.values.join(`, `))}),G.add(`isValueInRange`,{type:`isValueInRange`,preComputeCriterion:(e,t,n)=>{if(t.length===0)return new Set;let r=t[0].sheetId,i=n.getDataValidationRangeValues(r,e);return new Set(i.map(e=>e.value.toString().toLowerCase()))},isValueValid:(e,t,n)=>e?n.has(e.toString().toLowerCase()):!1,getErrorString:e=>M(`The value must be a value in the range %s`,String(e.values[0])),isCriterionValueValid:e=>xl.test(e),criterionValueErrorString:sb.CriterionError.validRange,numberOfValues:()=>1,allowedValues:`onlyLiterals`,name:M(`Value in range`),getPreview:e=>M(`Value in range %s`,e.values[0])}),G.add(`customFormula`,{type:`customFormula`,isValueValid:(e,t)=>{let n=t.values[0];return typeof n==`number`||typeof n==`boolean`?!!n:!1},getErrorString:()=>M(`The value does not match the custom formula data validation rule`),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>1,allowedValues:`onlyFormulas`,name:M(`Custom formula`),getPreview:e=>M(`Custom formula %s`,e.values[0])}),G.add(`beginsWithText`,{type:`beginsWithText`,isValueValid:(e,t)=>String(e).toLowerCase().startsWith(String(t.values[0]).toLowerCase()),getErrorString:e=>M(`The value must be a text that begins with "%s"`,String(e.values[0])),isCriterionValueValid:e=>!!e,criterionValueErrorString:sb.CriterionError.notEmptyValue,numberOfValues:()=>1,name:M(`Text begins with`),getPreview:e=>M(`Text begins with "%s"`,e.values[0])}),G.add(`endsWithText`,{type:`endsWithText`,isValueValid:(e,t)=>String(e).toLowerCase().endsWith(String(t.values[0]).toLowerCase()),getErrorString:e=>M(`The value must be a text that ends with "%s"`,String(e.values[0])),isCriterionValueValid:e=>!!e,criterionValueErrorString:sb.CriterionError.notEmptyValue,numberOfValues:()=>1,name:M(`Text ends with`),getPreview:e=>M(`Text ends with "%s"`,e.values[0])}),G.add(`isEmpty`,{type:`isEmpty`,isValueValid:(e,t)=>(e??``).toString().trim()===``,getErrorString:()=>M(`The value must be empty`),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>0,name:M(`Is empty`),getPreview:()=>M(`Is empty`)}),G.add(`isNotEmpty`,{type:`isNotEmpty`,isValueValid:(e,t)=>(e??``).toString().trim()!==``,getErrorString:()=>M(`The value must not be empty`),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>0,name:M(`Is not empty`),getPreview:()=>M(`Is not empty`)}),G.add(`top10`,{type:`top10`,preComputeCriterion:(e,t,n)=>{let r=Yo(e.values[0],z);if(r===void 0||r<=0)return;let i=[];for(let e of t)for(let{value:t}of n.getVisibleRangeValues(e))typeof t==`number`&&i.push(t);let a=i.sort((e,t)=>e-t);e.isPercent&&(r=x(r,1,100));let o=0;return o=e.isBottom&&!e.isPercent?r-1:e.isBottom&&e.isPercent?Math.floor(a.length*r/100)-1:!e.isBottom&&e.isPercent?a.length-Math.floor(a.length*r/100):a.length-r,o=x(o,0,a.length-1),a[o]},isValueValid:(e,t,n)=>typeof e!=`number`||n===void 0?!1:t.isBottom?e<=n:e>=n,getErrorString:e=>{let t={value:String(e.values[0]),percentSymbol:e.isPercent?`%`:``};return e.isBottom?M(`The value must be in bottom %(value)s%(percentSymbol)s`,t):M(`The value must be in top %(value)s%(percentSymbol)s`,t)},isCriterionValueValid:e=>Mb(e),criterionValueErrorString:sb.CriterionError.positiveNumber,numberOfValues:()=>1,name:M(`Is in Top/Bottom ranking`),getPreview:e=>{let t={value:e.values[0],percentSymbol:e.isPercent?`%`:``};return e.isBottom?M(`Value is in bottom %(value)s%(percentSymbol)s`,t):M(`Value is in top %(value)s%(percentSymbol)s`,t)}}),G.add(`uniqueValues`,{type:`uniqueValues`,preComputeCriterion:(e,t,n)=>{let r=Nb(t,n);return new Set(Object.keys(r).filter(e=>r[e]===1))},isValueValid:(e,t,n)=>e===null||n===void 0?!1:n.has(String(e).toLowerCase()),getErrorString:()=>M(`The value must be unique`),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>0,name:M(`Is value unique`),getPreview:()=>M(`Value is unique`)}),G.add(`duplicateValues`,{type:`duplicateValues`,preComputeCriterion:(e,t,n)=>{let r=Nb(t,n);return new Set(Object.keys(r).filter(e=>r[e]!==1))},isValueValid:(e,t,n)=>e===null||n===void 0?!1:n.has(String(e).toLowerCase()),getErrorString:()=>M(`The value must not be unique`),isCriterionValueValid:()=>!0,criterionValueErrorString:``,numberOfValues:()=>0,name:M(`Is value duplicate`),getPreview:()=>M(`Value is duplicate`)});function Ob(e,t){return e.values.map(e=>e===void 0?N.InvalidReference:_b(String(e),t))}function kb(e,t){return fb(e,z).map(e=>e===void 0?N.InvalidReference:B(e,{locale:t,format:t.dateFormat}))}function Ab(e){return Ba(e,z)!==void 0}function jb(e){return Yo(e,z)!==void 0}function Mb(e){let t=Yo(e,z);return t!==void 0&&t>0}function Nb(e,t){let n={};for(let r of e)for(let e of t.getVisibleRangeValues(r)){let t=I(e).toLowerCase();t&&(n[t]=(n[t]||0)+1)}return n}function Pb(e,t,n,r,i){if(r.filterType===`values`){let e=r.hiddenValues?.map(Lp);if(!e)return!1;if(new Set(e).has(Lp(n.formattedValue)))return!0}else{if(r.type===`none`)return!1;let a=G.get(r.type),o=r.values.map(n=>n.startsWith(`=`)?e.evaluateFormula(t,n)??``:uf(n,z));if(o.some(Nv))return!1;let s={type:r.type,values:o.map(jv),dateValue:r.dateValue};if(!a.isValueValid(n.value,s,i))return!0}return!1}var Fb=class{columns;rows;rowFields;measures;fieldsType;maxIndent;pivotCells={};rowTree;colTree;isSorted=!1;constructor(e,t,n,r,i={COL:[],ROW:[]}){this.measures=n,this.fieldsType=r,i.COL.length&&(e=this.removeCollapsedColumns(e,n,i.COL)),this.columns=e.map(e=>{let t=0;return e.map(e=>(e={...e,offset:t},t+=e.width,e))}),this.rows=t.filter(e=>!this.isParentCollapsed(i.ROW,e));let a=Math.max(...t.map(e=>e.fields.length)),o=t.find(e=>e.fields.length===a);this.rowFields=o?[...o.fields]:[],this.maxIndent=Math.max(...this.rows.map(e=>e.indent)),this.rowTree=Yt(()=>this.buildRowsTree()),this.colTree=Yt(()=>this.buildColumnsTree())}removeCollapsedColumns(e,t,n){let r=(n,r)=>{let i=this.getDomain(n),a=e[r],o=a.findIndex(e=>_v(this.getDomain(e),i)),s=a.findLastIndex(e=>_v(this.getDomain(e),i)),c=r===e.length-1,l=t.map(e=>({fields:c?[...n.fields,`measure`]:[],values:c?[...n.values,e]:[],width:1,offset:0,collapsedHeader:!c}));a.splice(o,s-o+1,...l)};return e.map((i,a)=>{for(let o of i){if(a>=e.length-2)return i;let s=this.getDomain(o);if(n.some(e=>w(s,e))){o.width=t.length;for(let t=a+1;t<e.length;t++)r(o,t)}}return i})}isParentCollapsed(e,t){let n=this.getDomain(t);return e.some(e=>_v(n,e))}getNumberOfDataColumns(){return this.columns.at(-1)?.length||0}getSkippedRows(e){let t=new Set,n=this.getColHeadersHeight();if(!e.displayColumnHeaders)for(let e=0;e<n-1;e++)t.add(e);if(e.displayMeasuresRow||t.add(n-1),e.tabularForm)for(let e=0;e<this.rows.length;e++){let r=this.rows[e].indent;r!==0&&r!==this.maxIndent&&t.add(e+n)}return t}getPivotCells(e=yy){let t=JSON.stringify(e);if(!this.pivotCells[t]){let{displayTotals:n}=e,r=this.rows.length,i=this.getNumberOfDataColumns(),a=r+this.getColHeadersHeight(),o=i+this.getRowHeadersWidth(e);!n&&r!==1&&--a,!n&&i!==this.measures.length&&(o-=this.measures.length);let s=[],c=this.getSkippedRows(e);for(let t=0;t<o;t++){s.push([]);for(let n=0;n<a;n++){if(c.has(n))continue;let r=this.getPivotCell(t,n,e);s[t].push(r)}}this.pivotCells[t]=s}return this.pivotCells[t]}getRowTree(){return this.rowTree()}getColTree(){return this.colTree()}isTotalRow(e){return this.rows[e].indent!==this.maxIndent}getPivotCell(e,t,n){let r=this.getColHeadersHeight(),i=this.getRowHeadersWidth(n),a=n.tabularForm,o=t<r-1&&e>=i,s=t===r-1&&e>=i,c=t>r-1&&e<i,l=t>r-1&&e>=i,u=a&&t===r-1&&e<i;if(a&&c){let n=t-r,i=this.getDomain(this.rows[n]).slice(0,e+1);return i.length===0&&e!==0?Ib:{type:`HEADER`,domain:i,dimension:`ROW`}}else if(a&&u)return{type:`ROW_GROUP_NAME`,rowField:this.rowFields[e]};else if(s){let n=e-i,r=this.getColHeaderDomain(n,t);if(!r)return Ib;let a=r.at(-1)?.value?.toString()||``;return{type:`MEASURE_HEADER`,domain:r.slice(0,-1),measure:a}}else if(o){let n=e-i,r=this.getColHeaderDomain(n,t);return r?{type:`HEADER`,domain:r,dimension:`COL`}:Ib}else if(c){let e=t-r;return{type:`HEADER`,domain:this.getDomain(this.rows[e]),dimension:`ROW`}}else if(l){let a=t-r,o=e-i;return!n.displayTotals&&this.isTotalRow(a)?Ib:{type:`VALUE`,domain:[...this.getDomain(this.rows[a]),...this.getColDomain(o)],measure:this.getColMeasure(o)}}return Ib}getColHeaderDomain(e,t){let n=this.columns[t].find(t=>t.offset===e);if(!(!n||n.collapsedHeader))return this.getDomain(n)}getDomain(e){return e.fields.map((t,n)=>{if(t===`measure`)return{type:`char`,field:t,value:Ny({displayName:`measure`,type:`char`},e.values[n])};{let{fieldName:r,granularity:i}=Oy(t),a=this.fieldsType[r]||`char`;return{type:a,field:t,value:Ny({displayName:r,type:a,granularity:i},e.values[n])}}})}getColDomain(e){let t=this.getColHeaderDomain(e,this.getColHeadersHeight()-1);return t?t.slice(0,-1):[]}getColMeasure(e){let t=this.getColHeaderDomain(e,this.getColHeadersHeight()-1)?.at(-1)?.value;if(t==null)throw Error(`Measure is missing`);return t.toString()}getRowHeadersWidth(e){return e.tabularForm?this.rowFields.length:1}getColHeadersHeight(){return this.columns.length}buildRowsTree(){let e=[],t=0,n={};n[0]=e;for(let r of this.rows){if(r.fields.length===0||r.values.length===0)return e;let i=r.fields.length-1,a=r.fields[i],{fieldName:o,granularity:s}=Oy(a),c=Ny({displayName:o,type:this.fieldsType[o]??`char`,granularity:s},r.values[i]);if(i>t){t=i,n[t]=[];let e=n[t-1].at(-1);e&&(e.children=n[t])}t=i;let l={value:c,field:r.fields[i],children:[],type:this.fieldsType[o]||`char`,width:0};n[t].push(l)}return e}buildColumnsTree(){let e=[],t=this.columns.at(-2)||[],n={};n[0]=e;for(let e of t)for(let t=0;t<e.fields.length;t++){let r=e.fields[t],{fieldName:i,granularity:a}=Oy(r),o=Ny({displayName:i,type:this.fieldsType[i]??`char`,granularity:a},e.values[t]),s={value:o,field:e.fields[t],children:[],width:e.width,type:this.fieldsType[i]||`char`};n[t]?.at(-1)?.value!==o&&(n[t+1]=[],s.children=n[t+1],n[t].push(s))}return e}export(){return{cols:this.columns,rows:this.rows,measures:this.measures,fieldsType:this.fieldsType}}sort(e,t,n){if(this.isSorted)return;let r=(e,t)=>{let r=n(e,t).value;return typeof r==`number`?r:-1/0},i=t.domain,a=gv(this.rowTree(),[],(n,a)=>{let o=r(e,[...n,...i]),s=r(e,[...a,...i]);return t.order===`asc`?o-s:s-o});this.rowTree=Yt(a),this.rows=[...this.rowTreeToRows(a),this.rows[this.rows.length-1]],this.isSorted=!0}rowTreeToRows(e,t){return e.flatMap(e=>{let n={indent:t?t.indent+1:1,fields:[...t?.fields||[],e.field],values:[...t?.values||[],e.value]};return[n,...this.rowTreeToRows(e.children,n)]})}get numberOfCells(){return this.rows.length*this.getNumberOfDataColumns()}getColumnDomainsAtDepth(e){return e<0||e>=this.getColHeadersHeight()-1?[]:this.columns[e].map(e=>this.getDomain(e)).filter(e=>e.length)}getRowDomainsAtDepth(e){return e<0||e>this.maxIndent?[]:this.rows.filter(t=>t.indent===e+1).map(e=>this.getDomain(e))}getPivotTableDimensions(e){let t=this.getPivotCells(e),n=0;return e.displayColumnHeaders&&(n=this.getColHeadersHeight()-1),e.displayMeasuresRow&&n++,{numberOfCols:Math.min(this.getRowHeadersWidth(e)+e.numberOfColumns,t.length),numberOfRows:Math.min(n+e.numberOfRows,t[0].length),numberOfHeaderRows:n}}getNumberOfRowGroupBys(){return Math.max(...this.rows.map(e=>e.fields.length))}};let Ib={type:`EMPTY`};function Lb(e,t,n){let r=t.measures.filter(e=>!e.isHidden).map(e=>e.id),i=zb(e,t.columns,0);Bb(i,r.length);let a=Vb(i,t),o=Rb(e,0,t.rows,[],[]);o.push({fields:[],values:[],indent:0});let s={};for(let e of t.columns)s[e.fieldName]=e.type;for(let e of t.rows)s[e.fieldName]=e.type;return new Fb(a,o,r,s,n===`collapsed`?t.collapsedDomains:void 0)}function Rb(e,t,n,r,i){if(t>=n.length)return[];let a=n[t],o=a.nameWithGranularity,s=Hb(e,a),c=Wb(s,a),l=[],u=r.concat(o);for(let e of c){let r=i.concat(e);l.push({fields:u,values:r,indent:t+1});let a=s[e];a&&l.push(...Rb(a,t+1,n,u,r))}return l}function zb(e,t,n){if(n>=t.length)return[];let r=t[n],i=t[n].nameWithGranularity,a=Hb(e,r);return Wb(a,t[n]).map(e=>({value:a[e]?.[0]?.[r.nameWithGranularity]?.value??null,field:i,children:zb(a[e]||[],t,n+1),type:r.type,width:0}))}function Bb(e,t){for(let n in e){let r=e[n];r.children.length===0?r.width=t:(Bb(r.children,t),r.width=r.children.reduce((e,t)=>e+t.width,0))}}function Vb(e,t){let n=t.columns.map(e=>e.nameWithGranularity),r=n.length,i=t.measures.filter(e=>!e.isHidden),a=i.length,o=Array(r).fill(0).map(()=>[]);function s(e,t,i){let a=o[t];for(let o of e){let e=i.concat([o.value]),c={fields:n.slice(0,t+1),values:e,width:o.width,offset:0};a.push(c),t<=r-1&&s(o.children,t+1,e)}}s(e,0,[]);let c=n.length>0,l=[];return c&&o[o.length-1].forEach(e=>{i.forEach(t=>{let n={fields:[...e.fields,`measure`],values:[...e.values,t.id],width:1,offset:0};l.push(n)})}),i.forEach(e=>{let t={fields:[`measure`],values:[e.id],width:1,offset:0};l.push(t)}),o.push(l),o.length===1&&o.unshift([]),o[o.length-2].push({fields:[],values:[],width:a,offset:0}),o}function Hb(e,t){return Object.groupBy(e,Ub(t))}function Ub(e){let t=e.nameWithGranularity;return e=>`${e[t]?.value??null}`}function Wb(e,t){let n=t.order,r=t.customGroups?.find(e=>e.isOtherGroup);return!n&&!r?Object.keys(e):Object.keys(e).sort((e,i)=>r&&e===r.name?1:r&&i===r.name?-1:n?Gb(t,e,i):0)}function Gb(e,t,n){return t===`null`?e.order===`asc`?1:-1:n===`null`?e.order===`asc`?-1:1:e.type===`integer`||e.type===`datetime`?e.order===`asc`?F(t,z)-F(n,z):F(n,z)-F(t,z):e.order===`asc`?t.localeCompare(n):n.localeCompare(t)}let Kb=Symbol(`NULL`);function qb(e,t,n){let r=e.granularity||`month`;if(!(r in Jb))throw Error(`Unknown date granularity: ${r}`);let i=typeof t==`number`||typeof t==`string`?t:Kb;if(!Jb[r].set.has(t)){Jb[r].set.add(t);let a=null;if(typeof t==`number`||typeof t==`string`){let e=rs(t,n);switch(r){case`year`:a=e.getFullYear();break;case`quarter_number`:a=Math.floor(e.getMonth()/3)+1;break;case`month_number`:a=e.getMonth()+1;break;case`month`:a=Math.floor(F(t,n));break;case`iso_week_number`:a=e.getIsoWeek();break;case`day_of_month`:a=e.getDate();break;case`day`:a=Math.floor(F(t,n));break;case`day_of_week`:a=(e.getDay()+7-n.weekStart)%7+1;break;case`hour_number`:a=e.getHours();break;case`minute_number`:a=e.getMinutes();break;case`second_number`:a=e.getSeconds();break}}Jb[r].values[i]=Ny(e,a)}return Jb[r].values[i]}let Jb={year:{set:new Set,values:{}},quarter_number:{set:new Set,values:{}},month_number:{set:new Set,values:{}},month:{set:new Set,values:{}},iso_week_number:{set:new Set,values:{}},day_of_month:{set:new Set,values:{}},day:{set:new Set,values:{}},day_of_week:{set:new Set,values:{}},hour_number:{set:new Set,values:{}},minute_number:{set:new Set,values:{}},second_number:{set:new Set,values:{}}};function Yb(){for(let e in Jb)Jb[e].set.clear(),Jb[e].values={}}var Xb=class{type=`SPREADSHEET`;getters;_definition;coreDefinition;metaData={fields:{},fieldKeys:[]};unfilteredDataEntries=[];filteredDataEntries=[];collapsedTable;expandedTable;invalidRangeError;needsReevaluation=!0;constructor(e,t){this.getters=t.getters,this.coreDefinition=t.definition}init(e={}){(!this._definition||e.reload)&&(this.reload(4),this.needsReevaluation=!1)}reload(e){e===4&&(this.metaData=this.loadMetaData()),e>=3&&(this._definition=this.loadRuntimeDefinition()),e>=2&&(this.unfilteredDataEntries=this.loadDataEntries(),this.filteredDataEntries=this.loadFilteredDataEntries(this.unfilteredDataEntries)),e>=1&&(this.collapsedTable=void 0,this.expandedTable=void 0)}onDefinitionChange(e){let t=this.coreDefinition;if(this.coreDefinition=e,this._definition){let n=Math.max(this.computeShouldReload(t,e),0);this.reload(n)}}computeShouldReload(e,t){return w(e.dataSet,t.dataSet)?3:4}get isInvalidRange(){return!!this.invalidRangeError}get invalidRangeMessage(){return this.invalidRangeError?.message}get definition(){if(this._definition||this.init(),!this._definition)throw Error(`Pivot definition should be defined at this point.`);return this._definition}isValid(){if(this.invalidRangeError||!this.definition)return!1;for(let e of this.definition.measures)if(!e.isValid)return!1;for(let e of this.definition.columns)if(!e.isValid)return!1;for(let e of this.definition.rows)if(!e.isValid)return!1;for(let e of this.definition.filters??[])if(!e.isValid)return!1;return!0}assertIsValid({throwOnError:e}){if(!this.isValid()){if(e)throw this.invalidRangeError?this.invalidRangeError:new P(M(`At least one measure/dimension and/or filter is not correct.`));return{value:N.GenericError,message:this.invalidRangeError?.message??M(`At least one measure/dimension and/or filter is not correct.`)}}}areDomainArgsFieldsValid(e){let t=e.filter((e,t)=>t%2==0).map(I);return t.length&&t.at(-1)===`measure`&&(t=t.slice(0,-1)),jy(t,this.definition)}parseArgsToPivotDomain(e){let t=[];for(let n=0;n<e.length-1;n+=2){let r=I(e[n]),i=this.getTypeOfDimension(r),a=r===`measure`?I(e[n+1]):Ny(this.getDimension(r),e[n+1]);t.push({field:r,value:a,type:i})}return t}markAsDirtyForEvaluation(){this.needsReevaluation=!0}getMeasure(e){return this.definition.getMeasure(e)}getPivotMeasureValue(e){return{value:this.getMeasure(e).displayName}}getPivotHeaderValueAndFormat(e){let t=e.at(-1);if(!t)return{value:M(`Total`)};let n=this.getDimension(t.field),r=this.filterDataEntriesFromDomain(this.filteredDataEntries,e)[0]?.[n.nameWithGranularity];return n.type===`datetime`?oy(n.granularity||`month`).toValueAndFormat(t.value,this.getters.getLocale()):r?r.value===null?{value:M(`(Undefined)`)}:r:{value:``}}getPivotCellValueAndFormat(e,t){let n=this.filterDataEntriesFromDomain(this.filteredDataEntries,t);if(n.length===0)return{value:``};let r=this.getMeasure(e),i=n.map(e=>e[r.fieldName]).filter(C),a=i.filter(e=>e.type!==`empty`),o=r.aggregator,s=wy[o];if(!s)throw Error(`Aggregator ${o} does not exist`);try{let e=s([i],this.getters.getLocale());return a.length===0?{...e,value:``}:e}catch(e){return cl(e,o.toUpperCase())}}getDataEntries(){return this.unfilteredDataEntries}getPossibleFieldValues(e){let t=[],n=Hb(this.filteredDataEntries,e),r=Wb(n,e);for(let i of r)t.push({value:n[i]?.[0]?.[e.nameWithGranularity]?.value??``,label:n[i]?.[0]?.[e.nameWithGranularity]?.formattedValue||``});return t}getCollapsedTableStructure(){if(!this.isValid())throw Error(`Pivot is not valid !`);return this.coreDefinition.style?.tabularForm?this.getExpandedTableStructure():(this.collapsedTable||=Lb(this.filteredDataEntries,this.definition,`collapsed`),this.collapsedTable)}getExpandedTableStructure(){if(!this.isValid())throw Error(`Pivot is not valid !`);return this.expandedTable||=Lb(this.filteredDataEntries,this.definition,`expanded`),this.expandedTable}getFields(){return this.metaData.fields}get fields(){return this.getFields()}loadMetaData(){if(this.invalidRangeError=void 0,this.coreDefinition.dataSet){let{zone:e,sheetId:t}=this.coreDefinition.dataSet,n=this.getters.getRangeFromZone(t,e);try{let e=this.extractFieldsFromRange(n),t=Wy(this.coreDefinition,e.fields);return{...e,fields:{...e.fields,...t}}}catch(e){return this.invalidRangeError=e,{fields:{},fieldKeys:[]}}}else return this.invalidRangeError=new P(M(`The pivot cannot be created because the dataset is missing.`)),{fields:{},fieldKeys:[]}}loadRuntimeDefinition(){return new $y(this.coreDefinition,this.fields,this.getters)}loadDataEntries(){let e=this._definition?.range;return this.isValid()&&e?this.extractDataEntriesFromRange(e):[]}loadFilteredDataEntries(e){let t=this._definition?.range?.sheetId;return t?(this._definition&&this._definition.filters&&(e=e.filter(e=>{let n=!0;for(let r of this._definition?.filters??[]){let i=e[r.fieldName];if(i&&Pb(this.getters,t,i,r)){n=!1;break}}return n})),e):[]}getTypeOfDimension(e){if(e===`measure`)return`char`;let{fieldName:t}=Oy(e),n=this.fields[t]?.type;if(!n)throw Error(`Field ${t} does not exist`);return n}filterDataEntriesFromDomain(e,t){return t.reduce((e,t)=>this.filterDataEntriesFromDomainNode(e,t),e)}filterDataEntriesFromDomainNode(e,t){let{field:n,value:r,type:i}=t,{nameWithGranularity:a}=this.getDimension(n);return e.filter(e=>{let t=e[a]?.value;return i===`char`?String(t)===String(r):t===r})}getDimension(e){return this.definition.getDimension(e)}getTypeFromZone(e,t){let n=this.getters.getEvaluatedCellsInZone(e,t).filter(e=>!(e.type===`empty`||e.value===``));return n.length===0?`integer`:n.every(e=>e.type===`number`&&e.format&&Sc(e.format))?`datetime`:n.every(e=>e.type===`boolean`)?`boolean`:n.every(e=>e.type===`number`)?`integer`:`char`}assertCellIsValidField(e,t,n){if(n.type===`error`)throw new P(M(`The pivot cannot be created because cell %s contains an error`,T(e,t)));if(n.type===`empty`||n.value===``)throw new P(M(`The pivot cannot be created because cell %s is empty`,T(e,t)));if(n.value===`__count`)throw new P(M(`The pivot cannot be created because cell %s contains a reserved value`,T(e,t)))}extractFieldsFromRange(e){let t={},n=[],r=e.sheetId,i=e.zone.top;for(let a=e.zone.left;a<=e.zone.right;a++){let o=this.getters.getEvaluatedCell({sheetId:r,col:a,row:i});this.assertCellIsValidField(a,i,o);let s=o.value?.toString();if(s){let i=this.getTypeFromZone(r,{top:e.zone.top+1,left:a,bottom:e.zone.bottom,right:a}),o=Uy(s,t);t[o]={name:o,type:i,string:o,aggregator:i===`integer`?`sum`:`count`},n.push(o)}}return{fields:t,fieldKeys:n}}extractDataEntriesFromRange(e){let t=[];for(let n=e.zone.top+1;n<=e.zone.bottom;n++){let r={top:n,bottom:n,left:e.zone.left,right:e.zone.right},i=this.getters.getEvaluatedCellsInZone(e.sheetId,r),a={},o=!0;for(let e in i){let t=i[e],n=this.fields[this.metaData.fieldKeys[e]];if(!n)throw Error(`Field ${this.metaData.fieldKeys[e]} does not exist`);t.value===``?a[n.name]={value:null,type:`empty`,formattedValue:``}:(a[n.name]=t,t.type!==`empty`&&(o=!1))}for(let e in this.definition.customFields||{}){let t=this.definition.customFields?.[e];if(!t)continue;let n=a[t.parentField],r=this.fields[t.parentField];if(!n||!r){a[e]={value:null,type:`empty`,formattedValue:``};continue}let i=t.groups.find(e=>e.values.some(e=>e===n?.value))||t.groups.find(e=>e.isOtherGroup);a[e]={...n,value:i?i.name:n.value}}o||(a.__count={value:1,type:`number`,formattedValue:`1`},t.push(a))}let n=this.definition.columns.concat(this.definition.rows).filter(e=>e.type===`datetime`);if(n.length){let e=this.getters.getLocale();for(let r of t)for(let t of n){let n=qb(t,r[t.fieldName]?.value||null,this.getters.getLocale()),{format:i,value:a}=oy(t.granularity||`month`).toValueAndFormat(n,e);r[t.nameWithGranularity]={value:n,type:r[t.fieldName]?.type||`empty`,format:r[t.fieldName]?.format,formattedValue:B(a,{locale:e,format:i})}}}return t}};let Zb=new D,Qb=[`year`,`quarter_number`,`month_number`,`month`,`iso_week_number`,`day_of_month`,`day`,`day_of_week`],$b=[...Qb,`hour_number`,`minute_number`,`second_number`];Zb.add(`SPREADSHEET`,{ui:Xb,definition:$y,dateGranularities:[...Qb],isMeasureCandidate:e=>e.type!==`boolean`,datetimeGranularities:[...$b],isGroupable:()=>!0,canHaveCustomGroup:e=>e.type===`char`&&!e.isCustomField,isPivotUnused:()=>!0,adaptRanges:(e,t,n)=>{if(t.type!==`SPREADSHEET`||!t.dataSet)return t;let{sheetId:r,zone:i}=t.dataSet,a=e.getRangeFromZone(r,i),o=ex(a,n);if(o===a)return t;let s=o&&{sheetId:o.sheetId,zone:o.zone};return{...t,dataSet:s}}});function ex(e,t){if(!e)return;let n=t(e);switch(n.changeType){case`REMOVE`:return;default:return n.range}}let tx={name:M(`See pivot properties`),execute(e){let t=e.model.getters.getActivePosition(),n=e.model.getters.getPivotIdFromPosition(t);e.openSidePanel(`PivotSidePanel`,{pivotId:n})},isVisible:e=>{let t=e.model.getters.getActivePosition(),n=e.model.getters.getPivotIdFromPosition(t);return!e.isSmall&&n&&e.model.getters.isExistingPivot(n)||!1},isReadonlyAllowed:!0,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.PIVOT`},nx={name:M(`Ascending`),execute:e=>mx(e,e.model.getters.getActivePosition(),`asc`),isActive:e=>e.model.getters.getPivotCellSortDirection(e.model.getters.getActivePosition())===`asc`},rx={name:M(`Descending`),execute:e=>mx(e,e.model.getters.getActivePosition(),`desc`),isActive:e=>e.model.getters.getPivotCellSortDirection(e.model.getters.getActivePosition())===`desc`},ix={name:M(`No sorting`),execute:e=>mx(e,e.model.getters.getActivePosition(),`none`),isActive:e=>e.model.getters.getPivotCellSortDirection(e.model.getters.getActivePosition())===`none`},ax={name:M(`Convert to individual formulas`),execute(e){let t=e.model.getters.getActivePosition(),n=e.model.getters.getCorrespondingFormulaCell(t),r=e.model.getters.getPivotIdFromPosition(t);if(!n||!r)return;let{sheetId:i,col:a,row:o}=e.model.getters.getCellPosition(n.id),s=e.model.getters.getPivot(r);s.init(),s.isValid()&&e.model.dispatch(`SPLIT_PIVOT_FORMULA`,{sheetId:i,col:a,row:o,pivotId:r})},isVisible:e=>{let t=e.model.getters.getActivePosition(),n=e.model.getters.getPivotIdFromPosition(t);if(!n)return!1;let r=e.model.getters.getPivot(n),i=e.model.getters.getEvaluatedCell(t);return r.isValid()&&e.model.getters.isSpillPivotFormula(t)&&i.type!==`error`},icon:`o-spreadsheet-Icon.PIVOT`},ox={name:M(`Group pivot dimensions`),execute:e=>{let t=hx(e);if(!t)return;let{pivotId:n,values:r,field:i}=t,a=e.model.getters.getPivot(n),o=b(e.model.getters.getPivotCoreDefinition(n));if(!i.isCustomField)gx(o,r,i,a.getFields());else{let e=(o.customFields||{})[i.name];if(!e)return;_x(e,r)}e.model.dispatch(`UPDATE_PIVOT`,{pivotId:n,pivot:o})},isVisible:e=>{let t=hx(e);if(!t)return!1;let{pivotId:n,values:r,field:i}=t,a=e.model.getters.getPivot(n);return r.length>1&&(i.isCustomField||Zb.get(a.type).canHaveCustomGroup(i))}},sx={name:M(`Group all remaining dimensions`),execute:e=>{let t=hx(e);if(!t)return;let{pivotId:n,field:r}=t,i=e.model.getters.getPivot(n),a=b(e.model.getters.getPivotCoreDefinition(n)),o=r.isCustomField?(a.customFields||{})[r.name]:qy(a,r,i.getFields());o&&(o.groups.push({name:Hy(M(`Others`),o),values:[],isOtherGroup:!0}),Ky(a,r.name,o.name),e.model.dispatch(`UPDATE_PIVOT`,{pivotId:n,pivot:a}))},isVisible:e=>{let t=hx(e);if(!t)return!1;let{pivotId:n,field:r,values:i}=t;return bx(e,n,i,r)}},cx={name:M(`Ungroup pivot dimensions`),execute:e=>{let t=hx(e);if(!t)return;let{pivotId:n,values:r,field:i}=t,a=e.model.getters.getPivot(n),o=b(e.model.getters.getPivotCoreDefinition(n));vx(o,r,i,a.getFields()),e.model.dispatch(`UPDATE_PIVOT`,{pivotId:n,pivot:o})},isVisible:e=>{let t=hx(e);if(!t)return!1;let{pivotId:n,values:r,field:i}=t,a=e.model.getters.getPivot(n),o=e.model.getters.getPivotCoreDefinition(n);if(!i.isCustomField){let e=qy(o,i,a.getFields());if(![...o.rows,...o.columns].some(t=>t.fieldName===e.name))return!1}return yx(o,r,i,a.getFields())}},lx={name:e=>{let t=e.model.getters.getActivePosition(),n=fx(e.model.getters,t);return n.isPivotGroup?n.isCollapsed?M(`Expand`):M(`Collapse`):``},execute(e){Jy(e.model.getters.getActivePosition(),e)},isVisible:e=>{let t=e.model.getters.getActivePosition(),n=fx(e.model.getters,t),r=e.model.getters.getPivotStyleAtPosition(t);return n.isPivotGroup&&!r?.pivotStyle.tabularForm}},ux={name:M(`Collapse all`),execute(e){let t=e.model.getters.getActivePosition(),n=fx(e.model.getters,t);if(!n.isPivotGroup)return;let{pivotCell:r,pivotId:i,siblingDomains:a}=n,o=b(e.model.getters.getPivotCoreDefinition(i));o.collapsedDomains=o.collapsedDomains||{COL:[],ROW:[]};let s=[...o.collapsedDomains[r.dimension]||[],...a],c=s.filter((e,t)=>t===s.findIndex(t=>w(t,e)));o.collapsedDomains[r.dimension]=c,e.model.dispatch(`UPDATE_PIVOT`,{pivotId:i,pivot:o})},isVisible:e=>{let t=e.model.getters.getActivePosition(),n=fx(e.model.getters,t),r=e.model.getters.getPivotStyleAtPosition(t);if(!n.isPivotGroup||r?.pivotStyle.tabularForm)return!1;let{pivotCell:i,pivotId:a,siblingDomains:o}=n,s=e.model.getters.getPivotCoreDefinition(a);return!o.every(e=>(s.collapsedDomains?.[i.dimension]||[]).some(t=>w(t,e)))}},dx={name:M(`Expand all`),execute(e){let t=e.model.getters.getActivePosition(),n=fx(e.model.getters,t);if(!n.isPivotGroup)return;let{pivotCell:r,pivotId:i,siblingDomains:a}=n,o=b(e.model.getters.getPivotCoreDefinition(i));o.collapsedDomains=o.collapsedDomains||{COL:[],ROW:[]};let s=(o.collapsedDomains[r.dimension]||[]).filter(e=>!a.find(t=>w(t,e)));o.collapsedDomains[r.dimension]=s,e.model.dispatch(`UPDATE_PIVOT`,{pivotId:i,pivot:o})},isVisible:e=>{let t=e.model.getters.getActivePosition(),n=fx(e.model.getters,t),r=e.model.getters.getPivotStyleAtPosition(t);if(!n.isPivotGroup||r?.pivotStyle.tabularForm)return!1;let{pivotCell:i,pivotId:a,siblingDomains:o}=n;return(e.model.getters.getPivotCoreDefinition(a).collapsedDomains?.[i.dimension]||[]).some(e=>o.some(t=>w(t,e)))}};function fx(e,t){if(!e.isSpillPivotFormula(t))return{isPivotGroup:!1};let n=e.getPivotCellFromPosition(t),r=e.getPivotIdFromPosition(t);if(n.type!==`HEADER`||!r||!n.domain.length)return{isPivotGroup:!1};let i=e.getPivotCoreDefinition(r),a=e.isDashboard(),o=n.dimension===`COL`?i.columns:i.rows;if(!(!a&&n.domain.length!==o.length))return{isPivotGroup:!1};let s=(i.collapsedDomains?.[n.dimension]??[]).some(e=>w(e,n.domain)),c=e.getPivot(r).getExpandedTableStructure(),l=n.domain.length-1;return{isPivotGroup:!0,isCollapsed:s,pivotCell:n,pivotId:r,siblingDomains:n.dimension===`ROW`?c.getRowDomainsAtDepth(l):c.getColumnDomainsAtDepth(l)}}function px(e,t){let n=e.getPivotIdFromPosition(t);if(!n||!e.isExistingPivot(n)||!e.isSpillPivotFormula(t)||!e.getPivot(n).isValid())return!1;let r=e.getPivotCellFromPosition(t);return r.type===`VALUE`||r.type===`MEASURE_HEADER`}function mx(e,t,n){let r=e.model.getters.getPivotIdFromPosition(t),i=e.model.getters.getPivotCellFromPosition(t);if(i.type===`EMPTY`||i.type===`HEADER`||i.type===`ROW_GROUP_NAME`||!r)return;if(n===`none`){e.model.dispatch(`UPDATE_PIVOT`,{pivotId:r,pivot:{...e.model.getters.getPivotCoreDefinition(r),sortedColumn:void 0}});return}let a=tv(e.model.getters.getPivot(r),i.domain).colDomain;e.model.dispatch(`UPDATE_PIVOT`,{pivotId:r,pivot:{...e.model.getters.getPivotCoreDefinition(r),sortedColumn:{domain:a,order:n,measure:i.measure}}})}function hx(e){let t,n,r=[];for(let i of e.model.getters.getSelectedZones()){let a=e.model.getters.getActiveSheetId();for(let o of vr(a,i)){let i=e.model.getters.getPivotIdFromPosition(o);if(!t)t=i;else if(i&&t!==i)return;if(!t)continue;let a=e.model.getters.getPivotCellFromPosition(o);if(a.type!==`HEADER`||!e.model.getters.isSpillPivotFormula(o))continue;let s=a.domain.at(-1)?.field;if(!n&&s)n=s;else if(n&&s&&n!==s)return;r.push(a)}}if(!t||!n||r.length===0)return;let i=e.model.getters.getPivot(t).getFields()[n];if(!i)return;let a=r.map(e=>e.domain.at(-1)?.value).filter(e=>e!==void 0);return{pivotId:t,values:a,field:i}}function gx(e,t,n,r){let i=qy(e,n,r);Gy(t,i);let a={name:Hy(M(`Group`),i),values:t};i.groups.push(a),e.customFields||={},e.customFields[i.name]=i,Ky(e,n.name,i.name)}function _x(e,t){let n=new Set,r=[];for(let i of t){let t=e.groups.find(e=>e.name===i);t?(r.push(t),t.values.forEach(e=>n.add(e))):n.add(i)}if(r.some(e=>e.isOtherGroup))e.groups=e.groups.filter(e=>e.isOtherGroup||!r.includes(e));else if(r.length===0){let n={name:Hy(M(`Group`),e),values:t};e.groups.push(n)}else{let t=r.slice(1);e.groups=e.groups.filter(e=>!t.includes(e)),r[0].values=Array.from(n)}}function vx(e,t,n,r){let i;if(!n.isCustomField)i=qy(e,n,r),i.groups.some(e=>e.isOtherGroup)&&t.some(e=>!i?.groups.some(t=>t.values.includes(e)))&&(i.groups=i.groups.filter(e=>!e.isOtherGroup)),Gy(t,i);else{if(i=(e.customFields||{})[n.name],!i)return;i.groups=i.groups.filter(e=>!t.includes(e.name))}i.groups.every(e=>e.values.length===0&&!e.isOtherGroup)&&(xx(e,i.name),delete e.customFields?.[i.name])}function yx(e,t,n,r){if(n.isCustomField){let r=(e.customFields||{})[n.name];return r?r.groups.some(e=>t.includes(e.name)):!1}else return qy(e,n,r).groups.some(e=>e.isOtherGroup||t.some(t=>e.values.includes(t)))}function bx(e,t,n,r){let i=e.model.getters.getPivot(t),a=e.model.getters.getPivotCoreDefinition(t),o=r.isCustomField?(a.customFields||{})[r.name]:Object.values(a.customFields||{}).find(e=>e.parentField===r.name),s=i.definition.getDimension(r.name);if(!s||!o||yx(a,n,r,i.getFields()))return!1;let c=new Set(i.getPossibleFieldValues(s).map(e=>e.value)),l=r.isCustomField?o.groups.map(e=>e.name):o.groups.flatMap(e=>e.values);for(let e of[...n,...l])c.delete(e);return c.size===0}function xx(e,t){let n=e.customFields?.[t];if(!n)return;let r=[...e.rows,...e.columns].some(e=>e.fieldName===n.parentField);for(let i of[e.rows,e.columns]){let e=i.findIndex(e=>e.fieldName===t);e!==-1&&(r?i.splice(e,1):i.splice(e,1,{fieldName:n.parentField}))}}let Sx=new D;Sx.add(`link`,{condition:(e,t)=>!!t.getEvaluatedCell(e).link,execute:(e,t,n)=>nf(t.model.getters.getEvaluatedCell(e).link,t,n),title:(e,t)=>{let n=t.getEvaluatedCell(e).link;return n?n.isExternal?M(`Go to url: %(url)s`,{url:n.url}):M(`Go to %(label)s`,{label:n.label}):``},sequence:5}),Sx.add(`dashboard_pivot_sorting`,{condition:(e,t)=>{if(!t.isDashboard())return!1;let n=t.getPivotCellFromPosition(e);return px(t,e)&&n.type===`MEASURE_HEADER`},execute:(e,t)=>{mx(t,e,wx(t.model.getters,e))},component:X_,componentProps:(e,t)=>({position:e,sortDirection:t.getPivotCellSortDirection(e)}),sequence:2});let Cx={none:`asc`,asc:`desc`,desc:`none`};function wx(e,t){return Cx[e.getPivotCellSortDirection(t)??`none`]}var Tx=class extends Yr{viewStore=this.get(H);_clickableCells=(0,t.markRaw)({});_registryItems=(0,t.markRaw)(Sx.getAll().sort((e,t)=>e.sequence-t.sequence));handle(e){(Id.has(e.type)||e.type===`EVALUATE_CELLS`||e.type===`UPDATE_CELL`&&(`content`in e||`format`in e))&&(this._clickableCells=(0,t.markRaw)({}),this._registryItems=(0,t.markRaw)(Sx.getAll().sort((e,t)=>e.sequence-t.sequence)))}getClickableItem(e){let{sheetId:t,col:n,row:r}=e,i=this._clickableCells,a=T(n,r);if(i[t]||(i[t]={}),!(a in i[t])){let n=this.findClickableItem(e);i[t][a]=n}return i[t][a]}findClickableItem(e){let t=this.getters;for(let n of this._registryItems)if(n.condition(e,t))return n}get clickableCells(){let e=[],t=this.getters;for(let n of this.viewStore.visibleCellPositions){let r=this.getClickableItem(n);if(!r)continue;let i=typeof r.title==`function`?r.title(n,t):r.title,a=this.getClickableCellRect(n);a&&e.push({coordinates:a,position:n,action:r.execute,title:i||``,component:r.component,componentProps:r.componentProps?.(n,t)??{}})}return e}getClickableCellRect(e){let t=this.getters.expandZone(e.sheetId,E(e)),n=this.viewStore.viewports.getVisibleRect(e.sheetId,t),r=this.getters.getCellIcons(e),i={center:r.find(e=>e.horizontalAlign===`center`),left:r.find(e=>e.horizontalAlign===`left`),right:r.find(e=>e.horizontalAlign===`right`)};if(!i.center?.onClick){if(i.right?.onClick){let r=this.viewStore.viewports.getRect(e.sheetId,t),a=this.getters.getCellIconRect(i.right,r);n.width-=a.width+i.right.margin}if(i.left?.onClick){let r=this.viewStore.viewports.getRect(e.sheetId,t),a=this.getters.getCellIconRect(i.left,r);n.x+=a.width+i.left.margin,n.width-=a.width+i.left.margin}return n}}},Ex=class extends O{static template=`o-spreadsheet-ClickableCellsOverlay`;static components={};clickableCellsStore;setup(){this.clickableCellsStore=k(Tx)}getCellClickableStyle(e){return U({top:`${e.y}px`,left:`${e.x}px`,width:`${e.width}px`,height:`${e.height}px`})}getClickableCells(){return(0,t.toRaw)(this.clickableCellsStore.clickableCells)}selectClickableCell(e,t){if(![0,1].includes(e.button))return;let{position:n,action:r}=t;r(n,this.env,de(e))}},Dx=class extends Yr{mutators=[`clear`,`hover`];col;row;handle(e){switch(e.type){case`ACTIVATE_SHEET`:this.clear()}}hover(e){if(e.col===this.col&&e.row===this.row)return`noStateChange`;this.col=e.col,this.row=e.row}clear(){if(this.col===void 0&&this.row===void 0)return`noStateChange`;this.col=void 0,this.row=void 0}},Ox=class extends O{static template=`o-spreadsheet-ValidationMessages`;props=(0,t.useProps)({messages:j.array(j.string()).optional(),msgType:j.or([j.literal(`warning`),j.literal(`error`),j.literal(`info`)]),slots:j.object().optional()});get divClasses(){return this.props.msgType===`warning`?`o-validation-warning`:this.props.msgType===`info`?`o-validation-info`:`o-validation-error`}},kx=class extends O{static template=`o-spreadsheet-GridAddRowsFooter`;static components={ValidationMessages:Ox};DOMFocusableElementStore;viewStore;inputRef=t.signal.ref(HTMLInputElement);state=(0,t.proxy)({inputValue:`100`,errorFlag:!1});setup(){this.DOMFocusableElementStore=k(M_),this.viewStore=k(H),Wi(window,`click`,this.onExternalClick,{capture:!0})}get addRowsPosition(){let{scrollY:e}=this.viewStore.activeSheetScrollInfo,{y:t,height:n}=this.viewStore.mainViewportRect;return U({top:`${t+n-e-46}px`,height:`46px`})}get errorMessages(){return[M(`Please enter a number between 0 and 10000.`)]}onKeydown(e){e.key.toUpperCase()===`ESCAPE`?this.focusDefaultElement():e.key.toUpperCase()===`ENTER`&&this.onConfirm()}onInput(e){let t=e.target.value;this.state.inputValue=t;let n=Number(t);this.state.errorFlag=Number.isNaN(n)||n<=0||n>1e4}onConfirm(){if(this.state.errorFlag)return;let e=Number(this.state.inputValue),t=this.viewStore.displayedSheetId,n=this.env.model.getters.getNumberRows(t);this.env.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:t,sheetName:this.env.model.getters.getSheetName(t),position:`after`,base:n-1,quantity:e,dimension:`ROW`}),this.focusDefaultElement();let{scrollX:r}=this.viewStore.activeSheetScrollInfo,{end:i}=this.env.model.getters.getRowDimensions(t,n+e-1);this.viewStore.setViewportOffset({offsetX:r,offsetY:i})}onExternalClick(e){let t=this.inputRef();t!==document.activeElement||e.target===t||this.focusDefaultElement()}focusDefaultElement(){document.activeElement===this.inputRef()&&this.DOMFocusableElementStore.focus()}};let Ax=function(e){return e.PlainText=`text/plain`,e.Html=`text/html`,e.Image=`image`,e}({}),jx=[`image/avif`,`image/bmp`,`image/gif`,`image/vnd.microsoft.icon`,`image/jpeg`,`image/png`,`image/tiff`,`image/webp`];function Mx(e,t){let n=new Set(t.map(e=>e.left)),r=new Set(t.map(e=>e.right)),i=new Set(t.map(e=>e.top)),a=new Set(t.map(e=>e.bottom)),o=i.size===1&&a.size===1||n.size===1&&r.size===1?Sr(t):[t[t.length-1]],s=o.map(e=>_r(e)).flat();return{sheetId:e,zones:t,clippedZones:o,columnsIndexes:[...new Set(s.map(e=>e.col))].sort((e,t)=>e-t),rowsIndexes:[...new Set(s.map(e=>e.row))].sort((e,t)=>e-t)}}function Nx(e,t,n){let r=Math.max(e.right-t+1,e.left),i=Math.max(e.bottom-n+1,e.top),a=[];for(let o=e.left;o<=r;o+=t)for(let r=e.top;r<=i;r+=n)a.push({left:o,top:r,bottom:r+n-1,right:o+t-1});return a}function Px(e,t){if(!t.length||!t[0].length)return e;let n=t[0].length,r=t.length;return e.map(e=>Nx(e,n,r)).flat()}function Fx(e){let t;e[`text/html`]&&(t=Lx(new DOMParser().parseFromString(e[`text/html`],`text/html`)));let n=e[`text/plain`]||``,r;if(!n.trim()){for(let t of jx)if(e[t]){r=e[t];break}}return{text:n,data:t,imageBlob:r}}function Ix(e){return e?.match(/<div data-osheet-clipboard-id=(['"])([^'"]+)\1/)?.[2]}function Lx(e){if([...e.documentElement.attributes].some(e=>e.value.includes(`microsoft`)))return;let t=e.querySelector(`div`)?.getAttribute(`data-osheet-clipboard`);return t&&JSON.parse(t)}let Rx=(e,t,n,r)=>{e.forEach(({handlerName:e,handler:i})=>{let a=t[e];a&&i.paste(n,a,r)})};function zx(e,t,n,r,i){let a,o=[],s={sheetId:e,zones:t};for(let{handlerName:c,handler:l}of r){let r=n[c];if(!r)continue;let u=l.getPasteTarget(e,t,r,i);u.figureIds&&(s.figureIds={...s.figureIds,...u.figureIds});for(let e of u.zones){if(o.push(e),a===void 0){a=e;continue}a=or(a,e)}}return{target:s,zone:a,selectedZones:o}}let Bx=(e,t,n)=>{let r={col:t[0].left,row:t[0].top};e.getBackToDefault(),e.selectZone({cell:r,zone:or(...n)},{scrollIntoView:!1})},Vx={figureHandlers:new D,cellHandlers:new D};function Hx(e,t,n){let{x:r,y:i,width:a,height:o}=n;if(a<0||o<0)return;let s=t.color||`#017E84`,{ctx:c}=e;c.save(),t.noBorder||(t.dashed&&c.setLineDash([5,3]),c.strokeStyle=s,t.thinLine?(c.lineWidth=1,c.strokeRect(r,i,a,o)):(c.lineWidth=2,c.strokeRect(r+.5,i+.5,a,o))),t.noFill||(c.fillStyle=qf(jf(s),t.fillAlpha??.12),c.fillRect(r,i,a,o)),c.restore()}var Ux=class extends Yr{mutators=[`register`,`unRegister`];providers=[];constructor(e){super(e),this.onDispose(()=>{this.providers=[]})}get renderingLayers(){return[`Highlights`]}get highlights(){let e=this.getters.getActiveSheetId();return this.providers.flatMap(e=>e.highlights).filter(t=>t.range.sheetId===e).map(e=>{let{numberOfRows:t,numberOfCols:n}=mr(e.range.zone),r=t*n===1?this.getters.expandZone(e.range.sheetId,e.range.zone):e.range.unboundedZone;return{...e,range:this.model.getters.getRangeFromZone(e.range.sheetId,r)}})}register(e){this.providers.push(e)}unRegister(e){this.providers=this.providers.filter(t=>t!==e)}drawLayer(e,t){if(t===`Highlights`)for(let t of this.highlights)Hx(e,t,e.viewports.getVisibleRect(e.sheetId,t.range.zone))}};let Wx=[`cell`,`border`,`table`,`conditionalFormat`,`merge`];var Gx=class extends Yr{mutators=[`activate`,`cancel`,`pasteFormat`];highlightStore=this.get(Ux);status=`inactive`;copiedData;constructor(e){super(e),this.highlightStore.register(this),this.onDispose(()=>{this.highlightStore.unRegister(this)})}handle(e){switch(e.type){case`PAINT_FORMAT`:this.paintFormat(e.sheetId,e.target);break}}activate(e){this.copiedData=this.copyFormats(),this.status=e.persistent?`persistent`:`oneOff`}cancel(){this.status=`inactive`,this.copiedData=void 0}pasteFormat(e){this.model.dispatch(`PAINT_FORMAT`,{target:e,sheetId:this.getters.getActiveSheetId()})}get isActive(){return this.status!==`inactive`}get clipboardHandlers(){return Wx.map(e=>({handlerName:e,handler:new(Vx.cellHandlers.get(e))(this.getters,this.model.dispatch)}))}copyFormats(){let e=this.getters.getActiveSheetId(),t=this.getters.getSelectedZones(),n={zones:t,sheetId:e};for(let{handlerName:r,handler:i}of this.clipboardHandlers){let a=i.copy(Mx(e,t),!1);a!==void 0&&(n[r]=a)}return n}paintFormat(e,t){if(!this.copiedData)return;let n={isCutOperation:!1,pasteOption:`onlyFormat`},{target:r,selectedZones:i}=zx(e,t,this.copiedData,this.clipboardHandlers,n);Rx(this.clipboardHandlers,this.copiedData,r,n),Bx(this.model.selection,t,i),this.status===`oneOff`&&this.cancel()}get highlights(){let e=this.copiedData;return e?e.zones.map(t=>({range:this.model.getters.getRangeFromZone(e.sheetId,t),color:je,dashed:!0,sheetId:e.sheetId,noFill:!0,thinLine:!0,interactive:!1})):[]}};let Kx=new D;var qx=class extends Yr{mutators=[`open`,`close`];persistentPopover;hoveredCell=this.get(Dx);viewStore=this.get(H);handle(e){switch(e.type){case`ACTIVATE_SHEET`:this.close()}}open({col:e,row:t},n){let r=this.viewStore.displayedSheetId;Kx.contains(n)&&(this.persistentPopover={col:e,row:t,sheetId:r,type:n})}close(){if(!this.persistentPopover)return`noStateChange`;this.persistentPopover=void 0}get persistentCellPopover(){return this.persistentPopover&&{isOpen:!0,...this.persistentPopover}||{isOpen:!1}}get isOpen(){return this.persistentPopover!==void 0}get cellPopover(){let e=this.viewStore.displayedSheetId;if(this.persistentPopover&&this.persistentPopover.sheetId===e&&this.viewStore.viewports.isVisibleInViewport(this.persistentPopover)){let e=this.getters.getMainCellPosition(this.persistentPopover),t=Kx.get(this.persistentPopover.type).onOpen?.(e,this.getters);return t?.isOpen?{...t,anchorRect:this.computePopoverAnchorRect(this.persistentPopover)}:{isOpen:!1}}let{col:t,row:n}=this.hoveredCell;if(t===void 0||n===void 0||!this.viewStore.viewports.isVisibleInViewport({sheetId:e,col:t,row:n}))return{isOpen:!1};let r=this.getters.getMainCellPosition({sheetId:e,col:t,row:n}),i=Kx.getAll().map(e=>e.onHover?.(r,this.getters)).find(e=>e?.isOpen);return i?.isOpen?{...i,anchorRect:this.computePopoverAnchorRect(r)}:{isOpen:!1}}computePopoverAnchorRect({col:e,row:t}){let n=this.viewStore.displayedSheetId,r=this.getters.getMerge({sheetId:n,col:e,row:t});return r?this.viewStore.viewports.getVisibleRect(n,r):this.viewStore.viewports.getVisibleRect(n,E({col:e,row:t}))}},Jx=class extends Yr{mutators=[`setHoveredIcon`];hoveredIcon=void 0;setHoveredIcon(e){this.hoveredIcon=e}};function Yx(e,n){let r=k(Dx),i=k(Y_),a=k(H),o={col:void 0,row:void 0},{Date:s}=window,c,l,u=0;function d(){let e=a.displayedSheetId;return c===void 0||l===void 0?{sheetId:e,col:-1,row:-1}:{sheetId:e,col:a.viewports.getColIndex(e,c),row:a.viewports.getRowIndex(e,l)}}function f(e){let t=y(n());return{x:e.clientX-t.x,y:e.clientY-t.y}}let{pause:p,resume:m}=N_(h,200);function h(){let{col:e,row:t}=d(),n=s.now()-u;if(n>300&&(e!==o.col||t!==o.row)&&ne(void 0,void 0),n>300){if(e<0||t<0)return;ne(e,t)}}function g(e){_(n(),e.ev)&&({x:c,y:l}=f(e),u=s.now(),i.hover(d()))}function v(){let{col:e,row:t}=d();(e!==o.col||t!==o.row)&&ne(void 0,void 0)}function ee(t){let r=Sg(e,t),{x:i,y:a}=f(r),o=y(n());return a<0||a>o.height||i<0||i>o.width?g(r):p()}(0,t.useListener)(n,`pointermove`,t=>!e.isMobile()&&g(Sg(e,t))),(0,t.useListener)(n,`mouseleave`,ee),(0,t.useListener)(n,`mouseenter`,m),(0,t.useListener)(n,`pointerdown`,v),(0,t.useListener)(n,`pointerdown`,t=>e.isMobile()&&g(Sg(e,t))),Wi(window,`click`,te);function te(e){let t=e.target,r=n();r&&!r.contains(t)&&ne(void 0,void 0)}function ne(e,t){(e!==o.col||t!==o.row)&&(o.col=e,o.row=t,r.hover({col:e,row:t}))}return o}var Xx=class extends O{static template=`o-spreadsheet-GridOverlay`;static components={GridAddRowsFooter:kx};props=(0,t.useProps)({onCellDoubleClicked:j.function().optional(()=>()=>{}),onCellClicked:j.function().optional(()=>()=>{}),onCellRightClicked:j.function().optional(()=>()=>{}),onGridResized:j.function().optional(()=>()=>{}),gridOverlayDimensions:j.string(),hasFooter:j.boolean().optional(()=>!0)});gridOverlayRef=(0,t.signal)(null);cellPopovers;paintFormatStore;hoveredIconStore;viewStore;setup(){Yx(this.env,this.gridOverlayRef);let e=new ResizeObserver(()=>{this.props.onGridResized()});(0,t.onMounted)(()=>{e.observe(this.gridOverlayEl)}),(0,t.onWillUnmount)(()=>{e.disconnect()}),this.cellPopovers=k(qx),this.paintFormatStore=k(Gx),this.hoveredIconStore=k(Jx),this.viewStore=k(H)}get gridOverlayEl(){let e=this.gridOverlayRef();if(!e)throw Error(`GridOverlay el is not defined.`);return e}get style(){return this.props.gridOverlayDimensions+U({cursor:this.hoveredIconStore.hoveredIcon?`pointer`:`default`})}get isPaintingFormat(){return this.paintFormatStore.isActive}onPointerMove(e){if(this.env.isMobile())return;let t=this.getInteractiveIconAtEvent(Sg(this.env,e)),n=t?.type?{id:t.type,position:t.position}:void 0;w(n,this.hoveredIconStore.hoveredIcon)||this.hoveredIconStore.setHoveredIcon(n)}onPointerDown(e){e.button>0||this.env.isMobile()||this.onCellClicked(Sg(this.env,e))}onClick(e){e.button>0||!this.env.isMobile()||this.onCellClicked(Sg(this.env,e))}onCellClicked(e){let t=this.cellPopovers.persistentCellPopover,[n,r]=this.getCartesianCoordinates(e),i=this.getInteractiveIconAtEvent(e);if(i&&this.env.model.selection.getBackToDefault(),this.props.onCellClicked(n,r,{expandZone:e.ev.shiftKey,addZone:ue(e.ev)},e),i?.onClick&&i.onClick(i.position,this.env),e.ev.target===this.gridOverlayRef()&&this.cellPopovers.isOpen&&w(t,this.cellPopovers.persistentCellPopover)){this.cellPopovers.close();return}}onDoubleClick(e){let t=Sg(this.env,e);if(this.getInteractiveIconAtEvent(t))return;let[n,r]=this.getCartesianCoordinates(t);this.props.onCellDoubleClicked(n,r,e)}onContextMenu(e){let[t,n]=this.getCartesianCoordinates(Sg(this.env,e));this.props.onCellRightClicked(t,n,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){let t=this.viewStore.displayedSheetId;return[this.viewStore.viewports.getColIndex(t,e.offsetX),this.viewStore.viewports.getRowIndex(t,e.offsetY)]}getInteractiveIconAtEvent(e){let t=y(this.gridOverlayRef()),n=this.viewStore.viewports.getGridOffset(),r=e.clientX-t.x+n.x,i=e.clientY-t.y+n.y,[a,o]=this.getCartesianCoordinates(e),s=this.viewStore.displayedSheetId,c={col:a,row:o,sheetId:s},l=this.env.model.getters.getMerge(c);l&&(c={col:l.left,row:l.top,sheetId:s});let u=this.env.model.getters.getCellIcons(c).find(e=>{let t=this.env.model.getters.getMerge(c)||E(c),n=this.viewStore.viewports.getRect(s,t);return B_(r,i,this.env.model.getters.getCellIconRect(e,n))});return u?.onClick?u:void 0}},Zx=class extends O{static template=`o-spreadsheet-GridPopover`;static components={Popover:U_};props=(0,t.useProps)({onClosePopover:j.function(),onMouseWheel:j.function(),gridRect:j.Rect()});cellPopovers;viewStore;setup(){this.cellPopovers=k(qx),this.viewStore=k(H)}get cellPopover(){let e=this.cellPopovers.cellPopover;if(!e.isOpen)return{isOpen:!1};let t=this.viewStore.zoomLevel,n=wg(t,e.anchorRect);return{...e,anchorRect:{...n,x:n.x+this.props.gridRect.x,y:n.y+this.props.gridRect.y}}}};function Qx(e,t){let n=()=>{window.removeEventListener(`pointerup`,r,{capture:!0}),window.removeEventListener(`dragstart`,i),window.removeEventListener(`pointermove`,e),window.removeEventListener(`wheel`,e)},r=e=>{t(e),n()};function i(e){e.preventDefault()}return window.addEventListener(`pointerup`,r,{capture:!0}),window.addEventListener(`dragstart`,i),window.addEventListener(`pointermove`,e),window.addEventListener(`wheel`,e,{passive:!1}),n}let $x={name:`ARROW_DOWN`,width:448,height:512,paths:[{fillColor:`#E06666`,path:`M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z`}]},eS={name:`ARROW_UP`,width:448,height:512,paths:[{fillColor:`#6AA84F`,path:`M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z`}]},tS={name:`ARROW_RIGHT`,width:448,height:512,paths:[{fillColor:`#F0AD4E`,path:`M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z`}]},nS={name:`SMILE`,width:496,height:512,paths:[{fillColor:`#6AA84F`,path:`M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm4 72.6c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.7-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.1-8.4-25.3-7.1-33.8 3.1z`}]},rS={name:`MEH`,width:496,height:512,paths:[{fillColor:`#F0AD4E`,path:`M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm8 144H160c-13.2 0-24 10.8-24 24s10.8 24 24 24h176c13.2 0 24-10.8 24-24s-10.8-24-24-24z`}]},iS={name:`FROWN`,width:496,height:512,paths:[{fillColor:`#E06666`,path:`M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-80 128c-40.2 0-78 17.7-103.8 48.6-8.5 10.2-7.1 25.3 3.1 33.8 10.2 8.4 25.3 7.1 33.8-3.1 16.6-19.9 41-31.4 66.9-31.4s50.3 11.4 66.9 31.4c8.1 9.7 23.1 11.9 33.8 3.1 10.2-8.5 11.5-23.6 3.1-33.8C326 321.7 288.2 304 248 304z`}]},aS=`M256 9 a247 247 0 1 0.1 0 0`,oS={name:`GREEN_DOT`,width:512,height:512,paths:[{fillColor:`#6AA84F`,path:aS}]},sS={name:`YELLOW_DOT`,width:512,height:512,paths:[{fillColor:`#F0AD4E`,path:aS}]},cS={name:`RED_DOT`,width:512,height:512,paths:[{fillColor:`#E06666`,path:aS}]},lS=`M40 160 h320 l-160 160`;function uS(e){return{name:`CARET_DOWN`,width:512,height:512,paths:[{fillColor:e.textColor||`#374151C2`,path:lS}]}}function dS(e){return{name:`CARET_UP`,width:512,height:512,paths:[{fillColor:e.textColor||`#374151C2`,path:`M40 320 h320 l-160 -160`}]}}function fS(e){return{name:`CARET_DOWN`,width:512,height:512,paths:[{fillColor:e.textColor||`#374151C2`,path:`M200 32a200 200 0 1 1 0 400 200 200 0 1 1 0-400`},{fillColor:e.fillColor||`#fff`,path:lS}]}}let pS=e=>({name:`CHECKBOX_UNCHECKED`,width:512,height:512,paths:[{fillColor:e?ze:`#91959d`,path:`M45,45 h422 v422 h-422 v-422 m30,30 v362 h362 v-362`}]}),mS=e=>({name:`CHECKBOX_UNCHECKED`,width:512,height:512,paths:[{fillColor:e?`#82d1d5`:Ve,path:`M45,45 h422 v422 h-422 v-422 m30,30 v362 h362 v-362`}]}),hS=e=>({name:`CHECKBOX_CHECKED`,width:512,height:512,paths:[{fillColor:e?`#82d1d5`:Ve,path:`M45,45 h422 v422 h-422 v-422`},{fillColor:e?`#505050`:`#FFF`,path:`M165,240 l45,45 l135,-135 h60 l-195,195 l-105,-105`}]});function gS(e,t){return{name:`PIVOT_ICON`,width:512,height:512,paths:[{path:`M21,21 h469 v469 h-469`,fillColor:t?Le:`#777`},{path:`M64,64 v384 h384 v-384`,fillColor:t?`#E7E9ED`:`#eee`},{path:e?`M149,235 h213 v43 h-213 M235,149 h43 v213 h-43`:`M149,235 h213 v43 h-213`,fillColor:t?Le:`#777`}]}}function _S(e,t,n){let r=e?`M18.6 3.5H4.29c-.7 0-1.06.85-.56 1.35l6.1 6.1v6.8c0 .26.13.5.34.65l2.64 1.85a.79.79 0 0 0 1.25-.65v-8.64l6.1-6.1a.79.79 0 0 0-.56-1.35`:`M 339.667 681 L 510.333 681 L 510.333 595.667 L 339.667 595.667 L 339.667 681 Z M 41 169 L 41 254.333 L 809 254.333 L 809 169 L 41 169 Z M 169 467.667 L 681 467.667 L 681 382.333 L 169 382.333 L 169 467.667 Z`,i=e?`M0,0 h24 v24 h-24`:`M0,0 h850 v850 h-850`,a={iconColor:Pe,hoverBackgroundColor:Pe};return n&&!t?a.iconColor=`#fff`:!n&&t?a.iconColor=`#defade`:n&&t&&(a.iconColor=Pe,a.hoverBackgroundColor=`#fff`),{name:`DATA_FILTER_ICON`,width:e?24:850,height:e?24:850,paths:[n?{path:i,fillColor:a.hoverBackgroundColor}:void 0,{path:r,fillColor:a.iconColor}].filter(C)}}let vS={arrowGood:{template:`ARROW_UP`,svg:eS},arrowNeutral:{template:`ARROW_RIGHT`,svg:tS},arrowBad:{template:`ARROW_DOWN`,svg:$x},smileyGood:{template:`SMILE`,svg:nS},smileyNeutral:{template:`MEH`,svg:rS},smileyBad:{template:`FROWN`,svg:iS},dotGood:{template:`GREEN_DOT`,svg:oS},dotNeutral:{template:`YELLOW_DOT`,svg:sS},dotBad:{template:`RED_DOT`,svg:cS}},yS={arrows:{good:`arrowGood`,neutral:`arrowNeutral`,bad:`arrowBad`},smiley:{good:`smileyGood`,neutral:`smileyNeutral`,bad:`smileyBad`},dots:{good:`dotGood`,neutral:`dotNeutral`,bad:`dotBad`}},bS={};function xS(e){if(bS[e])return bS[e];let t=new Path2D(e);return bS[e]=t,t}var SS=class{static getters=[];history;constructor(e){this.history=Object.assign(Object.create(e),{update:e.addChange.bind(e,this),selectCell:()=>{}})}exportForExcel(e){}allowDispatch(e){return`Success`}beforeHandle(e){}handle(e){}finalize(){}batchValidations(...e){return t=>e.map(e=>e.call(this,t)).flat()}chainValidations(...e){return t=>{for(let n of e){let e=n.call(this,t);Array.isArray(e)||(e=[e]);let r=e.filter(e=>e!==`Success`);if(r.length)return r}return`Success`}}checkValidations(e,...t){return this.batchValidations(...t)(e)}},CS=class extends SS{getters;constructor({getters:e,stateObserver:t}){super(t),this.getters=e}},wS=class extends CS{static getters=[`getCellFingerprint`];getCellFingerprint(e){let t=this.getters.getCellPosition(e.id);return e.isFormula?this.computeFormulaFingerprint(t,e):this.getLiteralFingerprint(t)}computeFormulaFingerprint(e,t){let n=t.compiledFormula.rangeDependencies,r=e.col,i=e.row,a=this.getters.getSheetIds().indexOf(e.sheetId),o={dx:0,dy:0,dSheet:0};for(let e of n){let t=e.zone,[n,s]=e.parts;o.dSheet=this.getters.getSheetIds().indexOf(e.sheetId)-a;let c=ju(e)&&!e.unboundedZone.hasHeader,l=Au(e)&&!e.unboundedZone.hasHeader,u=c||n?.colFixed?0:r,d=l||n?.rowFixed?0:i,f=!s&&n?.colFixed||s?.colFixed,p=!s&&n?.rowFixed||s?.rowFixed,m=e.unboundedZone.right===void 0,h=e.unboundedZone.bottom===void 0,g=m||f?0:r,_=h||p?0:i,v=yr({top:t.top-d,left:t.left-u,right:t.right-g,bottom:t.bottom-_});for(let e=v.top;e<=v.bottom;e++)for(let t=v.left;t<=v.right;t++)o.dx+=t,o.dy+=e}let s=t.compiledFormula.normalizedFormula;return TS(o)+s}getLiteralFingerprint(e){switch(this.getters.getEvaluatedCell(e).type){case`number`:case`boolean`:return ES;case`text`:case`empty`:case`error`:return}}};function TS(e){return Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>t).join(`,`)}let ES=`DATA_FINGERPRINT`;var DS=class extends Yr{mutators=[`enable`,`disable`];isInvalidated=!1;fingerprintColors={[ES]:`#D9D9D9`};isEnabled=!1;colors=new J_;handle(e){switch(Gd(e)&&this.isEnabled&&(this.isInvalidated=!0),e.type){case`UNDO`:case`REDO`:case`ACTIVATE_SHEET`:this.isEnabled&&(this.isInvalidated=!0);break}}finalize(){this.isInvalidated&&(this.isInvalidated=!1,this.computeFingerprints())}enable(){this.isEnabled=!0,this.computeFingerprints()}disable(){this.isEnabled=!1,this.colors=new J_}computeFingerprints(){this.colors=new J_;let e=new J_,t=new Set,n=this.getters.getActiveSheetId(),r=this.getters.getCells(n);for(let n in r){let i=r[n],a=this.getters.getCellFingerprint(i);if(!a)continue;t.add(a);let o=this.getters.getCellPosition(i.id);e.set(o,a)}this.assignColors(t);for(let[t,n]of e.entries()){let e=this.fingerprintColors[n];this.colors.set(t,e),this.colorSpreadZone(t,e)}}colorSpreadZone(e,t){let n=this.getters.getSpreadZone(e);if(!n)return;let r=e.sheetId;for(let e=n.top;e<=n.bottom;e++)for(let i=n.left;i<=n.right;i++){let n={sheetId:r,col:i,row:e};this.colors.set(n,t)}}assignColors(e){let t=new pp(e.size);Object.keys(this.fingerprintColors).forEach(()=>t.next());for(let n of e)this.fingerprintColors[n]||(this.fingerprintColors[n]=qf(t.next(),.8))}},OS=class extends Ur{renderer;fingerprints;hoveredTables;hoveredIcon;lastRenderSheetId=void 0;lastRenderBoxes=new Map;preventNewAnimationsInNextFrame=!1;zonesWithPreventedAnimationsInNextFrame={};animations=new Map;getters;constructor(e,t=e(Jr)){super(e),this.renderer=t;let n=e(Wr);this.getters=n.getters,this.fingerprints=e(DS),this.hoveredTables=e(Y_),this.hoveredIcon=e(Jx),n.on(`command-dispatched`,this,this.handle),n.on(`command-finalized`,this,this.finalize),this.renderer.register(this),this.onDispose(()=>{n.off(`command-dispatched`,this),n.off(`command-finalized`,this),this.renderer.unRegister(this)})}handle(e){switch(e.type){case`START`:case`ACTIVATE_SHEET`:case`ADD_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:this.animations.clear(),this.preventNewAnimationsInNextFrame=!0;break;case`RESIZE_COLUMNS_ROWS`:this.preventNewAnimationsInNextFrame=!0;break;case`REDO`:this.zonesWithPreventedAnimationsInNextFrame={};break;case`UNDO`:for(let t of e.commands)if(t.type===`ADD_COLUMNS_ROWS`||t.type===`REMOVE_COLUMNS_ROWS`||t.type===`RESIZE_COLUMNS_ROWS`){this.animations.clear(),this.preventNewAnimationsInNextFrame=!0;break}break;case`PASTE`:this.preventNewAnimationsInNextFrame=!0;break;case`UPDATE_CELL`:let t=this.getters.getCommandZones(e);this.zonesWithPreventedAnimationsInNextFrame[e.sheetId]||(this.zonesWithPreventedAnimationsInNextFrame[e.sheetId]=[]),this.zonesWithPreventedAnimationsInNextFrame[e.sheetId].push(...t);break}}finalize(){for(let e in this.zonesWithPreventedAnimationsInNextFrame)this.zonesWithPreventedAnimationsInNextFrame[e]=zn(this.zonesWithPreventedAnimationsInNextFrame[e])}get renderingLayers(){return[`Background`,`Headers`]}drawLayer(e,t,n){switch(t){case`Background`:this.drawGlobalBackground(e);let t=e.sheetId===this.lastRenderSheetId?this.lastRenderBoxes:new Map;this.lastRenderSheetId=e.sheetId,this.lastRenderBoxes=new Map;let{sheetId:r,viewports:i}=e;for(let{zone:a,rect:o}of i.getAllSheetViewportsZonesAndRect(r)){let{ctx:s}=e;s.save(),s.beginPath(),s.rect(o.x,o.y,o.width,o.height),s.clip();let c=this.getGridBoxes(i,r,a),l=this.getBoxesWithAnimations(c,t,n);this.drawBackground(e,l),this.drawOverflowingCellBackground(e,l),this.drawCellBackground(e,l),this.drawBorders(e,l),this.drawTexts(e,l),this.drawIcon(e,l),s.restore()}this.drawFrozenPanes(e),this.preventNewAnimationsInNextFrame=!1,this.zonesWithPreventedAnimationsInNextFrame={};break;case`Headers`:this.drawHeaders(e),this.drawFrozenPanesHeaders(e);break}}drawGlobalBackground(e){let{ctx:t,viewports:n}=e,{width:r,height:i}=n.getSheetViewDimensionWithHeaders();t.fillStyle=this.getBackgroundColor(e),t.fillRect(0,0,r+ke,i+ke)}drawBackground(e,t){let{ctx:n,thinLineWidth:r}=e,i=!e.hideGridLines&&this.getters.getGridLinesVisibility(e.sheetId),a=i?.1*r:0;if(i){let i=this.getters.getSpreadsheetTheme(),o=this.getBackgroundColor(e);n.strokeStyle=qf(Wf(i.gridBorderColor+`aa`,o+`50`),1),n.lineWidth=r;for(let e of t)e.style.hideGridLines||n.strokeRect(e.x+a,e.y+a,e.width-2*a,e.height-2*a)}}drawCellBackground(e,t){let{ctx:n}=e;for(let r of t){let t=r.style;if(t.fillColor&&jf(t.fillColor)!==jf(this.getBackgroundColor(e))&&(n.fillStyle=jf(t.fillColor),n.fillRect(r.x-ke,r.y-ke,r.width+ke*2,r.height+ke*2)),r.dataBarFill){n.fillStyle=r.dataBarFill.color;let e=r.dataBarFill.percentage,t=r.width*(e/100);n.fillRect(r.x,r.y,t,r.height)}if(r.overlayColor&&(n.fillStyle=Wf(t.fillColor||this.getBackgroundColor(e),r.overlayColor),n.fillRect(r.x-ke,r.y-ke,r.width+ke*2,r.height+ke*2)),r?.chip){n.save(),n.beginPath(),n.rect(r.x,r.y,r.width,r.height),n.clip();let e=r.chip;n.fillStyle=r.overlayColor?Wf(e.color,r.overlayColor):e.color,n.beginPath(),n.roundRect(e.x,e.y,e.width,e.height,10),n.fill(),n.restore()}r.isError&&(n.fillStyle=`red`,n.beginPath(),n.moveTo(r.x+r.width-5,r.y),n.lineTo(r.x+r.width,r.y),n.lineTo(r.x+r.width,r.y+5),n.fill())}}drawOverflowingCellBackground(e,t){let{ctx:n,thinLineWidth:r}=e;for(let i of t)if(i.content&&i.isOverflow){let t=i.content.align||`left`,a,o,s=i.y+r/2,c=i.height-r,l=Math.min(i.clipRect?.width||1/0,i.content.width);t===`left`?(a=i.x+r/2,o=l-2*r):t===`right`?(a=i.x+i.width-r/2,o=-l+2*r):(a=(i.clipRect?.x||i.x+i.width/2-i.content.width/2)+r/2,o=l-2*r),n.fillStyle=this.getBackgroundColor(e),n.fillRect(a,s,o,c)}}drawBorders(e,t){let{ctx:n}=e;for(let e of t){let t=e.border;if(t){let{x:n,y:i,width:a,height:o}=e;t.left&&r(t.left,n,i,n,i+o),t.top&&r(t.top,n,i,n+a,i),t.right&&r(t.right,n+a,i,n+a,i+o),t.bottom&&r(t.bottom,n,i+o,n+a,i+o)}}function r({color:e,style:t,opacity:r},i,a,o,s){switch(n.globalAlpha=r??1,n.strokeStyle=e,t){case`medium`:n.lineWidth=2,i+=a===s?-.5:.5,o+=a===s?1.5:.5,a+=i===o?-.5:.5,s+=i===o?1.5:.5;break;case`thick`:n.lineWidth=3,a===s&&(i--,o++),i===o&&(a--,s++);break;case`dashed`:n.lineWidth=1,n.setLineDash([1,3]);break;case`dotted`:n.lineWidth=1,a===s&&(i+=.5,o+=.5),i===o&&(a+=.5,s+=.5),n.setLineDash([1,1]);break;default:n.lineWidth=1;break}n.beginPath(),n.moveTo(i,a),n.lineTo(o,s),n.stroke(),n.lineWidth=1,n.setLineDash([]),n.globalAlpha=1}}drawTexts(e,t){let{ctx:n}=e;n.textBaseline=`top`;let r;for(let e of t)if(e.content){n.globalAlpha=e.textOpacity??1;let t=e.content.align||`left`,i=e.chip?0:e.style.rotation,a={...e.style,align:t,rotation:i},o=Mp(a);if(o!==r&&(r=o,n.font=o),n.fillStyle=a.textColor||`#000`,n.textAlign=t,e.clipRect){n.save(),n.beginPath();let{x:t,y:r,width:i,height:a}=e.clipRect;n.rect(t,r,i,a),n.clip()}let s=e.content.x,c=e.content.y;a.rotation&&(n.save(),n.rotate(a.rotation),{x:s,y:c}=Up(e.content,a));for(let t of e.content.textLines)Vp(n,t,{x:s,y:c},a.underline,a.strikethrough),c+=4+e.content.fontSizePx;a.rotation&&n.restore(),e.clipRect&&n.restore(),n.globalAlpha=1}}drawIcon(e,t){let{ctx:n}=e;for(let e of t)for(let t of Object.values(e.icons)){if(!t)continue;let r=w({id:t.type,position:t.position},this.hoveredIcon.hoveredIcon)&&t.hoverSvg||t.svg;if(!r)continue;n.save(),n.globalAlpha=t.opacity??1,n.beginPath();let i=t.clipRect||e;n.rect(i.x,i.y,i.width,i.height),n.clip();let a=t.size,{x:o,y:s}=this.getters.getCellIconRect(t,e);n.translate(o,s),n.scale(a/r.width,a/r.height);for(let e of r.paths)n.fillStyle=e.fillColor,n.fill(xS(e.path));n.restore()}}drawHeaders(e){let{ctx:t,thinLineWidth:n,viewports:r,sheetId:i}=e,a=r.getSheetViewVisibleCols(i),o=a[0],s=r.getSheetViewVisibleRows(i),c=s[0],{width:l,height:u}=r.getSheetViewDimensionWithHeaders(),d=e.selectedZones,f=Mr(d),p=Pr(d),m=this.getters.getNumberCols(i),h=this.getters.getNumberRows(i),g=e.activeCols,_=e.activeRows,v=this.getters.getSpreadsheetTheme();t.font=`400 11px ${Qe}`,t.textAlign=`center`,t.textBaseline=`middle`,t.lineWidth=n,t.strokeStyle=v.headerTextColor,t.fillStyle=this.getters.getSpreadsheetTheme().backgroundColor,t.fillRect(0,0,48,u),t.fillRect(0,0,l,26);for(let e of a){let n={left:e,right:e,top:0,bottom:h-1},{x:a,width:o}=r.getVisibleRect(i,n),s=g.has(e),c=f.has(e);s?t.fillStyle=v.headerActiveBackgroundColor:c?t.fillStyle=v.headerSelectedBackgroundColor:t.fillStyle=v.headerBackgroundColor,t.fillRect(a,0,o,26)}for(let e of s){let n={top:e,bottom:e,left:0,right:m-1},{y:a,height:o}=r.getVisibleRect(i,n),s=_.has(e),c=p.has(e);s?t.fillStyle=v.headerActiveBackgroundColor:c?t.fillStyle=v.headerSelectedBackgroundColor:t.fillStyle=v.headerBackgroundColor,t.fillRect(0,a,48,o)}t.beginPath(),t.moveTo(48,0),t.lineTo(48,u),t.moveTo(0,26),t.lineTo(l,26),t.strokeStyle=v.headerBorderColor,t.stroke();for(let e of a){let n=kn(e);t.fillStyle=g.has(e)?`#fff`:v.headerTextColor;let a={left:e,right:e,top:c,bottom:c},{x:o,width:s}=r.getRect(i,a),{x:l,width:u}=r.getVisibleRect(i,a);t.save(),t.beginPath(),t.rect(l,0,u,26),t.clip(),t.fillText(n,o+s/2,26/2),t.restore(),t.beginPath(),t.moveTo(o+s,0),t.lineTo(o+s,26),t.stroke()}for(let e of s){t.fillStyle=_.has(e)?`#fff`:v.headerTextColor;let n={top:e,bottom:e,left:o,right:o},{y:a,height:s}=r.getRect(i,n),{y:c,height:l}=r.getVisibleRect(i,n);t.save(),t.beginPath(),t.rect(0,c,48,l),t.clip(),t.fillText(String(e+1),48/2,a+s/2),t.restore(),t.beginPath(),t.moveTo(0,a+s),t.lineTo(48,a+s),t.stroke()}}drawFrozenPanesHeaders(e){let{ctx:t,thinLineWidth:n,sheetId:r,viewports:i}=e,{paneWidth:a,paneHeight:o}=i.getPanesDimensions(r),s=i.getGridOffsetX(),c=i.getGridOffsetY();t.lineWidth=6*n,t.strokeStyle=this.getters.getSpreadsheetTheme().frozenPaneHeaderBorderColor,t.beginPath(),a&&(t.moveTo(s+a,0),t.lineTo(s+a,c)),o&&(t.moveTo(0,c+o),t.lineTo(s,c+o)),t.stroke()}drawFrozenPanes(e){if(e.hideFrozenPaneBorder)return;let{ctx:t,thinLineWidth:n,sheetId:r,viewports:i}=e,{x:a,y:o}=i.getMainViewportCoordinates(r),s=i.getSheetViewVisibleCols(r),c=s[0],l=s[s.length-1],u=i.getSheetViewVisibleRows(r),d={left:c,right:l,top:u[0],bottom:u[u.length-1]},f=e.viewports.getVisibleRect(e.sheetId,d),p=i.getGridOffsetX(),m=i.getGridOffsetY();t.lineWidth=6*n,t.strokeStyle=this.getters.getSpreadsheetTheme().frozenPaneBorderColor,t.beginPath(),a&&(t.moveTo(p+a,m),t.lineTo(p+a,f.height+m)),o&&(t.moveTo(p,m+o),t.lineTo(f.width+p,m+o)),t.stroke()}findNextEmptyCol(e,t,n,r){let i=t;for(;i<n;){let t={sheetId:e,col:i+1,row:r},n=this.getters.getEvaluatedCell(t),a=this.getters.getCellComputedBorder(t),o=this.getters.doesCellHaveGridIcon(t);if(n.type!==`empty`||this.getters.isInMerge(t)||a?.left||o)return i;i++}return i}findPreviousEmptyCol(e,t,n,r){let i=t;for(;i>n;){let t={sheetId:e,col:i-1,row:r},n=this.getters.getEvaluatedCell(t),a=this.getters.getCellComputedBorder(t),o=this.getters.doesCellHaveGridIcon(t);if(n.type!==`empty`||this.getters.isInMerge(t)||a?.right||o)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!n&&Gc(r.value,r.format)?`left`:t&&r.type===`number`?n===`center`?n:`left`:!n||n==="default"?r.defaultAlign:n}createZoneBox(e,t,n,r){let{left:i,right:a}=r,o=n.left,s=n.top,c={sheetId:t,col:o,row:s},l=this.getters.getEvaluatedCell(c),u=this.getters.shouldShowFormulas(),{x:d,y:f,width:p,height:m}=e.getRect(t,n),h=this.getters.getDataValidationChipStyle(c),g=this.getters.getCellComputedStyle(c);if(this.fingerprints.isEnabled){let e=this.fingerprints.colors.get(c);g={...g,fillColor:e}}h?.textColor&&(g={...g,textColor:h.textColor});let _=this.fingerprints.isEnabled?void 0:this.getters.getConditionalDataBar(c),v=this.getters.getCellIcons(c),ee={left:v.find(e=>e?.horizontalAlign===`left`),right:v.find(e=>e?.horizontalAlign===`right`),center:v.find(e=>e?.horizontalAlign===`center`)},y={id:tr(n),x:d,y:f,width:p,height:m,border:this.getters.getCellComputedBorder(c)||void 0,style:g,dataBarFill:_,overlayColor:this.hoveredTables.overlayColors.get(c),isError:l.type===`error`&&!!l.message||this.getters.isDataValidationInvalid(c),icons:ee,disabledAnimation:this.zonesWithPreventedAnimationsInNextFrame[t]?.some(e=>pr(n,e)||ur(n,e))},te=Np(y.style);if(l.type===`empty`||y.icons.center)return y;let ne=g.wrapping||`overflow`,re=ne===`wrap`&&!u,ie=p-8,ae=g.align?0:ie,oe=re?ie:void 0,se=this.getters.getCellMultiLineText(c,{maxWidth:ae,wrapWidth:oe}),ce={...g,align:`left`,rotation:0},le=Math.max(...se.map(e=>this.getters.getTextWidth(e,ce)))+4,ue=this.getters.getMultilineTextSize(se,g),de=h?5:0,fe=(y.icons.left?y.icons.left.size+y.icons.left.margin:0)+de,pe=(y.icons.right?y.icons.right.size+y.icons.right.margin:0)+de,me=fe+ue.width+pe+4,he=this.computeCellAlignment(c,me>p),ge=se.length,_e=Math.round(this.getters.computeTextYCoordinate(y,te,g.verticalAlign,ge)),ve=y.x;he===`left`?ve+=4+fe:he===`right`?ve+=y.width-4-pe:ve+=y.width/2,ve=Math.round(ve);let ye=bp(te,ge);if(y.content={textLines:se,width:ne===`overflow`?le:p,textHeight:ye,textWidth:le,align:he,x:ve,y:_e,fontSizePx:te},h?.fillColor){let e=fe;y.chip={color:h.fillColor,width:y.width-e-5,height:ye+2,x:y.x+e,y:_e-2}}let be=me>p||ue.height>m;if(y.icons.left||y.icons.right||y.chip)y.clipRect={x:y.x+fe,y:y.y,width:Math.max(0,p-fe-pe),height:m};else if(be&&ne===`overflow`){let r,l;switch(this.getters.isInMerge(c)?(r=this.getters.getMerge(c).right,l=o):(r=y.border?.right?n.right:this.findNextEmptyCol(t,o,a,s),l=y.border?.left?n.left:this.findPreviousEmptyCol(t,o,i,s),y.isOverflow=!0),he){case`left`:{let i=E({col:r,row:s}),{x:a,y:o,width:c,height:l}=e.getVisibleRect(t,or(n,i));(c<me||te>l||se.length>1)&&(y.clipRect={x:a,y:o,width:c,height:l});break}case`right`:{let r=E({col:l,row:s}),{x:i,y:a,width:o,height:c}=e.getVisibleRect(t,or(n,r));(o<me||te>c||se.length>1)&&(y.clipRect={x:i,y:a,width:o,height:c});break}case`center`:{let i={...n,left:l,right:r},{x:a,y:o,height:s,width:c}=e.getVisibleRect(t,i),u=me/2,d=y.x+y.width/2;if(a+c<d+u||a>d-u||te>s||se.length>1){let e=a>d-u?a:d-u;y.clipRect={x:e,y:o,width:a+c-e,height:s}}break}}}else(ne===`clip`||ne===`wrap`||se.length>1)&&(y.clipRect={x:y.x,y:y.y,width:p,height:m});return y}getGridBoxes(e,t,n){let r=[],i=e.getSheetViewVisibleCols(t).filter(e=>e>=n.left&&e<=n.right),a=i[0],o=i[i.length-1],s=e.getSheetViewVisibleRows(t).filter(e=>e>=n.top&&e<=n.bottom),c={left:a,right:o,top:s[0],bottom:s[s.length-1]};for(let n of s)for(let a of i){let i={sheetId:t,col:a,row:n};this.getters.isInMerge(i)||r.push(this.createZoneBox(e,t,E(i),c))}for(let n of this.getters.getMerges(t))if(!this.getters.isMergeHidden(t,n)&&ur(n,c)){let i=this.createZoneBox(e,t,n,c),a=this.getters.getCellComputedBorder({sheetId:t,col:n.right,row:n.bottom});i.border={...i.border,bottom:a?a.bottom:void 0,right:a?a.right:void 0},i.isMerge=!0,r.push(i)}return r}getBoxesWithAnimations(e,t,n){return this.updateAnimationsProgress(n),this.addNewAnimations(e,t,n),this.animations.size>0?(this.renderer.startAnimation(`grid_renderer_animation`),this.updateBoxesWithAnimations(e)):(this.renderer.stopAnimation(`grid_renderer_animation`),e)}updateBoxesWithAnimations(e){let t=[];for(let n of e){let e=this.animations.get(n.id);if(!e){t.push(n);continue}let r=b(n);t.push(r);for(let i of e.animationTypes){let a=C_.get(i).updateAnimation(e.progress,r,e.oldBox,n);a&&t.push(...a.newBoxes)}}return t}updateAnimationsProgress(e){if(e!==void 0)for(let t of this.animations.keys()){let n=this.animations.get(t);if(n.startTime===void 0){n.startTime=e;continue}let r=e-n.startTime,i=Math.min(1,r/200);i>=1&&this.animations.delete(t),n.progress=i}}addNewAnimations(e,t,n){for(let r of e){this.lastRenderBoxes.set(r.id,r);let e=t.get(r.id);if(this.preventNewAnimationsInNextFrame||!e||r.disabledAnimation)continue;let i=[];for(let t of C_.getAll())t.hasAnimation(e,r)&&i.push(t.id);let a=i.length>0?{animationTypes:i,oldBox:e,progress:0,startTime:n}:void 0;a&&this.animations.set(r.id,a)}}getBackgroundColor(e){return this.getters.getSheet(e.sheetId).backgroundColor||this.getters.getSpreadsheetTheme().backgroundColor}};function kS({canvasRef:e,renderingCtx:t,rendererStore:n,changeCanvasSizeOnZoom:r}){Gi(a);let i=n||k(Jr);ra(OS,i);function a(){let n=e(),a=n.getContext(`2d`,{alpha:!1}),o={ctx:a,thinLineWidth:.4,...t()},s=o.dpr,c=o.viewports.getZoomLevel();r||(c=Math.max(c,1));let{width:l,height:u}=o.viewports.getSheetViewDimensionWithHeaders();n.width=l*s*c,n.height=u*s*c;let d=U({width:r?`${l*c}px`:`${l}px`,height:r?`${u*c}px`:`${u}px`});n.setAttribute(`style`,d),!(l===0||u===0)&&(a.translate(-.5,-.5),a.scale(s*c,s*c),i.draw(o))}}function AS(e){function t(e,t){return e*(t===0?1:23)}return n=>{e(t(n.shiftKey&&!le()?n.deltaY:n.deltaX,n.deltaMode),t(n.shiftKey&&!le()?n.deltaX:n.deltaY,n.deltaMode),n)}}var jS=class{direction;el;constructor(e,t){this.el=e,this.direction=t}get scroll(){return this.direction===`horizontal`?this.el.scrollLeft:this.el.scrollTop}set scroll(e){this.direction===`horizontal`?this.el.scrollLeft=e:this.el.scrollTop=e}},MS=class extends O{static template=t.xml`
|
|
28
28
|
<div
|
|
29
29
|
t-attf-class="o-scrollbar {{this.props.direction}}"
|
|
30
30
|
t-on-scroll="this.onScroll"
|
|
@@ -40,7 +40,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
40
40
|
offset="this.offset"
|
|
41
41
|
direction="'vertical'"
|
|
42
42
|
onScroll.bind="(offset) => this.onScroll(offset)"
|
|
43
|
-
/>`;setup(){this.viewStore=k(H)}props=(0,t.useProps)({topOffset:j.number().optional(0),hasFooter:j.boolean().optional(!0)});get offset(){return this.viewStore.viewports.getSheetScrollInfo(this.viewStore.displayedSheetId).scrollY}get height(){return this.viewStore.viewports.getMainViewportRect(this.viewStore.displayedSheetId).height}get isDisplayed(){let{yRatio:e}=this.viewStore.viewports.getFrozenSheetViewRatio(this.viewStore.displayedSheetId);return e<1}get position(){let{y:e}=this.viewStore.viewports.getMainViewportRect(this.viewStore.displayedSheetId),t=this.viewStore.viewports.getScrollBarWidth();return{top:`${this.props.topOffset+e}px`,right:`0px`,width:`${t}px`,bottom:this.props.hasFooter?`${t}px`:`0px`}}onScroll(e){let{scrollX:t}=this.viewStore.viewports.getSheetScrollInfo(this.viewStore.displayedSheetId);this.viewStore.setViewportOffset({offsetX:t,offsetY:e})}},PS=class extends Yr{mutators=[`setContainerSize`,`setRange`,`resizeColumn`,`setCustomColWeights`];cachedColDimensions=void 0;containerWidth=0;containerHeight=0;range;customColWeights=void 0;viewStore=this.get(H);constructor(e,t,n){super(e),this.range=t,this.customColWeights=n,this.viewStore.setDisplayedSheetId(this.range.sheetId),this.viewStore.setViewportArgs({getHeaderDimensions:this.getHeaderDimensions.bind(this),zoneToDisplay:this.range.zone,getFooterSize:()=>0})}handle(e){this.cachedColDimensions=void 0}setContainerSize(e,t){if(this.containerWidth!==e||this.containerHeight!==t){this.containerWidth=e,this.containerHeight=t,this.cachedColDimensions=void 0,this.viewStore.resizeSheetView({width:e,height:t});return}return`noStateChange`}setRange(e){if(w(this.range,e))return`noStateChange`;this.range=e,this.cachedColDimensions=void 0,this.viewStore.setDisplayedSheetId(this.range.sheetId),this.viewStore.setViewportArgs({zoneToDisplay:this.range.zone})}setCustomColWeights(e){if(w(this.customColWeights,e))return`noStateChange`;this.changeColumnWeights(e)}resizeColumn(e,t,n){let r={};for(let e=0;e<n.length;e++)r[this.range.zone.left+e]=n[e];let i=Dn(n)/20,a=S(e+1,this.range.zone.right+1).filter(e=>r[e]),o=Dn(a.map(e=>r[e])),s={...r};t=Math.max(r[e]+t,i)-r[e];let c=Math.max(o-i*a.length,0);if(t>c&&(t=c),s[e]=r[e]+t,c>0&&t>0)for(let e of a){let n=(r[e]-i)/c*t;s[e]=Math.max(r[e]-n,i)}else if(t<0)for(let e of a){let n=r[e]/o*t;s[e]=Math.max(r[e]-n,i)}let l=S(this.range.zone.left,this.range.zone.right+1).map(e=>s[e]||0),u=this.normalizeWeights(l);this.changeColumnWeights(u)}changeColumnWeights(e){this.customColWeights=e,this.cachedColDimensions=void 0,this.viewStore.rebuildViewports()}get renderingContext(){let{sheetId:e}=this.range;return{sheetId:e,viewports:this.viewStore.viewports,hideGridLines:this.getters.isDashboard(),dpr:1,selectedZones:[],activeCols:new Set,activeRows:new Set,activePosition:void 0}}get headerDimensionsCallback(){return this.getHeaderDimensions.bind(this)}getHeaderDimensions(e,t,n){if(t===`ROW`)return this.getters.getRowDimensions(e,n);this.cachedColDimensions===void 0&&(this.cachedColDimensions=this.computeColDimensions());let r=this.range.zone;if(n>=r.left&&n<=r.right)return this.cachedColDimensions[n];if(n>r.right){let e=this.cachedColDimensions[r.right];return{start:e.end,size:0,end:e.end}}else return{start:0,size:0,end:this.cachedColDimensions[r.left].start}}get columnWeights(){let e=this.range.zone.right-this.range.zone.left+1,t=this.customColWeights;if(t&&t.length===e)return t;let{sheetId:n,zone:r}=this.range;if(!this.getters.tryGetSheet(n)||!$n(r))return Array(e).fill(1);let i=[];for(let e of S(r.left,r.right+1)){if(this.getters.isColHidden(n,e)){i.push(0);continue}let t={...this.range.zone,left:e,right:e},r=Math.floor(this.getters.getZoneMaxWidth(n,t));i.push(Math.max(96,r))}return this.normalizeWeights(i)}computeColDimensions(){let{zone:e}=this.range,t=S(e.left,e.right+1),n=this.columnWeights,r=Dn(n),i={},a=0;for(let o of t){let t=n[o-e.left],s=Math.floor(t/r*this.containerWidth);i[o]={start:a,size:s,end:a+s},a+=s}let o=t[t.length-1];return o!==void 0&&(i[o].size+=this.containerWidth-a,i[o].end=i[o].start+i[o].size),i}normalizeWeights(e){let t=Dn(e);if(t===0)return e;let n=0,r=[];for(let i=0;i<e.length;i++)r.push(Math.floor(e[i]/t*1e3)),n+=r[i];return r}},FS=class extends O{static template=`o-spreadsheet-StandaloneViewport`;static components={VerticalScrollBar:NS,GridOverlay:Xx,ClickableCellsOverlay:Ex,GridPopover:Zx};props=(0,t.useProps)({range:j.Range(),canResizeColumns:j.boolean().optional(!0),onResizeColumns:j.function().optional(),columnWeights:j.array().optional(),zoomLevel:j.number()});canvasRef=(0,t.signal)(null);containerRef=(0,t.signal)(null);store;dndState=(0,t.proxy)({col:void 0});onMouseWheel;rendererStore;viewStore;cellPopoverStore;setup(){na([H,Jx,Y_,Tx,Dx,qx]),this.store=ra(PS,this.props.range,this.props.columnWeights),this.viewStore=k(H),this.cellPopoverStore=k(qx),this.rendererStore=ra(Jr,[`Background`,`Chart`]);let e=new ResizeObserver(()=>{this.store.setContainerSize(this.containerWidth,this.containerHeight)});(0,t.useEffect)(()=>{let t=this.containerRef();return t&&e.observe(t),()=>e.disconnect()}),(0,t.useEffect)(()=>{this.store.setRange(this.props.range),this.dndState.col===void 0&&this.store.setCustomColWeights(this.props.columnWeights),this.viewStore.setZoom(this.props.zoomLevel),this.store.setContainerSize(this.containerWidth,this.containerHeight)}),kS({canvasRef:this.canvasRef,renderingCtx:()=>this.store.renderingContext,rendererStore:this.rendererStore}),this.onMouseWheel=AS((e,t,n)=>{if(this.hasVerticalScrollBar){n.stopPropagation(),n.preventDefault();let r=this.viewStore.activeSheetScrollInfo;this.viewStore.setViewportOffset({offsetX:r.scrollX+e,offsetY:r.scrollY+t})}})}get containerWidth(){return Math.floor(y(this.containerRef()).width/this.viewStore.zoomLevel)}get containerHeight(){return Math.floor(y(this.containerRef()).height/this.viewStore.zoomLevel)}get hasVerticalScrollBar(){return this.containerHeight&&this.viewStore.mainViewportCoordinates.y+this.viewStore.mainViewportRect.height>this.containerHeight}get scrollBarContainerStyle(){return U({width:`${this.viewStore.scrollBarWidth}px`})}onCellDoubleClicked(e,t,n){if(!this.env.model.getters.isDashboard()){n.stopPropagation();let r=this.env.model.getters.getActiveSheetId();this.props.range.sheetId!==r&&this.env.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:r,sheetIdTo:this.props.range.sheetId}),this.env.model.selection.selectCell(e,t);return}}get gridOverlayDimensions(){let{sheetId:e,zone:t}=this.props.range,n=this.viewStore.viewports.getVisibleRect(e,t);return U({height:`${n.height}px`,width:`${n.width}px`})}get colResizers(){let e=[],t=this.props.range.zone,n=this.props.range.sheetId;for(let r=t.left;r<t.right;r++){if(this.env.model.getters.isColHidden(n,r))continue;let t=U({left:`${this.viewStore.viewports.getColDimensionsInViewport(n,r).end}px`});e.push({style:t,col:r})}return e}onResizerPointerDown(e,t){if(e.button!==0)return;this.dndState.col=t.col;let n=Sg(this.env,e).clientX,r=this.store.columnWeights,i=Dn(r),a=0;Qx(e=>{a=Sg(this.env,e).clientX-n;let o=a/this.containerWidth*i;this.store.resizeColumn(t.col,o,r)},e=>{this.dndState.col=void 0,a&&this.props.onResizeColumns?.(this.store.columnWeights)})}onResizerDoubleClick(){this.props.onResizeColumns?.(void 0)}getGridRect(){return{...y(this.containerRef()),...this.viewStore.sheetViewDimensionWithHeaders}}},IS=class extends O{static template=`o-spreadsheet-Select`;static components={Popover:U_};props=(0,t.useProps)({onChange:j.function(),values:j.array(),selectedValue:j.string().optional(),class:j.string().optional(),popoverClass:j.string().optional(),name:j.string().optional(),title:j.string().optional()});selectRef=(0,t.signal)(null);dropdownRef=(0,t.signal)(null);state=(0,t.proxy)({isPopoverOpen:!1,hoveredValue:void 0});setup(){Wi(window,`pointerdown`,this.onExternalClick,{capture:!0}),Gi(()=>{let e=this.dropdownRef();e&&(e.style.width=`${this.selectRef()?.offsetWidth}px`)})}onMouseDown(){this.toggleDropdown()}onKeyDown(e){if(e.key===`Enter`){if(e.stopPropagation(),e.preventDefault(),!this.state.isPopoverOpen){this.toggleDropdown();return}this.state.hoveredValue!==void 0&&this.state.hoveredValue!==this.props.selectedValue&&this.props.onChange(this.state.hoveredValue),this.closeDropdown()}else e.key===`ArrowDown`?(e.stopPropagation(),e.preventDefault(),this.state.isPopoverOpen?this.navigateToNextOption(this.activeValue):(this.toggleDropdown(),this.navigateToNextOption(void 0))):e.key===`ArrowUp`?(e.stopPropagation(),e.preventDefault(),this.state.isPopoverOpen?this.navigateToPreviousOption(this.activeValue):(this.toggleDropdown(),this.navigateToPreviousOption(void 0))):e.key===`Escape`&&(e.stopPropagation(),e.preventDefault(),this.closeDropdown())}onExternalClick(e){!_(this.selectRef(),e)&&!_(this.dropdownRef(),e)&&this.closeDropdown()}onOptionClick(e){e!==this.props.selectedValue&&this.props.onChange(e),this.closeDropdown()}toggleDropdown(){this.state.isPopoverOpen?this.closeDropdown():this.state.isPopoverOpen=!0}closeDropdown(){this.state.isPopoverOpen=!1,this.state.hoveredValue=void 0}get popoverProps(){return{anchorRect:y(this.selectRef()),positioning:`bottom-left`,verticalOffset:0}}get selectedLabel(){return this.props.values?.find(e=>e.value===this.props.selectedValue)?.label||``}onOptionHover(e){this.state.hoveredValue=e}get activeValue(){return this.state.hoveredValue===void 0?this.props.selectedValue:this.state.hoveredValue}navigateToNextOption(e){let t=this.props.values.findIndex(t=>t.value===e);if(t===-1){this.state.hoveredValue=this.props.values[0]?.value;return}let n=Math.min(t+1,this.props.values.length-1);this.state.hoveredValue=this.props.values[n]?.value}navigateToPreviousOption(e){let t=this.props.values.findIndex(t=>t.value===e);if(t===-1){this.state.hoveredValue=this.props.values.at(-1)?.value;return}let n=Math.max(t-1,0);this.state.hoveredValue=this.props.values[n]?.value}},LS=class extends O{static template=`o-spreadsheet-Info-Popover`;props=(0,t.useProps)({anchorRect:j.Rect(),onClose:j.function(),annotationText:j.string().optional(),annotationLink:j.string().optional()});static components={Popover:U_};setup(){Wi(window,`click`,this.onExternalClick,{capture:!0})}infoRef=(0,t.signal)(null);get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:300,maxWidth:350,positioning:`bottom-left`,verticalOffset:0}}onExternalClick(e){let t=this.infoRef();t&&_(t,e)||(e.closedMenuId=`info-popover`,this.props.onClose())}getAnnotationLinkWithHttps(){if(this.props.annotationLink)return Xd(this.props.annotationLink)}},RS=class extends O{static template=`o-spreadsheet-ChartMenu`;static components={MenuPopover:q_,InfoPopover:LS,Select:IS};props=(0,t.useProps)({chartId:j.UID(),hasFullScreenButton:j.boolean().optional(!0),displayEllipsisButton:j.boolean().optional(!0)});fullScreenFigureStore;state=(0,t.proxy)({openedPopover:void 0,anchorRect:null,menuItems:[]});setup(){super.setup(),this.fullScreenFigureStore=k(j_)}getMenuItems(){let e=[];return this.fullScreenMenuItem&&e.push(this.fullScreenMenuItem),(this.getAnnotationLink()||this.getAnnotationText())&&e.push({id:`chartInfo`,label:M(`Chart Info`),icon:`o-spreadsheet-Icon.INFO`,onClick:e=>this.showInfo(e)}),e}get figureId(){return this.env.model.getters.getFigureIdFromChartId(this.props.chartId)}get chartDefinition(){return this.env.model.getters.getChartDefinition(this.props.chartId)}get backgroundColor(){return`background-color: `+(this.chartDefinition.background||`#FFFFFF`)}onClose(){this.state.openedPopover=void 0,this.state.anchorRect=null,this.state.menuItems=[]}openContextMenu(e){if(e.closedMenuId===`menu-popover`){this.onClose();return}this.state.openedPopover=`menu`,this.state.anchorRect=te(e.currentTarget),this.state.menuItems=o_(this.figureId,this.env)}showInfo(e){if(e.closedMenuId===`info-popover`){this.onClose();return}this.state.openedPopover=`info`,this.state.anchorRect=te(e.currentTarget)}getAnnotationText(){return this.chartDefinition.annotationText}getAnnotationLink(){return this.chartDefinition.annotationLink}get fullScreenMenuItem(){if(!this.props.hasFullScreenButton||this.chartDefinition.type===`scorecard`)return;let e=this.figureId===this.fullScreenFigureStore.fullScreenFigure?.id;return{id:`fullScreenChart`,label:M(e?`Exit Full Screen`:`Full Screen`),icon:e?`o-spreadsheet-Icon.FULLSCREEN_OUT`:`o-spreadsheet-Icon.FULLSCREEN_IN`,onClick:()=>{this.fullScreenFigureStore.toggleFullScreenFigure(this.figureId)}}}get regionOptions(){return this.env.model.getters.getAvailableChartRegions(this.props.chartId).map(e=>({value:e.id,label:e.label}))}get selectedRegion(){let e=this.env.model.getters.getChartDefinition(this.props.chartId);if(!e.type.includes(`geo`))return``;let t=e,n=this.env.model.getters.getGeoChartAvailableRegions();return t.region||n[0]?.id||``}onRegionSelected(e){this.env.model.dispatch(`UPDATE_CHART_REGION`,{chartId:this.props.chartId,region:e})}isMenuAvailable(){return(this.env.model.getters.isDashboard()||!this.env.model.getters.isReadonly())&&this.props.displayEllipsisButton}},zS=class extends O{static template=`o-spreadsheet-CarouselFigure`;static components={ChartMenu:RS,MenuPopover:q_,StandaloneViewport:FS};props=(0,t.useProps)({figureUI:j.FigureUI(),editFigureStyle:j.function().optional(),isFullScreen:j.boolean().optional(),openContextMenu:j.function().optional()});carouselTabsRef=(0,t.signal)(null);carouselTabsDropdownRef=(0,t.signal)(null);menuState=(0,t.proxy)({isOpen:!1,anchorRect:null,menuItems:[]});hiddenItems=[];animationStore;fullScreenFigureStore;viewStore;setup(){this.animationStore=k(wa),this.fullScreenFigureStore=k(j_),this.viewStore=k(H),Gi(()=>{this.updateTabsVisibility()})}get carousel(){return this.env.model.getters.getCarousel(this.props.figureUI.id)}get selectedCarouselItem(){return this.env.model.getters.getSelectedCarouselItem(this.props.figureUI.id)}get chartComponent(){let e=this.selectedCarouselItem;if(e?.type!==`chart`)throw Error(`Selected item is not a chart`);let t=this.env.model.getters.getChartType(e.chartId),n=A_.get(t);if(!n)throw Error(`Component is not defined for type ${t}`);return n}onCarouselDoubleClick(){this.env.model.dispatch(`SELECT_FIGURE`,{figureId:this.props.figureUI.id}),this.env.openSidePanel(`CarouselPanel`,{figureId:this.props.figureUI.id})}onCarouselChartDoubleClick(){if(this.selectedCarouselItem?.type!==`chart`)return;let e=this.selectedCarouselItem.chartId;this.env.model.dispatch(`SELECT_FIGURE`,{figureId:this.props.figureUI.id}),this.env.openSidePanel(`ChartPanel`,{chartId:e})}isItemSelected(e){let t=this.selectedCarouselItem;return w(t,e)}getItemTitle(e){return Ag(this.env.model.getters,e)}onCarouselTabClick(e){if(this.env.model.dispatch(`UPDATE_CAROUSEL_ACTIVE_ITEM`,{figureId:this.props.figureUI.id,sheetId:this.env.model.getters.getActiveSheetId(),item:e}),e.type===`chart`){let t=e.chartId+(this.props.isFullScreen?`-fullscreen`:``);this.animationStore?.enableAnimationForChart(t)}}get carouselStyle(){let e={},t=this.env.model.getters.getSpreadsheetTheme().backgroundColor;if(this.selectedCarouselItem?.type===`chart`){let n=this.env.model.getters.getChartRuntime(this.selectedCarouselItem.chartId);`background`in n&&n.background?e[`background-color`]=n.background:`chartJsConfig`in n&&(e[`background-color`]=n.chartJsConfig.options?.plugins?.background?.color||t)}else e[`background-color`]=t;return U(e)}get title(){return this.carousel.title?.text??``}get titleStyle(){return U(__(Cn({...mt,...this.carousel.title})))}updateTabsVisibility(){let e=this.carouselTabsRef(),t=this.carouselTabsDropdownRef();if(!e||!t)return;this.hiddenItems=[];let n=te(e),r=Array.from(e.children);for(let e of r)e.style.display=`block`;let i=r.map(e=>te(e).width),a=0;for(let e=0;e<r.length;e++){let t=a+i[e]>n.width;a+=i[e],t&&(r[e].style.display=`none`,this.hiddenItems.push(this.carousel.items[e]))}t.style.display=this.hiddenItems.length?`block`:`none`}get menuId(){return`carousel-tabs-menu-`}toggleMenu(e){if(e.closedMenuId===this.menuId){this.menuState.isOpen=!1;return}let t=y(this.carouselTabsDropdownRef()),n=this.hiddenItems.map(e=>({name:this.getItemTitle(e),execute:()=>this.onCarouselTabClick(e),isActive:()=>this.isItemSelected(e),isReadonlyAllowed:!0}));this.menuState.isOpen=!0,this.menuState.anchorRect=t,this.menuState.menuItems=be(n)}toggleFullScreen(){this.fullScreenFigureStore.toggleFullScreenFigure(this.props.figureUI.id)}get fullScreenButtonTitle(){return this.props.isFullScreen?M(`Exit Full Screen`):M(`Full Screen`)}openContextMenu(e){if(e.closedMenuId===`figure-context-menu`)return;let t=e.currentTarget;t&&this.props.openContextMenu?.(te(t))}removeEmptyHeadersFromRange(e){if(e.invalidXc||e.invalidSheetName){let e=this.props.figureUI.id;throw Error(`Invalid range provided to carousel ${e} data view ${JSON.stringify(this.carousel)}`)}let t=e.zone,n=t.top,r=e.sheetId;for(let e of vr(r,t))this.env.model.getters.getEvaluatedCell(e).type!==`empty`&&(n=Math.max(n,e.row));let i={...e.zone,bottom:n};return this.env.model.getters.getRangeFromZone(r,i)}onResizeColumns(e){let t=this.selectedCarouselItem;if(t?.type!==`carouselDataView`)return;let n=this.env.model.getters.getCarousel(this.props.figureUI.id),r=n.items.findIndex(e=>w(e,t));if(r===-1)return;let i=[...n.items];i[r]={...t,columnWeights:e},this.env.model.dispatch(`UPDATE_CAROUSEL`,{figureId:this.props.figureUI.id,sheetId:this.env.model.getters.getActiveSheetId(),definition:this.env.model.getters.carouselToCarouselData({...n,items:i})})}get canResizeDataViewColumns(){return!this.env.model.getters.isReadonly()&&!this.env.model.getters.isSheetLocked(this.env.model.getters.getActiveSheetId())}},BS=class extends O{static template=`o-spreadsheet-ChartFigure`;static components={ChartMenu:RS};props=(0,t.useProps)({figureUI:j.FigureUI(),isFullScreen:j.boolean().optional(),openContextMenu:j.function().optional()});onDoubleClick(){this.env.model.dispatch(`SELECT_FIGURE`,{figureId:this.props.figureUI.id}),this.env.openSidePanel(`ChartPanel`)}get chartType(){return this.env.model.getters.getChartType(this.chartId)}get chartId(){let e=this.env.model.getters.getChartIdFromFigureId(this.props.figureUI.id);if(!e)throw Error(`No chart found for figure ID: ${this.props.figureUI.id}`);return e}get chartComponent(){let e=this.chartType,t=A_.get(e);if(!t)throw Error(`Component is not defined for type ${e}`);return t}},VS=class extends O{static template=`o-spreadsheet-ImageFigure`;props=(0,t.useProps)({figureUI:j.FigureUI(),openContextMenu:j.function()});menuButtonRef=(0,t.signal)(null);showMenu(e){this.env.model.getters.getSelectedFigureIds().includes(this.props.figureUI.id)||this.env.model.dispatch(`SELECT_FIGURE`,{figureId:this.props.figureUI.id,selectMultiple:e.shiftKey||ue(e)}),this.props.openContextMenu(y(this.menuButtonRef()))}get figureId(){return this.props.figureUI.id}get getImagePath(){return this.env.model.getters.getImagePath(this.figureId)}get shouldShowMenuButton(){return!this.env.model.getters.isReadonly()&&!this.env.model.getters.isDashboard()}};let HS=new D;HS.add(`chart`,{Component:BS,SidePanelComponent:`ChartPanel`,menuBuilder:o_}),HS.add(`image`,{Component:VS,keepRatio:!0,minFigSize:20,borderWidth:0,menuBuilder:s_}),HS.add(`carousel`,{Component:zS,menuBuilder:c_});var US=class extends O{static template=`o-spreadsheet-FigureComponent`;static components={MenuPopover:q_};props=(0,t.useProps)({figureUI:j.FigureUI(),style:j.string(),class:j.string(),onMouseDown:j.function().optional(()=>()=>{}),onClickAnchor:j.function().optional(()=>()=>{})});menuState=(0,t.proxy)({isOpen:!1,anchorRect:null,menuItems:[]});figureRef=(0,t.signal)(null);borderWidth;get isSelected(){return this.env.model.getters.getSelectedFigureIds().includes(this.props.figureUI.id)}get figureRegistry(){return HS}getBorderWidth(){return this.env.model.getters.isDashboard()?0:this.isSelected?2:this.borderWidth}getBorderStyle(e){return`border-${e}-width: ${this.getBorderWidth()}px;`}get wrapperStyle(){let{x:e,y:t,width:n,height:r}=this.props.figureUI;return U({left:`${e}px`,top:`${t}px`,width:`${n}px`,height:`${r}px`})}getResizerPosition(e){let t={};return e.includes(`top`)?t.top=`-3px`:e.includes(`bottom`)?t.bottom=`-3px`:t.bottom=`calc(50% - 3px)`,e.includes(`left`)?t.left=`-3px`:e.includes(`right`)?t.right=`-3px`:t.right=`calc(50% - 3px)`,U(t)}setup(){let e=HS.get(this.props.figureUI.tag).borderWidth;this.borderWidth=e===void 0?1:e,Gi(()=>{let e=this.env.model.getters.getSelectedFigureIds(),t=this.props.figureUI.id,n=this.figureRef();e.includes(t)&&n?.focus({preventScroll:!0})},()=>[this.env.model.getters.getSelectedFigureIds(),this.props.figureUI.id])}clickAnchor(e,t,n){this.props.onClickAnchor(e,t,n)}onMouseDown(e){this.env.isMobile()||this.props.onMouseDown(e)}onClick(e){this.env.isMobile()&&this.props.onMouseDown(e)}onKeyDown(e){let t=ce(e);switch(t){case`Delete`:case`Backspace`:this.env.model.dispatch(`DELETE_FIGURES`,{sheetId:this.env.model.getters.getActiveSheetId(),figureIds:this.env.model.getters.getSelectedFigureIds()}),e.preventDefault(),e.stopPropagation();break;case`Shift+ArrowDown`:case`Shift+ArrowLeft`:case`Shift+ArrowRight`:case`Shift+ArrowUp`:case`ArrowDown`:case`ArrowLeft`:case`ArrowRight`:case`ArrowUp`:let n=this.env.model.getters.getActiveSheetId(),r=this.env.model.getters.getSelectedFigureIds(),i=[];for(let t of r){let r=this.env.model.getters.getFigure(n,t);r&&i.push({sheetId:n,figureId:t,...this.positionInBoundary(n,this.env.model.getters.getFigureUI(n,r),e.key,e.shiftKey)})}this.env.model.dispatch(`MOVE_FIGURES`,{figures:i}),e.preventDefault(),e.stopPropagation();break;case`Ctrl+A`:e.preventDefault(),e.stopPropagation();break;case`Ctrl+Y`:case`Ctrl+Z`:t===`Ctrl+Y`?this.env.model.dispatch(`REQUEST_REDO`):t===`Ctrl+Z`&&this.env.model.dispatch(`REQUEST_UNDO`),e.preventDefault(),e.stopPropagation();break}}positionInBoundary(e,t,n,r){let i=r?1:5,{col:a,row:o,offset:s}=t;s={...s};let c=this.env.model.getters.getMaxAnchorOffset(e,t.height,t.width);switch(n){case`ArrowUp`:if(s.y<i){for(o--;o>0&&this.env.model.getters.isRowHiddenByUser(e,o);)o--;s.y=this.env.model.getters.getRowSize(e,o)-i+s.y}else s.y-=i;break;case`ArrowLeft`:if(s.x<i){for(a--;a>0&&this.env.model.getters.isColHiddenByUser(e,a);)a--;s.x=this.env.model.getters.getColSize(e,a)-i+s.x}else s.x-=i;break;case`ArrowDown`:let t=this.env.model.getters.getRowSize(e,o);if(s.y+i>=t){for(o++;o<=c.row&&this.env.model.getters.isRowHiddenByUser(e,o);)o++;s.y=s.y+i-t}else s.y+=i;break;case`ArrowRight`:let n=this.env.model.getters.getColSize(e,a);if(s.x+i>=n){for(a++;a<=c.col&&this.env.model.getters.isColHiddenByUser(e,a);)a++;s.x=s.x+i-n}else s.x+=i}return a<0?(a=0,s.x=0):(a>c.col||a===c.col&&s.x>c.offset.x)&&(a=c.col,s.x=c.offset.x),o<0?(o=0,s.y=0):(o>c.row||o===c.row&&s.y>c.offset.y)&&(o=c.row,s.y=c.offset.y),{col:a,row:o,offset:s}}onContextMenu(e){if(this.env.model.getters.isDashboard())return;let t=Sg(this.env,e);this.openContextMenu({x:t.clientX,y:t.clientY,width:0,height:0})}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.anchorRect=e,this.menuState.menuItems=HS.get(this.props.figureUI.tag).menuBuilder(this.props.figureUI.id,this.env)}get isFigureResizable(){return this.isSelected&&!this.env.isMobile()&&!this.env.model.getters.isDashboard()&&!this.env.model.getters.isCurrentSheetLocked()}},K=class{static getCrypto(){if(typeof globalThis<`u`&&globalThis.crypto)return globalThis.crypto}static smallUuid(){let e=this.getCrypto();return e?`10000000-1000`.replace(/[01]/g,t=>{let n=Number(t);return(n^e.getRandomValues(new Uint8Array(1))[0]&15>>n/4).toString(16)}):`xxxxxxxx-xxxx`.replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}static uuidv4(){let e=this.getCrypto();return e?`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,t=>{let n=Number(t);return(n^e.getRandomValues(new Uint8Array(1))[0]&15>>n/4).toString(16)}):`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}},WS=class{xmlString;constructor(e){this.xmlString=e}toString(){return this.xmlString}};let GS=[`areaChart`,`area3DChart`,`lineChart`,`line3DChart`,`stockChart`,`radarChart`,`scatterChart`,`pieChart`,`pie3DChart`,`doughnutChart`,`barChart`,`bar3DChart`,`ofPieChart`,`surfaceChart`,`surface3DChart`,`bubbleChart`,`comboChart`,`radarChart`];var KS=class extends SS{getters;dispatch;canDispatch;constructor({getters:e,stateObserver:t,range:n,dispatch:r,canDispatch:i,formulasPlugin:a}){super(t),n.addRangeProvider(this.adaptRanges.bind(this)),a.addFormulaProvider(this.getFormulas.bind(this)),this.getters=e,this.dispatch=r,this.canDispatch=i}import(e){}export(e,t){}adaptRanges(e){}getFormulas(){return[]}};let qS=/^[\p{L}\p{N}_.]+$/u;var JS=class extends KS{static getters=[`getNamedRange`,`getNamedRangeFromZone`,`getNamedRanges`];namedRanges=[];adaptRanges({applyChange:e}){let t=[],n=!1;for(let r of this.namedRanges){let i=e(r.range);switch(i.changeType){case`REMOVE`:n=!0;break;case`RESIZE`:case`MOVE`:case`CHANGE`:n=!0,t.push({...r,range:i.range});break;case`NONE`:t.push(r)}}n&&this.history.update(`namedRanges`,t)}allowDispatch(e){switch(e.type){case`CREATE_NAMED_RANGE`:return this.checkValidNewNamedRangeName(e.name);case`UPDATE_NAMED_RANGE`:return this.checkValidations(e,()=>this.checkNamedRangeExists(e.oldRangeName),()=>e.newRangeName===e.oldRangeName?`Success`:this.checkValidNewNamedRangeName(e.newRangeName));case`DELETE_NAMED_RANGE`:return this.checkNamedRangeExists(e.name)}return`Success`}handle(e){switch(e.type){case`CREATE_NAMED_RANGE`:{let t=this.getters.getRangeFromRangeData(e.ranges[0]),n=[...this.namedRanges,{name:e.name,range:t}];this.history.update(`namedRanges`,n);break}case`UPDATE_NAMED_RANGE`:{let t=this.getNamedRangeIndex(e.oldRangeName);if(t!==-1){let n=this.getters.getRangeFromRangeData(e.ranges[0]);this.history.update(`namedRanges`,t,{name:e.newRangeName,range:n})}break}case`DELETE_NAMED_RANGE`:{let t=this.getNamedRangeIndex(e.name);if(t!==-1){let e=[...this.namedRanges];e.splice(t,1),this.history.update(`namedRanges`,e)}break}}}getNamedRange(e){return this.namedRanges[this.getNamedRangeIndex(e)]}getNamedRangeFromZone(e,t){for(let n of this.namedRanges){let r=n.range;if(r.sheetId===e&&w(r.unboundedZone,t))return n}}getNamedRanges(){return this.namedRanges}getNamedRangeIndex(e){return this.namedRanges.findIndex(t=>t&&t.name.toLowerCase()===e.toLowerCase())}import(e){for(let t in e.namedRanges||{})this.namedRanges.push({name:t,range:this.getters.getRangeFromSheetXC(void 0,e.namedRanges[t])})}export(e){e.namedRanges={};for(let t of this.namedRanges){let n=this.getters.getRangeString(t.range);e.namedRanges[t.name]=n}}exportForExcel(e){this.export(e)}checkValidNewNamedRangeName(e){return this.getNamedRange(e)?`NamedRangeNameAlreadyExists`:!qS.test(e)||bo(e,z)||[`TRUE`,`FALSE`].includes(e.toUpperCase())?`NamedRangeInvalidName`:xl.test(e)?`NamedRangeNameLooksLikeCellReference`:`Success`}checkNamedRangeExists(e){return this.getNamedRange(e)?`Success`:`NamedRangeNotFound`}};function YS(e,t){let n={};for(let r of e.namedRanges){if(!r.value.split(`!`)[0]?.replace(/'/g,``)){t.addConversionWarning(`Named range "${r.name}" does not specify a sheet and will be ignored.`);continue}if(!qS.test(r.name)){t.addConversionWarning(`Named range "${r.name}" has an invalid name and will be ignored.`);continue}n[r.name]=r.value}return n}let XS=new WeakMap,ZS=new WeakMap;function QS(e,t){XS.has(t)||(XS.set(t,new Map),ZS.set(t,0));let n=XS.get(t),r=tC(e);if(n.has(r)){let i=n.get(r);return t[i]=e,i}let i=ZS.get(t)+1;return n.set(r,i),ZS.set(t,i),t[i]=e,i}function $S(e){let t={};for(let n in e){let r=zn(e[n].map(E));for(let e of r)t[tr(e)]=Number(n)}return t}function*eC(e,t){for(let n in t){let r=Xn(n),i=t[n];for(let t=r.top;t<=r.bottom;t++)for(let n=r.left;n<=r.right;n++)yield[{sheetId:e,col:n,row:t},i]}}function tC(e){if(e===null)return`null`;if(e===void 0)return`undefined`;if(typeof e!=`object`)return String(e);if(Array.isArray(e)){let t=e.length,n=`[`;for(let r=0;r<t;r++)r>0&&(n+=`,`),n+=tC(e[r]);return n+`]`}let t=Object.keys(e).sort(),n=`{`;for(let r of t)e[r]!==void 0&&(n+=`"${r}":${tC(e[r])},`);return n+=`}`,n}let nC=[`thin`,`medium`,`thick`,`dashed`,`dotted`],rC=[`general`,`left`,`center`,`right`],iC=[`top`,`center`,`bottom`],aC=[`Arial`],oC=[`solid`,`none`],sC=[`expression`,`cellIs`,`colorScale`,`iconSet`,`containsText`,`notContainsText`,`beginsWith`,`endsWithText`,`containsBlanks`,`notContainsBlanks`],cC={b:`boolean`,d:`date`,e:`error`,inlineStr:`inlineStr`,n:`number`,s:`sharedString`,str:`str`},lC={dashDot:`thin`,dashDotDot:`thin`,dashed:`dashed`,dotted:`dotted`,double:`thin`,hair:`thin`,medium:`medium`,mediumDashDot:`thin`,mediumDashDotDot:`thin`,mediumDashed:`thin`,none:void 0,slantDashDot:`thin`,thick:`thick`,thin:`thin`},uC={general:void 0,left:`left`,center:`center`,right:`right`,fill:`left`,justify:`left`,centerContinuous:`center`,distributed:`center`},dC={top:`top`,center:`middle`,bottom:`bottom`,justify:`middle`,distributed:`middle`},fC={top:`top`,middle:`center`,bottom:`bottom`},pC={beginsWith:`beginsWithText`,endsWith:`endsWithText`,containsText:`containsText`,notContains:`notContainsText`,between:`isBetween`,notBetween:`isNotBetween`,equal:`isEqual`,notEqual:`isNotEqual`,greaterThan:`isGreaterThan`,greaterThanOrEqual:`isGreaterOrEqualTo`,lessThan:`isLessThan`,lessThanOrEqual:`isLessOrEqualTo`},mC={aboveAverage:void 0,expression:`customFormula`,cellIs:void 0,colorScale:void 0,dataBar:void 0,iconSet:void 0,top10:`top10`,uniqueValues:`uniqueValues`,duplicateValues:`duplicateValues`,containsText:`containsText`,notContainsText:`notContainsText`,beginsWith:`beginsWithText`,endsWith:`endsWithText`,containsBlanks:`isEmpty`,notContainsBlanks:`isNotEmpty`,containsErrors:void 0,notContainsErrors:void 0,timePeriod:void 0},hC={num:`number`,percent:`percentage`,max:`value`,min:`value`,percentile:`percentile`,formula:`formula`},gC={NoIcons:void 0,"3Arrows":`arrows`,"3ArrowsGray":`arrows`,"3Symbols":`smiley`,"3Symbols2":`smiley`,"3Signs":`dots`,"3Flags":`dots`,"3TrafficLights1":`dots`,"3TrafficLights2":`dots`,"4Arrows":`arrows`,"4ArrowsGray":`arrows`,"4RedToBlack":`dots`,"4Rating":`smiley`,"4TrafficLights":`dots`,"5Arrows":`arrows`,"5ArrowsGray":`arrows`,"5Rating":`smiley`,"5Quarters":`dots`,"3Stars":`smiley`,"3Triangles":`arrows`,"5Boxes":`dots`},_C={none:`none`,b:`bottom`,t:`top`,l:`left`,r:`right`,tr:`right`},vC={areaChart:void 0,area3DChart:void 0,lineChart:`line`,line3DChart:void 0,stockChart:void 0,radarChart:`radar`,scatterChart:`scatter`,pieChart:`pie`,pie3DChart:void 0,doughnutChart:`pie`,barChart:`bar`,bar3DChart:void 0,ofPieChart:void 0,surfaceChart:void 0,surface3DChart:void 0,bubbleChart:void 0,comboChart:`combo`},yC={exp:`exponential`,log:`logarithmic`,poly:`polynomial`,movingAvg:`trailingMovingAverage`},bC={1:`AVERAGE`,2:`COUNT`,3:`COUNTA`,4:`MAX`,5:`MIN`,6:`PRODUCT`,7:`STDEV`,8:`STDEVP`,9:`SUM`,10:`VAR`,11:`VARP`,101:`AVERAGE`,102:`COUNT`,103:`COUNTA`,104:`MAX`,105:`MIN`,106:`PRODUCT`,107:`STDEV`,108:`STDEVP`,109:`SUM`,110:`VAR`,111:`VARP`},xC={0:`General`,1:`0`,2:`0.00`,3:`#,#00`,4:`#,##0.00`,9:`0%`,10:`0.00%`,11:void 0,12:void 0,13:void 0,14:`m/d/yyyy`,15:`m/d/yyyy`,16:`m/d/yyyy`,17:`m/d/yyyy`,18:`hh:mm:ss a`,19:`hh:mm:ss a`,20:`hhhh:mm:ss`,21:`hhhh:mm:ss`,22:`m/d/yy h:mm`,37:void 0,38:void 0,39:void 0,40:void 0,45:`hhhh:mm:ss`,46:`hhhh:mm:ss`,47:`hhhh:mm:ss`,48:void 0,49:`@`},SC={0:1,"0.00":2,"#,#00":3,"#,##0.00":4,"0%":9,"0.00%":10,"0.00E+00":11,"# ?/?":12,"# ??/??":13,"mm-dd-yy":14,"d-mm-yy":15,"mm-yy":16,"mmm-yy":17,"h:mm AM/PM":18,"h:mm:ss AM/PM":19,"h:mm":20,"h:mm:ss":21,"m/d/yy h:mm":22,"#,##0 ;(#,##0)":37,"#,##0 ;[Red](#,##0)":38,"#,##0.00;(#,##0.00)":39,"#,##0.00;[Red](#,##0.00)":40,"mm:ss":45,"[h]:mm:ss":46,"mmss.0":47,"##0.0E+0":48,"@":49,"hh:mm:ss a":19},CC={0:`000000`,1:`FFFFFF`,2:`FF0000`,3:`00FF00`,4:`0000FF`,5:`FFFF00`,6:`FF00FF`,7:`00FFFF`,8:`000000`,9:`FFFFFF`,10:`FF0000`,11:`00FF00`,12:`0000FF`,13:`FFFF00`,14:`FF00FF`,15:`00FFFF`,16:`800000`,17:`008000`,18:`000080`,19:`808000`,20:`800080`,21:`008080`,22:`C0C0C0`,23:`808080`,24:`9999FF`,25:`993366`,26:`FFFFCC`,27:`CCFFFF`,28:`660066`,29:`FF8080`,30:`0066CC`,31:`CCCCFF`,32:`000080`,33:`FF00FF`,34:`FFFF00`,35:`00FFFF`,36:`800080`,37:`800000`,38:`008080`,39:`0000FF`,40:`00CCFF`,41:`CCFFFF`,42:`CCFFCC`,43:`FFFF99`,44:`99CCFF`,45:`FF99CC`,46:`CC99FF`,47:`FFCC99`,48:`3366FF`,49:`33CCCC`,50:`99CC00`,51:`FFCC00`,52:`FF9900`,53:`FF6600`,54:`666699`,55:`969696`,56:`003366`,57:`339966`,58:`003300`,59:`333300`,60:`993300`,61:`993366`,62:`333399`,63:`333333`,64:`000000`,65:`FFFFFF`},wC={"image/avif":`avif`,"image/bmp":`bmp`,"image/gif":`gif`,"image/vnd.microsoft.icon":`ico`,"image/jpeg":`jpeg`,"image/png":`png`,"image/tiff":`tiff`,"image/webp":`webp`},TC={avif:`image/avif`,bmp:`image/bmp`,gif:`image/gif`,ico:`image/vnd.microsoft.icon`,jpeg:`image/jpeg`,png:`image/png`,tiff:`image/tiff`,webp:`image/webp`,jpg:`image/jpeg`},EC={between:`isBetween`,notBetween:`isNotBetween`,equal:`isEqual`,notEqual:`isNotEqual`,greaterThan:`isGreaterThan`,greaterThanOrEqual:`isGreaterOrEqualTo`,lessThan:`isLessThan`,lessThanOrEqual:`isLessOrEqualTo`},DC={between:`dateIsBetween`,notBetween:`dateIsNotBetween`,equal:`dateIs`,greaterThan:`dateIsAfter`,greaterThanOrEqual:`dateIsOnOrAfter`,lessThan:`dateIsBefore`,lessThanOrEqual:`dateIsOnOrBefore`};function OC(e){switch(e){case`isNotEmpty`:return`notContainsBlanks`;case`isEmpty`:return`containsBlanks`;case`notContainsText`:return`notContainsBlanks`;case`containsText`:return`containsText`;case`beginsWithText`:return`beginsWith`;case`endsWithText`:return`endsWith`;case`isGreaterThan`:return`greaterThan`;case`isGreaterOrEqualTo`:return`greaterThanOrEqual`;case`isLessThan`:return`lessThan`;case`isLessOrEqualTo`:return`lessThanOrEqual`;case`isBetween`:return`between`;case`isNotBetween`:return`notBetween`;case`isEqual`:return`equal`;case`isNotEqual`:return`notEqual`;case`customFormula`:return``;case`dateIs`:return``;case`dateIsBefore`:return`lessThan`;case`dateIsAfter`:return`greaterThan`;case`dateIsOnOrAfter`:return`greaterThanOrEqual`;case`dateIsOnOrBefore`:return`lessThanOrEqual`;case`top10`:return`top10`;case`uniqueValues`:return`uniqueValues`;case`duplicateValues`:return`duplicateValues`}}function kC(e){switch(typeof e){case`boolean`:return`b`;case`string`:return`str`;case`number`:return`n`;default:return}}function AC(e){return Math.round(im*e*100)/100}function jC(e){return Math.round(am*e*100)/100}function MC(e){return e&&Math.round(e/im*100)/100}function NC(e){return e&&Math.round(e/am*100)/100}function PC(e,t,n,r,i){let a=n?e.styles[n]:{},o=r?e.formats[r]:void 0,s={font:{size:a?.fontSize||Ze,color:{rgb:a?.textColor?a.textColor:`000000`},family:2,name:`Arial`},fill:a?.fillColor?{fgColor:{rgb:a.fillColor}}:{reservedAttribute:`none`},numFmt:o?{format:o,id:0}:void 0,border:i||0,alignment:{horizontal:a.align==="default"?void 0:a.align,vertical:a.verticalAlign?fC[a.verticalAlign]:void 0,wrapText:a.wrapping===`wrap`||t?.includes(`
|
|
43
|
+
/>`;setup(){this.viewStore=k(H)}props=(0,t.useProps)({topOffset:j.number().optional(0),hasFooter:j.boolean().optional(!0)});get offset(){return this.viewStore.viewports.getSheetScrollInfo(this.viewStore.displayedSheetId).scrollY}get height(){return this.viewStore.viewports.getMainViewportRect(this.viewStore.displayedSheetId).height}get isDisplayed(){let{yRatio:e}=this.viewStore.viewports.getFrozenSheetViewRatio(this.viewStore.displayedSheetId);return e<1}get position(){let{y:e}=this.viewStore.viewports.getMainViewportRect(this.viewStore.displayedSheetId),t=this.viewStore.viewports.getScrollBarWidth();return{top:`${this.props.topOffset+e}px`,right:`0px`,width:`${t}px`,bottom:this.props.hasFooter?`${t}px`:`0px`}}onScroll(e){let{scrollX:t}=this.viewStore.viewports.getSheetScrollInfo(this.viewStore.displayedSheetId);this.viewStore.setViewportOffset({offsetX:t,offsetY:e})}},PS=class extends Yr{mutators=[`setContainerSize`,`setRange`,`resizeColumn`,`setCustomColWeights`];cachedColDimensions=void 0;containerWidth=0;containerHeight=0;range;customColWeights=void 0;viewStore=this.get(H);constructor(e,t,n){super(e),this.range=t,this.customColWeights=n,this.viewStore.setDisplayedSheetId(this.range.sheetId),this.viewStore.setViewportArgs({getHeaderDimensions:this.getHeaderDimensions.bind(this),zoneToDisplay:this.range.zone,getFooterSize:()=>0})}handle(e){this.cachedColDimensions=void 0}setContainerSize(e,t){if(this.containerWidth!==e||this.containerHeight!==t){this.containerWidth=e,this.containerHeight=t,this.cachedColDimensions=void 0,this.viewStore.resizeSheetView({width:e,height:t});return}return`noStateChange`}setRange(e){if(w(this.range,e))return`noStateChange`;this.range=e,this.cachedColDimensions=void 0,this.viewStore.setDisplayedSheetId(this.range.sheetId),this.viewStore.setViewportArgs({zoneToDisplay:this.range.zone})}setCustomColWeights(e){if(w(this.customColWeights,e))return`noStateChange`;this.changeColumnWeights(e)}resizeColumn(e,t,n){let r={};for(let e=0;e<n.length;e++)r[this.range.zone.left+e]=n[e];let i=Dn(n)/20,a=S(e+1,this.range.zone.right+1).filter(e=>r[e]),o=Dn(a.map(e=>r[e])),s={...r};t=Math.max(r[e]+t,i)-r[e];let c=Math.max(o-i*a.length,0);if(t>c&&(t=c),s[e]=r[e]+t,c>0&&t>0)for(let e of a){let n=(r[e]-i)/c*t;s[e]=Math.max(r[e]-n,i)}else if(t<0)for(let e of a){let n=r[e]/o*t;s[e]=Math.max(r[e]-n,i)}let l=S(this.range.zone.left,this.range.zone.right+1).map(e=>s[e]||0),u=this.normalizeWeights(l);this.changeColumnWeights(u)}changeColumnWeights(e){this.customColWeights=e,this.cachedColDimensions=void 0,this.viewStore.rebuildViewports()}get renderingContext(){let{sheetId:e}=this.range;return{sheetId:e,viewports:this.viewStore.viewports,hideGridLines:this.getters.isDashboard(),hideFrozenPaneBorder:!0,dpr:1,selectedZones:[],activeCols:new Set,activeRows:new Set,activePosition:void 0}}get headerDimensionsCallback(){return this.getHeaderDimensions.bind(this)}getHeaderDimensions(e,t,n){if(t===`ROW`)return this.getters.getRowDimensions(e,n);this.cachedColDimensions===void 0&&(this.cachedColDimensions=this.computeColDimensions());let r=this.range.zone;if(n>=r.left&&n<=r.right)return this.cachedColDimensions[n];if(n>r.right){let e=this.cachedColDimensions[r.right];return{start:e.end,size:0,end:e.end}}else return{start:0,size:0,end:this.cachedColDimensions[r.left].start}}get columnWeights(){let e=this.range.zone.right-this.range.zone.left+1,t=this.customColWeights;if(t&&t.length===e)return t;let{sheetId:n,zone:r}=this.range;if(!this.getters.tryGetSheet(n)||!$n(r))return Array(e).fill(1);let i=[];for(let e of S(r.left,r.right+1)){if(this.getters.isColHidden(n,e)){i.push(0);continue}let t={...this.range.zone,left:e,right:e},r=Math.floor(this.getters.getZoneMaxWidth(n,t));i.push(Math.max(96,r))}return this.normalizeWeights(i)}computeColDimensions(){let{zone:e}=this.range,t=S(e.left,e.right+1),n=this.columnWeights,r=Dn(n),i={},a=0;for(let o of t){let t=n[o-e.left],s=Math.floor(t/r*this.containerWidth);i[o]={start:a,size:s,end:a+s},a+=s}let o=t[t.length-1];return o!==void 0&&(i[o].size+=this.containerWidth-a,i[o].end=i[o].start+i[o].size),i}normalizeWeights(e){let t=Dn(e);if(t===0)return e;let n=0,r=[];for(let i=0;i<e.length;i++)r.push(Math.floor(e[i]/t*1e3)),n+=r[i];return r}},FS=class extends O{static template=`o-spreadsheet-StandaloneViewport`;static components={VerticalScrollBar:NS,GridOverlay:Xx,ClickableCellsOverlay:Ex,GridPopover:Zx};props=(0,t.useProps)({range:j.Range(),canResizeColumns:j.boolean().optional(!0),onResizeColumns:j.function().optional(),columnWeights:j.array().optional(),zoomLevel:j.number()});canvasRef=(0,t.signal)(null);containerRef=(0,t.signal)(null);store;dndState=(0,t.proxy)({col:void 0});onMouseWheel;rendererStore;viewStore;cellPopoverStore;setup(){na([H,Jx,Y_,Tx,Dx,qx]),this.store=ra(PS,this.props.range,this.props.columnWeights),this.viewStore=k(H),this.cellPopoverStore=k(qx),this.rendererStore=ra(Jr,[`Background`,`Chart`]);let e=new ResizeObserver(()=>{this.store.setContainerSize(this.containerWidth,this.containerHeight)});(0,t.useEffect)(()=>{let t=this.containerRef();return t&&e.observe(t),()=>e.disconnect()}),(0,t.useEffect)(()=>{this.store.setRange(this.props.range),this.dndState.col===void 0&&this.store.setCustomColWeights(this.props.columnWeights),this.viewStore.setZoom(this.props.zoomLevel),this.store.setContainerSize(this.containerWidth,this.containerHeight)}),kS({canvasRef:this.canvasRef,renderingCtx:()=>this.store.renderingContext,rendererStore:this.rendererStore}),this.onMouseWheel=AS((e,t,n)=>{if(this.hasVerticalScrollBar){n.stopPropagation(),n.preventDefault();let r=this.viewStore.activeSheetScrollInfo;this.viewStore.setViewportOffset({offsetX:r.scrollX+e,offsetY:r.scrollY+t})}})}get containerWidth(){return Math.floor(y(this.containerRef()).width/this.viewStore.zoomLevel)}get containerHeight(){return Math.floor(y(this.containerRef()).height/this.viewStore.zoomLevel)}get hasVerticalScrollBar(){return this.containerHeight&&this.viewStore.mainViewportCoordinates.y+this.viewStore.mainViewportRect.height>this.containerHeight}get scrollBarContainerStyle(){return U({width:`${this.viewStore.scrollBarWidth}px`})}onCellDoubleClicked(e,t,n){if(!this.env.model.getters.isDashboard()){n.stopPropagation();let r=this.env.model.getters.getActiveSheetId();this.props.range.sheetId!==r&&this.env.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:r,sheetIdTo:this.props.range.sheetId}),this.env.model.selection.selectCell(e,t);return}}get gridOverlayDimensions(){let{sheetId:e,zone:t}=this.props.range,n=this.viewStore.viewports.getVisibleRect(e,t);return U({height:`${n.height}px`,width:`${n.width}px`})}get colResizers(){let e=[],t=this.props.range.zone,n=this.props.range.sheetId;for(let r=t.left;r<t.right;r++){if(this.env.model.getters.isColHidden(n,r))continue;let t=U({left:`${this.viewStore.viewports.getColDimensionsInViewport(n,r).end}px`});e.push({style:t,col:r})}return e}onResizerPointerDown(e,t){if(e.button!==0)return;this.dndState.col=t.col;let n=Sg(this.env,e).clientX,r=this.store.columnWeights,i=Dn(r),a=0;Qx(e=>{a=Sg(this.env,e).clientX-n;let o=a/this.containerWidth*i;this.store.resizeColumn(t.col,o,r)},e=>{this.dndState.col=void 0,a&&this.props.onResizeColumns?.(this.store.columnWeights)})}onResizerDoubleClick(){this.props.onResizeColumns?.(void 0)}getGridRect(){return{...y(this.containerRef()),...this.viewStore.sheetViewDimensionWithHeaders}}},IS=class extends O{static template=`o-spreadsheet-Select`;static components={Popover:U_};props=(0,t.useProps)({onChange:j.function(),values:j.array(),selectedValue:j.string().optional(),class:j.string().optional(),popoverClass:j.string().optional(),name:j.string().optional(),title:j.string().optional()});selectRef=(0,t.signal)(null);dropdownRef=(0,t.signal)(null);state=(0,t.proxy)({isPopoverOpen:!1,hoveredValue:void 0});setup(){Wi(window,`pointerdown`,this.onExternalClick,{capture:!0}),Gi(()=>{let e=this.dropdownRef();e&&(e.style.width=`${this.selectRef()?.offsetWidth}px`)})}onMouseDown(){this.toggleDropdown()}onKeyDown(e){if(e.key===`Enter`){if(e.stopPropagation(),e.preventDefault(),!this.state.isPopoverOpen){this.toggleDropdown();return}this.state.hoveredValue!==void 0&&this.state.hoveredValue!==this.props.selectedValue&&this.props.onChange(this.state.hoveredValue),this.closeDropdown()}else e.key===`ArrowDown`?(e.stopPropagation(),e.preventDefault(),this.state.isPopoverOpen?this.navigateToNextOption(this.activeValue):(this.toggleDropdown(),this.navigateToNextOption(void 0))):e.key===`ArrowUp`?(e.stopPropagation(),e.preventDefault(),this.state.isPopoverOpen?this.navigateToPreviousOption(this.activeValue):(this.toggleDropdown(),this.navigateToPreviousOption(void 0))):e.key===`Escape`&&(e.stopPropagation(),e.preventDefault(),this.closeDropdown())}onExternalClick(e){!_(this.selectRef(),e)&&!_(this.dropdownRef(),e)&&this.closeDropdown()}onOptionClick(e){e!==this.props.selectedValue&&this.props.onChange(e),this.closeDropdown()}toggleDropdown(){this.state.isPopoverOpen?this.closeDropdown():this.state.isPopoverOpen=!0}closeDropdown(){this.state.isPopoverOpen=!1,this.state.hoveredValue=void 0}get popoverProps(){return{anchorRect:y(this.selectRef()),positioning:`bottom-left`,verticalOffset:0}}get selectedLabel(){return this.props.values?.find(e=>e.value===this.props.selectedValue)?.label||``}onOptionHover(e){this.state.hoveredValue=e}get activeValue(){return this.state.hoveredValue===void 0?this.props.selectedValue:this.state.hoveredValue}navigateToNextOption(e){let t=this.props.values.findIndex(t=>t.value===e);if(t===-1){this.state.hoveredValue=this.props.values[0]?.value;return}let n=Math.min(t+1,this.props.values.length-1);this.state.hoveredValue=this.props.values[n]?.value}navigateToPreviousOption(e){let t=this.props.values.findIndex(t=>t.value===e);if(t===-1){this.state.hoveredValue=this.props.values.at(-1)?.value;return}let n=Math.max(t-1,0);this.state.hoveredValue=this.props.values[n]?.value}},LS=class extends O{static template=`o-spreadsheet-Info-Popover`;props=(0,t.useProps)({anchorRect:j.Rect(),onClose:j.function(),annotationText:j.string().optional(),annotationLink:j.string().optional()});static components={Popover:U_};setup(){Wi(window,`click`,this.onExternalClick,{capture:!0})}infoRef=(0,t.signal)(null);get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:300,maxWidth:350,positioning:`bottom-left`,verticalOffset:0}}onExternalClick(e){let t=this.infoRef();t&&_(t,e)||(e.closedMenuId=`info-popover`,this.props.onClose())}getAnnotationLinkWithHttps(){if(this.props.annotationLink)return Xd(this.props.annotationLink)}},RS=class extends O{static template=`o-spreadsheet-ChartMenu`;static components={MenuPopover:q_,InfoPopover:LS,Select:IS};props=(0,t.useProps)({chartId:j.UID(),hasFullScreenButton:j.boolean().optional(!0),displayEllipsisButton:j.boolean().optional(!0)});fullScreenFigureStore;state=(0,t.proxy)({openedPopover:void 0,anchorRect:null,menuItems:[]});setup(){super.setup(),this.fullScreenFigureStore=k(j_)}getMenuItems(){let e=[];return this.fullScreenMenuItem&&e.push(this.fullScreenMenuItem),(this.getAnnotationLink()||this.getAnnotationText())&&e.push({id:`chartInfo`,label:M(`Chart Info`),icon:`o-spreadsheet-Icon.INFO`,onClick:e=>this.showInfo(e)}),e}get figureId(){return this.env.model.getters.getFigureIdFromChartId(this.props.chartId)}get chartDefinition(){return this.env.model.getters.getChartDefinition(this.props.chartId)}get backgroundColor(){return`background-color: `+(this.chartDefinition.background||`#FFFFFF`)}onClose(){this.state.openedPopover=void 0,this.state.anchorRect=null,this.state.menuItems=[]}openContextMenu(e){if(e.closedMenuId===`menu-popover`){this.onClose();return}this.state.openedPopover=`menu`,this.state.anchorRect=te(e.currentTarget),this.state.menuItems=o_(this.figureId,this.env)}showInfo(e){if(e.closedMenuId===`info-popover`){this.onClose();return}this.state.openedPopover=`info`,this.state.anchorRect=te(e.currentTarget)}getAnnotationText(){return this.chartDefinition.annotationText}getAnnotationLink(){return this.chartDefinition.annotationLink}get fullScreenMenuItem(){if(!this.props.hasFullScreenButton||this.chartDefinition.type===`scorecard`)return;let e=this.figureId===this.fullScreenFigureStore.fullScreenFigure?.id;return{id:`fullScreenChart`,label:M(e?`Exit Full Screen`:`Full Screen`),icon:e?`o-spreadsheet-Icon.FULLSCREEN_OUT`:`o-spreadsheet-Icon.FULLSCREEN_IN`,onClick:()=>{this.fullScreenFigureStore.toggleFullScreenFigure(this.figureId)}}}get regionOptions(){return this.env.model.getters.getAvailableChartRegions(this.props.chartId).map(e=>({value:e.id,label:e.label}))}get selectedRegion(){let e=this.env.model.getters.getChartDefinition(this.props.chartId);if(!e.type.includes(`geo`))return``;let t=e,n=this.env.model.getters.getGeoChartAvailableRegions();return t.region||n[0]?.id||``}onRegionSelected(e){this.env.model.dispatch(`UPDATE_CHART_REGION`,{chartId:this.props.chartId,region:e})}isMenuAvailable(){return(this.env.model.getters.isDashboard()||!this.env.model.getters.isReadonly())&&this.props.displayEllipsisButton}},zS=class extends O{static template=`o-spreadsheet-CarouselFigure`;static components={ChartMenu:RS,MenuPopover:q_,StandaloneViewport:FS};props=(0,t.useProps)({figureUI:j.FigureUI(),editFigureStyle:j.function().optional(),isFullScreen:j.boolean().optional(),openContextMenu:j.function().optional()});carouselTabsRef=(0,t.signal)(null);carouselTabsDropdownRef=(0,t.signal)(null);menuState=(0,t.proxy)({isOpen:!1,anchorRect:null,menuItems:[]});hiddenItems=[];animationStore;fullScreenFigureStore;viewStore;setup(){this.animationStore=k(wa),this.fullScreenFigureStore=k(j_),this.viewStore=k(H),Gi(()=>{this.updateTabsVisibility()})}get carousel(){return this.env.model.getters.getCarousel(this.props.figureUI.id)}get selectedCarouselItem(){return this.env.model.getters.getSelectedCarouselItem(this.props.figureUI.id)}get chartComponent(){let e=this.selectedCarouselItem;if(e?.type!==`chart`)throw Error(`Selected item is not a chart`);let t=this.env.model.getters.getChartType(e.chartId),n=A_.get(t);if(!n)throw Error(`Component is not defined for type ${t}`);return n}onCarouselDoubleClick(){this.env.model.dispatch(`SELECT_FIGURE`,{figureId:this.props.figureUI.id}),this.env.openSidePanel(`CarouselPanel`,{figureId:this.props.figureUI.id})}onCarouselChartDoubleClick(){if(this.selectedCarouselItem?.type!==`chart`)return;let e=this.selectedCarouselItem.chartId;this.env.model.dispatch(`SELECT_FIGURE`,{figureId:this.props.figureUI.id}),this.env.openSidePanel(`ChartPanel`,{chartId:e})}isItemSelected(e){let t=this.selectedCarouselItem;return w(t,e)}getItemTitle(e){return Ag(this.env.model.getters,e)}onCarouselTabClick(e){if(this.env.model.dispatch(`UPDATE_CAROUSEL_ACTIVE_ITEM`,{figureId:this.props.figureUI.id,sheetId:this.env.model.getters.getActiveSheetId(),item:e}),e.type===`chart`){let t=e.chartId+(this.props.isFullScreen?`-fullscreen`:``);this.animationStore?.enableAnimationForChart(t)}}get carouselStyle(){let e={},t=this.env.model.getters.getSpreadsheetTheme().backgroundColor;if(this.selectedCarouselItem?.type===`chart`){let n=this.env.model.getters.getChartRuntime(this.selectedCarouselItem.chartId);`background`in n&&n.background?e[`background-color`]=n.background:`chartJsConfig`in n&&(e[`background-color`]=n.chartJsConfig.options?.plugins?.background?.color||t)}else e[`background-color`]=t;return U(e)}get title(){return this.env.model.getters.dynamicTranslate(this.carousel.title?.text??``)}get titleStyle(){return U(__(Cn({...mt,...this.carousel.title})))}updateTabsVisibility(){let e=this.carouselTabsRef(),t=this.carouselTabsDropdownRef();if(!e||!t)return;this.hiddenItems=[];let n=te(e),r=Array.from(e.children);for(let e of r)e.style.display=`block`;let i=r.map(e=>te(e).width),a=0;for(let e=0;e<r.length;e++){let t=a+i[e]>n.width;a+=i[e],t&&(r[e].style.display=`none`,this.hiddenItems.push(this.carousel.items[e]))}t.style.display=this.hiddenItems.length?`block`:`none`}get menuId(){return`carousel-tabs-menu-`}toggleMenu(e){if(e.closedMenuId===this.menuId){this.menuState.isOpen=!1;return}let t=y(this.carouselTabsDropdownRef()),n=this.hiddenItems.map(e=>({name:this.getItemTitle(e),execute:()=>this.onCarouselTabClick(e),isActive:()=>this.isItemSelected(e),isReadonlyAllowed:!0}));this.menuState.isOpen=!0,this.menuState.anchorRect=t,this.menuState.menuItems=be(n)}toggleFullScreen(){this.fullScreenFigureStore.toggleFullScreenFigure(this.props.figureUI.id)}get fullScreenButtonTitle(){return this.props.isFullScreen?M(`Exit Full Screen`):M(`Full Screen`)}openContextMenu(e){if(e.closedMenuId===`figure-context-menu`)return;let t=e.currentTarget;t&&this.props.openContextMenu?.(te(t))}removeEmptyHeadersFromRange(e){if(e.invalidXc||e.invalidSheetName){let e=this.props.figureUI.id;throw Error(`Invalid range provided to carousel ${e} data view ${JSON.stringify(this.carousel)}`)}let t=e.zone,n=t.top,r=e.sheetId;for(let e of vr(r,t))this.env.model.getters.getEvaluatedCell(e).type!==`empty`&&(n=Math.max(n,e.row));let i={...e.zone,bottom:n};return this.env.model.getters.getRangeFromZone(r,i)}onResizeColumns(e){let t=this.selectedCarouselItem;if(t?.type!==`carouselDataView`)return;let n=this.env.model.getters.getCarousel(this.props.figureUI.id),r=n.items.findIndex(e=>w(e,t));if(r===-1)return;let i=[...n.items];i[r]={...t,columnWeights:e},this.env.model.dispatch(`UPDATE_CAROUSEL`,{figureId:this.props.figureUI.id,sheetId:this.env.model.getters.getActiveSheetId(),definition:this.env.model.getters.carouselToCarouselData({...n,items:i})})}get canResizeDataViewColumns(){return!this.env.model.getters.isReadonly()&&!this.env.model.getters.isSheetLocked(this.env.model.getters.getActiveSheetId())}},BS=class extends O{static template=`o-spreadsheet-ChartFigure`;static components={ChartMenu:RS};props=(0,t.useProps)({figureUI:j.FigureUI(),isFullScreen:j.boolean().optional(),openContextMenu:j.function().optional()});onDoubleClick(){this.env.model.dispatch(`SELECT_FIGURE`,{figureId:this.props.figureUI.id}),this.env.openSidePanel(`ChartPanel`)}get chartType(){return this.env.model.getters.getChartType(this.chartId)}get chartId(){let e=this.env.model.getters.getChartIdFromFigureId(this.props.figureUI.id);if(!e)throw Error(`No chart found for figure ID: ${this.props.figureUI.id}`);return e}get chartComponent(){let e=this.chartType,t=A_.get(e);if(!t)throw Error(`Component is not defined for type ${e}`);return t}},VS=class extends O{static template=`o-spreadsheet-ImageFigure`;props=(0,t.useProps)({figureUI:j.FigureUI(),openContextMenu:j.function()});menuButtonRef=(0,t.signal)(null);showMenu(e){this.env.model.getters.getSelectedFigureIds().includes(this.props.figureUI.id)||this.env.model.dispatch(`SELECT_FIGURE`,{figureId:this.props.figureUI.id,selectMultiple:e.shiftKey||ue(e)}),this.props.openContextMenu(y(this.menuButtonRef()))}get figureId(){return this.props.figureUI.id}get getImagePath(){return this.env.model.getters.getImagePath(this.figureId)}get shouldShowMenuButton(){return!this.env.model.getters.isReadonly()&&!this.env.model.getters.isDashboard()}};let HS=new D;HS.add(`chart`,{Component:BS,SidePanelComponent:`ChartPanel`,menuBuilder:o_}),HS.add(`image`,{Component:VS,keepRatio:!0,minFigSize:20,borderWidth:0,menuBuilder:s_}),HS.add(`carousel`,{Component:zS,menuBuilder:c_});var US=class extends O{static template=`o-spreadsheet-FigureComponent`;static components={MenuPopover:q_};props=(0,t.useProps)({figureUI:j.FigureUI(),style:j.string(),class:j.string(),onMouseDown:j.function().optional(()=>()=>{}),onClickAnchor:j.function().optional(()=>()=>{})});menuState=(0,t.proxy)({isOpen:!1,anchorRect:null,menuItems:[]});figureRef=(0,t.signal)(null);borderWidth;get isSelected(){return this.env.model.getters.getSelectedFigureIds().includes(this.props.figureUI.id)}get figureRegistry(){return HS}getBorderWidth(){return this.env.model.getters.isDashboard()?0:this.isSelected?2:this.borderWidth}getBorderStyle(e){return`border-${e}-width: ${this.getBorderWidth()}px;`}get wrapperStyle(){let{x:e,y:t,width:n,height:r}=this.props.figureUI;return U({left:`${e}px`,top:`${t}px`,width:`${n}px`,height:`${r}px`})}getResizerPosition(e){let t={};return e.includes(`top`)?t.top=`-3px`:e.includes(`bottom`)?t.bottom=`-3px`:t.bottom=`calc(50% - 3px)`,e.includes(`left`)?t.left=`-3px`:e.includes(`right`)?t.right=`-3px`:t.right=`calc(50% - 3px)`,U(t)}setup(){let e=HS.get(this.props.figureUI.tag).borderWidth;this.borderWidth=e===void 0?1:e,Gi(()=>{let e=this.env.model.getters.getSelectedFigureIds(),t=this.props.figureUI.id,n=this.figureRef();e.includes(t)&&n?.focus({preventScroll:!0})},()=>[this.env.model.getters.getSelectedFigureIds(),this.props.figureUI.id])}clickAnchor(e,t,n){this.props.onClickAnchor(e,t,n)}onMouseDown(e){this.env.isMobile()||this.props.onMouseDown(e)}onClick(e){this.env.isMobile()&&this.props.onMouseDown(e)}onKeyDown(e){let t=ce(e);switch(t){case`Delete`:case`Backspace`:this.env.model.dispatch(`DELETE_FIGURES`,{sheetId:this.env.model.getters.getActiveSheetId(),figureIds:this.env.model.getters.getSelectedFigureIds()}),e.preventDefault(),e.stopPropagation();break;case`Shift+ArrowDown`:case`Shift+ArrowLeft`:case`Shift+ArrowRight`:case`Shift+ArrowUp`:case`ArrowDown`:case`ArrowLeft`:case`ArrowRight`:case`ArrowUp`:let n=this.env.model.getters.getActiveSheetId(),r=this.env.model.getters.getSelectedFigureIds(),i=[];for(let t of r){let r=this.env.model.getters.getFigure(n,t);r&&i.push({sheetId:n,figureId:t,...this.positionInBoundary(n,this.env.model.getters.getFigureUI(n,r),e.key,e.shiftKey)})}this.env.model.dispatch(`MOVE_FIGURES`,{figures:i}),e.preventDefault(),e.stopPropagation();break;case`Ctrl+A`:e.preventDefault(),e.stopPropagation();break;case`Ctrl+Y`:case`Ctrl+Z`:t===`Ctrl+Y`?this.env.model.dispatch(`REQUEST_REDO`):t===`Ctrl+Z`&&this.env.model.dispatch(`REQUEST_UNDO`),e.preventDefault(),e.stopPropagation();break}}positionInBoundary(e,t,n,r){let i=r?1:5,{col:a,row:o,offset:s}=t;s={...s};let c=this.env.model.getters.getMaxAnchorOffset(e,t.height,t.width);switch(n){case`ArrowUp`:if(s.y<i){for(o--;o>0&&this.env.model.getters.isRowHiddenByUser(e,o);)o--;s.y=this.env.model.getters.getRowSize(e,o)-i+s.y}else s.y-=i;break;case`ArrowLeft`:if(s.x<i){for(a--;a>0&&this.env.model.getters.isColHiddenByUser(e,a);)a--;s.x=this.env.model.getters.getColSize(e,a)-i+s.x}else s.x-=i;break;case`ArrowDown`:let t=this.env.model.getters.getRowSize(e,o);if(s.y+i>=t){for(o++;o<=c.row&&this.env.model.getters.isRowHiddenByUser(e,o);)o++;s.y=s.y+i-t}else s.y+=i;break;case`ArrowRight`:let n=this.env.model.getters.getColSize(e,a);if(s.x+i>=n){for(a++;a<=c.col&&this.env.model.getters.isColHiddenByUser(e,a);)a++;s.x=s.x+i-n}else s.x+=i}return a<0?(a=0,s.x=0):(a>c.col||a===c.col&&s.x>c.offset.x)&&(a=c.col,s.x=c.offset.x),o<0?(o=0,s.y=0):(o>c.row||o===c.row&&s.y>c.offset.y)&&(o=c.row,s.y=c.offset.y),{col:a,row:o,offset:s}}onContextMenu(e){if(this.env.model.getters.isDashboard())return;let t=Sg(this.env,e);this.openContextMenu({x:t.clientX,y:t.clientY,width:0,height:0})}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.anchorRect=e,this.menuState.menuItems=HS.get(this.props.figureUI.tag).menuBuilder(this.props.figureUI.id,this.env)}get isFigureResizable(){return this.isSelected&&!this.env.isMobile()&&!this.env.model.getters.isDashboard()&&!this.env.model.getters.isCurrentSheetLocked()}},K=class{static getCrypto(){if(typeof globalThis<`u`&&globalThis.crypto)return globalThis.crypto}static smallUuid(){let e=this.getCrypto();return e?`10000000-1000`.replace(/[01]/g,t=>{let n=Number(t);return(n^e.getRandomValues(new Uint8Array(1))[0]&15>>n/4).toString(16)}):`xxxxxxxx-xxxx`.replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}static uuidv4(){let e=this.getCrypto();return e?`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,t=>{let n=Number(t);return(n^e.getRandomValues(new Uint8Array(1))[0]&15>>n/4).toString(16)}):`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}},WS=class{xmlString;constructor(e){this.xmlString=e}toString(){return this.xmlString}};let GS=[`areaChart`,`area3DChart`,`lineChart`,`line3DChart`,`stockChart`,`radarChart`,`scatterChart`,`pieChart`,`pie3DChart`,`doughnutChart`,`barChart`,`bar3DChart`,`ofPieChart`,`surfaceChart`,`surface3DChart`,`bubbleChart`,`comboChart`,`radarChart`];var KS=class extends SS{getters;dispatch;canDispatch;constructor({getters:e,stateObserver:t,range:n,dispatch:r,canDispatch:i,formulasPlugin:a}){super(t),n.addRangeProvider(this.adaptRanges.bind(this)),a.addFormulaProvider(this.getFormulas.bind(this)),this.getters=e,this.dispatch=r,this.canDispatch=i}import(e){}export(e,t){}adaptRanges(e){}getFormulas(){return[]}};let qS=/^[\p{L}\p{N}_.]+$/u;var JS=class extends KS{static getters=[`getNamedRange`,`getNamedRangeFromZone`,`getNamedRanges`];namedRanges=[];adaptRanges({applyChange:e}){let t=[],n=!1;for(let r of this.namedRanges){let i=e(r.range);switch(i.changeType){case`REMOVE`:n=!0;break;case`RESIZE`:case`MOVE`:case`CHANGE`:n=!0,t.push({...r,range:i.range});break;case`NONE`:t.push(r)}}n&&this.history.update(`namedRanges`,t)}allowDispatch(e){switch(e.type){case`CREATE_NAMED_RANGE`:return this.checkValidNewNamedRangeName(e.name);case`UPDATE_NAMED_RANGE`:return this.checkValidations(e,()=>this.checkNamedRangeExists(e.oldRangeName),()=>e.newRangeName===e.oldRangeName?`Success`:this.checkValidNewNamedRangeName(e.newRangeName));case`DELETE_NAMED_RANGE`:return this.checkNamedRangeExists(e.name)}return`Success`}handle(e){switch(e.type){case`CREATE_NAMED_RANGE`:{let t=this.getters.getRangeFromRangeData(e.ranges[0]),n=[...this.namedRanges,{name:e.name,range:t}];this.history.update(`namedRanges`,n);break}case`UPDATE_NAMED_RANGE`:{let t=this.getNamedRangeIndex(e.oldRangeName);if(t!==-1){let n=this.getters.getRangeFromRangeData(e.ranges[0]);this.history.update(`namedRanges`,t,{name:e.newRangeName,range:n})}break}case`DELETE_NAMED_RANGE`:{let t=this.getNamedRangeIndex(e.name);if(t!==-1){let e=[...this.namedRanges];e.splice(t,1),this.history.update(`namedRanges`,e)}break}}}getNamedRange(e){return this.namedRanges[this.getNamedRangeIndex(e)]}getNamedRangeFromZone(e,t){for(let n of this.namedRanges){let r=n.range;if(r.sheetId===e&&w(r.unboundedZone,t))return n}}getNamedRanges(){return this.namedRanges}getNamedRangeIndex(e){return this.namedRanges.findIndex(t=>t&&t.name.toLowerCase()===e.toLowerCase())}import(e){for(let t in e.namedRanges||{})this.namedRanges.push({name:t,range:this.getters.getRangeFromSheetXC(void 0,e.namedRanges[t])})}export(e){e.namedRanges={};for(let t of this.namedRanges){let n=this.getters.getRangeString(t.range);e.namedRanges[t.name]=n}}exportForExcel(e){this.export(e)}checkValidNewNamedRangeName(e){return this.getNamedRange(e)?`NamedRangeNameAlreadyExists`:!qS.test(e)||bo(e,z)||[`TRUE`,`FALSE`].includes(e.toUpperCase())?`NamedRangeInvalidName`:xl.test(e)?`NamedRangeNameLooksLikeCellReference`:`Success`}checkNamedRangeExists(e){return this.getNamedRange(e)?`Success`:`NamedRangeNotFound`}};function YS(e,t){let n={};for(let r of e.namedRanges){if(!r.value.split(`!`)[0]?.replace(/'/g,``)){t.addConversionWarning(`Named range "${r.name}" does not specify a sheet and will be ignored.`);continue}if(!qS.test(r.name)){t.addConversionWarning(`Named range "${r.name}" has an invalid name and will be ignored.`);continue}n[r.name]=r.value}return n}let XS=new WeakMap,ZS=new WeakMap;function QS(e,t){XS.has(t)||(XS.set(t,new Map),ZS.set(t,0));let n=XS.get(t),r=tC(e);if(n.has(r)){let i=n.get(r);return t[i]=e,i}let i=ZS.get(t)+1;return n.set(r,i),ZS.set(t,i),t[i]=e,i}function $S(e){let t={};for(let n in e){let r=zn(e[n].map(E));for(let e of r)t[tr(e)]=Number(n)}return t}function*eC(e,t){for(let n in t){let r=Xn(n),i=t[n];for(let t=r.top;t<=r.bottom;t++)for(let n=r.left;n<=r.right;n++)yield[{sheetId:e,col:n,row:t},i]}}function tC(e){if(e===null)return`null`;if(e===void 0)return`undefined`;if(typeof e!=`object`)return String(e);if(Array.isArray(e)){let t=e.length,n=`[`;for(let r=0;r<t;r++)r>0&&(n+=`,`),n+=tC(e[r]);return n+`]`}let t=Object.keys(e).sort(),n=`{`;for(let r of t)e[r]!==void 0&&(n+=`"${r}":${tC(e[r])},`);return n+=`}`,n}let nC=[`thin`,`medium`,`thick`,`dashed`,`dotted`],rC=[`general`,`left`,`center`,`right`],iC=[`top`,`center`,`bottom`],aC=[`Arial`],oC=[`solid`,`none`],sC=[`expression`,`cellIs`,`colorScale`,`iconSet`,`containsText`,`notContainsText`,`beginsWith`,`endsWithText`,`containsBlanks`,`notContainsBlanks`],cC={b:`boolean`,d:`date`,e:`error`,inlineStr:`inlineStr`,n:`number`,s:`sharedString`,str:`str`},lC={dashDot:`thin`,dashDotDot:`thin`,dashed:`dashed`,dotted:`dotted`,double:`thin`,hair:`thin`,medium:`medium`,mediumDashDot:`thin`,mediumDashDotDot:`thin`,mediumDashed:`thin`,none:void 0,slantDashDot:`thin`,thick:`thick`,thin:`thin`},uC={general:void 0,left:`left`,center:`center`,right:`right`,fill:`left`,justify:`left`,centerContinuous:`center`,distributed:`center`},dC={top:`top`,center:`middle`,bottom:`bottom`,justify:`middle`,distributed:`middle`},fC={top:`top`,middle:`center`,bottom:`bottom`},pC={beginsWith:`beginsWithText`,endsWith:`endsWithText`,containsText:`containsText`,notContains:`notContainsText`,between:`isBetween`,notBetween:`isNotBetween`,equal:`isEqual`,notEqual:`isNotEqual`,greaterThan:`isGreaterThan`,greaterThanOrEqual:`isGreaterOrEqualTo`,lessThan:`isLessThan`,lessThanOrEqual:`isLessOrEqualTo`},mC={aboveAverage:void 0,expression:`customFormula`,cellIs:void 0,colorScale:void 0,dataBar:void 0,iconSet:void 0,top10:`top10`,uniqueValues:`uniqueValues`,duplicateValues:`duplicateValues`,containsText:`containsText`,notContainsText:`notContainsText`,beginsWith:`beginsWithText`,endsWith:`endsWithText`,containsBlanks:`isEmpty`,notContainsBlanks:`isNotEmpty`,containsErrors:void 0,notContainsErrors:void 0,timePeriod:void 0},hC={num:`number`,percent:`percentage`,max:`value`,min:`value`,percentile:`percentile`,formula:`formula`},gC={NoIcons:void 0,"3Arrows":`arrows`,"3ArrowsGray":`arrows`,"3Symbols":`smiley`,"3Symbols2":`smiley`,"3Signs":`dots`,"3Flags":`dots`,"3TrafficLights1":`dots`,"3TrafficLights2":`dots`,"4Arrows":`arrows`,"4ArrowsGray":`arrows`,"4RedToBlack":`dots`,"4Rating":`smiley`,"4TrafficLights":`dots`,"5Arrows":`arrows`,"5ArrowsGray":`arrows`,"5Rating":`smiley`,"5Quarters":`dots`,"3Stars":`smiley`,"3Triangles":`arrows`,"5Boxes":`dots`},_C={none:`none`,b:`bottom`,t:`top`,l:`left`,r:`right`,tr:`right`},vC={areaChart:void 0,area3DChart:void 0,lineChart:`line`,line3DChart:void 0,stockChart:void 0,radarChart:`radar`,scatterChart:`scatter`,pieChart:`pie`,pie3DChart:void 0,doughnutChart:`pie`,barChart:`bar`,bar3DChart:void 0,ofPieChart:void 0,surfaceChart:void 0,surface3DChart:void 0,bubbleChart:void 0,comboChart:`combo`},yC={exp:`exponential`,log:`logarithmic`,poly:`polynomial`,movingAvg:`trailingMovingAverage`},bC={1:`AVERAGE`,2:`COUNT`,3:`COUNTA`,4:`MAX`,5:`MIN`,6:`PRODUCT`,7:`STDEV`,8:`STDEVP`,9:`SUM`,10:`VAR`,11:`VARP`,101:`AVERAGE`,102:`COUNT`,103:`COUNTA`,104:`MAX`,105:`MIN`,106:`PRODUCT`,107:`STDEV`,108:`STDEVP`,109:`SUM`,110:`VAR`,111:`VARP`},xC={0:`General`,1:`0`,2:`0.00`,3:`#,#00`,4:`#,##0.00`,9:`0%`,10:`0.00%`,11:void 0,12:void 0,13:void 0,14:`m/d/yyyy`,15:`m/d/yyyy`,16:`m/d/yyyy`,17:`m/d/yyyy`,18:`hh:mm:ss a`,19:`hh:mm:ss a`,20:`hhhh:mm:ss`,21:`hhhh:mm:ss`,22:`m/d/yy h:mm`,37:void 0,38:void 0,39:void 0,40:void 0,45:`hhhh:mm:ss`,46:`hhhh:mm:ss`,47:`hhhh:mm:ss`,48:void 0,49:`@`},SC={0:1,"0.00":2,"#,#00":3,"#,##0.00":4,"0%":9,"0.00%":10,"0.00E+00":11,"# ?/?":12,"# ??/??":13,"mm-dd-yy":14,"d-mm-yy":15,"mm-yy":16,"mmm-yy":17,"h:mm AM/PM":18,"h:mm:ss AM/PM":19,"h:mm":20,"h:mm:ss":21,"m/d/yy h:mm":22,"#,##0 ;(#,##0)":37,"#,##0 ;[Red](#,##0)":38,"#,##0.00;(#,##0.00)":39,"#,##0.00;[Red](#,##0.00)":40,"mm:ss":45,"[h]:mm:ss":46,"mmss.0":47,"##0.0E+0":48,"@":49,"hh:mm:ss a":19},CC={0:`000000`,1:`FFFFFF`,2:`FF0000`,3:`00FF00`,4:`0000FF`,5:`FFFF00`,6:`FF00FF`,7:`00FFFF`,8:`000000`,9:`FFFFFF`,10:`FF0000`,11:`00FF00`,12:`0000FF`,13:`FFFF00`,14:`FF00FF`,15:`00FFFF`,16:`800000`,17:`008000`,18:`000080`,19:`808000`,20:`800080`,21:`008080`,22:`C0C0C0`,23:`808080`,24:`9999FF`,25:`993366`,26:`FFFFCC`,27:`CCFFFF`,28:`660066`,29:`FF8080`,30:`0066CC`,31:`CCCCFF`,32:`000080`,33:`FF00FF`,34:`FFFF00`,35:`00FFFF`,36:`800080`,37:`800000`,38:`008080`,39:`0000FF`,40:`00CCFF`,41:`CCFFFF`,42:`CCFFCC`,43:`FFFF99`,44:`99CCFF`,45:`FF99CC`,46:`CC99FF`,47:`FFCC99`,48:`3366FF`,49:`33CCCC`,50:`99CC00`,51:`FFCC00`,52:`FF9900`,53:`FF6600`,54:`666699`,55:`969696`,56:`003366`,57:`339966`,58:`003300`,59:`333300`,60:`993300`,61:`993366`,62:`333399`,63:`333333`,64:`000000`,65:`FFFFFF`},wC={"image/avif":`avif`,"image/bmp":`bmp`,"image/gif":`gif`,"image/vnd.microsoft.icon":`ico`,"image/jpeg":`jpeg`,"image/png":`png`,"image/tiff":`tiff`,"image/webp":`webp`},TC={avif:`image/avif`,bmp:`image/bmp`,gif:`image/gif`,ico:`image/vnd.microsoft.icon`,jpeg:`image/jpeg`,png:`image/png`,tiff:`image/tiff`,webp:`image/webp`,jpg:`image/jpeg`},EC={between:`isBetween`,notBetween:`isNotBetween`,equal:`isEqual`,notEqual:`isNotEqual`,greaterThan:`isGreaterThan`,greaterThanOrEqual:`isGreaterOrEqualTo`,lessThan:`isLessThan`,lessThanOrEqual:`isLessOrEqualTo`},DC={between:`dateIsBetween`,notBetween:`dateIsNotBetween`,equal:`dateIs`,greaterThan:`dateIsAfter`,greaterThanOrEqual:`dateIsOnOrAfter`,lessThan:`dateIsBefore`,lessThanOrEqual:`dateIsOnOrBefore`};function OC(e){switch(e){case`isNotEmpty`:return`notContainsBlanks`;case`isEmpty`:return`containsBlanks`;case`notContainsText`:return`notContainsBlanks`;case`containsText`:return`containsText`;case`beginsWithText`:return`beginsWith`;case`endsWithText`:return`endsWith`;case`isGreaterThan`:return`greaterThan`;case`isGreaterOrEqualTo`:return`greaterThanOrEqual`;case`isLessThan`:return`lessThan`;case`isLessOrEqualTo`:return`lessThanOrEqual`;case`isBetween`:return`between`;case`isNotBetween`:return`notBetween`;case`isEqual`:return`equal`;case`isNotEqual`:return`notEqual`;case`customFormula`:return``;case`dateIs`:return``;case`dateIsBefore`:return`lessThan`;case`dateIsAfter`:return`greaterThan`;case`dateIsOnOrAfter`:return`greaterThanOrEqual`;case`dateIsOnOrBefore`:return`lessThanOrEqual`;case`top10`:return`top10`;case`uniqueValues`:return`uniqueValues`;case`duplicateValues`:return`duplicateValues`}}function kC(e){switch(typeof e){case`boolean`:return`b`;case`string`:return`str`;case`number`:return`n`;default:return}}function AC(e){return Math.round(im*e*100)/100}function jC(e){return Math.round(am*e*100)/100}function MC(e){return e&&Math.round(e/im*100)/100}function NC(e){return e&&Math.round(e/am*100)/100}function PC(e,t,n,r,i){let a=n?e.styles[n]:{},o=r?e.formats[r]:void 0,s={font:{size:a?.fontSize||Ze,color:{rgb:a?.textColor?a.textColor:`000000`},family:2,name:`Arial`},fill:a?.fillColor?{fgColor:{rgb:a.fillColor}}:{reservedAttribute:`none`},numFmt:o?{format:o,id:0}:void 0,border:i||0,alignment:{horizontal:a.align==="default"?void 0:a.align,vertical:a.verticalAlign?fC[a.verticalAlign]:void 0,wrapText:a.wrapping===`wrap`||t?.includes(`
|
|
44
44
|
`)?!0:void 0,textRotation:a.rotation?FC(a.rotation):void 0,shrinkToFit:a.wrapping===`clip`?!0:void 0}};return s.font.strike=!!a?.strikethrough||void 0,s.font.underline=!!a?.underline||void 0,s.font.bold=!!a?.bold||void 0,s.font.italic=!!a?.italic||void 0,s}function FC(e){let t=Math.round(-e/Math.PI*180)%180;return t>90?t-=180:t<-90&&(t+=180),t>=0?t:90-t}function IC(e){return e<=90?-(e/180)*Math.PI:-(90-e)/180*Math.PI}function LC(e,t){let n=RC(t.numFmt,e.numFmts);return VC({fontId:VC(t.font,e.fonts),fillId:VC(t.fill,e.fills),borderId:t.border,numFmtId:n,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal,wrapText:t.alignment.wrapText,textRotation:t.alignment.textRotation,shrinkToFit:t.alignment.shrinkToFit}},e.styles)}function RC(e,t){if(!e)return 0;let n=SC[e.format];return n||=VC(e,t)+164,n}function zC(e,t,n){let r=e.find(e=>e.path===t),i;return r?(i=`rId${(r.rels.length+1).toString()}`,r.rels.push({...n,id:i})):(i=`rId1`,e.push({path:t,rels:[{...n,id:i}]})),i}let BC=new WeakMap;function VC(e,t){let n=BC.get(t);if(!n){n=new Map;for(let e=0;e<t.length;e++){let r=tC(t[e]);n.set(r,e)}BC.set(t,n)}let r=tC(e);if(n.has(r))return n.get(r);let i=t.length;return t.push(e),n.set(r,i),i}function HC(e,t){let n=t.chartIds.findIndex(t=>t===e);return n===-1?(t.chartIds.push(e),t.chartIds.length):n+1}let UC=[];function WC(e){let t=UC.findIndex(t=>t===e);return t===-1?(UC.push(e),UC.length):t+1}function GC(e){return Math.round(e*914400/96)}function KC(e,t,n){let r=e,i;({xc:r,sheetName:i}=Dl(e));let a;if(i){let e=n.sheets.findIndex(e=>$u(e.name,i));if(e<0)throw Error(`Unable to find a sheet with the name `+i);a=e}else a=Number(t);let o=Yn(r);return o.right===void 0&&(o.right=n.sheets[a].colNumber),o.bottom===void 0&&(o.bottom=n.sheets[a].rowNumber),(o.right-o.left+1)*(o.bottom-o.top+1)}function qC(e){return Math.round(e*96/914400)}function JC(e,t){let n=0;for(let r=0;r<e;r++){let e=t.cols.find(e=>r>=e.min&&r<=e.max);e?.width?n+=e.width:t.sheetFormat?.defaultColWidth?n+=t.sheetFormat.defaultColWidth:n+=om}return n/am}function YC(e,t){let n=0;for(let r=0;r<e;r++){let e=t.rows.find(e=>e.index-1===r);e?.height?n+=e.height:t.sheetFormat?.defaultRowHeight?n+=t.sheetFormat.defaultRowHeight:n+=sm}return n/im}function XC(e){return Object.keys(EC).find(t=>EC[t]===e)}function ZC(e){return Object.keys(DC).find(t=>DC[t]===e)}var QC=class{_parsingWarnings=new Set;_conversionWarnings=new Set;addParsingWarning(e){this._parsingWarnings.add(e)}addConversionWarning(e){this._conversionWarnings.add(e)}get warnings(){return[...this._parsingWarnings,...this._conversionWarnings]}generateNotSupportedWarning(e,t,n){let r=`${e} ${t?`"`+t+`" is`:`are`} not yet supported. `;n&&(r+=`Only ${n.join(`, `)} are currently supported.`),this._conversionWarnings.has(r)||this._conversionWarnings.add(r)}};function $C(e,t){let n=e.split(`/`),r=t.split(`/`),i=``,a=0;for(let e=0;e<n.length-1;e++)n[e]===r[e]?a++:i+=`../`;return i+=r.slice(a).join(`/`),i}function ew(e,t=0){let n={};for(let r=0;r<e.length;r++)e[r]&&(n[r+t]=e[r]);return n}function tw(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,(e,t)=>String.fromCharCode(parseInt(t,16)))}function nw(e,t,n){return t===`COL`?(e.cols[n]||(e.cols[n]={}),e.cols[n]):(e.rows[n]||(e.rows[n]={}),e.rows[n])}function rw(e){if(e[0]===`=`)return e;let t=zl(e);return t.length===1&&t[0].type!==`REFERENCE`?e:`=`+e}function iw(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=Xp;else if(e.indexed)t=CC[e.indexed];else return;return t=aw(t),e.tint&&(t=sw(t,e.tint)),t=t.toUpperCase(),t.length===9&&t.endsWith(`FF`)&&(t=t.slice(0,7)),t}function aw(e){return e.length===6?`#`+e+`FF`:`#`+e.slice(2)+e.slice(0,2)}function ow(e,t,n){let r=Vf(zf(e));return r.l=Math.min(100,Math.max(0,r.l*t+n*100)),Rf(Bf(r))}function sw(e,t){let n=Vf(zf(e));return t<0&&(n.l*=1+t),t>0&&(n.l=n.l*(1-t)+(100-100*(1-t))),Rf(Bf(n))}function cw(e){return e.length===9&&(e=e.slice(0,7)),parseInt(e.replace(`#`,``),16)}let lw=/^(yy|yyyy|m{1,5}|d{1,4}|h{1,2}|s{1,2}|am\/pm|a\/m|\s|-|\/|\.|:)+$/i;function uw(e,t,n){let r=xC[e]||t.find(t=>t.id===e)?.format;if(r!==`General`){if(r)try{let e=r.replace(/\[(.*)-[A-Z0-9]{3}\]/g,`[$1]`);if(e=e.replace(/\[\$\]/g,``),e=e.replace(/_.{1}/g,``),e=e.replace(/\*.{1}/g,``),fw(e)&&(e=pw(e)),dw(e))return e}catch{}n.generateNotSupportedWarning(`Number format`,r||`nmFmtId ${e}`)}}function dw(e){try{return B(0,{format:e,locale:z}),!0}catch{return!1}}function fw(e){return lw.test(e)}function pw(e){return e=e.toLowerCase(),e=e.replace(/mmmmm/g,`mmm`),e=e.replace(/am\/pm|a\/m/g,`a`),e=e.replace(/hhhh/g,`hh`),e=e.replace(/\bh\b/g,`hh`),e}function mw(e,t){return ew(e.borders.map(e=>{xw(e,t);let n={top:hw(e.top,t),bottom:hw(e.bottom,t),left:hw(e.left,t),right:hw(e.right,t)};return Object.keys(n).forEach(e=>n[e]===void 0&&delete n[e]),n}),1)}function hw(e,t){if(!e)return;bw(e,t);let n=lC[e.style];return n?{style:n,color:iw(e.color)}:void 0}function gw(e,t){return ew(e.styles.map(n=>_w({fontStyle:e.fonts[n.fontId],fillStyle:e.fills[n.fillId],alignment:n.alignment},t)),1)}function _w(e,t){return yw(e?.fontStyle,e?.fillStyle,t),Sw(e?.alignment?.horizontal,t),Cw(e?.alignment?.vertical,t),{bold:e.fontStyle?.bold,italic:e.fontStyle?.italic,strikethrough:e.fontStyle?.strike,underline:e.fontStyle?.underline,verticalAlign:e.alignment?.vertical?dC[e.alignment.vertical]:void 0,align:e.alignment?.horizontal?uC[e.alignment.horizontal]:void 0,rotation:e.alignment?.textRotation?IC(e.alignment.textRotation):void 0,fillColor:e.fillStyle?.patternType===`solid`?iw(e.fillStyle?.fgColor):iw(e.fillStyle?.bgColor),textColor:iw(e.fontStyle?.color),fontSize:e.fontStyle?.size,wrapping:e.alignment?.wrapText?`wrap`:`overflow`}}function vw(e,t){let n=[];for(let r of e.styles){let i=uw(r.numFmtId,e.numFmts,t);i&&(n[r.numFmtId]=i)}return ew(n,1)}function yw(e,t,n){e&&e.name&&!aC.includes(e.name)&&n.generateNotSupportedWarning(`Font`,e.name,aC),t&&t.patternType&&!oC.includes(t.patternType)&&n.generateNotSupportedWarning(`Fill Style`,t.patternType,oC)}function bw(e,t){nC.includes(e.style)||t.generateNotSupportedWarning(`Border style`,e.style,nC)}function xw(e,t){e.diagonal&&t.generateNotSupportedWarning(`Diagonal Borders`)}function Sw(e,t){e&&!rC.includes(e)&&t.generateNotSupportedWarning(`Horizontal Alignment`,e,rC)}function Cw(e,t){e&&!iC.includes(e)&&t.generateNotSupportedWarning(`Vertical Alignments`,e,iC)}function ww(e,t,n){let r=[],i=1;for(let a of e){if(a.cfRules.length===0)continue;kw(a,t,n);let e=a.cfRules[0],o,s=[],c={};if(!(e.dxfId===void 0&&!(e.type===`colorScale`||e.type===`iconSet`||e.type===`dataBar`))){switch(e.type){case`aboveAverage`:case`containsErrors`:case`notContainsErrors`:case`timePeriod`:continue;case`dataBar`:let t=Tw(i++,a);t&&r.push(t);continue;case`colorScale`:let l=Ew(i++,a);l&&r.push(l);continue;case`iconSet`:let u=Dw(i++,a,n);u&&r.push(u);continue;case`containsText`:case`notContainsText`:case`beginsWith`:case`endsWith`:if(!e.text)continue;o=mC[e.type],s.push(e.text);break;case`expression`:if(!e.formula?.length)continue;o=mC[e.type],s.push(`=${e.formula[0]}`);break;case`duplicateValues`:case`uniqueValues`:case`containsBlanks`:case`notContainsBlanks`:o=mC[e.type];break;case`cellIs`:if(!e.operator||!e.formula||e.formula.length===0)continue;o=pC[e.operator],s.push(rw(e.formula[0])),e.formula.length===2&&s.push(rw(e.formula[1]));break;case`top10`:if(e.rank===void 0)continue;o=mC[e.type],s.push(e.rank.toString()),e.percent&&(c.isPercent=!0),e.bottom&&(c.isBottom=!0);break}o&&e.dxfId!==void 0&&r.push({id:(i++).toString(),ranges:a.sqref,stopIfTrue:e.stopIfTrue,rule:{type:`CellIsRule`,operator:o,values:s,...c,style:_w({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},n)}})}}return r}function Tw(e,t){let n=t.cfRules[0].dataBar;if(!n)return;let r=cw(iw(n.color)||`#FFFFFF`);return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:`DataBarRule`,color:r}}}function Ew(e,t){let n=t.cfRules[0].colorScale;if(!n||n.cfvos.length!==n.colors.length||n.cfvos.length<2||n.cfvos.length>3)return;let r=[];for(let e=0;e<n.cfvos.length;e++)r.push({color:cw(iw(n.colors[e])||`#FFFFFF`),type:hC[n.cfvos[e].type],value:n.cfvos[e].value});let i=r[0],a=r.length===2?r[1]:r[2],o=r.length===3?r[1]:void 0;return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:`ColorScaleRule`,minimum:i,midpoint:o,maximum:a}}}function Dw(e,t,n){let r=t.cfRules[0].iconSet;if(!r)return;let i=r.cfvos,a=r.cfIcons;if(i.length<3||a&&a.length<3)return;i.length>3&&(i=[i[0],i[Math.floor(i.length/2)],i[i.length-1]]),a&&a.length>3&&(a=[a[0],a[Math.floor(a.length/2)],a[a.length-1]]);let o=[];for(let e=1;e<=2;e++){let t=hC[i[e].type];if(t===`value`)return;o.push({value:i[e].value||``,operator:i[e].gte?`ge`:`gt`,type:t})}let s={lower:a?Ow(a[0].iconSet,a[0].iconId):Ow(r.iconSet,0),middle:a?Ow(a[1].iconSet,a[1].iconId):Ow(r.iconSet,1),upper:a?Ow(a[2].iconSet,a[2].iconId):Ow(r.iconSet,2)};r.reverse&&(s={upper:s.lower,middle:s.middle,lower:s.upper});for(let e of Object.keys(s))if(!s[e])switch(n.generateNotSupportedWarning(`IconSets with empty icons`),e){case`upper`:s[e]=yS.dots.good;break;case`middle`:s[e]=yS.dots.neutral;break;case`lower`:s[e]=yS.dots.bad;break}return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:`IconSetRule`,icons:s,upperInflectionPoint:o[1],lowerInflectionPoint:o[0]}}}function Ow(e,t){let n=gC[e];return n?t===0?yS[n].bad:t===1?yS[n].neutral:yS[n].good:``}function kw(e,t,n){if(e.cfRules.length>1&&n.generateNotSupportedWarning(`Multiple rules conditional formats`),sC.includes(e.cfRules[0].type)||n.generateNotSupportedWarning(`Conditional format type`,e.cfRules[0].type),e.cfRules[0].dxfId){let r=t[e.cfRules[0].dxfId];r.border&&n.generateNotSupportedWarning(`Borders in conditional formats`),r.alignment&&n.generateNotSupportedWarning(`Alignment in conditional formats`),r.numFmt&&n.generateNotSupportedWarning(`Num formats in conditional formats`)}}function Aw(e,t){let n=[],r=1;for(let i of e)if(i)switch(i.type){case`time`:t.generateNotSupportedWarning(`Time data validation rules`);break;case`textLength`:t.generateNotSupportedWarning(`Text length data validation rules`);break;case`whole`:t.generateNotSupportedWarning(`Whole number data validation rules`);break;case`decimal`:let e=jw(r++,i);n.push(e);break;case`list`:let a=Mw(r++,i);n.push(a);break;case`date`:if(i.operator===`notEqual`){t.generateNotSupportedWarning(`Not equal date data validation rules`);break}let o=Nw(r++,i);n.push(o);break;case`custom`:let s=Pw(r++,i);n.push(s);break}return n}function jw(e,t){let n=[rw(t.formula1.toString())];return t.formula2&&n.push(rw(t.formula2.toString())),{id:e.toString(),ranges:t.sqref,isBlocking:t.errorStyle!==`warning`,criterion:{type:EC[t.operator],values:n}}}function Mw(e,t){let n=t.formula1.toString(),r=xl.test(n);return{id:e.toString(),ranges:t.sqref,isBlocking:t.errorStyle!==`warning`,criterion:{type:r?`isValueInRange`:`isValueInList`,values:r?[n]:n.replaceAll(`"`,``).split(`,`),displayStyle:`arrow`}}}function Nw(e,t){let n,r=[rw(t.formula1.toString())];return t.formula2?(r.push(rw(t.formula2.toString())),n={type:DC[t.operator],values:pb(r,z)}):n={type:DC[t.operator],values:pb(r,z),dateValue:`exactDate`},{id:e.toString(),ranges:t.sqref,isBlocking:t.errorStyle!==`warning`,criterion:n}}function Pw(e,t){return{id:e.toString(),ranges:t.sqref,isBlocking:t.errorStyle!==`warning`,criterion:{type:`customFormula`,values:[rw(t.formula1.toString())]}}}let Fw=new D,Iw=new D;function Lw(e){let t=1;return e.figures.map(n=>Rw(n,(t++).toString(),e)).filter(C)}function Rw(e,t,n){let r,i,a,o,s;if(e.anchors.length===1)({col:r,row:i,offset:a}=Ww(e.anchors[0])),s=qC(e.figureSize.cx),o=qC(e.figureSize.cy);else{({col:r,row:i,offset:a}=Ww(e.anchors[0]));let{x:t,y:c}=Gw(e.anchors[0],n),{x:l,y:u}=Gw(e.anchors[1],n);s=l-t,o=u-c}let c={id:t,col:r,row:i,offset:a};if(zw(e.data))return{...c,width:s,height:o,tag:`chart`,data:Vw(e.data)};if(Bw(e.data))return{...c,width:qC(e.data.size.cx),height:qC(e.data.size.cy),tag:`image`,data:{path:e.data.imageSrc,mimetype:e.data.mimetype}}}function zw(e){return`dataSets`in e&&e.dataSets.length>0}function Bw(e){return`imageSrc`in e}function Vw(e){let t=e.dataSets.some(e=>`reference`in(e.label??{})),n={},r=e.labelRange?Hw(e.labelRange,t):void 0,i=e.dataSets.map((e,r)=>{let i;e.label&&`text`in e.label&&(i=e.label.text);let a=r.toString();return n[a]={label:i,backgroundColor:e.backgroundColor,trend:Uw(e.trend)},{dataSetId:a,dataRange:Hw(e.range,t)}});e.type===`pie`&&i.reverse();let a={dataSource:{dataSets:i,dataSetsHaveTitle:t,labelRange:r,type:`range`},dataSetStyles:n,auxiliaryRange:r,title:e.title??{text:``},background:iw({rgb:e.backgroundColor})||`#FFFFFF`,legendPosition:e.legendPosition,stacked:e.stacked||!1,aggregated:!1,cumulative:e.cumulative||!1,labelsAsText:!1,horizontal:e.horizontal,isDoughnut:e.isDoughnut,pieHolePercentage:e.pieHolePercentage,showValues:e.showValues,axesDesign:e.axesDesign,slicesColors:e.slicesColors};try{let t=Iw.get(e.type),n=Fw.get(`range`);return t.getDefinitionFromContextCreation(a,n)}catch{return}}function Hw(e,t){let{sheetName:n,xc:r}=Dl(e),i=Yn(r);if(t&&i.bottom!==void 0&&i.right!==void 0){let e=i.bottom-i.top+1,t=i.right-i.left+1;e===1?i={...i,left:i.left-1}:t===1&&(i={...i,top:i.top-1})}return Ol(n,tr(i))}function Uw(e){if(!(!e||!e.type))return{type:e.type===`linear`?`polynomial`:yC[e.type],order:e.type===`linear`?1:e.order,color:e.color,window:e.window||2,display:!0}}function Ww(e){let t={x:qC(e.colOffset)-1,y:qC(e.rowOffset)-1};return{col:e.col,row:e.row,offset:t}}function Gw(e,t){return{x:JC(e.col,t)+qC(e.colOffset),y:YC(e.row,t)+qC(e.rowOffset)}}let Kw=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),qw=new RegExp(/SUBTOTAL\(([0-9]*),/g),Jw=new RegExp(hl.source,`ig`);function Yw(e,t){let n=Xw(e);for(let r of e.rows.map(e=>e.cells).flat())r?.formula&&(r.formula.content=r.formula.sharedIndex!==void 0&&!r.formula.content?`=`+Qw(r.xc,n[r.formula.sharedIndex]):`=`+r.formula.content,r.formula.content=Zw(r.formula.content,t))}function Xw(e){let t={};for(let n of e.rows)for(let e of n.cells)e.formula&&e.formula.sharedIndex!==void 0&&e.formula.content&&(t[e.formula.sharedIndex]={refCellXc:e.xc,formula:e.formula.content});return t}function Zw(e,t){return e=e.replace(`_xlfn.`,``),e=e.replace(/#REF!/g,`#REF`),e=e.replace(qw,(e,t)=>{let n=bC[t];return n?n+`(`:e}),e=e.replace(Kw,(e,n,r,i)=>{n=Number(n)-1,i=i.replace(/\$/g,``);let a=t.externalBooks[n]?.sheetNames.findIndex(e=>$u(e,r))??-1;if(a===-1)return e;let o=t.externalBooks[n].datasets.find(e=>e.sheetId===a)?.data;if(!o)return e;let s=o&&o[i];return(Number(s)?s:`"${s}"`)||e}),e}function Qw(e,t){let n=Rn(t.refCellXc),r=t.formula.slice(),i;do if(i=Jw.exec(r),i){let t=Rn(i[0].replace(`$`,``)),a=Rn(e),o={colFixed:i[0].startsWith(`$`),rowFixed:i[0].includes(`$`,1)},s={col:a.col-n.col,row:a.row-n.row},c={col:o.colFixed?t.col:t.col+s.col,row:o.rowFixed?t.row:t.row+s.row};r=r.slice(0,i.index)+T(c.col,c.row,o)+r.slice(i.index+i[0].length)}while(i);return r}function $w(e,t){return e.sheets.map(n=>{Yw(n,e);let r=sT(n),i=n.sheetViews[0],a=cT(n,`ROW`,r[1]),o=cT(n,`COL`,r[0]);return{id:n.sheetName,areGridLinesVisible:i?i.showGridLines:!0,name:n.sheetName,colNumber:r[0],rowNumber:r[1],...iT(n,e,r,t),merges:n.merges,cols:eT(n,r[0],o),rows:tT(n,r[1],a),...nT(n,e,r),conditionalFormats:ww(n.cfs,e.dxfs,t),dataValidationRules:Aw(n.dataValidations,t),figures:Lw(n),isVisible:n.isVisible,panes:i?{xSplit:i.pane.xSplit,ySplit:i.pane.ySplit}:{xSplit:0,ySplit:0},tables:[],headerGroups:{COL:o,ROW:a},color:iw(n.sheetProperties?.tabColor),isLocked:n.isLocked}})}function eT(e,t,n){let r={};for(let i=1;i<t+1;i++){let t=e.cols.find(e=>e.min<=i&&i<=e.max),a;a=t&&t.width?t.width:e.sheetFormat?.defaultColWidth?e.sheetFormat.defaultColWidth:om;let o=i-1,s=n.some(e=>e.isFolded&&e.start<=o&&o<=e.end);r[o]={size:NC(a),isHidden:!s&&t?.hidden}}return r}function tT(e,t,n){let r={};for(let i=1;i<t+1;i++){let t=e.rows.find(e=>e.index===i),a;a=t&&t.height?t.height:e.sheetFormat?.defaultRowHeight?e.sheetFormat.defaultRowHeight:sm;let o=i-1,s=n.some(e=>e.isFolded&&e.start<=o&&o<=e.end);r[o]={size:MC(a),isHidden:!s&&t?.hidden}}return r}function nT(e,t,n){let r={rowDefault:[],colDefault:[]},i={rowDefault:[],colDefault:[]};for(let n of e.rows.filter(e=>e.styleIndex))r.rowDefault[n.index-1]=n.styleIndex+1,i.rowDefault[n.index-1]=t.styles[n.styleIndex].numFmtId+1;for(let a of e.cols.filter(e=>e.styleIndex))if(a.min===1&&a.max>=n[0])r.sheetDefault=a.styleIndex+1,i.sheetDefault=t.styles[a.styleIndex].numFmtId+1;else for(let e=a.min;e<=a.max;e++)r.colDefault[e-1]=a.styleIndex+1,i.colDefault[e-1]=t.styles[a.styleIndex].numFmtId+1;return{defaultFormat:i,defaultStyle:r}}function rT(e){return e.map(sn)}function iT(e,t,n,r){let i={},a={},o={},s={},c=rT(t.sharedStrings),l=e.hyperlinks.reduce((e,t)=>(e[t.xc]=t,e),{});for(let n of e.rows)for(let e of n.cells)i[e.xc]=aT(e,l,c,r),e.styleIndex&&(a[e.xc]=e.styleIndex+1,o[e.xc]=t.styles[e.styleIndex].numFmtId+1,s[e.xc]=t.styles[e.styleIndex].borderId+1);for(let r of e.rows.filter(e=>e.styleIndex))for(let e=1;e<=n[0];e++){let n=T(e-1,r.index-1);s[n]??=t.styles[r.styleIndex].borderId+1}for(let r of e.cols.filter(e=>e.styleIndex))for(let e=r.min;e<=Math.min(r.max,n[0]);e++)for(let i=1;i<=n[1];i++){let n=T(e-1,i-1);s[n]??=t.styles[r.styleIndex].borderId+1}return{cells:i,styles:a,formats:o,borders:s}}function aT(e,t,n,r){let i;switch(e.type){case`sharedString`:i=n[parseInt(e.value,10)];break;case`boolean`:i=Number(e.value)?`TRUE`:`FALSE`;break;case`date`:case`error`:case`inlineStr`:case`number`:case`str`:i=e.value;break}return i&&t[e.xc]&&(i=oT(t[e.xc],i,r)),e.formula&&(i=e.formula.content),i}function oT(e,t,n){let r=e.display||t;return!e.relTarget&&!e.location&&n.generateNotSupportedWarning(`Badly formatted hyperlink`),Rt(r,e.relTarget?e.relTarget:Ht(Dl(e.location).sheetName))}function sT(e){let t=[0,0];for(let n of e.rows)t[0]=Math.max(t[0],gn(n.cells.map(e=>Rn(e.xc).col))),t[1]=Math.max(t[1],n.index);for(let n of e.figures)t[0]=Math.max(t[0],n.anchors[n.anchors.length-1]?.col??0),t[1]=Math.max(t[1],n.anchors[n.anchors.length-1]?.row??0);return t[0]=Math.max(t[0]+5,30),t[1]=Math.max(t[1]+5,100),t}function cT(e,t,n){let r=e?.sheetProperties?.outlinePr,i=[],a=0;for(let o=0;o<n;o++){let n=uT(e,t,o)?.outlineLevel||0;if(n>a){let n=(t===`ROW`?r?.summaryBelow:r?.summaryRight)??!0,a=lT(e,t,o,n);a&&i.push(a)}a=n}return i}function lT(e,t,n,r){let i=uT(e,t,n),a=i?.outlineLevel;if(!a||!a)return;let o=a,s=n,c=i;for(;c&&o>=a;)s++,c=uT(e,t,s),o=c?.outlineLevel||0;let l=n,u=s-1,d=(r?uT(e,t,u+1):uT(e,t,l-1))?.collapsed||!1;return{start:l-1,end:u-1,isFolded:d}}function uT(e,t,n){return t===`COL`?e.cols.find(e=>e.min<=n&&n<=e.max):e.rows.find(e=>e.index===n)}let dT={hasFilters:!1,totalRow:!1,firstColumn:!1,lastColumn:!1,numberOfHeaders:1,bandedRows:!0,bandedColumns:!1,automaticAutofill:!0,styleId:`TableStyleMedium2`},fT={light:M(`Light`),medium:M(`Medium`),dark:M(`Dark`)};function pT(e,t){return{coloredText:$f(t,.3),light:Jf(t,.8),medium:Jf(t,.6),dark:$f(t,.3),mediumBorder:Jf(t,.45),highlight:t,name:e}}let q={black:{name:M(`Black`),coloredText:`#000000`,light:`#D9D9D9`,medium:`#A6A6A6`,dark:`#404040`,mediumBorder:`#000000`,highlight:`#000000`},lightBlue:pT(M(`Blue`),`#346B90`),red:pT(M(`Red`),`#C53628`),lightGreen:pT(M(`Green`),`#748747`),purple:pT(M(`Purple`),`#6C4E65`),gray:{name:M(`Gray`),coloredText:`#666666`,light:`#EEEEEE`,medium:`#DDDDDD`,dark:`#767676`,mediumBorder:`#D0D0D0`,highlight:`#A9A9A9`},orange:pT(M(`Orange`),`#C37034`)},mT={black:q.black,orangeBlue:{...q.lightBlue,highlight:q.orange.highlight},purpleGreen:{...q.lightGreen,highlight:q.purple.highlight},redBlue:{...q.lightBlue,highlight:q.red.highlight}},hT=e=>({category:`light`,templateName:`lightColoredText`,primaryColor:e.highlight,wholeTable:{style:{textColor:e.coloredText},border:{top:{color:e.highlight,style:`thin`},bottom:{color:e.highlight,style:`thin`}}},headerRow:{border:{bottom:{color:e.highlight,style:`thin`}},style:{bold:!0}},totalRow:{border:{top:{color:e.highlight,style:`thin`}},style:{bold:!0}},firstRowStripe:{style:{fillColor:e.light}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}}}),gT=e=>({category:`light`,templateName:`lightWithHeader`,primaryColor:e.highlight,wholeTable:{border:{top:{color:e.highlight,style:`thin`},bottom:{color:e.highlight,style:`thin`},left:{color:e.highlight,style:`thin`},right:{color:e.highlight,style:`thin`}}},headerRow:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0},border:{bottom:{color:e.highlight,style:`thin`}}},totalRow:{border:{top:{color:e.highlight,style:`medium`}},style:{bold:!0}},firstRowStripe:{border:{bottom:{color:e.highlight,style:`thin`}}},secondRowStripe:{border:{bottom:{color:e.highlight,style:`thin`}}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}}}),_T=e=>({category:`light`,templateName:`lightAllBorders`,primaryColor:e.highlight,wholeTable:{border:{top:{color:e.highlight,style:`thin`},bottom:{color:e.highlight,style:`thin`},left:{color:e.highlight,style:`thin`},right:{color:e.highlight,style:`thin`},horizontal:{color:e.highlight,style:`thin`},vertical:{color:e.highlight,style:`thin`}}},headerRow:{border:{bottom:{color:e.highlight,style:`medium`}},style:{bold:!0}},totalRow:{border:{top:{color:e.highlight,style:`medium`}},style:{bold:!0}},firstRowStripe:{style:{fillColor:e.light}},firstColumnStripe:{style:{fillColor:e.light}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}}}),vT=e=>({category:`medium`,templateName:`mediumBandedBorders`,primaryColor:e.highlight,wholeTable:{border:{top:{color:e.mediumBorder,style:`thin`},bottom:{color:e.mediumBorder,style:`thin`},left:{color:e.mediumBorder,style:`thin`},right:{color:e.mediumBorder,style:`thin`},horizontal:{color:e.mediumBorder,style:`thin`}}},headerRow:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},totalRow:{border:{top:{color:e.highlight,style:`medium`}},style:{bold:!0}},firstRowStripe:{style:{fillColor:e.light}},firstColumnStripe:{style:{fillColor:e.light}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}}}),yT=e=>({category:`medium`,templateName:`mediumWhiteBorders`,primaryColor:e.highlight,wholeTable:{border:{horizontal:{color:`#FFFFFF`,style:`thin`},vertical:{color:`#FFFFFF`,style:`thin`}},style:{fillColor:e.light}},headerRow:{border:{bottom:{color:`#FFFFFF`,style:`thick`}},style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},totalRow:{border:{top:{color:`#FFFFFF`,style:`thick`}},style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},firstColumn:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},lastColumn:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},firstRowStripe:{style:{fillColor:e.medium}},firstColumnStripe:{style:{fillColor:e.medium}}}),bT=e=>({category:`medium`,templateName:`mediumMinimalBorders`,primaryColor:e.highlight,wholeTable:{border:{top:{color:`#000000`,style:`medium`},bottom:{color:`#000000`,style:`medium`}}},totalRow:{border:{top:{color:`#000000`,style:`medium`}},style:{bold:!0}},headerRow:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0},border:{bottom:{color:`#000000`,style:`medium`}}},firstColumn:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},lastColumn:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},firstRowStripe:{style:{fillColor:q.black.light}},firstColumnStripe:{style:{fillColor:q.black.light}}}),xT=e=>({category:`medium`,templateName:`mediumAllBorders`,primaryColor:e.highlight,wholeTable:{border:{top:{color:e.mediumBorder,style:`thin`},bottom:{color:e.mediumBorder,style:`thin`},left:{color:e.mediumBorder,style:`thin`},right:{color:e.mediumBorder,style:`thin`},horizontal:{color:e.mediumBorder,style:`thin`},vertical:{color:e.mediumBorder,style:`thin`}},style:{fillColor:e.light}},totalRow:{border:{top:{color:e.highlight,style:`medium`}},style:{bold:!0}},firstRowStripe:{style:{fillColor:e.medium}},firstColumnStripe:{style:{fillColor:e.medium}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}},headerRow:{style:{bold:!0}}}),ST=e=>({category:`dark`,templateName:`dark`,primaryColor:e.highlight,wholeTable:{style:{fillColor:e.highlight,textColor:`#FFFFFF`}},totalRow:{style:{fillColor:e.dark,textColor:`#FFFFFF`,bold:!0},border:{top:{color:`#FFFFFF`,style:`thick`}}},headerRow:{style:{fillColor:`#000000`,bold:!0},border:{bottom:{color:`#FFFFFF`,style:`thick`}}},firstColumn:{style:{fillColor:e.dark,bold:!0},border:{right:{color:`#FFFFFF`,style:`thick`}}},lastColumn:{style:{fillColor:e.dark,bold:!0},border:{left:{color:`#FFFFFF`,style:`thick`}}},firstRowStripe:{style:{fillColor:e.dark}},firstColumnStripe:{style:{fillColor:e.dark}}}),CT=e=>({category:`dark`,templateName:`darkNoBorders`,primaryColor:e.highlight,wholeTable:{style:{fillColor:e.light}},totalRow:{border:{top:{color:`#000000`,style:`medium`}},style:{bold:!0}},headerRow:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},firstRowStripe:{style:{fillColor:e.medium}},firstColumnStripe:{style:{fillColor:e.medium}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}}}),wT=ST(q.black);wT.wholeTable.style.fillColor=`#737373`;let TT=bT(q.black);TT.wholeTable.border={...TT.wholeTable.border,left:{color:`#000000`,style:`thin`},right:{color:`#000000`,style:`thin`},horizontal:{color:`#000000`,style:`thin`},vertical:{color:`#000000`,style:`thin`}};function J(e,t,n){return{...t(n),displayName:`${n.name}, ${e}`}}let ET={None:{category:`light`,templateName:`none`,primaryColor:``,displayName:M(`None`)},TableStyleLight1:J(`TableStyleLight1`,hT,q.black),TableStyleLight2:J(`TableStyleLight2`,hT,q.lightBlue),TableStyleLight3:J(`TableStyleLight3`,hT,q.red),TableStyleLight4:J(`TableStyleLight4`,hT,q.lightGreen),TableStyleLight5:J(`TableStyleLight5`,hT,q.purple),TableStyleLight6:J(`TableStyleLight6`,hT,q.gray),TableStyleLight7:J(`TableStyleLight7`,hT,q.orange),TableStyleLight8:J(`TableStyleLight8`,gT,q.black),TableStyleLight9:J(`TableStyleLight9`,gT,q.lightBlue),TableStyleLight10:J(`TableStyleLight10`,gT,q.red),TableStyleLight11:J(`TableStyleLight11`,gT,q.lightGreen),TableStyleLight12:J(`TableStyleLight12`,gT,q.purple),TableStyleLight13:J(`TableStyleLight13`,gT,q.gray),TableStyleLight14:J(`TableStyleLight14`,gT,q.orange),TableStyleLight15:J(`TableStyleLight15`,_T,q.black),TableStyleLight16:J(`TableStyleLight16`,_T,q.lightBlue),TableStyleLight17:J(`TableStyleLight17`,_T,q.red),TableStyleLight18:J(`TableStyleLight18`,_T,q.lightGreen),TableStyleLight19:J(`TableStyleLight19`,_T,q.purple),TableStyleLight20:J(`TableStyleLight20`,_T,q.gray),TableStyleLight21:J(`TableStyleLight21`,_T,q.orange),TableStyleMedium1:J(`TableStyleMedium1`,vT,q.black),TableStyleMedium2:J(`TableStyleMedium2`,vT,q.lightBlue),TableStyleMedium3:J(`TableStyleMedium3`,vT,q.red),TableStyleMedium4:J(`TableStyleMedium4`,vT,q.lightGreen),TableStyleMedium5:J(`TableStyleMedium5`,vT,q.purple),TableStyleMedium6:J(`TableStyleMedium6`,vT,q.gray),TableStyleMedium7:J(`TableStyleMedium7`,vT,q.orange),TableStyleMedium8:J(`TableStyleMedium8`,yT,q.black),TableStyleMedium9:J(`TableStyleMedium9`,yT,q.lightBlue),TableStyleMedium10:J(`TableStyleMedium10`,yT,q.red),TableStyleMedium11:J(`TableStyleMedium11`,yT,q.lightGreen),TableStyleMedium12:J(`TableStyleMedium12`,yT,q.purple),TableStyleMedium13:J(`TableStyleMedium13`,yT,q.gray),TableStyleMedium14:J(`TableStyleMedium14`,yT,q.orange),TableStyleMedium15:{...TT,displayName:`Black, TableStyleMedium15`},TableStyleMedium16:J(`TableStyleMedium16`,bT,q.lightBlue),TableStyleMedium17:J(`TableStyleMedium17`,bT,q.red),TableStyleMedium18:J(`TableStyleMedium18`,bT,q.lightGreen),TableStyleMedium19:J(`TableStyleMedium19`,bT,q.purple),TableStyleMedium20:J(`TableStyleMedium20`,bT,q.gray),TableStyleMedium21:J(`TableStyleMedium21`,bT,q.orange),TableStyleMedium22:J(`TableStyleMedium22`,xT,q.black),TableStyleMedium23:J(`TableStyleMedium23`,xT,q.lightBlue),TableStyleMedium24:J(`TableStyleMedium24`,xT,q.red),TableStyleMedium25:J(`TableStyleMedium25`,xT,q.lightGreen),TableStyleMedium26:J(`TableStyleMedium26`,xT,q.purple),TableStyleMedium27:J(`TableStyleMedium27`,xT,q.gray),TableStyleMedium28:J(`TableStyleMedium28`,xT,q.orange),TableStyleDark1:{...wT,displayName:`Black, TableStyleDark1`},TableStyleDark2:J(`TableStyleDark2`,ST,q.lightBlue),TableStyleDark3:J(`TableStyleDark3`,ST,q.red),TableStyleDark4:J(`TableStyleDark4`,ST,q.lightGreen),TableStyleDark5:J(`TableStyleDark5`,ST,q.purple),TableStyleDark6:J(`TableStyleDark6`,ST,q.gray),TableStyleDark7:J(`TableStyleDark7`,ST,q.orange),TableStyleDark8:J(`TableStyleDark8`,CT,mT.black),TableStyleDark9:J(`TableStyleDark9`,CT,mT.redBlue),TableStyleDark10:J(`TableStyleDark10`,CT,mT.purpleGreen),TableStyleDark11:J(`TableStyleDark11`,CT,mT.orangeBlue)},DT={none:()=>({category:`none`,templateName:`none`,primaryColor:``,name:`none`}),lightColoredText:hT,lightAllBorders:_T,mediumAllBorders:xT,lightWithHeader:gT,mediumBandedBorders:vT,mediumMinimalBorders:bT,darkNoBorders:CT,mediumWhiteBorders:yT,dark:ST};function OT(e,t,n){let r=pT(``,n);return{...DT[t](r),category:`custom`,displayName:e}}function kT(e,t){for(let n of t.sheets){let t=e.sheets.find(e=>e.name===n.sheetName);if(t){t.tables||=[];for(let e of n.tables)t.tables.push({range:e.ref,config:AT(e)});for(let e of n.pivotTables)t.tables.push({range:e.location.ref,config:jT(e)})}}MT(e,t.sheets)}function AT(e){let t=e.style?.name||``;return{hasFilters:e.autoFilter!==void 0,numberOfHeaders:e.headerRowCount,totalRow:e.totalsRowCount>0,firstColumn:e.style?.showFirstColumn||!1,lastColumn:e.style?.showLastColumn||!1,bandedRows:e.style?.showRowStripes||!1,bandedColumns:e.style?.showColumnStripes||!1,styleId:ET[t]?t:dT.styleId}}function jT(e){return{hasFilters:!1,numberOfHeaders:e.location.firstDataRow,totalRow:e.rowGrandTotals,firstColumn:!0,lastColumn:e.style?.showLastColumn||!1,bandedRows:e.style?.showRowStripes||!1,bandedColumns:e.style?.showColStripes||!1,styleId:dT.styleId}}function MT(e,t){let n=null;PT(e,t);let r=e.sheets;for(let e of r){let i=t.find(t=>$u(t.sheetName,e.name)).tables;if(!(!i||i.length===0)){n||=NT(r);for(let t of i)for(let i in n){let a=r.find(e=>e.id===i);for(let r in n[i]){let o=n[i][r];for(let s=o.length-3;s>=0;s-=2){let o=n[i][r][s];if(!o.endsWith(t.name))continue;let c=n[i][r][s+1],l=FT(e.id===a.id?``:e.name+`!`,c,t,r);n[i][r][s+2]=o.slice(0,o.indexOf(t.name))+l+n[i][r][s+2],n[i][r].splice(s,2)}}}}}if(n)for(let e in n){let t=r.find(t=>t.id===e);for(let r in n[e]){let i=n[e][r];if(i.length===1){t.cells[r]=i[0];continue}let a=``;for(let e=0;e<i.length;e+=2)a+=i[e]+`[`+i[e+1]+`]`;a+=i[i.length-1],t.cells[r]=a}}}function NT(e){let t={};for(let n of e)for(let e in n.cells){let r=n.cells[e];if(!r||!r.startsWith(`=`))continue;let i=r.indexOf(`[`);if(i===-1)continue;let a=[],o=r.slice(0,i),s=``,c=1,l=0,u=i;for(let e=i+1;e<r.length;e++){if(r[e]===`[`){c===0&&(o=r.slice(l,e),u=e),c++;continue}r[e]===`]`&&(c--,c===0&&(s=r.slice(u+1,e),a.push(o),a.push(s),l=e+1))}a.length&&(t[n.id]||(t[n.id]={}),a.push(r.slice(l)),t[n.id][e]=[...a])}return t}function PT(e,t){for(let n in e.namedRanges||{}){let r=e.namedRanges[n];if(r.endsWith(`]`))for(let i of e.sheets){let a=t.find(e=>$u(e.sheetName,i.name))?.tables;for(let t of a||[]){if(!t.name||!r.startsWith(t.name+`[`))continue;let a=FT(i.name+`!`,r.slice(t.name.length+1,r.length-1),t,`invalidCellXc`);e.namedRanges[n]=a}}}}function FT(e,t,n,r){t===``&&(t=`#Data`);let i=t.split(`,`).map(e=>e.trim()),a=Xn(n.ref),o=[],s=[],c=[];for(let e of i)if(IT(e).startsWith(`#`)){let t=IT(e);switch(c.push(t),t){case`#All`:s.push(a.top,a.bottom);break;case`#Data`:let e=n.headerRowCount?a.top+n.headerRowCount:a.top,t=n.totalsRowCount?a.bottom-n.totalsRowCount:a.bottom;s.push(e,t);break;case`#This Row`:s.push(Rn(r).row);break;case`#Headers`:if(!n.headerRowCount)return N.InvalidReference;s.push(a.top);break;case`#Totals`:if(!n.totalsRowCount)return N.InvalidReference;s.push(a.bottom);break}}else{let t=e.split(`:`).map(e=>e.trim()).map(IT);if(o.length)return N.InvalidReference;let r=n.cols.findIndex(e=>e.name===t[0]);if(r===-1)return N.InvalidReference;if(o.push(r+a.left),t[1]){let e=n.cols.findIndex(e=>e.name===t[1]);if(e===-1)return N.InvalidReference;o.push(e+a.left)}}if(!LT(c))return N.InvalidReference;if(s.length===0){let e=n.headerRowCount?a.top+n.headerRowCount:a.top,t=n.totalsRowCount?a.bottom-n.totalsRowCount:a.bottom;s.push(e,t)}return o.length===0&&o.push(a.left,a.right),e+tr({top:Math.min(...s),left:Math.min(...o),bottom:Math.max(...s),right:Math.max(...o)})}function IT(e){return e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,e.length-1):e}function LT(e){return e.length<2?!0:e.length>2?!1:e.includes(`#Data`)&&e.includes(`#Totals`)?!0:!!(e.includes(`#Headers`)&&e.includes(`#Data`))}function RT(e,t,n){return{content:new XMLSerializer().serializeToString(e),path:t,contentType:n}}function zT(e){return String(e).replace(/\&/g,`&`).replace(/\</g,`<`).replace(/\>/g,`>`).replace(/\"/g,`"`).replace(/\'/g,`'`).replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,``)}function Y(e){return new WS(e.map(([e,t])=>`${e}="${zT(t)}"`).join(` `))}function BT(e,t=`text/xml`){let n=new DOMParser().parseFromString(e.toString(),t),r=n.querySelector(`parsererror`);if(r){let t=r.innerHTML,n=parseInt(t.split(`:`)[0],10),i=e.toString().trim().split(`
|
|
45
45
|
`),a=i.slice(Math.max(n-3,0),Math.min(n+2,i.length)).join(`
|
|
46
46
|
`);throw Error(`XML string could not be parsed: ${t}\n${a}`)}return n}function VT(e){if(e)return{style:e.style,color:{rgb:e.color}}}function HT(e){let t=[{},...Object.values(e.borders).map(e=>({left:VT(e.left),right:VT(e.right),bottom:VT(e.bottom),top:VT(e.top)}))];return{relsFiles:[],sharedStrings:[],chartIds:[],imageIds:[],styles:[{fontId:0,fillId:0,numFmtId:0,borderId:0,alignment:{}}],fonts:[{size:Ze,family:2,color:{rgb:`000000`},name:`Arial`}],fills:[{reservedAttribute:`none`},{reservedAttribute:`gray125`}],borders:t,numFmts:[],dxfs:[],namedRanges:[]}}function UT(e,t){return Z`
|
|
@@ -954,4 +954,4 @@ If you meant to create a named range, named range cannot have the same name as a
|
|
|
954
954
|
<Relationships xmlns="${Qp.Relationships}">
|
|
955
955
|
<Relationship ${Y(e)} />
|
|
956
956
|
</Relationships>
|
|
957
|
-
`),`_rels/.rels`)}function VK(e){let t={},n=[];for(let r of e.sheets){let e=r.name.slice(0,31);e=xn(e,n,{compute:(e,t)=>e.slice(0,31-String(t).length)+t}),n.push(e),e!==r.name&&(t[r.name]=e,r.name=e)}if(!Object.keys(t).length)return e;let r=Object.keys(t).sort((e,t)=>t.length-e.length),i=JSON.stringify(e);for(let e of r){let n=RegExp(`'?${Tt(e)}'?!`,`g`);i=i.replaceAll(n,n=>{let r=t[e];return n.replace(e,r)})}return JSON.parse(i)}function HK(e){for(let t of e.sheets)t.tables=t.tables.filter(e=>mr(Xn(e.range)).numberOfRows>1);return e}var UK=class e extends Qi{corePlugins=[];statefulUIPlugins=[];range;formulasPlugin;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;coreViewPluginConfig;uiPluginConfig;state;selection;getters;coreGetters;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},t={},n=[],r=!1){let i=performance.now();console.debug(`##### Model creation #####`),super(),Ao(),n=jE(e,n);let a=CE(e,r);this.state=new tG,this.config=this.setupConfig(t),this.getters={isReadonly:()=>this.config.mode===`readonly`||this.config.mode===`dashboard`,isDashboard:()=>this.config.mode===`dashboard`},this.session=this.setupSession(a.revisionId),this.coreGetters={},this.range=new ZW(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.getRangeData=this.range.getRangeData.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.coreGetters.recomputeRanges=this.range.recomputeRanges.bind(this.range),this.coreGetters.isRangeValid=this.range.isRangeValid.bind(this.range),this.coreGetters.extendRange=this.range.extendRange.bind(this.range),this.coreGetters.getRangesUnion=this.range.getRangesUnion.bind(this.range),this.coreGetters.removeRangesSheetPrefix=this.range.removeRangesSheetPrefix.bind(this.range),this.coreGetters.copyFormulaStringForSheet=this.range.copyFormulaStringForSheet.bind(this.range),this.formulasPlugin=new XW,this.coreGetters.getAllFormulas=this.formulasPlugin.getAllFormulas.bind(this.formulasPlugin),this.selection=new $W(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.coreViewPluginConfig=this.setupCoreViewPluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of zH.getAll())this.setupCorePlugin(e,a);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(n);for(let e of HH.getAll()){let t=this.setupCoreViewPlugin(e);this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of VH.getAll()){let t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of BH.getAll()){let t=this.setupUiPlugin(e);this.handlers.push(t),this.uiHandlers.push(t)}if(this.config.mode!==`export_verification`&&(this.dispatch(`START`),this.selection.observe(this,{handleEvent:()=>this.trigger(`update`)}),this.setupSessionEvents(),this.joinSession(),t.snapshotRequested||e[`[Content_Types].xml`]&&!this.getters.isReadonly())){let e=performance.now();console.debug(`Snapshot requested`),this.session.snapshot(this.exportData()),console.debug(`Snapshot taken in`,performance.now()-e,`ms`)}console.debug(`Model created in`,performance.now()-i,`ms`),console.debug(`######`)}joinSession(){this.session.join(this.config.client)}async leaveSession({shouldSnapshot:e}={shouldSnapshot:!0}){let t=e&&!this.getters.isReadonly()?Yt(()=>this.exportData()):void 0;await this.session.leave(t)}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)}for(let n of e.layers)this.renderers[n]||(this.renderers[n]=[]),this.renderers[n].push(t);return t}setupCoreViewPlugin(e){let t=new e(this.coreViewPluginConfig);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)}return 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 $V(qW({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{if(!this.checkDispatchAllowedRemoteCommand(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,new RW(this.getters))}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:K.smallUuid(),name:M(`Anonymous`).toString()},n=e.transportService||new jU,r=e.mode===`readonly`||e.mode===`dashboard`||e.mode===`export_verification`;return{...e,mode:e.mode||`normal`,custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:r?new zW(n):n,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger(`notify-ui`,e),raiseBlockingErrorUI:e=>this.trigger(`raise-error-ui`,{text:e}),customColors:e.customColors||[]}}setupExternalConfig(e){let t=e.loadLocales||(()=>Promise.resolve(js));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,formulasPlugin:this.formulasPlugin,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,custom:this.config.custom,external:this.config.external}}setupCoreViewPluginConfig(){return{getters:this.getters,stateObserver:this.state,custom:this.config.custom,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,canDispatch:this.canDispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external,colorScheme:this.config.colorScheme}}checkDispatchAllowed(e){let t=Gd(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return this.processCommandResults(t)}processCommandResults(e){return e.some(e=>e!==`Success`)?new qd(e.flat()):qd.Success}checkDispatchAllowedRemoteCommand(e){let t=this.coreHandlers.map(t=>t.allowDispatch(e));return this.processCommandResults(t)}checkDispatchAllowedCoreCommand(e){return this.handlers.map(t=>t.allowDispatch(e))}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,this.trigger(`command-finalized`)}canDispatch=(e,t)=>this.checkDispatchAllowed(WK(e,t));dispatch=(e,t)=>{let n=WK(e,t),r=this.status;if(this.getters.isReadonly()&&!Kd(n))return new qd(`Readonly`);if(!this.session.canApplyOptimisticUpdate())return new qd(`WaitingSessionConfirmation`);switch(r){case 0:let t=this.checkDispatchAllowed(n);if(!t.isSuccessful)return this.trigger(`update`),this.trigger(`command-rejected`,{command:n,result:t}),t;this.status=1;let{changes:r,commands:i}=this.state.recordChanges(()=>{let t=performance.now();Gd(n)&&this.state.addCommand(n),this.dispatchToHandlers(this.handlers,n),this.finalize();let r=performance.now()-t;r>5&&console.debug(e,r,`ms`)});this.session.save(n,i,r),this.status=0,this.trigger(`update`);break;case 1:if(Gd(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(Gd(n))throw Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,n)}return qd.Success};dispatchFromCorePlugin=(e,t)=>{let n=WK(e,t),r=this.status;this.status=2;let i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,n),this.status=r,qd.Success};dispatchToHandlers(e,t){let n=Gd(t);for(let r of e)!n&&r instanceof KS||r.beforeHandle(t);for(let r of e)!n&&r instanceof KS||r.handle(t);this.trigger(`command-dispatched`,t)}drawLayer(e,t){let n=this.renderers[t];if(n)for(let r of n)e.ctx.save(),r.drawLayer(e,t),e.ctx.restore()}exportData(){let t=this._exportData(!0),n=this._exportData(!1),r={...this.config,mode:`export_verification`,client:{id:`exporter`,name:`exporter`},snapshotRequested:!1,transportService:new jU};return w(n,new e(b(t),r)._exportData(!1))?t:(n.isNotSquishable=!0,n)}_exportData(e){let t=RE();for(let n of this.handlers)n instanceof KS&&n.export(t,e);return t.revisionId=this.session.getRevisionId()||`START_REVISION`,t=b(t),t}updateMode(e){this.config.mode=e,this.trigger(`update`)}async exportXLSX(){this.dispatch(`EVALUATE_CELLS`);let e=BE();for(let t of this.handlers)t instanceof SS&&await t.exportForExcel(e);return e=b(e),MK(e)}};function WK(e,t={}){let n=b(t);return n.type=e,n}var GK=class extends TI{queuedBordersToAdd={};copy(e){let t=e.sheetId;if(e.zones.length===0)return;let{rowsIndexes:n,columnsIndexes:r}=e,i=[];for(let e of n){let n=[];for(let i of r){let r={col:i,row:e,sheetId:t};n.push(this.getters.getCellBorder(r))}i.push(n)}return{borders:i}}paste(e,t,n){let r=e.sheetId;if(n.pasteOption===`asValue`)return;let i=e.zones;if(!n.isCutOperation)this.pasteFromCopy(r,i,t.borders);else{let{left:e,top:n}=i[0];this.pasteZone(r,e,n,t.borders)}this.executeQueuedChanges(r)}pasteZone(e,t,n,r){for(let[i,a]of r.entries())for(let[r,o]of a.entries()){let a={col:t+r,row:n+i,sheetId:e};this.pasteBorder(o,a)}}pasteBorder(e,t){let n={...this.getters.getCellBorder(t),...e},r=JSON.stringify(n);this.queuedBordersToAdd[r]||(this.queuedBordersToAdd[r]=[]),this.queuedBordersToAdd[r].push(E(t))}executeQueuedChanges(e){for(let t in this.queuedBordersToAdd){let n=this.queuedBordersToAdd[t],r=JSON.parse(t),i=zn(n,[]);this.dispatch(`SET_BORDERS_ON_TARGET`,{sheetId:e,target:i,border:r})}this.queuedBordersToAdd={}}},KK=class extends wI{copy(e){}getCopyRect(e){return L_(...e.figureIds.map(t=>this.getters.getFigure(e.sheetId,t)).filter(C).map(t=>this.getters.getFigureUI(e.sheetId,t)))}},qK=class extends KK{copy(e){let t=e.sheetId,n=[],r=this.getCopyRect(e);for(let i of e.figureIds){let e=this.getters.getFigure(t,i);if(!e)throw Error(`No figure for the given id: ${i}`);if(e.tag!==`carousel`)continue;let a={...e},o=this.getters.getCarousel(i),{x:s,y:c}=this.getters.getFigureUI(t,e),l={};for(let e of o.items)if(e.type===`chart`){let t=this.getters.getChart(e.chartId);if(!t)throw Error(`No chart for the given id: ${e.chartId}`);l[e.chartId]=t}n.push({figureId:i,copiedFigure:a,copiedCarousel:o,copiedCharts:l,copiedSheetId:t,offset:{x:s-r.x,y:c-r.y}})}return{figures:n,figureIds:e.figureIds}}getPasteTarget(e,t,n,r){let i={};for(let e of n.figures)i[e.figureId]=K.smallUuid();return{zones:[],figureIds:i,sheetId:e}}paste(e,t,n){if(!e.figureIds)return;let{zones:r}=e,i=e.sheetId;for(let a of t.figures){let o=e.figureIds[a.figureId],{width:s,height:c}=a.copiedFigure,{col:l,row:u,offset:d}=a_(this.getters,i,{col:r[0].left,row:r[0].top},{...a.copiedFigure,offset:a.offset});this.dispatch(`CREATE_CAROUSEL`,{figureId:o,sheetId:i,definition:{items:[]},col:l,row:u,offset:d,size:{height:c,width:s}});let f=b(a.copiedCarousel.items);for(let e of f){if(e.type!==`chart`)continue;let t=a.copiedCharts[e.chartId],n=K.smallUuid(),r=jO.fromDefinition(this.getters,i,t.copyInSheetId(i)).getDefinition();this.dispatch(`CREATE_CHART`,{figureId:o,chartId:n,sheetId:i,definition:r}),e.chartId=n}this.dispatch(`UPDATE_CAROUSEL`,{sheetId:i,figureId:o,definition:this.getters.carouselToCarouselData({...a.copiedCarousel,items:f})}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:a.copiedSheetId,figureId:a.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:o,selectMultiple:t.figureIds.length>1})}}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},JK=class extends KK{copy(e){let t=e.sheetId,n=[],r=this.getCopyRect(e);for(let i of e.figureIds){let e=this.getters.getFigure(t,i);if(!e)throw Error(`No figure for the given id: ${i}`);if(e.tag!==`chart`)continue;let a={...e},{x:o,y:s}=this.getters.getFigureUI(t,e),c=this.getters.getChartFromFigureId(i);if(!c)throw Error(`No chart for the given id: ${i}`);n.push({figureId:i,copiedFigure:a,copiedChart:c,offset:{x:o-r.x,y:s-r.y}})}return{figures:n,figureIds:e.figureIds}}getPasteTarget(e,t,n,r){let i={};for(let e of n.figures)i[e.figureId]=K.smallUuid();return{zones:[],figureIds:i,sheetId:e}}paste(e,t,n){if(!e.figureIds)return;let{zones:r}=e,i=e.sheetId;for(let a of t.figures){let o=e.figureIds[a.figureId],{width:s,height:c}=a.copiedFigure,l=a.copiedChart,u=jO.fromDefinition(this.getters,i,l.copyInSheetId(i)).getDefinition();u=jO.fromStrDefinition(this.getters,i,u).getDefinition();let{col:d,row:f,offset:p}=a_(this.getters,i,{col:r[0].left,row:r[0].top},{...a.copiedFigure,offset:a.offset});this.dispatch(`CREATE_CHART`,{figureId:o,chartId:K.smallUuid(),sheetId:i,definition:u,col:d,row:f,offset:p,size:{height:c,width:s}}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:a.copiedChart.sheetId,figureId:a.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:o,selectMultiple:t.figureIds.length>1})}}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},YK=class extends TI{queuedChanges={};copy(e){if(!e.zones.length)return;let{rowsIndexes:t,columnsIndexes:n}=e,r=e.sheetId,i=[];for(let e of t){let t=[];for(let i of n){let n=Array.from(this.getters.getRulesByCell(r,i,e));t.push({position:{col:i,row:e,sheetId:r},rules:n})}i.push(t)}return{cfRules:i}}paste(e,t,n){if(this.queuedChanges={},n.pasteOption===`asValue`)return;let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t):this.pasteFromCopy(i,r,t.cfRules,n),this.executeQueuedChanges()}pasteFromCut(e,t,n){let r=t[0];this.pasteZone(e,r.left,r.top,n.cfRules,{isCutOperation:!0})}pasteZone(e,t,n,r,i){for(let[a,o]of r.entries())for(let[r,s]of o.entries()){let o={col:t+r,row:n+a,sheetId:e};this.pasteCf(s,o,i?.isCutOperation)}}pasteCf(e,t,n){if(e?.rules&&e.rules.length>0){let r=E(e.position),i=E(t);for(let a of e.rules){let o=[];if(n&&o.push(r),e.position.sheetId===t.sheetId)this.adaptCFRules(e.position.sheetId,a,[i],o);else{this.adaptCFRules(e.position.sheetId,a,[],o);let n=this.getCFToCopyTo(t.sheetId,a);this.adaptCFRules(t.sheetId,n,[i],[])}}}}adaptCFRules(e,t,n,r){this.queuedChanges[e]||(this.queuedChanges[e]=[]);let i=this.queuedChanges[e].find(e=>e.cf.id===t.id);i?(i.toAdd.push(...n),i.toRemove.push(...r)):this.queuedChanges[e].push({toAdd:n,toRemove:r,cf:t})}executeQueuedChanges(){for(let e in this.queuedChanges)for(let{toAdd:t,toRemove:n,cf:r}of this.queuedChanges[e]){let i=this.getters.getAdaptedCfRanges(e,r,t,n);if(i){if(i.length===0){this.dispatch(`REMOVE_CONDITIONAL_FORMAT`,{id:r.id,sheetId:e});continue}this.dispatch(`ADD_CONDITIONAL_FORMAT`,{cf:{id:r.id,rule:r.rule,stopIfTrue:r.stopIfTrue},ranges:i,sheetId:e})}}}getCFToCopyTo(e,t){let n=this.getters.getConditionalFormats(e).find(e=>e.stopIfTrue===t.stopIfTrue&&w(e.rule,t.rule)),r=this.queuedChanges[e];return!n&&r&&(n=r.find(e=>e.cf.stopIfTrue===t.stopIfTrue&&w(e.cf.rule,t.rule))?.cf),n||{...t,id:K.smallUuid(),ranges:[]}}},XK=class extends TI{queuedChanges={};copy(e){let{rowsIndexes:t,columnsIndexes:n}=e,r=e.sheetId,i=[];for(let e of t){let t=[];for(let i of n){let n={sheetId:r,col:i,row:e},a=this.getters.getValidationRuleForCell(n);t.push({position:n,rule:a})}i.push(t)}return{dvRules:i}}paste(e,t,n){if(this.queuedChanges={},n.pasteOption)return;let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t):this.pasteFromCopy(i,r,t.dvRules),this.executeQueuedChanges()}pasteFromCut(e,t,n){let r=t[0];this.pasteZone(e,r.left,r.top,n.dvRules,{isCutOperation:!0})}pasteZone(e,t,n,r,i){for(let[a,o]of r.entries())for(let[r,s]of o.entries()){let o={col:t+r,row:n+a,sheetId:e};this.pasteDataValidation(s,o,i?.isCutOperation)}}pasteDataValidation(e,t,n){if(e){let r=E(t),i=E(e.position),a=e.rule;if(!a){let e=this.getters.getValidationRuleForCell(t);e&&this.adaptDataValidationRule(t.sheetId,e,[],[r]);return}let o=[];if(n&&o.push(i),e.position.sheetId===t.sheetId){let n=this.getDataValidationRuleToCopyTo(t.sheetId,a,!1);this.adaptDataValidationRule(e.position.sheetId,n,[r],o)}else{let n=this.getters.getValidationRuleForCell(e.position);n&&this.adaptDataValidationRule(e.position.sheetId,n,[],o);let i=this.getDataValidationRuleToCopyTo(t.sheetId,a);this.adaptDataValidationRule(t.sheetId,i,[r],[])}}}getDataValidationRuleToCopyTo(e,t,n=!0){let r=this.getters.getDataValidationRules(e).find(e=>w(t.criterion,e.criterion)&&t.isBlocking===e.isBlocking),i=this.queuedChanges[e];return!r&&i&&(r=i.find(e=>w(t.criterion,e.rule.criterion)&&t.isBlocking===e.rule.isBlocking)?.rule),r||{...t,id:n?K.smallUuid():t.id,ranges:[]}}adaptDataValidationRule(e,t,n,r){this.queuedChanges[e]||(this.queuedChanges[e]=[]);let i=this.queuedChanges[e].find(e=>e.rule.id===t.id);i?(i.toAdd.push(...n),i.toRemove.push(...r)):this.queuedChanges[e].push({toAdd:n,toRemove:r,rule:t})}executeQueuedChanges(){for(let e in this.queuedChanges)for(let{toAdd:t,toRemove:n,rule:r}of this.queuedChanges[e]){let i=zn([...zn(r.ranges.map(e=>e.zone),n),...t],[]);if(i.length===0){this.dispatch(`REMOVE_DATA_VALIDATION_RULE`,{sheetId:e,id:r.id});continue}this.dispatch(`ADD_DATA_VALIDATION_RULE`,{rule:{id:r.id,criterion:r.criterion,isBlocking:r.isBlocking},ranges:i.map(t=>this.getters.getRangeDataFromZone(e,t)),sheetId:e})}}},ZK=class extends TI{copy(e){let t={style:{},format:{},width:e.columnsIndexes.length,height:e.rowsIndexes.length,sheetId:e.sheetId,zones:e.clippedZones};t.format={sheetDefault:this.getters.getDefaultFormat(e.sheetId,`SHEET`,void 0)??``,colDefault:[],rowDefault:[]};let n=0;for(let r of e.columnsIndexes){let i=this.getters.getDefaultFormat(e.sheetId,`COL`,r);i&&t.format.colDefault&&(t.format.colDefault[n]=i),n++}let r=0;for(let n of e.rowsIndexes){let i=this.getters.getDefaultFormat(e.sheetId,`ROW`,n);i&&t.format.rowDefault&&(t.format.rowDefault[r]=i),r++}for(let n in Ke){t.style[n]={sheetDefault:this.getters.getDefaultStyle(e.sheetId,n,`SHEET`,void 0)??Ke[n],colDefault:[],rowDefault:[]};let r=0;for(let i of e.columnsIndexes){let a=this.getters.getDefaultStyle(e.sheetId,n,`COL`,i);a!==void 0&&(t.style[n].colDefault[r]=a),r++}let i=0;for(let r of e.rowsIndexes){let a=this.getters.getDefaultStyle(e.sheetId,n,`ROW`,r);a!==void 0&&(t.style[n].rowDefault[i]=a),i++}}return t}adaptContentToZone(e,t){let n=Math.max(Math.floor((e.right-e.left+1)/t.width),1),r=Math.max(Math.floor((e.bottom-e.top+1)/t.height),1);if(n===1&&r===1)return t;let i=b(t);i.height*=r,i.width*=n,r>1&&i.format.rowDefault&&(i.format.rowDefault.length=t.height,i.format.rowDefault=On(i.format.rowDefault,r)),n>1&&i.format.colDefault&&(i.format.colDefault.length=t.width,i.format.colDefault=On(i.format.colDefault,n));for(let e in t.style)r>1&&i.style[e].rowDefault&&(i.style[e].rowDefault.length=t.height,i.style[e].rowDefault=On(i.style[e].rowDefault,r)),n>1&&i.style[e].colDefault&&(i.style[e].colDefault.length=t.width,i.style[e].colDefault=On(i.style[e].colDefault,n));return i}paste(e,t,n){let r=e.sheetId;if(n.pasteOption===`asValue`)return;let i=e.zones;if(n.isCutOperation){this.clearClippedZones(t);let{left:e,top:n}=i[0];this.pasteStyle(r,e,n,t.width,t.height,t.style),this.pasteFormat(r,e,n,t.width,t.height,t.format)}else for(let e of i){let n=this.adaptContentToZone(e,t);this.pasteStyle(r,e.left,e.top,n.width,n.height,n.style),this.pasteFormat(r,e.left,e.top,n.width,n.height,n.format)}}clearClippedZones(e){this.dispatch(`CLEAR_FORMATTING`,{sheetId:e.sheetId,target:e.zones})}pasteStyle(e,t,n,r,i,a){let o=En({}),s={},c=0;function l(e,t){let n=`${e.left}:${e.right}:${e.top}:${e.bottom}`;s[n]=[e,c++],o.set(n,{...o.get(n),...t})}l({left:t,right:t+r-1,top:n,bottom:n+i-1},Ke);for(let e in a)l({left:t,right:t+r-1,top:n,bottom:n+i-1},{[e]:a[e].sheetDefault});for(let e in a)for(let r in a[e].colDefault){let o=parseInt(r);l({left:t+o,right:t+o,top:n,bottom:n+i-1},{[e]:a[e].colDefault[r]})}for(let e in a)for(let i in a[e].rowDefault){let o=parseInt(i);l({left:t,right:t+r-1,top:n+o,bottom:n+o},{[e]:a[e].rowDefault[i]})}let u=[];for(let[e,[t,n]]of Object.entries(s)){let r=o.get(e);Wt(r)||u.push([n,t,r])}u.sort((e,t)=>e[0]-t[0]);for(let[t,n,r]of u)this.dispatch(`SET_FORMATTING`,{sheetId:e,target:[n],style:r})}pasteFormat(e,t,n,r,i,a){let o={},s={},c=0;function l(e,t){let n=`${e.left}:${e.right}:${e.top}:${e.bottom}`;s[n]=[e,c++],o[n]=t}l({left:t,right:t+r-1,top:n,bottom:n+i-1},a.sheetDefault??``);for(let e in a.colDefault){let r=parseInt(e);l({left:t+r,right:t+r,top:n,bottom:n+i-1},a.colDefault[e])}for(let e in a.rowDefault){let i=parseInt(e);l({left:t,right:t+r-1,top:n+i,bottom:n+i},a.rowDefault[e])}let u=[];for(let[e,[t,n]]of Object.entries(s)){let r=o[e];r!==void 0&&u.push([n,t,r])}u.sort((e,t)=>e[0]-t[0]);for(let[t,n,r]of u)this.dispatch(`SET_FORMATTING`,{sheetId:e,target:[n],format:r})}},QK=class extends KK{copy(e){let t=e.sheetId,n=[],r=this.getCopyRect(e);for(let i of e.figureIds){let e=this.getters.getFigure(t,i);if(!e)throw Error(`No figure for the given id: ${i}`);if(e.tag!==`image`)continue;let a={...e},{x:o,y:s}=this.getters.getFigureUI(t,e),c=b(this.getters.getImage(i));n.push({figureId:i,copiedFigure:a,copiedImage:c,sheetId:t,offset:{x:o-r.x,y:s-r.y}})}return{figures:n,figureIds:e.figureIds}}getPasteTarget(e,t,n,r){let i={};for(let e of n.figures)i[e.figureId]=K.smallUuid();return{sheetId:e,zones:[],figureIds:i}}paste(e,t,n){if(!e.figureIds)return;let{zones:r}=e;for(let i of t.figures){let a=e.figureIds[i.figureId],o=this.getters.getActiveSheetId(),{width:s,height:c}=i.copiedFigure,l=b(i.copiedImage),{col:u,row:d,offset:f}=a_(this.getters,o,{col:r[0].left,row:r[0].top},{...i.copiedFigure,offset:i.offset});this.dispatch(`CREATE_IMAGE`,{figureId:a,sheetId:o,col:u,row:d,offset:f,size:{height:c,width:s},definition:l}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:i.sheetId,figureId:i.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:a,selectMultiple:t.figureIds.length>1})}}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},$K=class extends TI{copy(e){let t=this.getters.getActiveSheetId(),{rowsIndexes:n,columnsIndexes:r}=e,i=[];for(let e of n){let n=[];for(let i of r){let r={col:i,row:e,sheetId:t};n.push(this.getters.getMerge(r))}i.push(n)}return{merges:i,sheetId:t}}paste(e,t,n){if(n.isCutOperation){let e=t.merges.flat().filter(C);this.dispatch(`REMOVE_MERGE`,{sheetId:t.sheetId,target:e})}this.pasteFromCopy(e.sheetId,e.zones,t.merges,n)}pasteZone(e,t,n,r){for(let[i,a]of r.entries())for(let[r,o]of a.entries()){let a={col:t+r,row:n+i,sheetId:e};this.pasteMerge(o,a)}}pasteMerge(e,t){if(!e||this.getters.isInMerge(t))return;let{sheetId:n,col:r,row:i}=t;this.dispatch(`ADD_MERGE`,{sheetId:n,force:!0,target:[{left:r,top:i,right:r+e.right-e.left,bottom:i+e.bottom-e.top}]})}},eq=class extends TI{copy(e){return{zones:e.clippedZones,sheetId:e.sheetId}}paste(e,t,n){if(n.isCutOperation){let n=e.zones[0];this.dispatch(`MOVE_RANGES`,{target:t.zones,sheetId:t.sheetId,sheetName:this.getters.getSheetName(t.sheetId),targetSheetId:e.sheetId,col:n.left,row:n.top})}}},tq=class extends TI{isPasteAllowed(e,t,n,r){if(!(`cells`in n))return`Success`;let{xSplit:i,ySplit:a}=this.getters.getPaneDivisions(e);return kr(Px(t,n.cells),i,a)?`FrozenPaneOverlap`:`Success`}},nq=class extends TI{copy(e,t,n=`copyPaste`){let r=e.sheetId,{rowsIndexes:i,columnsIndexes:a,zones:o}=e,s=new Set,c=[];for(let e of i){let l=[];c.push(l);for(let c of a){let a={col:c,row:e,sheetId:r},u=this.getters.getTable(a);if(!u){l.push({});continue}let d=this.getters.getCoreTable(a),f=d?.range.zone,p;if(!s.has(u.id)&&d&&f&&o.some(e=>pr(f,e))){s.add(u.id);let{numberOfRows:e}=mr(f);for(let n=f.top;n<=f.bottom;n++)!t&&!i.includes(n)&&e--;let n=d.range,r=this.getters.extendRange(d.range,`ROW`,n.zone.top+e-1-n.zone.bottom);p={range:this.getters.getRangeData(r),config:d.config,type:d.type}}if(u.isPivotTable){let t=u.range.zone.top===e&&u.range.zone.left===c,n=o.some(e=>pr(u.range.zone,e));(t||n)&&s.add(u.id)}n!==`shiftCells`&&l.push({table:p,style:this.getTableStyleToCopy(a),isWholeTableCopied:s.has(u.id)})}}return{tableCells:c,sheetId:e.sheetId}}getTableStyleToCopy(e){let t=tn({...this.getters.getCellTableStyle(e),hideGridLines:!1}),n=this.getters.getCellStyle(e),r=this.getters.getCellTableBorder(e),i=this.getters.getCellBorder(e);return{style:{...t,...tn(n)},border:{...r,...tn(i)}}}paste(e,t,n){let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t,n):this.pasteFromCopy(i,r,t.tableCells,n)}pasteFromCut(e,t,n,r){for(let e of n.tableCells)for(let t of e)t.table&&this.dispatch(`REMOVE_TABLE`,{sheetId:n.sheetId,target:[this.getters.getRangeFromRangeData(t.table.range).zone]});let i=t[0];this.pasteZone(e,i.left,i.top,n.tableCells,r)}pasteZone(e,t,n,r,i){for(let a=0;a<r.length;a++){let o=r[a];for(let r=0;r<o.length;r++){let s=o[r];if(!s)continue;let c={col:t+r,row:n+a,sheetId:e};this.pasteTableCell(e,s,c,i)}}if(r.length===1)for(let i=0;i<r[0].length;i++)this.dispatch(`AUTOFILL_TABLE_COLUMN`,{col:t+i,row:n,sheetId:e})}pasteTableCell(e,t,n,r){if(t.table&&!r?.pasteOption){let{range:r}=t.table,i=mr(this.getters.getRangeFromRangeData(r).zone),a={left:n.col,top:n.row,right:n.col+i.numberOfCols-1,bottom:n.row+i.numberOfRows-1};this.dispatch(`CREATE_TABLE`,{sheetId:n.sheetId,ranges:[this.getters.getRangeDataFromZone(e,a)],config:t.table.config,tableType:t.table.type})}this.getters.getCoreTable(n)||r?.pasteOption===`asValue`||(!r?.pasteOption&&!t.isWholeTableCopied||r?.pasteOption===`onlyFormat`)&&(t.style?.style&&this.dispatch(`UPDATE_CELL`,{...n,style:t.style.style}),t.style?.border&&this.dispatch(`SET_BORDER`,{...n,border:t.style.border}))}};Vx.figureHandlers.add(`chart`,JK).add(`image`,QK).add(`carousel`,qK),Vx.cellHandlers.add(`dataValidation`,XK).add(`default`,ZK).add(`cell`,EI).add(`sheet`,tq).add(`merge`,$K).add(`border`,GK).add(`table`,nq).add(`conditionalFormat`,YK).add(`references`,eq);var rq=class extends O{static maxSize={maxHeight:80};static template=`o-spreadsheet-ErrorToolTip`;props=(0,t.useProps)({cellPosition:j.CellPosition(),onClosed:j.function().optional()});viewStore;setup(){this.viewStore=k(H)}get dataValidationErrorMessage(){return this.env.model.getters.getInvalidDataValidationMessage(this.props.cellPosition)}get evaluationError(){let e=this.env.model.getters.getEvaluatedCell(this.props.cellPosition);if(e.message)return e}get errorOriginPositionString(){if(this.env.model.getters.isDashboard())return``;let e=this.evaluationError?.errorOriginPosition;if(!e||w(e,this.props.cellPosition))return``;let t=e.sheetId;return this.env.model.getters.getRangeString(this.env.model.getters.getRangeFromZone(t,E(e)),this.viewStore.displayedSheetId)}selectCell(){let e=this.evaluationError?.errorOriginPosition;if(!e)return;let t=this.env.model.getters.getActiveSheetId();e.sheetId!==t&&this.env.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:t,sheetIdTo:e.sheetId}),this.env.model.selection.selectCell(e.col,e.row)}get isSpillErrorBecauseOfMissingHeaders(){let e=this.evaluationError;return e?.value===N.SpilledBlocked&&!e.errorOriginPosition&&!this.env.model.getters.getSpreadZone(this.props.cellPosition,{ignoreSpillError:!0})}getMissingHeadersForSpread(){if(!this.isSpillErrorBecauseOfMissingHeaders)return;let e=this.env.model.getters.getCell(this.props.cellPosition);if(!e||!e.isFormula)return;let t=e.compiledFormula.toFormulaString(this.env.model.getters);return Tn(this.env.model.getters,this.props.cellPosition,t)}addMissingHeaders({missingCols:e,missingRows:t}){let n=this.props.cellPosition.sheetId;e>0&&this.env.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:n,sheetName:this.env.model.getters.getSheetName(n),dimension:`COL`,base:this.env.model.getters.getNumberCols(n)-1,position:`after`,quantity:e+20}),t>0&&this.env.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:n,sheetName:this.env.model.getters.getSheetName(n),dimension:`ROW`,base:this.env.model.getters.getNumberRows(n)-1,position:`after`,quantity:t+50})}getAddMissingHeadersButtonText(e){return e.missingCols>0&&e.missingRows>0?M(`Add missing columns and rows`):e.missingCols>0?M(`Add missing columns`):M(`Add missing rows`)}};let iq={onHover:(e,t)=>{let n=t.getEvaluatedCell(e);return n.type===`error`&&n.message||t.getInvalidDataValidationMessage(e)?{isOpen:!0,props:{cellPosition:e},Component:rq,cellCorner:`top-right`}:{isOpen:!1}}};var aq=class extends O{static template=`o-spreadsheet-FilterMenu`;static components={FilterMenuValueList:hF,SidePanelCollapsible:hk,FilterMenuCriterion:pF};props=(0,t.useProps)({filterPosition:j.Position(),onClosed:j.function().optional()});state;criterionCategory=`text`;updatedCriterionValue;viewStore;setup(){this.viewStore=k(H),(0,t.onWillUpdateProps)(e=>{w(e.filterPosition,this.props.filterPosition)||(this.updatedCriterionValue=void 0,this.criterionCategory=this.getCriterionCategory(e.filterPosition),this.state.values=this.getFilterHiddenValues(e.filterPosition))}),this.state=(0,t.proxy)({values:this.getFilterHiddenValues(this.props.filterPosition)}),this.criterionCategory=this.getCriterionCategory(this.props.filterPosition)}get isSortable(){if(!this.table)return!1;let e=this.env.model.getters.getCoreTableMatchingTopLeft(this.table.range.sheetId,this.table.range.zone);return!this.env.model.getters.isReadonly()&&e?.type!==`dynamic`}get table(){let e=this.viewStore.displayedSheetId,t=this.props.filterPosition;return this.env.model.getters.getTable({sheetId:e,...t})}get filterValueType(){let e=this.viewStore.displayedSheetId,t=this.props.filterPosition;return this.env.model.getters.getFilterValue({sheetId:e,...t})?.filterType}getCriterionCategory(e){let t=this.viewStore.displayedSheetId,n=this.env.model.getters.getFilter({sheetId:t,...e});if(!n||!n.filteredRange)return`text`;let r={text:0,number:0,date:0},i=n.filteredRange.zone;for(let n=i.top;n<=i.bottom&&!(n>100);n++){let i=this.env.model.getters.getEvaluatedCell({sheetId:t,row:n,col:e.col});i.type===`text`||i.type===`boolean`?r.text++:i.type===`number`&&(i.format&&Sc(i.format)?r.date++:r.number++)}let a=Math.max(r.text,r.number,r.date);return Object.keys(r).find(e=>r[e]===a)||`text`}onUpdateHiddenValues(e){this.updatedCriterionValue={filterType:`values`,hiddenValues:e}}onCriterionChanged(e){this.updatedCriterionValue=e}confirm(){if(!this.updatedCriterionValue){this.props.onClosed?.();return}let e=this.props.filterPosition;this.env.model.dispatch(`UPDATE_FILTER`,{...e,sheetId:this.viewStore.displayedSheetId,value:this.updatedCriterionValue}),this.props.onClosed?.()}get criterionOperators(){return this.criterionCategory===`date`?fF:this.criterionCategory===`number`?dF:uF}cancel(){this.props.onClosed?.()}sortFilterZone(e){let t=this.props.filterPosition,n=this.table?.range.zone;if(!t||!n||n.top===n.bottom)return;let r=this.viewStore.displayedSheetId,i={...n,top:n.top+1},a={col:t.col,row:i.top};JL(this.env,r,a,i,e,{emptyCellAsZero:!0,sortHeaders:!0}),this.props.onClosed?.()}getFilterHiddenValues(e){let t=this.viewStore.displayedSheetId,n=this.env.model.getters.getFilter({sheetId:t,...e});if(!n?.filteredRange)return[];let r=this.env.model.getters.getFilterValue({sheetId:t,...e}),i=_r(n.filteredRange.zone);r?.filterType!==`criterion`&&(i=i.filter(e=>!this.env.model.getters.isRowHidden(t,e.row)));let a=i.map(e=>this.env.model.getters.getEvaluatedCell({sheetId:t,...e}).formattedValue),o=r?.filterType===`values`?r.hiddenValues:[],s=new Set(o.map(Lp)),c=new Set,l=[],u=e=>{let t=Lp(e);c.has(t)||(l.push({string:e||``,checked:r?.filterType===`criterion`?!1:!s.has(t),normalizedValue:t}),c.add(t))};return a.forEach(u),o.forEach(u),l.sort((e,t)=>e.normalizedValue.localeCompare(t.normalizedValue,void 0,{numeric:!0,sensitivity:`base`}))}getFilterCriterionValue(e){let t=this.viewStore.displayedSheetId,n=this.env.model.getters.getFilterCriterionValue({sheetId:t,...e});return n?.filterType===`criterion`?b(n):{filterType:`criterion`,type:`none`,values:[]}}};let oq={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:aq,cellCorner:`bottom-left`})};var sq=class extends O{static template=`o-spreadsheet-LinkDisplay`;props=(0,t.useProps)({cellPosition:j.CellPosition(),onClosed:j.function().optional()});cellPopovers;viewStore;setup(){this.cellPopovers=k(qx),this.viewStore=k(H)}get cell(){let{col:e,row:t}=this.props.cellPosition,n=this.viewStore.displayedSheetId;return this.env.model.getters.getEvaluatedCell({sheetId:n,col:e,row:t})}get link(){if(this.cell.link)return this.cell.link;let{col:e,row:t}=this.props.cellPosition;throw Error(`LinkDisplay Component can only be used with link cells. ${T(e,t)} is not a link.`)}getUrlRepresentation(e){return tf(e,this.env.model.getters)}openLink(e){nf(this.link,this.env,de(e))}edit(){let{col:e,row:t}=this.props.cellPosition;this.env.model.selection.selectCell(e,t),this.cellPopovers.open({col:e,row:t},`LinkEditor`)}unlink(){let e=this.viewStore.displayedSheetId,{col:t,row:n}=this.props.cellPosition,r=this.env.model.getters.getCellComputedStyle({sheetId:e,col:t,row:n}),i=r?.textColor===`#017E84`?void 0:r?.textColor;this.env.model.dispatch(`UPDATE_CELL`,{col:t,row:n,sheetId:e,content:this.link.label,style:{...r,textColor:i,underline:void 0}})}};let cq={onHover:(e,t)=>{let n=t.getEvaluatedCell(e);return!t.isDashboard()&&n.link?{isOpen:!0,Component:sq,props:{cellPosition:e},cellCorner:`bottom-left`}:{isOpen:!1}}};var lq=class extends O{static template=`o-spreadsheet-LinkEditor`;static components={MenuPopover:q_};props=(0,t.useProps)({cellPosition:j.CellPosition(),onClosed:j.function().optional()});static size={maxHeight:500};urlInput=(0,t.signal)(null);suggestionListRef=(0,t.signal)(null);urlInputContainer=(0,t.signal)(null);state;viewStore;setup(){this.viewStore=k(H),this.state=(0,t.proxy)(this.defaultState),this.computeLinks(),(0,t.onMounted)(()=>this.urlInput()?.focus())}computeLinks(){this.state.selectedIndex=null,this.state.linksByCategory=this.linkProposalByCategory,this.state.linksList=Object.values(this.state.linksByCategory).flat()}get linkProposalByCategory(){let e={},t=-1,n=this.state.url;for(let r of Zd.getKeys()){let i=Zd.get(r),a=i.getLinkProposals?.(this.env)||[],o=n&&this.state.isUrlEditable?CM(n,a,e=>i.urlRepresentation(e.url,this.env.model.getters)):a;o.length!==0&&(e[i.title]=o.map(e=>{t++;let n=i.urlRepresentation(e.url,this.env.model.getters),r=t;return{text:n,icon:e.icon,index:r,onSelect:()=>{this.state.url=e.url,this.state.label=e.label,this.state.isUrlEditable=e.isUrlEditable,this.state.selectedIndex=r,this.urlInputContainer()?.focus()}}}))}return e}get defaultState(){let{col:e,row:t}=this.props.cellPosition,n=this.viewStore.displayedSheetId,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,selectedIndex:null,linksByCategory:{},linksList:[]}:{label:r.formattedValue,url:``,isUrlEditable:!0,selectedIndex:null,linksByCategory:{},linksList:[]}}getUrlRepresentation(e){return tf(e,this.env.model.getters)}removeLink(){this.state.url=``,this.state.isUrlEditable=!0,this.computeLinks()}save(){let{col:e,row:t}=this.props.cellPosition,n=this.env.model.getters.getLocale(),r=this.state.label?hb(this.state.label,n):this.state.url;this.env.model.dispatch(`UPDATE_CELL`,{col:e,row:t,sheetId:this.viewStore.displayedSheetId,content:Rt(r,this.state.url)}),this.props.onClosed?.()}cancel(){this.props.onClosed?.()}onKeyDown(e){switch(e.key){case`Enter`:this.state.url&&this.save(),e.stopPropagation(),e.preventDefault();break;case`Escape`:this.cancel(),e.stopPropagation();break}}onInputKeyDown(e){switch(e.key){case`Enter`:if(this.state.selectedIndex!==null){let t=this.state.linksList[this.state.selectedIndex];if(t){let n=this.state.url;t.onSelect(),this.state.url!==n&&(e.stopPropagation(),e.preventDefault())}}break;case`ArrowDown`:this.state.selectedIndex=this.state.selectedIndex===null||this.state.selectedIndex===this.state.linksList.length-1?0:(this.state.selectedIndex+1)%this.state.linksList.length,this.showSelectedProposal(),e.stopPropagation(),e.preventDefault();break;case`ArrowUp`:this.state.selectedIndex!==null&&(this.state.selectedIndex=this.state.selectedIndex===0?this.state.linksList.length-1:(this.state.selectedIndex-1)%this.state.linksList.length,this.showSelectedProposal(),e.stopPropagation(),e.preventDefault());break}}showSelectedProposal(){this.suggestionListRef()?.querySelector(`.suggestion-item[data-index="${this.state.selectedIndex}"]`)?.scrollIntoView({block:`nearest`})}};Kx.add(`ErrorToolTip`,iq).add(`LinkCell`,cq).add(`LinkEditor`,{onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:lq,cellCorner:`bottom-left`})}).add(`FilterMenu`,oq),wM.add(`dataValidation`,{displayAllOnInitialContent:!0,canBeToggled:!1,getProposals(e,t){if(Sn(t)||!this.composer.currentEditedCell)return[];let n=this.composer.currentEditedCell,r=this.getters.getValidationRuleForCell(n);if(!r||r.criterion.type!==`isValueInList`&&r.criterion.type!==`isValueInRange`)return[];let i=this.composer.currentEditedCell.sheetId,a=r.criterion.type===`isValueInRange`?this.getters.getDataValidationRangeValues(i,r.criterion):r.criterion.values.map(e=>({label:e,value:e}));if(r.criterion.displayStyle!==`chip`)return a.map(e=>({text:e.value,fuzzySearchKey:e.label,htmlContent:[{value:e.label}]}));let o=r.criterion.colors;return a.map(e=>{let t=o?.[e.value];return{text:e.value,htmlContent:[{value:e.label,color:ep(t||`#E7E9ED`),backgroundColor:t||`#E7E9ED`,classes:[`badge rounded-pill fs-6 fw-normal w-100 mt-1 text-start`]}],fuzzySearchKey:e.label}})},selectProposal(e,t){this.composer.setCurrentContent(t.text),this.composer.stopEdition()}}),wM.add(`functions_and_named_ranges`,{sequence:100,autoSelectFirstProposal:!0,maxDisplayedProposals:10,getProposals(e){if(e.type!==`SYMBOL`)return[];let t=e.value;if(!Sn(this.composer.currentContent))return[];let n=Object.entries(ml.content).filter(([e,{hidden:t}])=>!t).map(([e,{description:n}])=>({type:`function`,text:e,icon:`o-spreadsheet-Icon.FX_SVG`,description:n,htmlContent:yF(t,e,Fe,`o-semi-bold`)}));return n.push(...this.getters.getNamedRanges().map(e=>({type:`named_range`,text:e.name,description:this.getters.getRangeString(e.range),icon:`o-spreadsheet-Icon.NAMED_RANGE`,htmlContent:yF(t,e.name,Fe,`o-semi-bold`)}))),n.sort((e,t)=>e.text.length-t.text.length||e.text.localeCompare(t.text)),n},selectProposal(e,t){let n=e.end,r=e.end;[`SYMBOL`,`FUNCTION`].includes(e.type)&&(n=e.start);let i=this.composer.currentTokens,a=t.text;if(t.type===`function`){a+=`(`;let t=i.map(e=>e.start).indexOf(e.start);t+1<i.length&&i[t+1]?.type===`LEFT_PAREN`&&r++}this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(a)}});function uq(e,t){for(let n=0;n<t.length;n++){let r=t[n].proposalValues;r===void 0||r.length===0||wM.add(`${e}_function_${t[n].name}_argument_proposals`,{sequence:50,autoSelectFirstProposal:!0,selectProposal:dq,getProposals:t=>{let i=t.functionContext;if(!i||i.parent.toUpperCase()!==e.toUpperCase()||i.argPosition!==n)return;let a=[],o=``;for(let{value:e,label:t}of r){switch(typeof e){case`string`:o=`"${e}"`;break;case`number`:o=e.toString();break;case`boolean`:o=e?`TRUE`:`FALSE`;break;default:}a.push({text:o,description:t,htmlContent:[{value:o,color:typeof e==`string`?_t.STRING:_t.NUMBER}],fuzzySearchKey:o,alwaysExpanded:!0})}return a}})}}function dq(e,t){let n=e.end,r=e.end;[`LEFT_PAREN`,`ARG_SEPARATOR`].includes(e.type)||(n=e.start),this.composer.stopComposerRangeSelection(),this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t.text)}ml.getAll().forEach(e=>uq(e.name,e.args)),wM.add(`pivot_ids`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||![`PIVOT.VALUE`,`PIVOT.HEADER`,`PIVOT`].includes(t.parent.toUpperCase())||t.argPosition!==0)return;let n=this.getters.getPivotIds();if(!n.includes(e.value))return n.map(e=>{let t=this.getters.getPivotCoreDefinition(e),n=`${this.getters.getPivotFormulaId(e)}`;return{text:n,description:t.name,htmlContent:[{value:n,color:_t.NUMBER}],fuzzySearchKey:n+t.name,alwaysExpanded:!0}}).filter(C)},selectProposal:dq}),wM.add(`pivot_measures`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(t?.parent.toUpperCase()!==`PIVOT.VALUE`||t.argPosition!==1)return[];let n=LF(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return[];let i=this.getters.getPivot(r);return i.init(),i.isValid()?i.definition.measures.map(e=>{if(e.fieldName===`__count`){let e=`"__count"`;return{text:e,description:M(`Count`),htmlContent:[{value:e,color:_t.STRING}],fuzzySearchKey:M(`Count`)+e}}return PF(e)}).filter(C):[]},selectProposal:dq}),wM.add(`pivot_group_fields`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!fq(e)&&!pq(e))return;let n=LF(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return;let i=this.getters.getPivot(r);i.init();let a=i.getFields(),{columns:o,rows:s}=i.definition,c=t.args;t?.parent.toUpperCase()===`PIVOT.VALUE`?(c=c.filter((e,t)=>t%2==0),c=c.slice(1,t.argPosition)):c=c.filter((e,t)=>t%2==1);let l=c.map(e=>e?.value).filter(C),u=o.map(e=>e.nameWithGranularity),d=s.map(e=>e.nameWithGranularity),f=[],p=[`ARG_SEPARATOR`,`SPACE`].includes(e.type)?l.at(-1):l.at(-2),m=Wz.get(i.type);if(m&&p?.startsWith(`#`)&&(p=p.slice(1)),p===void 0&&(f.push(u[0]),f.push(d[0])),d.includes(p)){let e=d[d.indexOf(p)+1];f.push(e),f.push(u[0])}if(u.includes(p)){let e=u[u.indexOf(p)+1];f.push(e)}let h=f.filter(C);return h.map(e=>{let[t,n]=e.split(`:`),r=a[t];return r?NF(r,n):void 0}).concat(h.map(e=>{if(!m)return;let t=a[e.split(`:`)[0]];if(!t)return;let n=`"#${e}"`;return{text:n,description:M(`%s (positional)`,t.string)+(t.help?` (${t.help})`:``),htmlContent:[{value:n,color:_t.STRING}],fuzzySearchKey:t.string+n}})).filter(C)},selectProposal:dq});function fq(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==0}function pq(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==1}wM.add(`pivot_group_values`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!e||!mq(e)&&!hq(e))return;let n=LF(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return;let i=this.getters.getPivot(r);if(!i.isValid())return;let a=t.argPosition,o=e.functionContext?.args[a-1]?.value;if(!o)return;let s;try{s=i.definition.getDimension(o)}catch{return}return s.granularity===`month_number`?Object.values(oc).map((e,t)=>({text:`${t+1}`,fuzzySearchKey:e.toString(),description:e.toString(),htmlContent:[{value:`${t+1}`,color:_t.NUMBER}]})):s.granularity===`quarter_number`?[1,2,3,4].map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:M(`Quarter %s`,e),htmlContent:[{value:`${e}`,color:_t.NUMBER}]})):s.granularity===`day_of_month`?S(1,32).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:_t.NUMBER}]})):s.granularity===`iso_week_number`?S(0,54).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:_t.NUMBER}]})):s.granularity===`day_of_week`?S(1,8).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:_t.NUMBER}]})):s.granularity===`hour_number`?S(0,24).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:_t.NUMBER}]})):s.granularity===`minute_number`?S(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:_t.NUMBER}]})):s.granularity===`second_number`?S(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:_t.NUMBER}]})):i.getPossibleFieldValues(s).map(({value:e,label:t})=>{let n=typeof e==`string`,r=n?`"${e}"`:e.toString(),i=n?_t.STRING:_t.NUMBER,a=t===e?``:t;return{text:r,description:a,htmlContent:[{value:r,color:i}],fuzzySearchKey:r+a}})},selectProposal:dq});function mq(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==1}function hq(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==0}wM.add(`sheet_names`,{sequence:150,autoSelectFirstProposal:!0,getProposals(e){return e.type===`SYMBOL`||e.type===`UNKNOWN`&&e.value.startsWith(`'`)?this.getters.getSheetIds().map(e=>{let t=kt(this.getters.getSheetName(e));return{text:t,fuzzySearchKey:t.startsWith(`'`)?t:`'`+t}}):[]},selectProposal(e,t){let n=e.start,r=e.end;this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t.text+`!`)}});function gq(e){return e.yRanges.length&&!xl.test(e.yRanges[0])?`InvalidYRange`:e.xRange&&!xl.test(e.xRange)?`InvalidXRange`:e.labelRange&&!xl.test(e.labelRange)?`InvalidLabelRange`:e.sizeRange&&!xl.test(e.sizeRange)?`InvalidBubbleSizeRange`:`Success`}let _q={sequence:40,allowedDefinitionKeys:[...rg.commonKeys,`yRanges`,`xRange`,`labelRange`,`sizeRange`,`dataSetsHaveTitle`,`verticalAxisPosition`,`labelsAsText`,`bubbleColor`,`legendPosition`,`axesDesign`,`showValues`],fromStrDefinition(e,t,n){let r=e.yRanges.map(e=>Pu(n,t,e)).filter(C),i=Pu(n,t,e.xRange),a=Pu(n,t,e.labelRange),o=Pu(n,t,e.sizeRange);return{...e,yRanges:r,xRange:i,labelRange:a,sizeRange:o}},toStrDefinition(e,t,n){return{...e,yRanges:e.yRanges.map(e=>n.getRangeString(e,t)),xRange:e.xRange?n.getRangeString(e.xRange,t):void 0,labelRange:e.labelRange?n.getRangeString(e.labelRange,t):void 0,sizeRange:e.sizeRange?n.getRangeString(e.sizeRange,t):void 0}},validateDefinition(e,t){return e.checkValidations(t,gq)},transformDefinition(e,t,{adaptRangeString:n}){let r=e=>{if(!e)return;let{changeType:r,range:i}=n(t,e);return r===`REMOVE`?void 0:i};return{...e,yRanges:e.yRanges.map(r).filter(C),xRange:r(e.xRange),sizeRange:r(e.sizeRange),labelRange:r(e.labelRange)}},getFormulas:()=>[],getDefinitionFromContextCreation(e,t){let n=e.dataSource?.type===`range`;return{background:e.background,yRanges:n?e.dataSource.dataSets?.map(e=>e.dataRange)??[]:[],verticalAxisPosition:e.dataSetStyles?.[0]?.verticalAxisPosition,dataSetsHaveTitle:n?e.dataSource.dataSetsHaveTitle??!1:!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`bubble`,labelRange:e.bubbleLabelRange||void 0,labelsAsText:e.labelsAsText??!1,xRange:e.auxiliaryRange||void 0,sizeRange:e.bubbleSizeRange||void 0,axesDesign:e.axesDesign,showValues:e.showValues,humanize:e.humanize,annotationText:e.annotationText,annotationLink:e.annotationLink,bubbleColor:e.bubbleColorMode||{color:`multiple`}}},getContextCreation(e,t){return{...e,dataSource:{type:`range`,dataSets:e.yRanges.map((e,t)=>({dataSetId:`${t}`,dataRange:e}))},bubbleLabelRange:e.labelRange,auxiliaryRange:e.xRange,bubbleSizeRange:e.sizeRange,bubbleColorMode:e.bubbleColor}},getDefinitionForExcel:()=>void 0,updateRanges(e,t){let n=e.yRanges.map(e=>pm(e,t)).filter(C),r=pm(e.xRange,t),i=pm(e.labelRange,t),a=pm(e.sizeRange,t);return{...e,yRanges:n,xRange:r,labelRange:i,sizeRange:a}},duplicateInDuplicatedSheet(e,t,n){let r=e=>fm(t,n,e);return{...e,yRanges:e.yRanges.map(r).filter(C),xRange:r(e.xRange),labelRange:r(e.labelRange),sizeRange:r(e.sizeRange)}},copyInSheetId:e=>e,getRuntime(e,t){let n=Yk(t,e);return{chartJsConfig:{type:`line`,data:{datasets:Dh(t,n),labels:n.labels},options:{...Jg,layout:bA(t,n),scales:ch(t,n),plugins:{title:nj(t,e),legend:zA(t,n),tooltip:lj(t,n),chartShowValuesPlugin:XA(t,n),background:{color:t.background}}}}}}};function vq(e){return!Gj.includes(e.horizontalGroupBy)||!Gj.includes(e.verticalGroupBy)?`InvalidChartDefinition`:`Success`}let yq={sequence:110,dataSeriesLimit:1,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`dataSetStyles`,`showValues`,`colorScale`,`missingValueColor`,`axesDesign`,`horizontalGroupBy`,`verticalGroupBy`,`legendPosition`],validateDefinition(e,t){return e.checkValidations(t,vq)},fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,updateRanges:e=>e,getContextCreation:e=>e,getFormulas:()=>[],getDefinitionFromContextCreation(e,t){let n=`left`;return e.legendPosition===`right`&&(n=`right`),{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},title:e.title||{text:``},type:`calendar`,showValues:e.showValues,axesDesign:e.axesDesign,legendPosition:n,horizontalGroupBy:`day_of_week`,verticalGroupBy:`month_number`,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractData:n}){let r=Vk(t,n(),e),{labels:i,datasets:a}=Ch(t,r);return{chartJsConfig:{type:`calendar`,data:{labels:i,datasets:a},options:{...Jg,indexAxis:`x`,layout:xA(t,r),scales:nh(t,a),plugins:{title:nj(t,e),legend:{display:!1},tooltip:sj(t,r),chartShowValuesPlugin:ZA(t,r),chartColorScalePlugin:rh(t,r),background:{color:r.background}}}}}}},bq={sequence:15,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`aggregated`,`axesDesign`,`showValues`,`hideDataMarkers`,`zoomable`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getFormulas:()=>[],getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){return{...t,backgroundColor:Fk(t.background||`#FFFFFF`),fontColor:Fk(vm(t.background)),dataSets:n,labelRange:r,verticalAxis:Cm(t)}},getDefinitionFromContextCreation(e,t){let n=e.dataSetStyles??{};if(e.dataSource?.type===`range`){let t=e.dataSource?.dataSets?.[0]?.dataSetId;for(let r of e.dataSource?.dataSets||[])n[r.dataSetId]={...e.dataSetStyles?.[r.dataSetId]||{},type:r.dataSetId===t?`bar`:`line`}}return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:n,aggregated:e.aggregated,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`combo`,axesDesign:e.axesDesign,showValues:e.showValues,hideDataMarkers:e.hideDataMarkers,zoomable:e.zoomable,humanize:e.humanize,annotationText:e.annotationText,annotationLink:e.annotationLink}},getRuntime(e,t,{extractData:n},r,i){let a=Rk(t,n(),e);return{chartJsConfig:{type:`bar`,data:{labels:a.labels,datasets:Ah(t,a)},options:{...Jg,layout:bA(t,a),scales:th(t,a),plugins:{title:nj(t,e),legend:BA(t,a),tooltip:oj(t,a),chartShowValuesPlugin:XA(t,a),background:{color:a.background}},...i}},customizableSeries:a.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},xq={sequence:100,dataSeriesLimit:1,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`dataSetStyles`,`axesDesign`,`legendPosition`,`horizontal`,`aggregated`,`showValues`,`funnelColors`,`cumulative`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getFormulas:()=>[],getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},aggregated:e.aggregated??!1,legendPosition:`none`,title:e.title||{text:``},type:`funnel`,showValues:e.showValues,axesDesign:e.axesDesign,funnelColors:e.funnelColors,horizontal:!0,cumulative:e.cumulative??!0,humanize:e.humanize,annotationText:e.annotationText,annotationLink:e.annotationLink}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractData:n},r,i){let a=qk(t,n(),e);return{chartJsConfig:{type:`funnel`,data:{labels:a.labels,datasets:Nh(t,a)},options:{...Jg,indexAxis:`y`,layout:bA(t,a),scales:ph(t,a),plugins:{title:nj(t,e),legend:{display:!1},tooltip:hj(t,a),chartShowValuesPlugin:XA(t,a),background:{color:a.background}},...i}}}}},Sq={sequence:90,dataSeriesLimit:1,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`colorScale`,`missingValueColor`,`region`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getFormulas:()=>[],getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`geo`,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractData:n},r,i){let a=Kk(t,n(),e);return{chartJsConfig:{type:`choropleth`,data:{datasets:Mh(t,a)},options:{...Jg,layout:bA(t,a),scales:fh(t,a),plugins:{title:nj(t,e),tooltip:mj(t,a),legend:{display:!1},background:{color:a.background}},...i}}}}},Cq={sequence:80,dataSeriesLimit:2,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showValues`,`aggregated`,`axesDesign`,`stacked`,`horizontal`],fromStrDefinition:e=>({...e,horizontal:!0,stacked:!0}),toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getFormulas:()=>[],getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},aggregated:e.aggregated??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`pyramid`,axesDesign:e.axesDesign,horizontal:!0,stacked:!0,showValues:e.showValues,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){if(t.dataSource.type!==`range`)return;let i=Hk(t,Bj(e,t.dataSource),e),{dataSetsValues:a}=i,o=Math.max(...a.map(e=>Math.max(...e.data.map(e=>pf(e)?Math.abs(e.value):-1/0))));return{...t,horizontal:!0,backgroundColor:Fk(i.background||`#FFFFFF`),fontColor:Fk(vm(i.background)),dataSets:n,labelRange:r,verticalAxis:Cm(t),maxValue:o}},getRuntime(e,t,{extractData:n},r,i){let a=Hk(t,n(),e);return{chartJsConfig:{type:`bar`,data:{labels:a.labels,datasets:xh(t,a)},options:{...Jg,indexAxis:`y`,layout:bA(t,a),scales:uh(t,a),plugins:{title:nj(t,e),legend:FA(t,a),tooltip:fj(t,a),chartShowValuesPlugin:$A(t,a),background:{color:a.background}},...i}},customizableSeries:a.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},wq={sequence:80,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showValues`,`aggregated`,`stacked`,`fillArea`,`hideDataMarkers`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getFormulas:()=>[],getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},stacked:e.stacked??!1,aggregated:e.aggregated??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`radar`,fillArea:e.fillArea??!1,showValues:e.showValues??!1,hideDataMarkers:e.hideDataMarkers,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){return{...t,backgroundColor:Fk(t.background||`#FFFFFF`),fontColor:Fk(vm(t.background)),dataSets:n,labelRange:r}},getRuntime(e,t,{extractData:n},r,i){let a=Gk(t,n(),e);return{chartJsConfig:{type:`radar`,data:{labels:a.labels,datasets:jh(t,a)},options:{...Jg,layout:bA(t,a),scales:dh(t,a),plugins:{title:nj(t,e),legend:HA(t,a),tooltip:pj(t,a),chartShowValuesPlugin:XA(t,a),background:{color:a.background}},...i}},customizableSeries:a.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},Tq={sequence:60,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showValues`,`labelsAsText`,`aggregated`,`axesDesign`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getFormulas:()=>[],getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},labelsAsText:e.labelsAsText??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`scatter`,aggregated:e.aggregated??!1,axesDesign:e.axesDesign,showValues:e.showValues,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){return{...t,backgroundColor:Fk(t.background||`#FFFFFF`),fontColor:Fk(vm(t.background)),dataSets:n,labelRange:r,verticalAxis:Cm(t)}},getRuntime(e,t,{extractData:n},r,i){let a=Uk(t,n(),e);return{chartJsConfig:{type:`line`,data:{labels:a.labels,datasets:Eh(t,a)},options:{...Jg,layout:bA(t,a),scales:sh(t,a),plugins:{title:nj(t,e),legend:RA(t,a),tooltip:cj(t,a),chartShowValuesPlugin:XA(t,a),background:{color:a.background}},...i}},customizableSeries:a.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},Eq={sequence:30,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showValues`,`showLabels`,`valuesDesign`,`groupColors`,`pieHolePercentage`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getFormulas:()=>[],getDefinitionFromContextCreation(e,t){return{background:e.background,dataSetStyles:e.dataSetStyles??{},dataSource:t.fromHierarchicalContextCreation(e),legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`sunburst`,showValues:e.showValues,showLabels:e.showLabels,valuesDesign:e.valuesDesign,groupColors:e.groupColors,humanize:e.humanize,pieHolePercentage:e.pieHolePercentage,annotationLink:e.annotationLink,annotationText:e.annotationText}},getContextCreation(e,t,n){return{...e,...t.getHierarchicalContextCreation(n)}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractHierarchicalData:n},r,i){let a=Jk(t,n(),e);return{chartJsConfig:{type:`doughnut`,data:{datasets:Fh(t,a)},options:{cutout:t.pieHolePercentage===void 0?`25%`:`${t.pieHolePercentage}%`,...Jg,layout:bA(t,a),plugins:{title:nj(t,e),legend:UA(t,a),tooltip:gj(t,a),sunburstLabelsPlugin:QA(t,a),sunburstHoverPlugin:{enabled:!0},background:{color:a.background}},...i}}}}},Dq={sequence:100,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showHeaders`,`headerDesign`,`showLabels`,`valuesDesign`,`coloringOptions`,`showValues`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getFormulas:()=>[],getDefinitionFromContextCreation(e,t){return{background:e.background,dataSetStyles:e.dataSetStyles??{},dataSource:t.fromHierarchicalContextCreation(e),legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`treemap`,showValues:e.showValues,showHeaders:e.showHeaders,headerDesign:e.headerDesign,showLabels:e.showLabels,valuesDesign:e.valuesDesign,coloringOptions:e.treemapColoringOptions,humanize:e.humanize,annotationText:e.annotationText,annotationLink:e.annotationLink}},getContextCreation(e,t,n){return{...e,treemapColoringOptions:e.coloringOptions,...t.getHierarchicalContextCreation(n)}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractHierarchicalData:n},r,i){let a=Jk(t,n(),e);return{chartJsConfig:{type:`treemap`,data:{labels:a.labels,datasets:Bh(t,a)},options:{...Jg,layout:bA(t,a),plugins:{title:nj(t,e),legend:{display:!1},tooltip:_j(t,a),background:{color:a.background}},...i}}}}};Iw.add(`bar`,xj),Iw.add(`combo`,bq),Iw.add(`line`,Mj),Iw.add(`pie`,Nj),Iw.add(`scorecard`,pg),Iw.add(`gauge`,Dj),Iw.add(`scatter`,Tq),Iw.add(`waterfall`,Pj),Iw.add(`pyramid`,Cq),Iw.add(`radar`,wq),Iw.add(`geo`,Sq),Iw.add(`funnel`,xq),Iw.add(`sunburst`,Eq),Iw.add(`treemap`,Dq),Iw.add(`calendar`,yq),Iw.add(`bubble`,_q),Dg.add(`line`,{matcher:e=>e.type===`line`&&!e.stacked&&!e.fillArea,displayName:M(`Line`),chartType:`line`,chartSubtype:`line`,subtypeDefinition:{stacked:!1,fillArea:!1},category:`line`,preview:`o-spreadsheet-ChartPreview.LINE_CHART`}).add(`stacked_line`,{matcher:e=>e.type===`line`&&!e.fillArea&&!!e.stacked,displayName:M(`Stacked Line`),chartType:`line`,chartSubtype:`stacked_line`,subtypeDefinition:{stacked:!0,fillArea:!1},category:`line`,preview:`o-spreadsheet-ChartPreview.STACKED_LINE_CHART`}).add(`area`,{matcher:e=>e.type===`line`&&!e.stacked&&!!e.fillArea,displayName:M(`Area`),chartType:`line`,chartSubtype:`area`,subtypeDefinition:{stacked:!1,fillArea:!0},category:`area`,preview:`o-spreadsheet-ChartPreview.AREA_CHART`}).add(`stacked_area`,{matcher:e=>e.type===`line`&&e.stacked&&!!e.fillArea,displayName:M(`Stacked Area`),chartType:`line`,chartSubtype:`stacked_area`,subtypeDefinition:{stacked:!0,fillArea:!0},category:`area`,preview:`o-spreadsheet-ChartPreview.STACKED_AREA_CHART`}).add(`scatter`,{displayName:M(`Scatter`),chartType:`scatter`,chartSubtype:`scatter`,category:`misc`,preview:`o-spreadsheet-ChartPreview.SCATTER_CHART`}).add(`bubble`,{displayName:M(`Bubble`),chartType:`bubble`,chartSubtype:`bubble`,category:`misc`,preview:`o-spreadsheet-ChartPreview.BUBBLE_CHART`}).add(`column`,{matcher:e=>e.type===`bar`&&!e.stacked&&!e.horizontal,displayName:M(`Column`),chartType:`bar`,chartSubtype:`column`,subtypeDefinition:{stacked:!1,horizontal:!1},category:`column`,preview:`o-spreadsheet-ChartPreview.COLUMN_CHART`}).add(`stacked_column`,{matcher:e=>e.type===`bar`&&e.stacked&&!e.horizontal,displayName:M(`Stacked Column`),chartType:`bar`,chartSubtype:`stacked_column`,subtypeDefinition:{stacked:!0,horizontal:!1},category:`column`,preview:`o-spreadsheet-ChartPreview.STACKED_COLUMN_CHART`}).add(`bar`,{matcher:e=>e.type===`bar`&&!e.stacked&&!!e.horizontal,displayName:M(`Bar`),chartType:`bar`,chartSubtype:`bar`,subtypeDefinition:{horizontal:!0,stacked:!1},category:`bar`,preview:`o-spreadsheet-ChartPreview.BAR_CHART`}).add(`stacked_bar`,{matcher:e=>e.type===`bar`&&e.stacked&&!!e.horizontal,displayName:M(`Stacked Bar`),chartType:`bar`,chartSubtype:`stacked_bar`,subtypeDefinition:{horizontal:!0,stacked:!0},category:`bar`,preview:`o-spreadsheet-ChartPreview.STACKED_BAR_CHART`}).add(`combo`,{displayName:M(`Combo`),chartSubtype:`combo`,chartType:`combo`,category:`line`,preview:`o-spreadsheet-ChartPreview.COMBO_CHART`}).add(`pie`,{matcher:e=>e.type===`pie`&&!e.isDoughnut,displayName:M(`Pie`),chartSubtype:`pie`,chartType:`pie`,subtypeDefinition:{isDoughnut:!1},category:`pie`,preview:`o-spreadsheet-ChartPreview.PIE_CHART`}).add(`doughnut`,{matcher:e=>e.type===`pie`&&!!e.isDoughnut,displayName:M(`Doughnut`),chartSubtype:`doughnut`,chartType:`pie`,subtypeDefinition:{isDoughnut:!0},category:`pie`,preview:`o-spreadsheet-ChartPreview.DOUGHNUT_CHART`}).add(`gauge`,{displayName:M(`Gauge`),chartSubtype:`gauge`,chartType:`gauge`,category:`misc`,preview:`o-spreadsheet-ChartPreview.GAUGE_CHART`}).add(`scorecard`,{displayName:M(`Scorecard`),chartSubtype:`scorecard`,chartType:`scorecard`,category:`misc`,preview:`o-spreadsheet-ChartPreview.SCORECARD_CHART`}).add(`waterfall`,{displayName:M(`Waterfall`),chartSubtype:`waterfall`,chartType:`waterfall`,category:`misc`,preview:`o-spreadsheet-ChartPreview.WATERFALL_CHART`}).add(`pyramid`,{displayName:M(`Population Pyramid`),chartSubtype:`pyramid`,chartType:`pyramid`,category:`misc`,preview:`o-spreadsheet-ChartPreview.POPULATION_PYRAMID_CHART`}).add(`radar`,{matcher:e=>e.type===`radar`&&!e.fillArea,displayName:M(`Radar`),chartSubtype:`radar`,chartType:`radar`,subtypeDefinition:{fillArea:!1},category:`misc`,preview:`o-spreadsheet-ChartPreview.RADAR_CHART`}).add(`filled_radar`,{matcher:e=>e.type===`radar`&&!!e.fillArea,displayName:M(`Filled Radar`),chartType:`radar`,chartSubtype:`filled_radar`,subtypeDefinition:{fillArea:!0},category:`misc`,preview:`o-spreadsheet-ChartPreview.FILLED_RADAR_CHART`}).add(`geo`,{displayName:M(`Geo Chart`),chartSubtype:`geo`,chartType:`geo`,category:`misc`,preview:`o-spreadsheet-ChartPreview.GEO_CHART`}).add(`funnel`,{displayName:M(`Funnel`),chartSubtype:`funnel`,chartType:`funnel`,category:`misc`,preview:`o-spreadsheet-ChartPreview.FUNNEL_CHART`}).add(`sunburst`,{matcher:e=>e.type===`sunburst`,displayName:M(`Sunburst`),chartSubtype:`sunburst`,chartType:`sunburst`,category:`hierarchical`,preview:`o-spreadsheet-ChartPreview.SUNBURST_CHART`}).add(`treemap`,{matcher:e=>e.type===`treemap`,displayName:M(`Tree Map`),chartType:`treemap`,chartSubtype:`treemap`,category:`hierarchical`,preview:`o-spreadsheet-ChartPreview.TREE_MAP_CHART`}).add(`calendar`,{displayName:M(`Calendar`),chartSubtype:`calendar`,chartType:`calendar`,category:`misc`,preview:`o-spreadsheet-ChartPreview.CALENDAR_CHART`}),KB.add(`filter_icon`,(e,t)=>{if(e.isFilterHeader(t)){let n=e.isFilterActive(t),r=If(e.getCellComputedStyle(t).fillColor||`#fff`)<.45;return{type:`filter_icon`,svg:_S(n,r,!1),hoverSvg:_S(n,r,!0),priority:3,horizontalAlign:`right`,size:17,margin:2,position:t,onClick:(e,t)=>{let n=t.getStore(qx),r=n.persistentCellPopover;if(r.isOpen&&r.col===e.col&&r.row===e.row&&r.type===`FilterMenu`){n.close();return}n.open(e,`FilterMenu`)}}}});var Oq=l({ARRAYTOTEXT:()=>rJ,ARRAY_CONSTRAIN:()=>jq,ARRAY_LITERAL:()=>Mq,ARRAY_ROW:()=>Nq,CHOOSECOLS:()=>Pq,CHOOSEROWS:()=>Fq,EXPAND:()=>Iq,FLATTEN:()=>Lq,FREQUENCY:()=>Rq,HSTACK:()=>zq,MDETERM:()=>Bq,MINVERSE:()=>Vq,MMULT:()=>Hq,SUMPRODUCT:()=>Uq,SUMX2MY2:()=>Gq,SUMX2PY2:()=>Kq,SUMXMY2:()=>qq,TOCOL:()=>Xq,TOROW:()=>Zq,TRANSPOSE:()=>Qq,VSTACK:()=>$q,WRAPCOLS:()=>eJ,WRAPROWS:()=>tJ});function kq(e,t){let n=e.map(R),r=n.map(e=>e?.[0]?.length??0),i=Math.max(...r);if(t?.requireSameRowCount){let e=r[0];if(r.some(t=>t!==e))return new P(M(`All ranges in [[FUNCTION_NAME]] must have the same number of rows (got %s).`,r.join(`, `)))}let a=[];for(let e of n)for(let t=0;t<e.length;t++){let n=Array(i).fill({value:null});for(let r=0;r<e[t].length;r++)n[r]=e[t][r];a.push(n)}return a}function Aq(e,t){let n=e.map(R),r=n.map(e=>e?.length??0),i=Math.max(...r);if(t?.requireSameColCount){let e=r[0];if(r.some(t=>t!==e))return new P(M(`All ranges in [[FUNCTION_NAME]] must have the same number of columns (got %s).`,r.join(`, `)))}let a=fs(i,n.reduce((e,t)=>e+(t?.[0]?.length??0),0),()=>({value:null})),o=0;for(let e of n){for(let t=0;t<e.length;t++)for(let n=0;n<e[t].length;n++)a[t][o+n]=e[t][n];o+=e[0]?.length??0}return a}let jq={description:M(`Returns a result array constrained to a specific width and height.`),args:[V(`input_range (any, range<any>)`,M(`The range to constrain.`)),V(`rows (number)`,M(`The number of rows in the constrained array.`)),V(`columns (number)`,M(`The number of columns in the constrained array.`))],computeArray:function(e,t,n){let r=R(e),i=Qo(t?.value,this.locale),a=Qo(n?.value,this.locale);if(i<=0)return new P(M(`The rows argument (%s) must be strictly positive.`,i.toString()));if(a<=0)return new P(M(`The columns argument (%s) must be strictly positive.`,a.toString()));let o=Math.min(i,r[0].length);return fs(Math.min(a,r.length),o,(e,t)=>r[e][t])},isExported:!1},Mq={description:M(`Appends ranges vertically and in sequence to return a larger array. All ranges must have the same number of columns.`),args:[V(`range (any, range<any>, repeating)`,M(`The range to be appended.`))],computeArray:function(...e){return Aq(e,{requireSameColCount:!0})},isExported:!1,hidden:!0},Nq={description:M(`Appends ranges horizontally and in sequence to return a larger array. All ranges must have the same number of rows.`),args:[V(`range (any, range<any>, repeating)`,M(`The range to be appended.`))],computeArray:function(...e){return kq(e,{requireSameRowCount:!0})},isExported:!1,hidden:!0},Pq={description:M(`Creates a new array from the selected columns in the existing range.`),args:[V(`array (any, range<any>)`,M(`The array that contains the columns to be returned.`)),V(`col_num (number, range<number>, repeating)`,M(`The column index of the column to be returned.`))],computeArray:function(e,...t){let n=R(e),r=Ds(t,e=>Qo(e?.value,this.locale)),i=r.filter(e=>e===0||n.length<Math.abs(e));if(i.length!==0)return new P(M(`The columns arguments must be between -%s and %s (got %s), excluding 0.`,n.length.toString(),n.length.toString(),i.join(`,`)));let a=Array(r.length);for(let e=0;e<r.length;e++)r[e]>0?a[e]=n[r[e]-1]:a[e]=n[n.length+r[e]];return a},isExported:!0},Fq={description:M(`Creates a new array from the selected rows in the existing range.`),args:[V(`array (any, range<any>)`,M(`The array that contains the rows to be returned.`)),V(`row_num (number, range<number>, repeating)`,M(`The row index of the row to be returned.`))],computeArray:function(e,...t){let n=R(e),r=Ds(t,e=>Qo(e?.value,this.locale)),i=n.length,a=r.filter(e=>e===0||n[0].length<Math.abs(e));return a.length===0?fs(i,r.length,(e,t)=>r[t]>0?n[e][r[t]-1]:n[e][n[e].length+r[t]]):new P(M(`The rows arguments must be between -%s and %s (got %s), excluding 0.`,n[0].length.toString(),n[0].length.toString(),a.join(`,`)))},isExported:!0},Iq={description:M(`Expands or pads an array to specified row and column dimensions.`),args:[V(`array (any, range<any>)`,M(`The array to expand.`)),V(`rows (number)`,M(`The number of rows in the expanded array. If missing, rows will not be expanded.`)),V(`columns (number, optional)`,M(`The number of columns in the expanded array. If missing, columns will not be expanded.`)),V(`pad_with (any, default=0)`,M(`The value with which to pad.`))],computeArray:function(e,t,n,r={value:0}){let i=R(e),a=Qo(t?.value,this.locale),o=n===void 0?i.length:Qo(n.value,this.locale);return a<i[0].length?new P(M(`The rows arguments (%s) must be greater or equal than the number of rows of the array.`,a.toString())):o<i.length?new P(M(`The columns arguments (%s) must be greater or equal than the number of columns of the array.`,o.toString())):fs(o,a,(e,t)=>e>=i.length||t>=i[e].length?r:i[e][t])},isExported:!0},Lq={description:M(`Flattens all the values from one or more ranges into a single column.`),args:[V(`range (any, range<any>, repeating)`,M(`The range to flatten.`))],computeArray:function(...e){return[Ds(e,e=>e===void 0?{value:``}:e)]},isExported:!1},Rq={description:M(`Calculates the frequency distribution of a range.`),args:[V(`data (range<number>)`,M(`The array of ranges containing the values to be counted.`)),V(`classes (number, range<number>)`,M(`The range containing the set of classes.`))],computeArray:function(e,t){let n=Ds([e],e=>e.value).filter(e=>typeof e==`number`),r=Ds([t],e=>e.value).filter(e=>typeof e==`number`).map((e,t)=>({initialIndex:t,value:e,count:0})).sort((e,t)=>e.value-t.value);r.push({initialIndex:r.length,value:1/0,count:0});let i=n.sort((e,t)=>e-t),a=0;for(let e of i){for(;e>r[a].value&&a<r.length-1;)a++;r[a].count++}return[r.sort((e,t)=>e.initialIndex-t.initialIndex).map(e=>({value:e.count}))]},isExported:!0},zq={description:M(`Appends ranges horizontally and in sequence to return a larger array.`),args:[V(`range (any, range<any>, repeating)`,M(`The range to be appended.`))],computeArray:function(...e){return kq(e)},isExported:!0},Bq={description:M(`Returns the matrix determinant of a square matrix.`),args:[V(`square_matrix (number, range<number>)`,M(`An range with an equal number of rows and columns representing a matrix whose determinant will be calculated.`))],compute:function(e){let t=Xo(e,`square_matrix`);return Tv(t)?{value:Ov(t).determinant}:new P(M(`The argument square_matrix must have the same number of columns and rows.`))},isExported:!0},Vq={description:M(`Returns the multiplicative inverse of a square matrix.`),args:[V(`square_matrix (number, range<number>)`,M(`An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated.`))],computeArray:function(e){let t=Xo(e,`square_matrix`);if(!Tv(t))return new P(M(`The argument square_matrix must have the same number of columns and rows.`));let{inverted:n}=Ov(t);return n?ps(n,e=>({value:e})):new P(M(`The matrix is not invertible.`))},isExported:!0},Hq={description:M(`Calculates the matrix product of two matrices.`),args:[V(`matrix1 (number, range<number>)`,M(`The first matrix in the matrix multiplication operation.`)),V(`matrix2 (number, range<number>)`,M(`The second matrix in the matrix multiplication operation.`))],computeArray:function(e,t){let n=Xo(e,`matrix1`),r=Xo(t,`matrix2`);return n.length===0||r.length===0?new P(M(`The first and second arguments of [[FUNCTION_NAME]] must be non-empty matrices.`)):n.length===r[0].length?ps(Av(n,r),e=>({value:e})):new P(M(`In [[FUNCTION_NAME]], the number of columns of the first matrix (%s) must be equal to the number of rows of the second matrix (%s).`,n.length.toString(),r[0].length.toString()))},isExported:!0},Uq={description:M(`Calculates the sum of the products of corresponding entries in equal-sized ranges.`),args:[V(`range (number, range<number>, repeating)`,M(`The range whose entries will be multiplied with corresponding entries in the other range.`))],compute:function(...e){if(!wv(...e))return new P(M(`All the ranges must have the same dimensions.`));let t=e.map(R),n=0;for(let e=0;e<t[0].length;e++)for(let r=0;r<t[0][e].length;r++){if(!t.every(t=>typeof t[e][r].value==`number`))continue;let i=1;for(let n of t)i*=F(n[e][r],this.locale);n+=i}return{value:n}},isExported:!0};function Wq(e,t,n){if(!wv(e,t))return new P(M(`The arguments array_x and array_y must have the same dimensions.`));let r=R(e),i=R(t),a=!1,o=0;for(let e in r)for(let t in r[e]){let s=r[e][t].value,c=i[e][t].value;typeof s!=`number`||typeof c!=`number`||(a=!0,o+=n(s,c))}return a?o:new P(M(`The arguments array_x and array_y must contain at least one pair of numbers.`))}let Gq={description:M(`Calculates the sum of the difference of the squares of the values in two array.`),args:[V(`array_x (number, range<number>)`,M(`The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.`)),V(`array_y (number, range<number>)`,M(`The array or range of values whose squares will be subtracted from the squares of corresponding entries in array_x and added together.`))],compute:function(e,t){let n=Wq(e,t,(e,t)=>e**2-t**2);return n instanceof P?n:{value:n}},isExported:!0},Kq={description:M(`Calculates the sum of the sum of the squares of the values in two array.`),args:[V(`array_x (number, range<number>)`,M(`The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.`)),V(`array_y (number, range<number>)`,M(`The array or range of values whose squares will be added to the squares of corresponding entries in array_x and added together.`))],compute:function(e,t){let n=Wq(e,t,(e,t)=>e**2+t**2);return n instanceof P?n:{value:n}},isExported:!0},qq={description:M(`Calculates the sum of squares of the differences of values in two array.`),args:[V(`array_x (number, range<number>)`,M(`The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.`)),V(`array_y (number, range<number>)`,M(`The array or range of values that will be subtracted from corresponding entries in array_x, the result squared, and all such results added together.`))],compute:function(e,t){let n=Wq(e,t,(e,t)=>(e-t)**2);return n instanceof P?n:{value:n}},isExported:!0},Jq=[V(`array (any, range<any>)`,M(`The array which will be transformed.`)),V(`ignore (number, default=0)`,M(`Whether to ignore certain types of values. By default, no values are ignored.`),[{value:0,label:M(`Keep all values (default)`)},{value:1,label:M(`Ignore blanks`)},{value:2,label:M(`Ignore errors`)},{value:3,label:M(`Ignore blanks and errors`)}]),V(`scan_by_column (number, default=false)`,M(`Scan the array by column. By default, the array is scanned by row.`),[{value:!1,label:M(`Scan by row (default)`)},{value:!0,label:M(`Scan by column`)}])];function Yq(e){let t=Math.trunc(e);if(t===0)return()=>!0;if(t===1)return e=>e.value!==null;if(t===2)return e=>!Uo(e.value);if(t===3)return e=>e.value!==null&&!Uo(e.value);throw new P(M(`Argument ignore must be between 0 and 3`))}let Xq={description:M(`Transforms a range of cells into a single column.`),args:Jq,computeArray:function(e,t={value:0},n={value:!1}){let r=R(e),i=F(t.value,this.locale),a=(L(n.value)?r:hs(r)).flat().filter(Yq(i));return a.length===0?new Io(M(`No results for the given arguments of TOCOL.`)):[a]},isExported:!0},Zq={description:M(`Transforms a range of cells into a single row.`),args:Jq,computeArray:function(e,t={value:0},n={value:!1}){let r=R(e),i=F(t.value,this.locale),a=(L(n.value)?r:hs(r)).flat().filter(Yq(i)).map(e=>[e]);return a.length===0||a[0].length===0?new Io(M(`No results for the given arguments of TOROW.`)):a},isExported:!0},Qq={description:M(`Transposes the rows and columns of a range.`),args:[V(`range (any, range<any>)`,M(`The range to be transposed.`))],computeArray:function(e){let t=R(e),n=t[0].length,r=t.length;return fs(n,r,(e,n)=>t[n][e])},isExported:!0},$q={description:M(`Appends ranges vertically and in sequence to return a larger array.`),args:[V(`range (any, range<any>, repeating)`,M(`The range to be appended.`))],computeArray:function(...e){return Aq(e)},isExported:!0},eJ={description:M(`Wraps the provided row or column of cells by columns after a specified number of elements to form a new array.`),args:[V(`range (any, range<any>)`,M(`The range to wrap.`)),V(`wrap_count (number)`,M(`The maximum number of cells for each column, rounded down to the nearest whole number.`)),V(`pad_with (any, default=0)`,M(`The value with which to fill the extra cells in the range.`))],computeArray:function(e,t,n={value:0}){let r=R(e),i=Qo(t?.value,this.locale);if(!Cv(r))return new P(M(`Argument range must be a single row or column.`));if(i<1)return new P(M(`The wrap_count (%s) must be strictly positive.`,i),N.InvalidNumber);let a=r.flat();return fs(Math.ceil(a.length/i),i,(e,t)=>{let r=e*i+t;return r<a.length?a[r]:n})},isExported:!0},tJ={description:M(`Wraps the provided row or column of cells by rows after a specified number of elements to form a new array.`),args:[V(`range (any, range<any>)`,M(`The range to wrap.`)),V(`wrap_count (number)`,M(`The maximum number of cells for each row, rounded down to the nearest whole number.`)),V(`pad_with (any, default=0)`,M(`The value with which to fill the extra cells in the range.`))],computeArray:function(e,t,n={value:0}){let r=R(e),i=Qo(t?.value,this.locale);if(!Cv(r))return new P(M(`Argument range must be a single row or column.`));if(i<1)return new P(M(`The wrap_count (%s) must be strictly positive.`,i),N.InvalidNumber);let a=r.flat();return fs(i,Math.ceil(a.length/i),(e,t)=>{let r=t*i+e;return r<a.length?a[r]:n})},isExported:!0},nJ=[{value:0,label:M(`Concise format\xA0(default)`)},{value:1,label:M(`Strict format`)}],rJ={description:M(`returns an array of text values from any specified range. It passes text values unchanged, and converts non-text values to text.`),args:[V(`array (range)`,M(`The array to convert into text`)),V(`format (number, default=0)`,M(`The format of the returned data.`),nJ)],compute:function(e,t={value:0}){let n=F(t,this.locale),r=R(e);if(n===1)return{value:yM(r,``,this.locale)};if(n===0){let e=this.locale.decimalSeparator===`,`?`/`:`,`;return{value:hs(r).flatMap(e=>e.map(e=>Uo(e.value)?e.value:I(e))).join(e)}}else return new P(M(`Format must be 0 or 1`))},isExported:!0};var iJ=l({ABS:()=>oJ,ACOS:()=>sJ,ACOSH:()=>cJ,ACOT:()=>lJ,ACOTH:()=>uJ,ASIN:()=>dJ,ASINH:()=>fJ,ATAN:()=>pJ,ATAN2:()=>mJ,ATANH:()=>hJ,CEILING:()=>gJ,CEILING_MATH:()=>vJ,CEILING_PRECISE:()=>yJ,COS:()=>bJ,COSH:()=>xJ,COT:()=>SJ,COTH:()=>CJ,COUNTBLANK:()=>wJ,COUNTIF:()=>TJ,COUNTIFS:()=>EJ,COUNTUNIQUE:()=>DJ,COUNTUNIQUEIFS:()=>OJ,CSC:()=>kJ,CSCH:()=>AJ,DECIMAL:()=>jJ,DEGREES:()=>MJ,EXP:()=>NJ,FLOOR:()=>PJ,FLOOR_MATH:()=>IJ,FLOOR_PRECISE:()=>LJ,INT:()=>yY,ISEVEN:()=>RJ,ISODD:()=>BJ,ISO_CEILING:()=>zJ,LN:()=>VJ,LOG:()=>HJ,MOD:()=>WJ,MUNIT:()=>GJ,ODD:()=>KJ,PI:()=>qJ,POWER:()=>JJ,PRODUCT:()=>YJ,RAND:()=>XJ,RANDARRAY:()=>ZJ,RANDBETWEEN:()=>QJ,ROUND:()=>$J,ROUNDDOWN:()=>eY,ROUNDUP:()=>tY,SEC:()=>nY,SECH:()=>rY,SEQUENCE:()=>iY,SIN:()=>aY,SINH:()=>oY,SQRT:()=>sY,SUBTOTAL:()=>dY,SUM:()=>fY,SUMIF:()=>pY,SUMIFS:()=>mY,TAN:()=>hY,TANH:()=>gY,TRUNC:()=>vY});let aJ=/^-?[a-z0-9]+$/i,oJ={description:M(`Absolute value of a number.`),args:[V(`value (number)`,M(`The number of which to return the absolute value.`))],compute:function(e){return{value:Math.abs(F(e,this.locale))}},isExported:!0},sJ={description:M(`Inverse cosine of a value, in radians.`),args:[V(`value (number)`,M(`The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.`))],compute:function(e){let t=F(e,this.locale);return Math.abs(t)>1?new P(M(`The value (%s) must be between -1 and 1 inclusive.`,t)):{value:Math.acos(t)}},isExported:!0},cJ={description:M(`Inverse hyperbolic cosine of a number.`),args:[V(`value (number)`,M(`The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.`))],compute:function(e){let t=F(e,this.locale);return t<1?new P(M(`The value (%s) must be greater than or equal to 1.`,t)):{value:Math.acosh(t)}},isExported:!0},lJ={description:M(`Inverse cotangent of a value.`),args:[V(`value (number)`,M(`The value for which to calculate the inverse cotangent.`))],compute:function(e){let t=F(e,this.locale);return{value:(Math.sign(t)||1)*Math.PI/2-Math.atan(t)}},isExported:!0},uJ={description:M(`Inverse hyperbolic cotangent of a value.`),args:[V(`value (number)`,M(`The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.`))],compute:function(e){let t=F(e,this.locale);return Math.abs(t)<=1?new P(M(`The value (%s) cannot be between -1 and 1 inclusive.`,t)):{value:Math.log((t+1)/(t-1))/2}},isExported:!0},dJ={description:M(`Inverse sine of a value, in radians.`),args:[V(`value (number)`,M(`The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.`))],compute:function(e){let t=F(e,this.locale);return Math.abs(t)>1?new P(M(`The value (%s) must be between -1 and 1 inclusive.`,t)):{value:Math.asin(t)}},isExported:!0},fJ={description:M(`Inverse hyperbolic sine of a number.`),args:[V(`value (number)`,M(`The value for which to calculate the inverse hyperbolic sine.`))],compute:function(e){return{value:Math.asinh(F(e,this.locale))}},isExported:!0},pJ={description:M(`Inverse tangent of a value, in radians.`),args:[V(`value (number)`,M(`The value for which to calculate the inverse tangent.`))],compute:function(e){return{value:Math.atan(F(e,this.locale))}},isExported:!0},mJ={description:M(`Angle from the X axis to a point (x,y), in radians.`),args:[V(`x (number)`,M(`The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.`)),V(`y (number)`,M(`The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.`))],compute:function(e,t){let n=F(e,this.locale),r=F(t,this.locale);return n===0&&r===0?new zo(M(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:Math.atan2(r,n)}},isExported:!0},hJ={description:M(`Inverse hyperbolic tangent of a number.`),args:[V(`value (number)`,M(`The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.`))],compute:function(e){let t=F(e,this.locale);return Math.abs(t)>=1?new P(M(`The value (%s) must be between -1 and 1 exclusive.`,t)):{value:Math.atanh(t)}},isExported:!0},gJ={description:M(`Rounds number up to nearest multiple of factor.`),args:[V(`value (number)`,M(`The value to round up to the nearest integer multiple of factor.`)),V(`factor (number, default=1)`,M(`The number to whose multiples value will be rounded.`))],compute:function(e,t={value:1}){let n=F(e,this.locale),r=F(t,this.locale);return r<0&&n>0?new P(M(`The factor (%s) must be positive when the value (%s) is positive.`,r,n)):{value:r?Math.ceil(n/r)*r:0,format:e?.format}},isExported:!0};function _J(e,t,n=0){return t===0?0:(t=Math.abs(t),e>=0?Math.ceil(e/t)*t:n===0?-Math.floor(Math.abs(e)/t)*t:-Math.ceil(Math.abs(e)/t)*t)}let vJ={description:M(`Rounds number up to nearest multiple of factor.`),args:[V(`number (number)`,M(`The value to round up to the nearest integer multiple of significance.`)),V(`significance (number, default=1)`,M(`The number to whose multiples number will be rounded. The sign of significance will be ignored.`)),V(`mode (number, default=0)`,M(`If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero.`))],compute:function(e,t={value:1},n={value:0}){let r=F(t,this.locale);return{value:_J(F(e,this.locale),r,F(n,this.locale)),format:e?.format}},isExported:!0},yJ={description:M(`Rounds number up to nearest multiple of factor.`),args:[V(`number (number)`,M(`The value to round up to the nearest integer multiple of significance.`)),V(`significance (number, default=1)`,M(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){let n=F(t,this.locale);return{value:_J(F(e,this.locale),n),format:e?.format}},isExported:!0},bJ={description:M(`Cosine of an angle provided in radians.`),args:[V(`angle (number)`,M(`The angle to find the cosine of, in radians.`))],compute:function(e){return{value:Math.cos(F(e,this.locale))}},isExported:!0},xJ={description:M(`Hyperbolic cosine of any real number.`),args:[V(`value (number)`,M(`Any real value to calculate the hyperbolic cosine of.`))],compute:function(e){return{value:Math.cosh(F(e,this.locale))}},isExported:!0},SJ={description:M(`Cotangent of an angle provided in radians.`),args:[V(`angle (number)`,M(`The angle to find the cotangent of, in radians.`))],compute:function(e){let t=F(e,this.locale);return t===0?new zo(M(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:1/Math.tan(t)}},isExported:!0},CJ={description:M(`Hyperbolic cotangent of any real number.`),args:[V(`value (number)`,M(`Any real value to calculate the hyperbolic cotangent of.`))],compute:function(e){let t=F(e,this.locale);return t===0?new zo(M(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:1/Math.tanh(t)}},isExported:!0},wJ={description:M(`Number of empty values.`),args:[V(`value (any, range, repeating)`,M(`Value or range in which to count the number of blanks.`))],compute:function(...e){return{value:ls(e,(e,t)=>t===void 0||t.value===null||t.value===``?e+1:e,0)}},isExported:!0},TJ={description:M(`A conditional count across a range.`),args:[V(`range (range)`,M(`The range that is tested against criterion.`)),V(`criterion (string)`,M(`The pattern or test to apply to range.`))],compute:function(...e){let t=0;return xs(e,(e,n)=>{t+=1},this.locale),{value:t}},isExported:!0},EJ={description:M(`Count values depending on multiple criteria.`),args:[V(`criteria_range (any, range, repeating)`,M(`Range over which to evaluate criteria.`)),V(`criterion (string, repeating)`,M(`Criteria to check.`))],compute:function(...e){let t=0;return xs(e,(e,n)=>{t+=1},this.locale),{value:t}},isExported:!0},DJ={description:M(`Counts number of unique values in a range.`),args:[V(`value (any, range, repeating)`,M(`Value or range to consider for uniqueness.`))],compute:function(...e){return{value:xv(e)}}},OJ={description:M(`Counts number of unique values in a range, filtered by a set of criteria.`),args:[V(`range (range)`,M(`The range of cells from which the number of unique values will be counted.`)),V(`criteria_range (any, range, repeating)`,M(`Range over which to evaluate criteria.`)),V(`criterion (string, repeating)`,M(`Criteria to check.`))],compute:function(e,...t){let n=new Set;return xs(t,(t,r)=>{let i=e[t]?.[r];Os(i)&&n.add(i.value)},this.locale),{value:n.size}}},kJ={description:M(`Cosecant of an angle provided in radians.`),args:[V(`angle (number)`,M(`The angle to find the cosecant of, in radians.`))],compute:function(e){let t=F(e,this.locale);return t===0?new zo(M(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:1/Math.sin(t)}},isExported:!0},AJ={description:M(`Hyperbolic cosecant of any real number.`),args:[V(`value (number)`,M(`Any real value to calculate the hyperbolic cosecant of.`))],compute:function(e){let t=F(e,this.locale);return t===0?new zo(M(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:1/Math.sinh(t)}},isExported:!0},jJ={description:M(`Converts from another base to decimal.`),args:[V(`value (string)`,M(`The number to convert.`)),V(`base (number)`,M(`The base to convert the value from.`))],compute:function(e,t){let n=F(t,this.locale);if(n=Math.floor(n),2>n||n>36)return new P(M(`The base (%s) must be between 2 and 36 inclusive.`,n));let r=I(e);if(r===``)return{value:0};if(!aJ.test(r))return new P(M(`The value (%s) must be a valid base %s representation.`,r,n));let i=r.replace(`-`,``);for(let e of i)if(parseInt(e,36)>=n)return new P(M(`The value (%s) must be a valid base %s representation.`,r,n));let a=parseInt(r,n);return isNaN(a)?new P(M(`The value (%s) must be a valid base %s representation.`,r,n)):{value:a}},isExported:!0},MJ={description:M(`Converts an angle value in radians to degrees.`),args:[V(`angle (number)`,M(`The angle to convert from radians to degrees.`))],compute:function(e){return{value:F(e,this.locale)*180/Math.PI}},isExported:!0},NJ={description:M(`Euler's number, e (~2.718) raised to a power.`),args:[V(`value (number)`,M(`The exponent to raise e.`))],compute:function(e){return{value:Math.exp(F(e,this.locale))}},isExported:!0},PJ={description:M(`Rounds number down to nearest multiple of factor.`),args:[V(`value (number)`,M(`The value to round down to the nearest integer multiple of factor.`)),V(`factor (number, default=1)`,M(`The number to whose multiples value will be rounded.`))],compute:function(e,t={value:1}){let n=F(e,this.locale),r=F(t,this.locale);return r<0&&n>0?new P(M(`The factor (%s) must be positive when the value (%s) is positive.`,r,n)):{value:r?Math.floor(n/r)*r:0,format:e?.format}},isExported:!0};function FJ(e,t,n=0){return t===0?0:(t=Math.abs(t),e>=0?Math.floor(e/t)*t:n===0?-Math.ceil(Math.abs(e)/t)*t:-Math.floor(Math.abs(e)/t)*t)}let IJ={description:M(`Rounds number down to nearest multiple of factor.`),args:[V(`number (number)`,M(`The value to round down to the nearest integer multiple of significance.`)),V(`significance (number, default=1)`,M(`The number to whose multiples number will be rounded. The sign of significance will be ignored.`)),V(`mode (number, default=0)`,M(`If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero.`))],compute:function(e,t={value:1},n={value:0}){let r=F(t,this.locale);return{value:FJ(F(e,this.locale),r,F(n,this.locale)),format:e?.format}},isExported:!0},LJ={description:M(`Rounds number down to nearest multiple of factor.`),args:[V(`number (number)`,M(`The value to round down to the nearest integer multiple of significance.`)),V(`significance (number, default=1)`,M(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){let n=F(t,this.locale);return{value:FJ(F(e,this.locale),n),format:e?.format}},isExported:!0},RJ={description:M(`Whether the provided value is even.`),args:[V(`value (number)`,M(`The value to be verified as even.`))],compute:function(e){let t=Zo(e,this.locale);return{value:!(Math.floor(Math.abs(t))&1)}},isExported:!0},zJ={description:M(`Rounds number up to nearest multiple of factor.`),args:[V(`number (number)`,M(`The value to round up to the nearest integer multiple of significance.`)),V(`significance (number, default=1)`,M(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){return{value:_J(F(e,this.locale),F(t,this.locale)),format:e?.format}},isExported:!0},BJ={description:M(`Whether the provided value is even.`),args:[V(`value (number)`,M(`The value to be verified as even.`))],compute:function(e){let t=Zo(e,this.locale);return{value:!!(Math.floor(Math.abs(t))&1)}},isExported:!0},VJ={description:M(`The logarithm of a number, base e (euler's number).`),args:[V(`value (number)`,M(`The value for which to calculate the logarithm, base e.`))],compute:function(e){let t=F(e,this.locale);return t<=0?new P(M(`The value (%s) must be strictly positive.`,t)):{value:Math.log(t)}},isExported:!0},HJ={description:M(`The logarithm of a number, for a given base.`),args:[V(`value (number)`,M(`The value for which to calculate the logarithm.`)),V(`base (number, default=10)`,M(`The base of the logarithm.`))],compute:function(e,t={value:10}){let n=F(e,this.locale),r=F(t,this.locale);return n<=0?new P(M(`The value (%s) must be strictly positive.`,n)):r<=0?new P(M(`The base (%s) must be strictly positive.`,r)):r===1?new P(M(`The base must be different from 1.`)):{value:Math.log10(n)/Math.log10(r)}},isExported:!0};function UJ(e,t){Sv(t,M(`The divisor must be different from 0.`));let n=e%t;return n>0&&t<0||n<0&&t>0?n+t:n}let WJ={description:M(`Modulo (remainder) operator.`),args:[V(`dividend (number)`,M(`The number to be divided to find the remainder.`)),V(`divisor (number)`,M(`The number to divide by.`))],compute:function(e,t){let n=F(t,this.locale);return{value:UJ(F(e,this.locale),n),format:e?.format}},isExported:!0},GJ={description:M(`Returns a n x n unit matrix, where n is the input dimension.`),args:[V(`dimension (number)`,M(`An integer specifying the dimension size of the unit matrix. It must be positive.`))],computeArray:function(e){let t=Qo(e,this.locale);return t<1?new P(M(`The argument dimension must be positive`)):ps(Dv(t),e=>({value:e}))},isExported:!0},KJ={description:M(`Rounds a number up to the nearest odd integer.`),args:[V(`value (number)`,M(`The value to round to the next greatest odd number.`))],compute:function(e){let t=F(e,this.locale),n=Math.ceil(Math.abs(t));return n=n&1?n:n+1,{value:t<0?-n:n,format:e?.format}},isExported:!0},qJ={description:M(`The number pi.`),args:[],compute:function(){return{value:Math.PI}},isExported:!0},JJ={description:M(`A number raised to a power.`),args:[V(`base (number)`,M(`The number to raise to the exponent power.`)),V(`exponent (number)`,M(`The exponent to raise base to.`))],compute:function(e,t){let n=F(e,this.locale),r=F(t,this.locale);return n<0&&!Number.isInteger(r)?new P(M(`The exponent (%s) must be an integer when the base is negative.`,r)):{value:n**+r,format:e?.format}},isExported:!0},YJ={description:M(`Result of multiplying a series of numbers together.`),args:[V(`factor (number, range<number>, repeating)`,M(`Number or range to calculate for the product.`))],compute:function(...e){let t=0,n=1;for(let r of e)if(yt(r))for(let e of r)for(let r of e){let e=r.value;if(typeof e==`number`&&(n*=e,t+=1),Uo(e))return r}else r!==void 0&&r.value!==null&&(n*=Zo(r,this.locale),t+=1);return{value:t===0?0:n,format:Ho(e[0])}},isExported:!0},XJ={description:M(`A random number between 0 inclusive and 1 exclusive.`),args:[],compute:function(){return{value:Math.random()}},isExported:!0},ZJ={description:M(`Returns a grid of random numbers between 0 inclusive and 1 exclusive.`),args:[V(`rows (number, default=1)`,M(`The number of rows to be returned.`)),V(`columns (number, default=1)`,M(`The number of columns to be returned.`)),V(`min (number, default=0)`,M(`The minimum number you would like returned.`)),V(`max (number, default=1)`,M(`The maximum number you would like returned.`)),V(`whole_number (boolean, default=FALSE)`,M(`Return a whole number or a decimal value.`),[{value:!1,label:M(`Decimal (default)`)},{value:!0,label:M(`Integer`)}])],computeArray:function(e={value:1},t={value:1},n={value:0},r={value:1},i={value:!1}){let a=Qo(t,this.locale),o=Qo(e,this.locale),s=F(n,this.locale),c=F(r,this.locale),l=L(i);if(a<1)return new P(M(`The number of columns (%s) must be positive.`,a));if(o<1)return new P(M(`The number of rows (%s) must be positive.`,o));if(s>c)return new P(M(`The maximum (%s) must be greater than or equal to the minimum (%s).`,c,s));if(l&&(!Number.isInteger(s)||!Number.isInteger(c)))return new P(M(`The maximum (%s) and minimum (%s) must be integers when whole_number is TRUE.`,c.toString(),s.toString()));let u=Array(a);for(let e=0;e<a;e++){u[e]=Array(o);for(let t=0;t<o;t++)l?u[e][t]=Math.floor(Math.random()*(c-s+1)+s):u[e][t]=s+Math.random()*(c-s)}return ps(u,e=>({value:e}))},isExported:!0},QJ={description:M(`Random integer between two values, inclusive.`),args:[V(`low (number)`,M(`The low end of the random range.`)),V(`high (number)`,M(`The high end of the random range.`))],compute:function(e,t){let n=F(e,this.locale);Number.isInteger(n)||(n=Math.ceil(n));let r=F(t,this.locale);return Number.isInteger(r)||(r=Math.floor(r)),n>r?new P(M(`The high (%s) must be greater than or equal to the low (%s).`,r,n)):{value:n+Math.floor((r-n+1)*Math.random()),format:e?.format}},isExported:!0},$J={description:M(`Rounds a number according to standard rules.`),args:[V(`value (number)`,M(`The value to round to places number of places.`)),V(`places (number, default=0)`,M(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=F(e,this.locale),r=F(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.round(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.round(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},eY={description:M(`Rounds down a number.`),args:[V(`value (number)`,M(`The value to round to places number of places, always rounding down.`)),V(`places (number, default=0)`,M(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=F(e,this.locale),r=F(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.floor(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.floor(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},tY={description:M(`Rounds up a number.`),args:[V(`value (number)`,M(`The value to round to places number of places, always rounding up.`)),V(`places (number, default=0)`,M(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=F(e,this.locale),r=F(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.ceil(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.ceil(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},nY={description:M(`Secant of an angle provided in radians.`),args:[V(`angle (number)`,M(`The angle to find the secant of, in radians.`))],compute:function(e){return{value:1/Math.cos(F(e,this.locale))}},isExported:!0},rY={description:M(`Hyperbolic secant of any real number.`),args:[V(`value (number)`,M(`Any real value to calculate the hyperbolic secant of.`))],compute:function(e){return{value:1/Math.cosh(F(e,this.locale))}},isExported:!0},iY={description:M(`Returns a sequence of numbers.`),args:[V(`rows (number)`,M(`The number of rows to return`)),V(`columns (number, optional, default=1)`,M(`The number of columns to return`)),V(`start (number, optional, default=1)`,M(`The first number in the sequence`)),V(`step (number, optional, default=1)`,M(`The amount to increment each value in the sequence`))],computeArray:function(e,t={value:1},n={value:1},r={value:1}){let i=F(n,this.locale),a=F(r,this.locale),o=Qo(e,this.locale),s=Qo(t,this.locale);return s<1?new P(M(`The number of columns (%s) must be positive.`,s)):o<1?new P(M(`The number of rows (%s) must be positive.`,o)):fs(s,o,(e,t)=>({value:i+t*s*a+e*a}))},isExported:!0},aY={description:M(`Sine of an angle provided in radians.`),args:[V(`angle (number)`,M(`The angle to find the sine of, in radians.`))],compute:function(e){return{value:Math.sin(F(e,this.locale))}},isExported:!0},oY={description:M(`Hyperbolic sine of any real number.`),args:[V(`value (number)`,M(`Any real value to calculate the hyperbolic sine of.`))],compute:function(e){return{value:Math.sinh(F(e,this.locale))}},isExported:!0},sY={description:M(`Positive square root of a positive number.`),args:[V(`value (number)`,M(`The number for which to calculate the positive square root.`))],compute:function(e){let t=F(e,this.locale);return t<0?new P(M(`The value (%s) must be positive or null.`,t)):{value:Math.sqrt(t),format:e?.format}},isExported:!0},cY={1:`AVERAGE`,2:`COUNT`,3:`COUNTA`,4:`MAX`,5:`MIN`,6:`PRODUCT`,7:`STDEV`,8:`STDEVP`,9:`SUM`,10:`VAR`,11:`VARP`},lY=Object.entries(cY).map(([e,t])=>({value:parseInt(e),label:M(`%s (include manually-hidden rows)`,t)})),uY=Object.entries(cY).map(([e,t])=>({value:parseInt(e)+100,label:M(`%s (exclude manually-hidden rows)`,t)})),dY={description:M(`Returns a subtotal for a vertical range of cells using a specified aggregation function.`),args:[V(`function_code (number)`,M(`The function to use in subtotal aggregation.`),[...lY,...uY]),V(`ref (any, range<any>, repeating)`,M(`Range or reference for which you want the subtotal.`))],compute:function(e,...t){let n=Qo(e,this.locale),r=!0;if(n>100&&(n-=100,r=!1),n<1||n>11)return new P(M(`The function code (%s) must be between 1 to 11 or 101 to 111.`,n));let i=[];for(let e of t){let t=R(e),n=t[0][0]?.position;if(n===void 0)return new Fo(Ko);let a=n.col+t.length-1,o=n.row+t[0].length-1,s=n.sheetId;for(let e=n.row;e<=o;e++)if(!this.getters.isRowFiltered(s,e)&&!(!r&&this.getters.isRowHiddenByUser(s,e)))for(let t=n.col;t<=a;t++){let n=this.getters.getCorrespondingFormulaCell({sheetId:s,col:t,row:e});(!n||!wn(n,`SUBTOTAL`))&&i.push(this.getFormulaResult({sheetId:s,col:t,row:e}))}}let a=cY[n],o=[i];return jv(ol(ml.get(a),o.length)(this,o))},isExported:!0},fY={description:M(`Sum of a series of numbers and/or cells.`),args:[V(`value (number, range<number>, repeating)`,M(`Number or range to add together.`))],compute:function(...e){let t=e[0];return{value:bv(e,this.locale),format:Ho(t)}},isExported:!0},pY={description:M(`A conditional sum across a range.`),args:[V(`criteria_range (range)`,M(`The range which is tested against criterion.`)),V(`criterion (string)`,M(`The pattern or test to apply to range.`)),V(`sum_range (range, default=criteria_range)`,M(`The range to be summed, if different from range.`))],compute:function(e,t,n){n===void 0&&(n=e);let r=0;return xs([e,t],(e,t)=>{let i=n[e]?.[t]?.value;typeof i==`number`&&(r+=i)},this.locale),{value:r}},isExported:!0},mY={description:M(`Sums a range depending on multiple criteria.`),args:[V(`sum_range (range)`,M(`The range to sum.`)),V(`criteria_range (any, range, repeating)`,M(`Range to check.`)),V(`criterion (string, repeating)`,M(`Criteria to check.`))],compute:function(e,...t){let n=0;return xs(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n+=i)},this.locale),{value:n}},isExported:!0},hY={description:M(`Tangent of an angle provided in radians.`),args:[V(`angle (number)`,M(`The angle to find the tangent of, in radians.`))],compute:function(e){return{value:Math.tan(F(e,this.locale))}},isExported:!0},gY={description:M(`Hyperbolic tangent of any real number.`),args:[V(`value (number)`,M(`Any real value to calculate the hyperbolic tangent of.`))],compute:function(e){return{value:Math.tanh(F(e,this.locale))}},isExported:!0};function _Y(e,t){return t===0?Math.trunc(e):(Number.isInteger(t)||(t=Math.trunc(t)),Math.trunc(e*10**t)/10**t)}let vY={description:M(`Truncates a number.`),args:[V(`value (number)`,M(`The value to be truncated.`)),V(`places (number, default=0)`,M(`The number of significant digits to the right of the decimal point to retain.`))],compute:function(e,t={value:0}){return{value:_Y(F(e,this.locale),F(t,this.locale)),format:e?.format}},isExported:!0},yY={description:M(`Rounds a number down to the nearest integer that is less than or equal to it.`),args:[V(`value (number)`,M(`The number to round down to the nearest integer.`))],compute:function(e){return{value:Math.floor(F(e,this.locale))}},isExported:!0};var bY=l({AVEDEV:()=>AY,AVERAGE:()=>jY,AVERAGEA:()=>FY,AVERAGEIF:()=>IY,AVERAGEIFS:()=>LY,AVERAGE_WEIGHTED:()=>PY,CHISQ_DIST_RT:()=>UY,CHISQ_TEST:()=>WY,CONFIDENCE_NORM:()=>GY,CONFIDENCE_T:()=>KY,CORREL:()=>pX,COUNT:()=>RY,COUNTA:()=>zY,COVAR:()=>BY,COVARIANCE_P:()=>VY,COVARIANCE_S:()=>HY,FORECAST:()=>JY,F_TEST:()=>qY,GEOMEAN:()=>YY,GROWTH:()=>XY,HARMEAN:()=>ZY,INTERCEPT:()=>QY,KURT:()=>$Y,LARGE:()=>eX,LINEST:()=>tX,LOGEST:()=>nX,MATTHEWS:()=>rX,MAX:()=>iX,MAXA:()=>aX,MAXIFS:()=>oX,MEDIAN:()=>sX,MIN:()=>cX,MINA:()=>lX,MINIFS:()=>uX,PEARSON:()=>fX,PERCENTILE:()=>mX,PERCENTILE_EXC:()=>hX,PERCENTILE_INC:()=>gX,POLYFIT_COEFFS:()=>_X,POLYFIT_FORECAST:()=>vX,QUARTILE:()=>yX,QUARTILE_EXC:()=>bX,QUARTILE_INC:()=>xX,RANK:()=>SX,RSQ:()=>CX,SKEW:()=>TX,SKEW_P:()=>EX,SLOPE:()=>wX,SMALL:()=>DX,SPEARMAN:()=>OX,STDEV:()=>kX,STDEVA:()=>MX,STDEVP:()=>NX,STDEVPA:()=>PX,STDEV_P:()=>AX,STDEV_S:()=>jX,STEYX:()=>IX,TREND:()=>LX,TRIMMEAN:()=>RX,T_TEST:()=>FX,VAR:()=>zX,VARA:()=>HX,VARP:()=>UX,VARPA:()=>WX,VAR_P:()=>BX,VAR_S:()=>VX});let xY=[{value:!0,label:M(`b is calculated normally`)},{value:!1,label:M(`b is forced to 1`)}],SY=[{value:!1,label:M(`do not return additional regression statistics`)},{value:!0,label:M(`return additional regression statistics`)}],CY=[{value:1,label:M(`order 1 (Linear)`)},{value:2,label:M(`order 2 (Quadratic)`)},{value:3,label:M(`order 3 (Cubic)`)},{value:4,label:M(`order 4 (Quartic)`)},{value:5,label:M(`order 5 (Quintic)`)},{value:6,label:M(`order 6 (Sextic)`)}],wY=[{value:!0,label:M(`Compute intercept`)},{value:!1,label:M(`Force intercept to 0`)}],TY=[{value:0,label:M(`Minimum value`)},{value:1,label:M(`First quartile (25th percentile)`)},{value:2,label:M(`Median value (50th percentile)`)},{value:3,label:M(`Third quartile (75th percentile)`)},{value:4,label:M(`Maximum value`)}];function EY(e,t){let n=[],r=[],i=0,a=0;os([e],e=>{n.push(e),i+=1}),os([t],e=>{r.push(e),a+=1}),W(i===a,M(`[[FUNCTION_NAME]] has mismatched argument count %s vs %s.`,i,a));let o=[],s=[];for(let e=0;e<i;e++){let t=n[e]?.value,i=r[e]?.value;typeof t==`number`&&typeof i==`number`&&(s.push(t),o.push(i))}return{flatDataX:o,flatDataY:s}}function DY(e,t,n){let{flatDataX:r,flatDataY:i}=EY(e,t),a=i.length;Sv(a),n&&Sv(a-1);let o=0,s=0;for(let e=0;e<a;e++)o+=i[e],s+=r[e];let c=o/a,l=s/a,u=0;for(let e=0;e<a;e++)u+=(i[e]-c)*(r[e]-l);return u/(a-+!!n)}function OY(e,t,n,r){let i=0,a=n?ds:us,o=a(e,(e,t)=>(i+=1,e+t),0,r);Sv(i),t&&Sv(i-1);let s=o/i;return a(e,(e,t)=>e+(t-s)**2,0,r)/(i-+!!t)}function kY(e,t,n,r){let i=F(t,r);W(n?0<=i&&i<=1:0<i&&i<1,M(`Function [[FUNCTION_NAME]] parameter 2 value is out of range.`));let a=[],o,s=0;return os(e,e=>{let t=e?.value;typeof t==`number`&&(o=Ss(a,e,`nextSmaller`,`asc`,a.length,(e,t)=>e[t]),a.splice(o+1,0,t),s++)}),W(s!==0,ks),n||W(1/(s+1)<=i&&i<=s/(s+1),M(`Function [[FUNCTION_NAME]] parameter 2 value is out of range.`)),Co(a,i,n)}let AY={description:M(`Average magnitude of deviations from mean.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the sample.`))],compute:function(...e){let t=0,n=us(e,(e,n)=>(t+=1,e+n),0,this.locale);if(t===0)return new zo(M(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`));let r=n/t;return{value:us(e,(e,t)=>e+Math.abs(r-t),0,this.locale)/t}},isExported:!0},jY={description:M(`Numerical average value in a dataset, ignoring text.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to consider when calculating the average value.`))],compute:function(...e){return{value:Iv(e,this.locale),format:Ho(e[0])}},isExported:!0},MY=M(`[[FUNCTION_NAME]] has mismatched range sizes.`),NY=M(`[[FUNCTION_NAME]] expects the weight to be positive or equal to 0.`),PY={description:M(`Weighted average.`),args:[V(`values (number, range<number>, repeating)`,M(`Value to average.`)),V(`weights (number, range<number>, repeating)`,M(`Weight for each corresponding value.`))],compute:function(...e){let t=0,n=0;for(let r=0;r<e.length-1;r+=2){let i=e[r],a=e[r+1];if(!wv(i,a))return new P(MY);if(yt(i))for(let e=0;e<i.length;e++)for(let r=0;r<i[0].length;r++){let o=i[e][r].value,s=yt(a)?a?.[e][r].value:F(a,this.locale),c=typeof o==`number`,l=typeof s==`number`;if(c&&l){if(s<0)return new P(NY);t+=o*s,n+=s;continue}if(c!==l)return new P(M(`[[FUNCTION_NAME]] expects number values.`))}else{let e=F(i,this.locale),r=yt(a)?a?.[0][0].value:F(a,this.locale);if(typeof r==`number`){if(r<0)return new P(NY);t+=e*r,n+=r}}}return n===0?new zo(M(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:t/n,format:Ho(e[0])}}},FY={description:M(`Numerical average value in a dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to consider when calculating the average value.`))],compute:function(...e){let t=0,n=ds(e,(e,n)=>(t+=1,e+n),0,this.locale);return t===0?new zo(M(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:n/t,format:Ho(e[0])}},isExported:!0},IY={description:M(`Average of values depending on criteria.`),args:[V(`criteria_range (number, range<number>)`,M(`The range to check against criterion.`)),V(`criterion (string)`,M(`The pattern or test to apply to criteria_range.`)),V(`average_range (number, range<number>, default=criteria_range)`,M(`The range to average. If not included, criteria_range is used for the average instead.`))],compute:function(e,t,n){let r=R(n===void 0?e:n),i=0,a=0;return xs([e,t],(e,t)=>{let n=r[e]?.[t]?.value;typeof n==`number`&&(i+=1,a+=n)},this.locale),i===0?new zo(M(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:a/i}},isExported:!0},LY={description:M(`Average of values depending on multiple criteria.`),args:[V(`average_range (range)`,M(`The range to average.`)),V(`criteria_range (any, range, repeating)`,M(`Range to check.`)),V(`criterion (string, repeating)`,M(`Criterion to check.`))],compute:function(e,...t){let n=R(e),r=0,i=0;return xs(t,(e,t)=>{let a=n[e]?.[t]?.value;typeof a==`number`&&(r+=1,i+=a)},this.locale),r===0?new zo(M(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:i/r}},isExported:!0},RY={description:M(`The number of numeric values in dataset.`),args:[V(`value (number, any, range<number>, repeating)`,M(`Value or range to consider when counting.`))],compute:function(...e){return{value:Rv(e,this.locale)}},isExported:!0},zY={description:M(`The number of values in a dataset.`),args:[V(`value (any, range, repeating)`,M(`Value or range to consider when counting.`))],compute:function(...e){return{value:zv(e)}},isExported:!0},BY={description:M(`The covariance of a dataset.`),args:[V(`data_y (any, range)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (any, range)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return{value:DY(e,t,!1)}},isExported:!0},VY={description:M(`The covariance of a dataset.`),args:[V(`data_y (any, range)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (any, range)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return{value:DY(e,t,!1)}},isExported:!0},HY={description:M(`The sample covariance of a dataset.`),args:[V(`data_y (any, range)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (any, range)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return{value:DY(e,t,!0)}},isExported:!0},UY={description:M(`Upper tail of the chi-square distribution.`),args:[V(`x (number)`,M(`The value to evaluate.`)),V(`degrees_of_freedom (number)`,M(`The degrees of freedom.`))],compute:function(e,t){let n=F(e,this.locale),r=Math.round(F(t,this.locale));return W(n>=0,M(`x must be non-negative.`)),W(r>=1,M(`Degrees of freedom must be >= 1.`)),{value:Qv(r/2,n/2)}},isExported:!0},WY={description:M(`Returns the p-value of a chi-square test for independence, comparing actual to expected values.`),args:[V(`actual_range (range<number>)`,M(`The range containing the observed values.`)),V(`expected_range (range<number>)`,M(`The range containing the expected values.`))],compute:function(e,t){W(wv(e,t),M(`The two ranges must have the same dimensions.`));let n=Xo(e,`actual_range`),r=Xo(t,`expected_range`),i=n.length,a=n[0]?.length??0;W(i*a>0,ks);let o=0;for(let e=0;e<i;e++)for(let t=0;t<a;t++){let i=r[e][t];Sv(i);let a=n[e][t]-i;o+=a*a/i}let s;return s=a>1&&i>1?(a-1)*(i-1):a===1?i-1:a-1,W(s>=1,M(`The ranges must contain at least 2 values.`)),{value:Qv(s/2,o/2)}},isExported:!0},GY={description:M(`Half-width of the confidence interval for a population mean (normal distribution).`),args:[V(`alpha (number)`,M(`The significance level (e.g. 0.05 for 95% CI).`)),V(`standard_deviation (number)`,M(`The population standard deviation.`)),V(`size (number)`,M(`The sample size.`))],compute:function(e,t,n){let r=F(e,this.locale),i=F(t,this.locale),a=Math.round(F(n,this.locale));return W(r>0&&r<1,M(`Alpha must be between 0 and 1.`)),W(i>0,M(`Standard deviation must be positive.`)),W(a>=1,M(`Size must be >= 1.`)),{value:-ty(r/2)*i/Math.sqrt(a)}},isExported:!0},KY={description:M(`Half-width of the confidence interval for a population mean (t-distribution).`),args:[V(`alpha (number)`,M(`The significance level (e.g. 0.05 for 95% CI).`)),V(`standard_deviation (number)`,M(`The sample standard deviation.`)),V(`size (number)`,M(`The sample size.`))],compute:function(e,t,n){let r=F(e,this.locale),i=F(t,this.locale),a=Math.round(F(n,this.locale));return W(r>0&&r<1,M(`Alpha must be between 0 and 1.`)),W(i>0,M(`Standard deviation must be positive.`)),W(a>=2,M(`Size must be >= 2.`)),{value:ry(r,a-1)*i/Math.sqrt(a)}},isExported:!0},qY={description:M(`Returns the two-tailed p-value of an F-test comparing the variances of two datasets.`),args:[V(`range1 (range<number>)`,M(`The first sample.`)),V(`range2 (range<number>)`,M(`The second sample.`))],compute:function(e,t){let n=[],r=[];ss([e],e=>n.push(e.value),this.locale),ss([t],e=>r.push(e.value),this.locale);let i=n.length,a=r.length;W(i>=2&&a>=2,M(`Each range must contain at least 2 numeric values.`));let o=n.reduce((e,t)=>e+t,0)/i,s=r.reduce((e,t)=>e+t,0)/a,c=n.reduce((e,t)=>e+(t-o)**2,0)/(i-1),l=r.reduce((e,t)=>e+(t-s)**2,0)/(a-1);Sv(c),Sv(l);let u=c/l,d=i-1,f=a-1,p=$v(d*u/(d*u+f),d/2,f/2);return{value:2*Math.min(p,1-p)}},isExported:!0},JY={description:M(`Calculates the expected y-value for a specified x based on a linear regression of a dataset.`),args:[V(`x (number, range<number>)`,M(`The value(s) on the x-axis to forecast.`)),V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`))],computeArray:function(e,t,n){let{flatDataX:r,flatDataY:i}=EY(t,n);return r.length===0||i.length===0?new Io(ks):ps(Yv([i],[r],ps(R(e),e=>F(e,this.locale)),!0),e=>({value:e}))},isExported:!0},YY={description:M(`Geometric mean of a dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Values to include.`))],compute:function(...e){let t=0,n=0;return ss(e,e=>{W(e.value>0,M(`GEOMEAN requires strictly positive values.`)),t+=Math.log(e.value),n++},this.locale),W(n>0,ks),{value:Math.exp(t/n)}},isExported:!0},XY={description:M(`Fits points to exponential growth trend.`),args:[V(`known_data_y (range<number>)`,M(`The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.`)),V(`known_data_x (range<number>, default={1;2;3;...})`,M(`The values of the independent variable(s) corresponding with known_data_y.`)),V(`new_data_x (any, range, default=known_data_x)`,M(`The data points to return the y values for on the ideal curve fit.`)),V(`b (boolean, default=TRUE)`,M(`Given a general exponential form of y = b*m^x for a curve fit, calculates b if TRUE or forces b to be 1 and only calculates the m values if FALSE.`),xY)],computeArray:function(e,t=[[]],n=[[]],r={value:!0}){return e.length===0||e[0].length===0?new P(As(`known_data_y`)):ps(qv(Yv(Jv(Xo(e,`known_data_y`)),Xo(t,`known_data_x`),Xo(n,`new_data_y`),L(r))),e=>({value:e}))}},ZY={description:M(`Harmonic mean of a dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Values to include.`))],compute:function(...e){let t=0,n=0;return ss(e,e=>{W(e.value>0,M(`HARMEAN requires strictly positive values.`)),t+=1/e.value,n++},this.locale),W(n>0,ks),{value:n/t}},isExported:!0},QY={description:M(`Compute the intercept of the linear regression.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=EY(e,t);if(n.length===0||r.length===0)return new Io(ks);let[[],[i]]=Uv([n],[r]);return{value:i}},isExported:!0},$Y={description:M(`Excess kurtosis of a dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Values to include.`))],compute:function(...e){let t=[];ss(e,e=>t.push(e.value),this.locale);let n=t.length;W(n>=4,M(`KURT requires at least 4 values.`));let r=t.reduce((e,t)=>e+t,0)/n,i=t.reduce((e,t)=>e+(t-r)**2,0)/(n-1);W(i>0,M(`KURT requires non-constant data.`));let a=Math.sqrt(i),o=t.reduce((e,t)=>e+((t-r)/a)**4,0);return{value:n*(n+1)/((n-1)*(n-2)*(n-3))*o-3*(n-1)**2/((n-2)*(n-3))}},isExported:!0},eX={description:M(`Nth largest element from a data set.`),args:[V(`data (any, range)`,M(`Array or range containing the dataset to consider.`)),V(`n (number)`,M(`The rank from largest to smallest of the element to return.`))],compute:function(e,t){let n=Math.trunc(F(t?.value,this.locale)),r=[],i,a=0;os([e],e=>{typeof e?.value==`number`&&(i=Ss(r,e,`nextSmaller`,`asc`,r.length,(e,t)=>e[t].value),r.splice(i+1,0,e),a++,a>n&&(r.shift(),a--))});let o=r.shift();return o===void 0?new P(ks):a<n?new P(M(`Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.`,n)):o},isExported:!0},tX={description:M(`Given partial data about a linear trend, calculates various parameters about the ideal linear trend using the least-squares method.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>, default={1;2;3;...})`,M(`The range representing the array or matrix of independent data.`)),V(`calculate_b (boolean, default=TRUE)`,M(`A flag specifying whether to compute the slope or not`),xY),V(`verbose (boolean, default=FALSE)`,M(`A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept`),SY)],computeArray:function(e,t=[[]],n={value:!0},r={value:!1}){return e.length===0||e[0].length===0?new P(As(`data_y`)):ps(Uv(Xo(t,`data_x`),Xo(e,`data_y`),L(n),L(r)),e=>({value:e}))},isExported:!0},nX={description:M(`Given partial data about an exponential growth curve, calculates various parameters about the best fit ideal exponential growth curve.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>, optional, default={1;2;3;...})`,M(`The range representing the array or matrix of independent data.`)),V(`calculate_b (boolean, default=TRUE)`,M(`A flag specifying whether to compute the slope or not`),xY),V(`verbose (boolean, default=FALSE)`,M(`A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept`),SY)],computeArray:function(e,t=[[]],n={value:!0},r={value:!1}){if(e.length===0||e[0].length===0)return new P(As(`data_y`));let i=Uv(Xo(t,`data_x`),Jv(Xo(e,`data_y`)),L(n),L(r));for(let e=0;e<i.length;e++)i[e][0]=Math.exp(i[e][0]);return ps(i,e=>({value:e}))},isExported:!0},rX={description:M(`Compute the Matthews correlation coefficient of a dataset.`),args:[V(`data_x (range)`,M(`The range representing the array or matrix of observed data.`)),V(`data_y (range)`,M(`The range representing the array or matrix of predicted data.`))],compute:function(e,t){let n=e.flat(),r=t.flat();if(Fv(n,r),n.length===0||r.length===0)return new Io(ks);let i=n.length,a=0,o=0,s=0,c=0;for(let e=0;e<i;++e){let t=L(n[e]);t===L(r[e])?t?o++:a++:t?c++:s++}return{value:(o*a-s*c)/Math.sqrt((o+s)*(o+c)*(a+s)*(a+c))}},isExported:!1},iX={description:M(`Maximum value in a numeric dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to consider when calculating the maximum value.`))],compute:function(...e){return Bv(e,this.locale)},isExported:!0},aX={description:M(`Maximum numeric value in a dataset.`),args:[V(`value (any, range, repeating)`,M(`Value or range to consider when calculating the maximum value.`))],compute:function(...e){let t=ds(e,(e,t)=>Math.max(t,e),-1/0,this.locale);return{value:t===-1/0?0:t,format:Ho(e[0])}},isExported:!0},oX={description:M(`Returns the maximum value in a range of cells, filtered by a set of criteria.`),args:[V(`range (range)`,M(`The range of cells from which the maximum will be determined.`)),V(`criteria_range (any, range, repeating)`,M(`Range to evaluate criteria.`)),V(`criterion (string, repeating)`,M(`Criteria to check.`))],compute:function(e,...t){let n=-1/0;return xs(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n=n<i?i:n)},this.locale),{value:n===-1/0?0:n}},isExported:!0},sX={description:M(`Median value in a numeric dataset.`),args:[V(`value (any, range, repeating)`,M(`Value or range to consider when calculating the median value.`))],compute:function(...e){let t=[];return ss(e,e=>{t.push(e)},this.locale),{value:kY(t,{value:.5},!0,this.locale),format:Ho(t[0])}},isExported:!0},cX={description:M(`Minimum value in a numeric dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to consider when calculating the minimum value.`))],compute:function(...e){return Vv(e,this.locale)},isExported:!0},lX={description:M(`Minimum numeric value in a dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to consider when calculating the minimum value.`))],compute:function(...e){let t=ds(e,(e,t)=>Math.min(t,e),1/0,this.locale);return{value:t===1/0?0:t,format:Ho(e[0])}},isExported:!0},uX={description:M(`Returns the minimum value in a range of cells, filtered by a set of criteria.`),args:[V(`range (range)`,M(`The range of cells from which the minimum will be determined.`)),V(`criteria_range (any, range, repeating)`,M(`Range to evaluate criteria.`)),V(`criterion (string, repeating)`,M(`Criterion to check.`))],compute:function(e,...t){let n=1/0;return xs(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n=n>i?i:n)},this.locale),{value:n===1/0?0:n}},isExported:!0};function dX(e,t){let{flatDataX:n,flatDataY:r}=EY(e,t);if(n.length===0||r.length===0)return new Io(ks);let i=n.length,a=0,o=0,s=0,c=0,l=0;for(let e=0;e<i;e++){let t=n[e],i=r[e];a+=t,o+=i,s+=t*i,c+=t*t,l+=i*i}let u=Math.sqrt((i*c-a*a)*(i*l-o*o));return u===0?new zo:(i*s-a*o)/u}let fX={description:M(`Compute the Pearson product-moment correlation coefficient of a dataset.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let n=dX(e,t);return n instanceof zo||n instanceof Io?n:{value:n}},isExported:!0},pX=fX,mX={description:M(`Value at a given percentile of a dataset.`),args:[V(`data (any, range)`,M(`The array or range containing the dataset to consider.`)),V(`percentile (number)`,M(`The percentile whose value within data will be calculated and returned.`))],compute:function(e,t){return gX.compute.bind(this)(e,t)},isExported:!0},hX={description:M(`Value at a given percentile of a dataset exclusive of 0 and 1.`),args:[V(`data (any, range)`,M(`The array or range containing the dataset to consider.`)),V(`percentile (number)`,M(`The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.`))],compute:function(e,t){return{value:kY([e],t,!1,this.locale),format:Ho(e)}},isExported:!0},gX={description:M(`Value at a given percentile of a dataset.`),args:[V(`data (any, range)`,M(`The array or range containing the dataset to consider.`)),V(`percentile (number)`,M(`The percentile whose value within data will be calculated and returned.`))],compute:function(e,t){return{value:kY([e],t,!0,this.locale),format:Ho(e)}},isExported:!0},_X={description:M(`Compute the coefficients of polynomial regression of the dataset.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`)),V(`order (number)`,M(`The order of the polynomial to fit the data, between 1 and 6.`),CY),V(`intercept (boolean, default=TRUE)`,M(`A flag specifying whether to compute the intercept or not.`),wY)],computeArray:function(e,t,n,r={value:!0}){let{flatDataX:i,flatDataY:a}=EY(e,t);return i.length===0||a.length===0?new Io(ks):ps(Wv(a,i,F(n,this.locale),L(r)),e=>({value:e}))},isExported:!1},vX={description:M(`Predict value by computing a polynomial regression of the dataset.`),args:[V(`x (number, range<number>)`,M(`The value(s) on the x-axis to forecast.`)),V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`)),V(`order (number)`,M(`The order of the polynomial to fit the data, between 1 and 6.`),CY),V(`intercept (boolean, default=TRUE)`,M(`A flag specifying whether to compute the intercept or not.`),wY)],computeArray:function(e,t,n,r,i={value:!0}){let a=F(r,this.locale),{flatDataX:o,flatDataY:s}=EY(t,n);if(o.length===0||s.length===0)return new Io(ks);let c=Wv(s,o,a,L(i)).flat();return ps(R(e),e=>({value:Kv(c,F(e,this.locale),a)}))},isExported:!1},yX={description:M(`Value nearest to a specific quartile of a dataset.`),args:[V(`data (any, range)`,M(`The array or range containing the dataset to consider.`)),V(`quartile_number (number)`,M(`Which quartile value to return.`),TY)],compute:function(e,t){return xX.compute.bind(this)(e,t)},isExported:!0},bX={description:M(`Value nearest to a specific quartile of a dataset exclusive of 0 and 4.`),args:[V(`data (any, range)`,M(`The array or range containing the dataset to consider.`)),V(`quartile_number (number)`,M(`Which quartile value, exclusive of 0 and 4, to return.`),[{value:1,label:M(`First quartile (25th percentile)`)},{value:2,label:M(`Median value (50th percentile)`)},{value:3,label:M(`Third quartile (75th percentile)`)}])],compute:function(e,t){let n={value:.25*Math.trunc(F(t,this.locale))};return{value:kY([e],n,!1,this.locale),format:Ho(e)}},isExported:!0},xX={description:M(`Value nearest to a specific quartile of a dataset.`),args:[V(`data (any, range)`,M(`The array or range containing the dataset to consider.`)),V(`quartile_number (number)`,M(`Which quartile value to return.`),TY)],compute:function(e,t){let n={value:.25*Math.trunc(F(t,this.locale))};return{value:kY([e],n,!0,this.locale),format:Ho(e)}},isExported:!0},SX={description:M(`Returns the rank of a specified value in a dataset.`),args:[V(`value (number)`,M(`The value whose rank will be determined.`)),V(`data (range)`,M(`The range containing the dataset to consider.`)),V(`is_ascending (boolean, default=FALSE)`,M(`Whether to consider the values in data in descending or ascending order.`),[{value:!1,label:M(`Descending`)},{value:!0,label:M(`Ascending`)}])],compute:function(e,t,n={value:!1}){let r=L(n),i=F(e,this.locale),a=1,o=!1;for(let e of t)for(let t of e){if(typeof t.value!=`number`)continue;let e=F(t,this.locale);e===i?o=!0:e>i!==r&&a++}return o?{value:a}:new Io(M(`Value not found in the given data.`))},isExported:!0},CX={description:M(`Compute the square of r, the Pearson product-moment correlation coefficient of a dataset.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let n=dX(e,t);return n instanceof zo||n instanceof Io?n:{value:n**2}},isExported:!0},wX={description:M(`Compute the slope of the linear regression.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=EY(e,t);if(n.length===0||r.length===0)return new Io(ks);let[[i]]=Uv([n],[r]);return{value:i}},isExported:!0},TX={description:M(`Skewness of a dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Values to include.`))],compute:function(...e){let t=[];ss(e,e=>t.push(e.value),this.locale);let n=t.length;W(n>=3,M(`SKEW requires at least 3 values.`));let r=t.reduce((e,t)=>e+t,0)/n,i=t.reduce((e,t)=>e+(t-r)**2,0)/(n-1);W(i>0,M(`SKEW requires non-constant data.`));let a=Math.sqrt(i),o=t.reduce((e,t)=>e+((t-r)/a)**3,0);return{value:n/((n-1)*(n-2))*o}},isExported:!0},EX={description:M(`Population skewness of a dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Values to include.`))],compute:function(...e){let t=[];ss(e,e=>t.push(e.value),this.locale);let n=t.length;W(n>=3,M(`SKEW.P requires at least 3 values.`));let r=t.reduce((e,t)=>e+t,0)/n,i=t.reduce((e,t)=>e+(t-r)**2,0)/n;W(i>0,M(`SKEW.P requires non-constant data.`));let a=Math.sqrt(i);return{value:t.reduce((e,t)=>e+((t-r)/a)**3,0)/n}},isExported:!0},DX={description:M(`Nth smallest element in a data set.`),args:[V(`data (any, range)`,M(`The array or range containing the dataset to consider.`)),V(`n (number)`,M(`The rank from smallest to largest of the element to return.`))],compute:function(e,t){let n=Math.trunc(F(t?.value,this.locale)),r=[],i,a=0;os([e],e=>{typeof e?.value==`number`&&(i=Ss(r,e,`nextSmaller`,`asc`,r.length,(e,t)=>e[t].value),r.splice(i+1,0,e),a++,a>n&&(r.pop(),a--))});let o=r.pop();return o===void 0?new P(ks):a<n?new P(M(`Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.`,n)):o},isExported:!0},OX={description:M(`Compute the Spearman rank correlation coefficient of a dataset.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=EY(t,e);if(n.length===0||r.length===0)return new Io(ks);let i=n.length,a=n.map((e,t)=>[e,r[t]]);a.sort((e,t)=>e[0]-t[0]);for(let e=0;e<i;++e)a[e][0]=e;a.sort((e,t)=>e[1]-t[1]);let o=0;for(let e=0;e<i;++e)o+=(a[e][0]-e)**2;return{value:1-6*o/(i**3-i)}},isExported:!1},kX={description:M(`Standard deviation.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the sample.`))],compute:function(...e){return{value:Math.sqrt(zX.compute.bind(this)(...e).value)}},isExported:!0},AX={description:M(`Standard deviation of entire population.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the population.`))],compute:function(...e){return{value:Math.sqrt(BX.compute.bind(this)(...e).value)}},isExported:!0},jX={description:M(`Standard deviation.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the sample.`))],compute:function(...e){return{value:Math.sqrt(VX.compute.bind(this)(...e).value)}},isExported:!0},MX={description:M(`Standard deviation of sample (text as 0).`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the sample.`))],compute:function(...e){return{value:Math.sqrt(HX.compute.bind(this)(...e).value)}},isExported:!0},NX={description:M(`Standard deviation of entire population.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the population.`))],compute:function(...e){return{value:Math.sqrt(UX.compute.bind(this)(...e).value)}},isExported:!0},PX={description:M(`Standard deviation of entire population (text as 0).`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the population.`))],compute:function(...e){return{value:Math.sqrt(WX.compute.bind(this)(...e).value)}},isExported:!0},FX={description:M(`Returns the p-value of a Student's t-test.`),args:[V(`range1 (range<number>)`,M(`The first sample.`)),V(`range2 (range<number>)`,M(`The second sample.`)),V(`tails (number)`,M(`1 for one-tailed, 2 for two-tailed.`)),V(`type (number)`,M(`1 = paired, 2 = two-sample equal variance, 3 = two-sample unequal variance (Welch).`))],compute:function(e,t,n,r){let i=Math.round(F(n,this.locale)),a=Math.round(F(r,this.locale));W(i===1||i===2,M(`Tails must be 1 or 2.`)),W(a>=1&&a<=3,M(`Type must be 1, 2, or 3.`));let o=[],s=[];ss([e],e=>o.push(e.value),this.locale),ss([t],e=>s.push(e.value),this.locale);let c,l;if(a===1){W(o.length===s.length,M(`Paired t-test requires equal-length ranges.`));let e=o.map((e,t)=>e-s[t]),t=e.length;W(t>=2,M(`Paired t-test requires at least 2 pairs.`));let n=e.reduce((e,t)=>e+t,0)/t,r=e.reduce((e,t)=>e+(t-n)**2,0)/(t-1);if(r===0){let e=+(n===0);return{value:i===1?e/2:e}}c=Math.abs(n)/Math.sqrt(r/t),l=t-1}else{let e=o.length,t=s.length;W(e>=2&&t>=2,M(`Each range must contain at least 2 numeric values.`));let n=o.reduce((e,t)=>e+t,0)/e,r=s.reduce((e,t)=>e+t,0)/t,i=o.reduce((e,t)=>e+(t-n)**2,0)/(e-1),u=s.reduce((e,t)=>e+(t-r)**2,0)/(t-1);if(a===2){let a=((e-1)*i+(t-1)*u)/(e+t-2);W(a>0,M(`T.TEST requires non-constant data.`)),c=Math.abs(n-r)/Math.sqrt(a*(1/e+1/t)),l=e+t-2}else{let a=i/e,o=u/t;W(a+o>0,M(`T.TEST requires non-constant data.`)),c=Math.abs(n-r)/Math.sqrt(a+o),l=(a+o)**2/(a**2/(e-1)+o**2/(t-1))}}let u=ny(c,l);return{value:i===1?u/2:u}},isExported:!0},IX={description:M(`Calculates the standard error of the predicted y-value for each x in the regression of a dataset.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=EY(e,t);return n.length===0||r.length===0?new Io(ks):{value:Uv([n],[r],!0,!0)[1][2]}},isExported:!0},LX={description:M(`Fits points to linear trend derived via least-squares.`),args:[V(`known_data_y (number, range<number>)`,M(`The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.`)),V(`known_data_x (number, range<number>, optional, default={1;2;3;...})`,M(`The values of the independent variable(s) corresponding with known_data_y.`)),V(`new_data_x (number, range<number>, optional, default=known_data_x)`,M(`The data points to return the y values for on the ideal curve fit.`)),V(`b (boolean, optional, default=TRUE)`,M(`Given a general linear form of y = m*x+b for a curve fit, calculates b if TRUE or forces b to be 0 and only calculates the m values if FALSE, i.e. forces the curve fit to pass through the origin.`),xY)],computeArray:function(e,t=[[]],n=[[]],r={value:!0}){return e.length===0||e[0].length===0?new P(As(`known_data_y`)):ps(Yv(Xo(e,`known_data_y`),Xo(t,`known_data_x`),Xo(n,`new_data_y`),L(r)),e=>({value:e}))}},RX={description:M(`Average of a dataset after discarding a fraction of data from the ends.`),args:[V(`range (number, range<number>)`,M(`The data to average.`)),V(`percent (number)`,M(`Fraction of data to trim from each end (0 to 0.5).`))],compute:function(e,t){let n=F(t,this.locale);W(n>=0&&n<.5,M(`Percent must be between 0 (inclusive) and 0.5 (exclusive).`));let r=[];ss([e],e=>r.push(e.value),this.locale),W(r.length>0,ks),r.sort((e,t)=>e-t);let i=Math.floor(r.length*n/2),a=r.slice(i,r.length-i);return{value:a.reduce((e,t)=>e+t,0)/a.length}},isExported:!0},zX={description:M(`Variance.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the sample.`))],compute:function(...e){return{value:OY(e,!0,!1,this.locale)}},isExported:!0},BX={description:M(`Variance of entire population.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the population.`))],compute:function(...e){return{value:OY(e,!1,!1,this.locale)}},isExported:!0},VX={description:M(`Variance.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the sample.`))],compute:function(...e){return{value:OY(e,!0,!1,this.locale)}},isExported:!0},HX={description:M(`Variance of sample (text as 0).`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the sample.`))],compute:function(...e){return{value:OY(e,!0,!0,this.locale)}},isExported:!0},UX={description:M(`Variance of entire population.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the population.`))],compute:function(...e){return{value:OY(e,!1,!1,this.locale)}},isExported:!0},WX={description:M(`Variance of entire population (text as 0).`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the population.`))],compute:function(...e){return{value:OY(e,!1,!0,this.locale)}},isExported:!0};var GX=l({DAVERAGE:()=>JX,DCOUNT:()=>YX,DCOUNTA:()=>XX,DGET:()=>ZX,DMAX:()=>QX,DMIN:()=>$X,DPRODUCT:()=>eZ,DSTDEV:()=>tZ,DSTDEVP:()=>nZ,DSUM:()=>rZ,DVAR:()=>iZ,DVARP:()=>aZ});function KX(e,t,n,r){let i=new Map,a=e.length;for(let t=a-1;t>=0;t--)i.set(I(e[t][0]).toUpperCase(),t);let o=t?.value;if(typeof o!=`number`&&typeof o!=`string`)throw new P(M(`The field must be a number or a string`));let s;if(typeof o==`number`){if(s=Math.trunc(o)-1,s<0||a-1<s)throw new P(M(`The field (%(fieldValue)s) must be one of %(dimRowDB)s or must be a number between 1 and %s inclusive.`,{fieldValue:o.toString(),dimRowDB:a.toString()}))}else{let e=I(t).toUpperCase();if(s=i.get(e)??-1,s===-1)throw new P(M(`The field (%s) must be one of %s.`,I(t),[...i.keys()].toString()))}let c=n[0].length;if(c<2)throw new P(M(`The criteria range contains %s row, it must be at least 2 rows.`,c.toString()));let l=new Set,u=e[0].length;for(let t=1;t<c;t++){let a=[],o=!0;for(let r=0;r<n.length;r++){let s=I(n[r][0]).toUpperCase(),c=i.get(s),l=n[r][t];if(l.value!==null)if(c!==void 0)a.push([e[c].slice(1,u)]),a.push(l);else{o=!1;break}}if(o)if(a.length>0)xs(a,(e,t)=>{l.add(t)},r,!0);else{l=new Set(Array(u-1).keys());break}}let d=e[s];return[...l].map(e=>d[e+1])}let qX=[V(`database (range)`,M(`The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.`)),V(`field (number, string)`,M(`Indicates which column in database contains the values to be extracted and operated on.`)),V(`criteria (range)`,M(`An array or range containing zero or more criteria to filter the database values by before operating.`))],JX={description:M(`Average of a set of values from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return jY.compute.bind(this)([r])},isExported:!0},YX={description:M(`Counts values from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return RY.compute.bind(this)([r])},isExported:!0},XX={description:M(`Counts values and text from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return zY.compute.bind(this)([r])},isExported:!0},ZX={description:M(`Single value from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return r.length===0?new P(M(`No match found in DGET evaluation.`)):r.length>1?new P(M(`More than one match found in DGET evaluation.`)):r[0]},isExported:!0},QX={description:M(`Maximum of values from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return iX.compute.bind(this)([r])},isExported:!0},$X={description:M(`Minimum of values from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return cX.compute.bind(this)([r])},isExported:!0},eZ={description:M(`Product of values from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return YJ.compute.bind(this)([r])},isExported:!0},tZ={description:M(`Standard deviation of population sample from table.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return kX.compute.bind(this)([r])},isExported:!0},nZ={description:M(`Standard deviation of entire population from table.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return NX.compute.bind(this)([r])},isExported:!0},rZ={description:M(`Sum of values from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return fY.compute.bind(this)([r])},isExported:!0},iZ={description:M(`Variance of population sample from table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return zX.compute.bind(this)([r])},isExported:!0},aZ={description:M(`Variance of a population from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return UX.compute.bind(this)([r])},isExported:!0},oZ=M(`The cashflow_amounts and cashflow_dates ranges must have the same dimensions.`),sZ=M(`There must be both positive and negative values in cashflow_amounts.`),cZ=e=>M(`The cost (%s) must be positive or null.`,e),lZ=e=>M(`The cost (%s) must be strictly positive.`,e),uZ=e=>M(`The frequency (%s) must be one of %s`,e,[1,2,4].toString()),dZ=e=>M(`The day_count_convention (%s) must be between 0 and 4 inclusive.`,e),fZ=e=>M(`The depreciation factor (%s) must be strictly positive.`,e),pZ=e=>M(`The discount (%s) must be different from -1.`,e),mZ=e=>M(`The discount (%s) must be strictly positive.`,e),hZ=e=>M(`The discount (%s) must be smaller than 1.`,e),gZ=e=>M(`The effective_rate (%s) must be strictly positive.`,e),_Z=e=>M(`The end_period (%s) must be positive or null.`,e),vZ=(e,t)=>M(`The end_period (%(end)s) must be smaller or equal to the life (%(life)s).`,{end:e,life:t}),yZ=e=>M(`All the dates should be greater or equal to the first date in cashflow_dates (%s).`,e),bZ=(e,t)=>M(`The first_period (%(first)s) must be smaller or equal to the last_period (%(last)s).`,{first:e,last:t}),xZ=e=>M(`The first_period (%s) must be strictly positive.`,e),SZ=e=>M(`The future_value (%s) must be strictly positive.`,e),CZ=e=>M(`The investment (%s) must be strictly positive.`,e),wZ=e=>M(`The issue (%s) must be positive or null.`,e),TZ=(e,t)=>M(`The last_period (%(last)s) must be smaller or equal to the number_of_periods (%(nPeriods)s).`,{last:e,nPeriods:t}),EZ=e=>M(`The last_period (%s) must be strictly positive.`,e),DZ=e=>M(`The life (%s) must be strictly positive.`,e),OZ=(e,t)=>M(`The maturity (%(maturity)s) must be strictly greater than the settlement (%(settlement)s).`,{maturity:t,settlement:e}),kZ=e=>M(`The month (%s) must be between 1 and 12 inclusive.`,e),AZ=e=>M(`The nominal_rate (%s) must be strictly positive.`,e),jZ=e=>M(`The number_of_periods (%s) must be different from zero.`,e),MZ=e=>M(`The number_of_periods (%s) must be strictly positive.`,e),NZ=e=>M(`The period must be between 1 and number_of_periods (%s)`,e),PZ=(e,t)=>M(`The period (%(period)s) must be less than or equal to %(lifeLimit)s.`,{period:e,lifeLimit:t}),FZ=e=>M(`The period (%s) must be positive or null.`,e),IZ=e=>M(`The periods_by_year (%s) must be strictly positive.`,e),LZ=(e,t)=>M(`The period (%(period)s) must be less than or equal life (%(life)s).`,{period:e,life:t}),RZ=e=>M(`The period (%s) must be strictly positive.`,e),zZ=e=>M(`The present_value (%s) must be strictly positive.`,e),BZ=e=>M(`The price (%s) must be strictly positive.`,e),VZ=(e,t)=>M(`The purchase_date (%(purchaseDate)s) must be before the first_period_end (%(firstPeriodEnd)s).`,{purchaseDate:e,firstPeriodEnd:t}),HZ=e=>M(`The purchase_date (%s) must be positive or null.`,e),UZ=e=>M(`The rate_guess (%s) must be strictly greater than -1.`,e),WZ=e=>M(`The rate (%s) must be positive or null.`,e),GZ=e=>M(`The rate (%s) must be strictly positive.`,e),KZ=e=>M(`The redemption (%s) must be strictly positive.`,e),qZ=e=>M(`The salvage (%s) must be positive or null.`,e),JZ=(e,t)=>M(`The salvage (%(salvage)s) must be smaller or equal than the cost (%(cost)s).`,{salvage:e,cost:t}),YZ=(e,t)=>M(`The settlement date (%(settlement)s) must be greater or equal to the issue date (%(issue)s).`,{settlement:e,issue:t}),XZ=(e,t)=>M(`The settlement date (%(settlement)s) must at most one year after the maturity date (%(maturity)s).`,{settlement:e,maturity:t}),ZZ=(e,t)=>M(`The settlement date (%(settlement)s) must be strictly greater than the issue date (%(issue)s).`,{settlement:e,issue:t}),QZ=e=>M(`The start_period (%s) must be positive or null.`,e),$Z=(e,t)=>M(`The start_period (%(start)s) must be smaller or equal to the end_period (%(end)s).`,{start:e,end:t}),eQ=e=>M(`The unit (%s) must be strictly positive.`,e),tQ=e=>M(`The yield (%s) must be positive or null.`,e);function nQ(e){return e.some(e=>e>0)&&e.some(e=>e<0)}function rQ(e){return![0,1,2,3,4].includes(e)}function iQ(e){return![1,2,4].includes(e)}function aQ(e,t,n){let r=rs(e,n),i=rs(t,n),a=rs(e,n);return a.setFullYear(r.getFullYear()+1),i.getTime()<=a.getTime()}let oQ=[{value:0,label:M(`US (NASD) 30/360`)},{value:1,label:M(`Actual/Actual`)},{value:2,label:M(`Actual/360`)},{value:3,label:M(`Actual/365`)},{value:4,label:M(`European 30/360`)}];var sQ=l({DATE:()=>lQ,DATEDIF:()=>uQ,DATEVALUE:()=>dQ,DAY:()=>fQ,DAYS:()=>pQ,DAYS360:()=>mQ,EDATE:()=>hQ,EOMONTH:()=>gQ,HOUR:()=>_Q,ISOWEEKNUM:()=>vQ,MINUTE:()=>yQ,MONTH:()=>bQ,MONTH_END:()=>LQ,MONTH_START:()=>IQ,NETWORKDAYS:()=>xQ,NETWORKDAYS_INTL:()=>wQ,NOW:()=>TQ,QUARTER:()=>RQ,QUARTER_END:()=>BQ,QUARTER_START:()=>zQ,SECOND:()=>EQ,TIME:()=>DQ,TIMEVALUE:()=>OQ,TODAY:()=>kQ,WEEKDAY:()=>AQ,WEEKNUM:()=>jQ,WORKDAY:()=>MQ,WORKDAY_INTL:()=>NQ,YEAR:()=>PQ,YEARFRAC:()=>FQ,YEAR_END:()=>HQ,YEAR_START:()=>VQ}),cQ=function(e){return e.WHOLE_YEARS=`Y`,e.WHOLE_MONTHS=`M`,e.WHOLE_DAYS=`D`,e.DAYS_WITHOUT_WHOLE_MONTHS=`MD`,e.MONTH_WITHOUT_WHOLE_YEARS=`YM`,e.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR=`YD`,e}(cQ||{});let lQ={description:M(`Converts year/month/day into a date.`),args:[V(`year (number)`,M(`The year component of the date.`)),V(`month (number)`,M(`The month component of the date.`)),V(`day (number)`,M(`The day component of the date.`))],compute:function(e,t,n){let r=Math.trunc(F(e,this.locale)),i=Math.trunc(F(t,this.locale)),a=Math.trunc(F(n,this.locale));if(r<0||r>9999)return new P(M(`The year (%s) must be between 0 and 9999 inclusive.`,r.toString()));r<1900&&(r+=1900);let o=eo(new Da(r,i-1,a));return o<0?new P(M(`The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.`)):{value:o,format:this.locale.dateFormat}},isExported:!0},uQ={description:M(`Calculates the number of days, months, or years between two dates.`),args:[V(`start_date (date)`,M(`The start date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.`)),V(`end_date (date)`,M(`The end date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.`)),V(`unit (string)`,M(`A text abbreviation for unit of time.`),[{value:`Y`,label:M(`The number of whole years between start_date and end_date`)},{value:`M`,label:M(`The number of whole months between start_date and end_date`)},{value:`D`,label:M(`The number of days between start_date and end_date`)},{value:`MD`,label:M(`The number of days between start_date and end_date after subtracting whole months`)},{value:`YM`,label:M(`The number of whole months between start_date and end_date after subtracting whole years`)},{value:`YD`,label:M(`The number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart`)}])],compute:function(e,t,n){let r=I(n).toUpperCase();if(!Object.values(cQ).includes(r))return new P(Jo(Object.values(cQ),I(n)));let i=Math.trunc(F(e,this.locale)),a=Math.trunc(F(t,this.locale)),o=$a(i),s=$a(a);if(a<i)return new P(M(`start_date (%s) should be on or before end_date (%s).`,o.toLocaleDateString(),s.toLocaleDateString()));switch(r){case`Y`:return{value:lo(o,s)};case`M`:return{value:so(o,s)};case`D`:return{value:co(o,s)};case`YM`:return{value:so(o,s)-lo(o,s)*12};case`MD`:let e=s.getDate()-o.getDate();return e<0&&(e=no(new Da(s.getFullYear(),s.getMonth()-1,1))-Math.abs(e)),{value:e};case`YD`:{if(uo(i,a))return{value:co(o,s)};let e=new Da(o.getFullYear(),s.getMonth(),s.getDate()),t=co(o,e);return t<0&&(e.setFullYear(o.getFullYear()+1),t=co(o,e)),{value:t}}}},isExported:!0},dQ={description:M(`Converts a date string to a date value.`),args:[V(`date_string (string)`,M(`The string representing the date.`))],compute:function(e){let t=I(e),n=Ua(t,this.locale);return n===null?new P(M(`The date_string (%s) cannot be parsed to date/time.`,t.toString())):{value:Math.trunc(n.value)}},isExported:!0},fQ={description:M(`Day of the month that a specific date falls on.`),args:[V(`date (string)`,M(`The date from which to extract the day.`))],compute:function(e){return{value:rs(e,this.locale).getDate()}},isExported:!0},pQ={description:M(`Number of days between two dates.`),args:[V(`end_date (date)`,M(`The end of the date range.`)),V(`start_date (date)`,M(`The start of the date range.`))],compute:function(e,t){let n=rs(e,this.locale),r=rs(t,this.locale),i=n.getTime()-r.getTime();return{value:Math.round(i/ka)}},isExported:!0},mQ={description:M(`Number of days between two dates on a 360-day year (months of 30 days).`),args:[V(`start_date (date)`,M(`The start date to consider in the calculation.`)),V(`end_date (date)`,M(`The end date to consider in the calculation.`)),V(`method (boolean, default=false)`,M(`An indicator of what day count method to use.`),[{value:!1,label:M(`U.S. NASD method (default)`)},{value:!0,label:M(`European method`)}])],compute:function(e,t,n={value:!1}){let r=Math.trunc(F(e,this.locale)),i=Math.trunc(F(t,this.locale)),a=oo(r,i,L(n)?4:0);return{value:Math.sign(i-r)*Math.round(a*360)}},isExported:!0},hQ={description:M(`Date a number of months before/after another date.`),args:[V(`start_date (date)`,M(`The date from which to calculate the result.`)),V(`months (number)`,M(`The number of months before (negative) or after (positive) 'start_date' to calculate.`))],compute:function(e,t){return{value:eo(io(rs(e,this.locale),Math.trunc(F(t,this.locale)),!1)),format:this.locale.dateFormat}},isExported:!0},gQ={description:M(`Last day of a month before or after a date.`),args:[V(`start_date (date)`,M(`The date from which to calculate the result.`)),V(`months (number)`,M(`The number of months before (negative) or after (positive) 'start_date' to consider.`))],compute:function(e,t){let n=rs(e,this.locale),r=Math.trunc(F(t,this.locale));return{value:eo(new Da(n.getFullYear(),n.getMonth()+r+1,0)),format:this.locale.dateFormat}},isExported:!0},_Q={description:M(`Hour component of a specific time.`),args:[V(`time (date)`,M(`The time from which to calculate the hour component.`))],compute:function(e){return{value:rs(e,this.locale).getHours()}},isExported:!0},vQ={description:M(`ISO week number of the year.`),args:[V(`date (date)`,M(`The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.`))],compute:function(e){let t=rs(e,this.locale),n=t.getFullYear(),r=1;for(;new Da(n,0,r).getDay()!==4;)r+=1;let i=new Da(n,0,r-3),a=31;for(;new Da(n,11,a).getDay()!==4;)--a;let o=new Da(n,11,a+3),s;s=i.getTime()<=t.getTime()?t.getTime()<=o.getTime()?0:1:-1;let c;switch(s){case 0:c=i;break;case 1:c=new Da(n,11,a+3+1);break;case-1:let e=1;for(;new Da(n-1,0,e).getDay()!==4;)e+=1;c=new Da(n-1,0,e-3);break}let l=(t.getTime()-c.getTime())/ka;return{value:Math.floor(l/7)+1}},isExported:!0},yQ={description:M(`Minute component of a specific time.`),args:[V(`time (date)`,M(`The time from which to calculate the minute component.`))],compute:function(e){return{value:rs(e,this.locale).getMinutes()}},isExported:!0},bQ={description:M(`Month of the year a specific date falls in`),args:[V(`date (date)`,M(`The date from which to extract the month.`))],compute:function(e){return{value:rs(e,this.locale).getMonth()+1}},isExported:!0},xQ={description:M(`Net working days between two provided days.`),args:[V(`start_date (date)`,M(`The start date of the period from which to calculate the number of net working days.`)),V(`end_date (date)`,M(`The end date of the period from which to calculate the number of net working days.`)),V(`holidays (date, range<date>, optional)`,M(`A range or array constant containing the date serial numbers to consider holidays.`))],compute:function(e,t,n){return wQ.compute.bind(this)(e,t,{value:1},n)},isExported:!0};function SQ(e){let t=e?.value;if(typeof t==`string`){W(t.length===7&&[...t].every(e=>e===`0`||e===`1`),M(`When weekend is a string (%s) it must be composed of "0" or "1".`,t));let e=[];for(let n=0;n<7;n++)t[n]===`1`&&e.push((n+1)%7);return e}if(typeof t==`number`)return W(1<=t&&t<=7||11<=t&&t<=17,M(`The weekend (%s) must be a string or a number in the range 1-7 or 11-17.`,t.toString())),t<=7?[t-2==-1?6:t-2,t-1]:[t-11];throw new P(M(`The weekend must be a number or a string.`))}let CQ=[{value:1,label:M(`Saturday/Sunday are weekends`)},{value:2,label:M(`Sunday/Monday are weekends`)},{value:3,label:M(`Monday/Tuesday are weekends`)},{value:4,label:M(`Tuesday/Wednesday are weekends`)},{value:5,label:M(`Wednesday/Thursday are weekends`)},{value:6,label:M(`Thursday/Friday are weekends`)},{value:7,label:M(`Friday/Saturday are weekends`)},{value:11,label:M(`Sunday is the only weekend`)},{value:12,label:M(`Monday is the only weekend`)},{value:13,label:M(`Tuesday is the only weekend`)},{value:14,label:M(`Wednesday is the only weekend`)},{value:15,label:M(`Thursday is the only weekend`)},{value:16,label:M(`Friday is the only weekend`)},{value:17,label:M(`Saturday is the only weekend`)}],wQ={description:M(`Net working days between two dates (specifying weekends).`),args:[V(`start_date (date)`,M(`The start date of the period from which to calculate the number of net working days.`)),V(`end_date (date)`,M(`The end date of the period from which to calculate the number of net working days.`)),V(`weekend (any, default=1)`,M(`A number or string representing which days of the week are considered weekends.`),CQ),V(`holidays (date, range<date>, optional)`,M(`A range or array constant containing the dates to consider as holidays.`))],compute:function(e,t,n={value:1},r){let i=rs(e,this.locale),a=rs(t,this.locale),o=SQ(n),s=new Set;r!==void 0&&os([r],e=>{let t=rs(e,this.locale);s.add(t.getTime())});let c=i.getTime()>a.getTime(),l=Da.fromTimestamp((c?i:a).getTime()),u=Da.fromTimestamp((c?a:i).getTime()),d=l.getTime(),f=u.getTime(),p=0;for(;f<=d;)!o.includes(u.getDay())&&!s.has(f)&&(p+=1),u.setDate(u.getDate()+1),f=u.getTime();return{value:c?-p:p}},isExported:!0},TQ={description:M(`Current date and time as a date value.`),args:[],compute:function(){let e=Da.now(),t=e.getTime()-Oa.getTime(),n=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return{value:Math.floor(t/ka)+n,format:Eb(this.locale)}},isExported:!0},EQ={description:M(`Minute component of a specific time.`),args:[V(`time (date)`,M(`The time from which to calculate the second component.`))],compute:function(e){return{value:rs(e,this.locale).getSeconds()}},isExported:!0},DQ={description:M(`Converts hour/minute/second into a time.`),args:[V(`hour (number)`,M(`The hour component of the time.`)),V(`minute (number)`,M(`The minute component of the time.`)),V(`second (number)`,M(`The second component of the time.`))],compute:function(e,t,n){let r=Math.trunc(F(e,this.locale)),i=Math.trunc(F(t,this.locale)),a=Math.trunc(F(n,this.locale));return i+=Math.floor(a/60),a=a%60+(a<0?60:0),r+=Math.floor(i/60),i=i%60+(i<0?60:0),r%=24,r<0?new P(M(`The function [[FUNCTION_NAME]] result cannot be negative`)):{value:r/24+i/1440+a/(1440*60),format:this.locale.timeFormat}},isExported:!0},OQ={description:M(`Converts a time string into its serial number representation.`),args:[V(`time_string (string)`,M(`The string that holds the time representation.`))],compute:function(e){let t=I(e),n=Ua(t,this.locale);if(n===null)return new P(M(`The time_string (%s) cannot be parsed to date/time.`,t));let r=n.value-Math.trunc(n.value);return{value:r<0?1+r:r}},isExported:!0},kQ={description:M(`Current date as a date value.`),args:[],compute:function(){let e=Da.now();return{value:eo(new Da(e.getFullYear(),e.getMonth(),e.getDate())),format:this.locale.dateFormat}},isExported:!0},AQ={description:M(`Day of the week of the date provided (as number).`),args:[V(`date (date)`,M(`The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),V(`type (number, default=1)`,M(`A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.`),[{value:1,label:M(`Numbers 1 (Sunday) trough 7 (Saturday)`)},{value:2,label:M(`Numbers 1 (Monday) trough 7 (Sunday)`)},{value:3,label:M(`Numbers 0 (Monday) trough 6 (Sunday)`)},{value:11,label:M(`Numbers 1 (Monday) trough 7 (Sunday)`)},{value:12,label:M(`Numbers 1 (Tuesday) trough 7 (Monday)`)},{value:13,label:M(`Numbers 1 (Wednesday) trough 7 (Tuesday)`)},{value:14,label:M(`Numbers 1 (Thursday) trough 7 (Wednesday)`)},{value:15,label:M(`Numbers 1 (Friday) trough 7 (Thursday)`)},{value:16,label:M(`Numbers 1 (Saturday) trough 7 (Friday)`)},{value:17,label:M(`Numbers 1 (Sunday) trough 7 (Saturday)`)}])],compute:function(e,t={value:1}){let n=rs(e,this.locale),r=Math.round(F(t,this.locale)),i=n.getDay();if(!(1<=r&&r<=3)&&!(11<=r&&r<=17))return new P(M(`The type (%s) must be between 1 and 3 or between 11 and 17.`,r));switch(r){case 1:return{value:i+1};case 2:return{value:i===0?7:i};case 3:return{value:i===0?6:i-1}}let a=r-10,o=(i+1-a+7)%7;return{value:o===0?7:o}},isExported:!0},jQ={description:M(`Week number of the year.`),args:[V(`date (date)`,M(`The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),V(`type (number, default=1)`,M(`A number representing the day that a week starts on. Sunday = 1.`),[{value:1,label:M(`Sunday`)},{value:2,label:M(`Monday`)},{value:11,label:M(`Monday`)},{value:12,label:M(`Tuesday`)},{value:13,label:M(`Wednesday`)},{value:14,label:M(`Thursday`)},{value:15,label:M(`Friday`)},{value:16,label:M(`Saturday`)},{value:17,label:M(`Sunday`)},{value:21,label:M(`ISO week number (Monday as first day of the week)`)}])],compute:function(e,t={value:1}){let n=rs(e,this.locale),r=Math.round(F(t,this.locale));if(![1,2,11,12,13,14,15,16,17,21].includes(r))return new P(M(`The type (%s) is out of range.`,r.toString()));if(r===21)return vQ.compute.bind(this)(e);let i;i=r===1||r===2?r-1:r-10==7?0:r-10;let a=n.getFullYear(),o=1,s=new Da(a,0,o);for(;s.getDay()!==i;)o+=1,s=new Da(a,0,o);let c=(n.getTime()-s.getTime())/ka;return c<0?{value:1}:{value:Math.floor(c/7)+(o===1?1:2)}},isExported:!0},MQ={description:M(`Date after a number of workdays.`),args:[V(`start_date (date)`,M(`The date from which to begin counting.`)),V(`num_days (number)`,M(`The number of working days to advance from start_date. If negative, counts backwards.`)),V(`holidays (date, range<date>, optional)`,M(`A range or array constant containing the dates to consider holidays.`))],compute:function(e,t,n={value:null}){return NQ.compute.bind(this)(e,t,{value:1},n)},isExported:!0},NQ={description:M(`Date after a number of workdays (specifying weekends).`),args:[V(`start_date (date)`,M(`The date from which to begin counting.`)),V(`num_days (number)`,M(`The number of working days to advance from start_date. If negative, counts backwards.`)),V(`weekend (any, default=1)`,M(`A number or string representing which days of the week are considered weekends.`),CQ),V(`holidays (date, range<date>, optional)`,M(`A range or array constant containing the dates to consider holidays.`))],compute:function(e,t,n={value:1},r){let i=rs(e,this.locale),a=Math.trunc(F(t,this.locale));if(n.value===`1111111`)return new P(M(`The weekend must be different from '1111111'.`));let o=SQ(n),s=new Set;r!==void 0&&os([r],e=>{let t=rs(e,this.locale);s.add(t.getTime())});let c=Da.fromTimestamp(i.getTime()),l=c.getTime(),u=Math.sign(a),d=Math.abs(a);for(;d>0;)c.setDate(c.getDate()+u),l=c.getTime(),!o.includes(c.getDay())&&!s.has(l)&&--d;let f=l-Oa.getTime();return{value:Math.round(f/ka),format:this.locale.dateFormat}},isExported:!0},PQ={description:M(`Year specified by a given date.`),args:[V(`date (date)`,M(`The date from which to extract the year.`))],compute:function(e){return{value:rs(e,this.locale).getFullYear()}},isExported:!0},FQ={description:M(`Exact number of years between two dates.`),args:[V(`start_date (date)`,M(`The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),V(`end_date (date)`,M(`The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),V(`day_count_convention (number, default=0)`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n={value:0}){let r=Math.trunc(F(e,this.locale)),i=Math.trunc(F(t,this.locale)),a=Math.trunc(F(n,this.locale));return r<0?new P(M(`The start_date (%s) must be positive or null.`,r)):i<0?new P(M(`The end_date (%s) must be positive or null.`,i)):0>a||a>4?new P(M(`The day_count_convention (%s) must be between 0 and 4 inclusive.`,a)):{value:oo(r,i,a)}}},IQ={description:M(`First day of the month a date falls in.`),args:[V(`date (date)`,M(`The date from which to calculate the result.`))],compute:function(e){let t=rs(e,this.locale);return{value:eo(new Da(t.getFullYear(),t.getMonth(),1)),format:this.locale.dateFormat}}},LQ={description:M(`Last day of the month a date falls in.`),args:[V(`date (date)`,M(`The date from which to calculate the result.`))],compute:function(e){return gQ.compute.bind(this)(e,{value:0})}},RQ={description:M(`Quarter of the year a specific date falls in`),args:[V(`date (date)`,M(`The date from which to extract the quarter.`))],compute:function(e){return{value:Math.ceil((rs(e,this.locale).getMonth()+1)/3)}}},zQ={description:M(`First day of the quarter of the year a specific date falls in.`),args:[V(`date (date)`,M(`The date from which to calculate the start of quarter.`))],compute:function(e){let t=RQ.compute.bind(this)(e).value,n=PQ.compute.bind(this)(e).value;return{value:eo(new Da(n,(t-1)*3,1)),format:this.locale.dateFormat}}},BQ={description:M(`Last day of the quarter of the year a specific date falls in.`),args:[V(`date (date)`,M(`The date from which to calculate the end of quarter.`))],compute:function(e){let t=RQ.compute.bind(this)(e).value,n=PQ.compute.bind(this)(e).value;return{value:eo(new Da(n,t*3,0)),format:this.locale.dateFormat}}},VQ={description:M(`First day of the year a specific date falls in.`),args:[V(`date (date)`,M(`The date from which to calculate the start of the year.`))],compute:function(e){let t=PQ.compute.bind(this)(e).value;return{value:eo(new Da(t,0,1)),format:this.locale.dateFormat}}},HQ={description:M(`Last day of the year a specific date falls in.`),args:[V(`date (date)`,M(`The date from which to calculate the end of the year.`))],compute:function(e){let t=PQ.compute.bind(this)(e).value;return{value:eo(new Da(t+1,0,0)),format:this.locale.dateFormat}}};var UQ=l({DELTA:()=>WQ});let WQ={description:M(`Compare two numeric values, returning 1 if they're equal.`),args:[V(`number1 (number)`,M(`The first number to compare.`)),V(`number2 (number, default=0)`,M(`The second number to compare.`))],compute:function(e,t={value:0}){return{value:+(F(e,this.locale)===F(t,this.locale))}},isExported:!0};var GQ=l({FILTER:()=>qQ,SORT:()=>JQ,SORTN:()=>YQ,UNIQUE:()=>XQ});function KQ(e,t,...n){for(let e=0;e<n.length;e++){let t=e%2==0?`sort_column`:`is_ascending`;W(n[e]!==void 0,M(`Value for parameter %s is missing in [[FUNCTION_NAME]].`,t))}let r=[],i=[],a=e.length;for(let o=0;o<n.length;o+=2){r.push(L(jv(n[o+1])?.value)?`asc`:`desc`);let s=n[o];if(yt(s)&&(s.length>1||s[0].length>1))W(s.length===1&&s[0].length===a,M(`Wrong size for %s. Expected a range of size 1x%s. Got %sx%s.`,`sort_column${o+1}`,a,s.length,s[0].length)),i.push(s.flat().map(e=>e.value));else{let n=F(jv(s)?.value,t);if(n<1||n>e[0].length)return e;i.push(e.map(e=>e[n-1].value))}}if(i.length===0)for(let t=0;t<e[0].length;t++)i.push(e.map(e=>e[t].value)),r.push(`asc`);let o={desc:bH(`desc`),asc:bH(`asc`)},s=S(0,e.length);return s.sort((e,t)=>{for(let[n,a]of i.entries()){let i=a[e],s=a[t],c={value:i,type:i===null?`empty`:typeof i==`string`?`text`:typeof i},l={value:s,type:s===null?`empty`:typeof s==`string`?`text`:typeof s},u=o[r[n]](c,l);if(u!==0)return u}return 0}),s.map(t=>e[t])}let qQ={description:M(`Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions.`),args:[V(`range (any, range<any>)`,M(`The data to be filtered.`)),V(`condition (boolean, range<boolean>, repeating)`,M(`Column or row containing true or false values corresponding to the range.`))],computeArray:function(e,...t){let n=R(e),r=t.map(e=>ps(R(e),e=>e.value));for(let e of r)if(!Cv(e))return new P(M(`The arguments condition must be a single column or row.`));if(!wv(...t))return new P(M(`The arguments conditions must have the same dimensions.`));let i=r.map(e=>e.flat()),a=r[0].length===1?`row`:`col`;if(n=a===`row`?hs(n):n,i.some(e=>e.length!==n.length))return new P(M(`FILTER has mismatched sizes on the range and conditions.`));let o=[];for(let e=0;e<n.length;e++){let t=n[e];i.every(t=>(typeof t[e]==`boolean`||typeof t[e]==`number`)&&t[e])&&o.push(t)}return o.length?a===`row`?hs(o):o:new Io(M(`No match found in FILTER evaluation`))},isExported:!1},JQ={description:M(`Sorts the rows of a given array or range by the values in one or more columns.`),args:[V(`range (range)`,M(`The data to be sorted.`)),V(`sort_column (any, range<number>, repeating, optional)`,M(`The index of the column in range or a range outside of range containing the value by which to sort.`)),V(`is_ascending (boolean, repeating, optional)`,M(`TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.`),[{value:!0,label:M(`Ascending`)},{value:!1,label:M(`Descending`)}])],computeArray:function(e,...t){return hs(KQ(hs(e),this.locale,...t))},isExported:!0},YQ={description:M(`Returns the first n items in a data set after performing a sort.`),args:[V(`range (range)`,M(`The data to be sorted.`)),V(`n (number)`,M(`The number of items to return.`)),V(`display_ties_mode (number, default=0)`,M(`A number representing the way to display ties.`)),V(`sort_column (number, range<number>, repeating, optional)`,M(`The index of the column in range or a range outside of range containing the value by which to sort.`)),V(`is_ascending (boolean, repeating, optional)`,M(`TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.`),[{value:!0,label:M(`Ascending`)},{value:!1,label:M(`Descending`)}])],compute:function(e,t,...n){let r=F(t?.value??1,this.locale),i=n.length%2==0?0:F(n[0]?.value,this.locale),a=n.length%2==0?n:n.slice(1);if(r<0)return new P(M(`Wrong value of 'n'. Expected a positive number. Got %s.`,r));if(i<0||i>3)return new P(M(`Wrong value of 'display_ties_mode'. Expected a positive number between 0 and 3. Got %s.`,i));let o=KQ(hs(e),this.locale,...a),s=(e,t)=>JSON.stringify(o[e].map(e=>e.value))===JSON.stringify(o[t].map(e=>e.value));switch(i){case 0:return hs(o.slice(0,r));case 1:for(let e=r;e<o.length;e++)if(!s(e,r-1))return hs(o.slice(0,e));return hs(o);case 2:{let e=[o[0]];for(let t=1;t<o.length;t++)for(let n=0;n<t&&!s(t,n);n++)n===t-1&&e.push(o[t]);return hs(e.slice(0,r))}case 3:{let e=[o[0]],t=1;for(let n=1;n<o.length&&(s(n,n-1)||t++,!(t>r));n++)e.push(o[n]);return hs(e)}}},isExported:!1},XQ={description:M(`Unique rows in the provided source range.`),args:[V(`range (any, range<any>)`,M(`The data to filter by unique entries.`)),V(`by_column (boolean, default=FALSE)`,M(`Whether to filter the data by columns or by rows.`),[{value:!0,label:M(`Return unique columns`)},{value:!1,label:M(`Return unique rows`)}]),V(`exactly_once (boolean, default=FALSE)`,M(`Whether to return only entries with no duplicates.`),[{value:!0,label:M(`Return items that appear exactly once`)},{value:!1,label:M(`Return every distinct item`)}])],computeArray:function(e={value:``},t,n){if(!yt(e))return[[e]];let r=L(t?.value)||!1,i=L(n?.value)||!1;r||(e=hs(e));let a=new Map;for(let t of e){let e=JSON.stringify(t.map(e=>e.value)),n=a.get(e);n?n.count++:a.set(e,{data:t,count:1})}let o=[];for(let e of a.values())i&&e.count>1||o.push(e.data);return o.length?r?o:hs(o):new P(M(`No unique values found`))},isExported:!0};var ZQ=l({ACCRINTM:()=>n$,AMORLINC:()=>r$,COUPDAYBS:()=>a$,COUPDAYS:()=>i$,COUPDAYSNC:()=>o$,COUPNCD:()=>s$,COUPNUM:()=>c$,COUPPCD:()=>l$,CUMIPMT:()=>u$,CUMPRINC:()=>d$,DB:()=>f$,DDB:()=>m$,DISC:()=>h$,DOLLARDE:()=>g$,DOLLARFR:()=>_$,DURATION:()=>v$,EFFECT:()=>y$,FV:()=>x$,FVSCHEDULE:()=>S$,INTRATE:()=>C$,IPMT:()=>T$,IRR:()=>D$,ISPMT:()=>O$,MDURATION:()=>k$,MIRR:()=>A$,NOMINAL:()=>j$,NPER:()=>M$,NPV:()=>P$,PDURATION:()=>F$,PMT:()=>L$,PPMT:()=>z$,PRICE:()=>V$,PRICEDISC:()=>H$,PRICEMAT:()=>U$,PV:()=>B$,RATE:()=>G$,RECEIVED:()=>K$,RRI:()=>q$,SLN:()=>J$,SYD:()=>Y$,TBILLEQ:()=>Q$,TBILLPRICE:()=>Z$,TBILLYIELD:()=>$$,VDB:()=>e1,XIRR:()=>t1,XNPV:()=>n1,YIELD:()=>r1,YIELDDISC:()=>i1,YIELDMAT:()=>a1});let QQ=[{value:1,label:M(`Annual`)},{value:2,label:M(`Semi-annual`)},{value:4,label:M(`Quarterly`)}],$Q=[{value:0,label:M(`End of period (default)`)},{value:1,label:M(`Beginning of period`)}],e$=[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`frequency (number)`,M(`The number of interest or coupon payments per year (1, 2, or 4).`),QQ),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)];function t$(e,t,n,r,i=1e-10,a){let o=n,s,c,l,u=!1,d=0,f;do{if(l=e(o),isNaN(l)){W(d<r&&a!==void 0,M(`Function [[FUNCTION_NAME]] didn't find any result.`)),d++,o=a(f),f=o;continue}s=o-l/t(o),c=Math.abs(s-o),o=s,u=c<i||Math.abs(l)<i,W(d<r,M(`Function [[FUNCTION_NAME]] didn't find any result.`)),d++}while(!u);return o}let n$={description:M(`Accrued interest of security paying at maturity.`),args:[V(`issue (date)`,M(`The date the security was initially issued.`)),V(`maturity (date)`,M(`The maturity date of the security.`)),V(`rate (number)`,M(`The annualized rate of interest.`)),V(`redemption (number)`,M(`The redemption amount per 100 face value, or par.`)),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i={value:0}){let a=Math.trunc(F(e,this.locale)),o=Math.trunc(F(t,this.locale)),s=F(r,this.locale),c=F(n,this.locale),l=Math.trunc(F(i,this.locale));if(a<0)return new P(wZ(a));if(a>=o)return new P(OZ(a,o));if(rQ(l))return new P(dZ(l));if(s<=0)return new P(KZ(s));if(c<=0)return new P(GZ(c));let u=oo(a,o,l);return{value:s*c*u}},isExported:!0},r$={description:M(`Depreciation for an accounting period.`),args:[V(`cost (number)`,M(`The initial cost of the asset.`)),V(`purchase_date (date)`,M(`The date the asset was purchased.`)),V(`first_period_end (date)`,M(`The date the first period ended.`)),V(`salvage (number)`,M(`The value of the asset at the end of depreciation.`)),V(`period (number)`,M(`The single period within life for which to calculate depreciation.`)),V(`rate (number)`,M(`The deprecation rate.`)),V(`day_count_convention (number, optional)`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=F(e,this.locale),c=Math.trunc(F(t,this.locale)),l=Math.trunc(F(n,this.locale)),u=F(r,this.locale),d=F(i,this.locale),f=F(a,this.locale),p=Math.trunc(F(o,this.locale));if(s<=0)return new P(lZ(s));if(c<0)return new P(HZ(c));if(u<0)return new P(qZ(u));if(u>s)return new P(JZ(u,s));if(d<0)return new P(FZ(d));if(f<=0)return new P(GZ(f));if(rQ(p))return new P(dZ(p));if(c>l)return new P(VZ(c,l));let m=d<1&&d>0?1:Math.trunc(d),h=s*f,g=oo(c,l,p),_=c===l?h:h*g,v=s-_-h*m;return v>=u?{value:m===0?_:h}:{value:u-v<h?h-(u-v):0}},isExported:!0},i$={description:M(`Days in coupon period containing settlement date.`),args:e$,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(F(e,this.locale)),a=Math.trunc(F(t,this.locale)),o=Math.trunc(F(n,this.locale)),s=Math.trunc(F(r,this.locale));if(i>=a)return new P(OZ(i,a));if(iQ(o))return new P(uZ(o));if(rQ(s))return new P(dZ(s));if(s===1){let i=l$.compute.bind(this)(e,t,n,r).value,a=s$.compute.bind(this)(e,t,n,r).value;return{value:F(a,this.locale)-F(i,this.locale)}}return{value:(s===3?365:360)/o}},isExported:!0},a$={description:M(`Days from settlement until next coupon.`),args:e$,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(F(e,this.locale)),a=Math.trunc(F(t,this.locale)),o=Math.trunc(F(n,this.locale)),s=Math.trunc(F(r,this.locale));if(i>=a)return new P(OZ(i,a));if(iQ(o))return new P(uZ(o));if(rQ(s))return new P(dZ(s));let c=l$.compute.bind(this)(e,t,n,r).value,l=F(c,this.locale);if([1,2,3].includes(s))return{value:i-l};if(s===4){let e=oo(l,i,s);return{value:Math.round(e*360)}}let u=rs(i,this.locale),d=rs(l,this.locale),f=d.getFullYear(),p=u.getFullYear(),m=d.getMonth()+1,h=u.getMonth()+1,g=d.getDate(),_=u.getDate();return m===2&&h===2&&ro(d)&&ro(u)&&(_=30),_===31&&(g===30||g===31)&&(_=30),m===2&&ro(d)&&(g=30),g===31&&(g=30),{value:(p-f)*360+(h-m)*30+(_-g)}},isExported:!0},o$={description:M(`Days from settlement until next coupon.`),args:e$,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(F(e,this.locale)),a=Math.trunc(F(t,this.locale)),o=Math.trunc(F(n,this.locale)),s=Math.trunc(F(r,this.locale));if(i>=a)return new P(OZ(i,a));if(iQ(o))return new P(uZ(o));if(rQ(s))return new P(dZ(s));let c=s$.compute.bind(this)(e,t,n,r).value,l=F(c,this.locale);if([1,2,3].includes(s))return{value:l-i};if(s===4){let e=oo(i,l,s);return{value:Math.round(e*360)}}let u=a$.compute.bind(this)(e,t,n,r);return{value:F(i$.compute.bind(this)(e,t,n,r),this.locale)-F(u,this.locale)}},isExported:!0},s$={description:M(`Next coupon date after the settlement date.`),args:e$,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(F(e,this.locale)),a=Math.trunc(F(t,this.locale)),o=Math.trunc(F(n,this.locale)),s=Math.trunc(F(r,this.locale));if(i>=a)return new P(OZ(i,a));if(iQ(o))return new P(uZ(o));if(rQ(s))return new P(dZ(s));let c=12/o,l=c$.compute.bind(this)(e,t,n,r);return{value:eo(io(rs(a,this.locale),-(F(l,this.locale)-1)*c,!0)),format:this.locale.dateFormat}},isExported:!0},c$={description:M(`Number of coupons between settlement and maturity.`),args:e$,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(F(e,this.locale)),a=Math.trunc(F(t,this.locale)),o=Math.trunc(F(n,this.locale)),s=Math.trunc(F(r,this.locale));if(i>=a)return new P(OZ(i,a));if(iQ(o))return new P(uZ(o));if(rQ(s))return new P(dZ(s));let c=1,l=a,u=12/o;for(;l>i;)l=eo(io(rs(l,this.locale),-u,!1)),c++;return{value:c-1}},isExported:!0},l$={description:M(`Last coupon date prior to or on the settlement date.`),args:e$,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(F(e,this.locale)),a=Math.trunc(F(t,this.locale)),o=Math.trunc(F(n,this.locale)),s=Math.trunc(F(r,this.locale));if(i>=a)return new P(OZ(i,a));if(iQ(o))return new P(uZ(o));if(rQ(s))return new P(dZ(s));let c=12/o,l=c$.compute.bind(this)(e,t,n,r).value;return{value:eo(io(rs(a,this.locale),-l*c,!0)),format:this.locale.dateFormat}},isExported:!0},u$={description:M(`Cumulative interest paid over a set of periods.`),args:[V(`rate (number)`,M(`The interest rate.`)),V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`present_value (number)`,M(`The current value of the annuity.`)),V(`first_period (number)`,M(`The number of the payment period to begin the cumulative calculation.`)),V(`last_period (number)`,M(`The number of the payment period to end the cumulative calculation.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q)],compute:function(e,t,n,r,i,a={value:0}){let o=F(r,this.locale),s=F(i,this.locale),c=F(e,this.locale),l=F(n,this.locale),u=F(t,this.locale),d=+!!L(a);if(u<=0)return new P(MZ(u));if(o<=0)return new P(xZ(o));if(s<=0)return new P(EZ(s));if(o>s)return new P(bZ(o,s));if(s>u)return new P(TZ(s,u));if(c<=0)return new P(GZ(c));if(l<=0)return new P(zZ(l));let f=0;for(let e=o;e<=s;e++)f+=w$(c,e,u,l,0,d);return{value:f}},isExported:!0},d$={description:M(`Cumulative principal paid over a set of periods.`),args:[V(`rate (number)`,M(`The interest rate.`)),V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`present_value (number)`,M(`The current value of the annuity.`)),V(`first_period (number)`,M(`The number of the payment period to begin the cumulative calculation.`)),V(`last_period (number)`,M(`The number of the payment period to end the cumulative calculation.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q)],compute:function(e,t,n,r,i,a={value:0}){let o=F(r,this.locale),s=F(i,this.locale),c=F(e,this.locale),l=F(n,this.locale),u=F(t,this.locale),d=+!!L(a);if(u<=0)return new P(MZ(u));if(o<=0)return new P(xZ(o));if(s<=0)return new P(EZ(s));if(o>s)return new P(bZ(o,s));if(s>u)return new P(TZ(s,u));if(c<=0)return new P(GZ(c));if(l<=0)return new P(zZ(l));let f=0;for(let e=o;e<=s;e++)f+=R$(c,e,u,l,0,d);return{value:f}},isExported:!0},f$={description:M(`Depreciation via declining balance method.`),args:[V(`cost (number)`,M(`The initial cost of the asset.`)),V(`salvage (number)`,M(`The value of the asset at the end of depreciation.`)),V(`life (number)`,M(`The number of periods over which the asset is depreciated.`)),V(`period (number)`,M(`The single period within life for which to calculate depreciation.`)),V(`month (number, optional)`,M(`The number of months in the first year of depreciation.`))],compute:function(e,t,n,r,...i){let a=F(e,this.locale),o=F(t,this.locale),s=F(n,this.locale),c=Math.trunc(F(r,this.locale)),l=i.length?Math.trunc(F(i[0],this.locale)):12,u=s+(l===12?0:1);if(a<0)return new P(cZ(a));if(o<0)return new P(qZ(o));if(c<=0)return new P(RZ(c));if(s<=0)return new P(DZ(s));if(1>l||l>12)return new P(kZ(l));if(c>u)return new P(PZ(c,u));let d=l/12,f=1-(o/a)**(1/s);f=Math.round(f*1e3)/1e3;let p=a,m=a*(1-f*d);for(let e=1;e<c;e++)p=m,m=p*(1-f),e===s&&(m=p*(1-f*(1-d)));return{value:p-m,format:`#,##0.00`}},isExported:!0},p$=`#,##0.00`,m$={description:M(`Depreciation via double-declining balance method.`),args:[V(`cost (number)`,M(`The initial cost of the asset.`)),V(`salvage (number)`,M(`The value of the asset at the end of depreciation.`)),V(`life (number)`,M(`The number of periods over which the asset is depreciated.`)),V(`period (number)`,M(`The single period within life for which to calculate depreciation.`)),V(`factor (number, default=2)`,M(`The factor by which depreciation decreases.`))],compute:function(e,t,n,r,i={value:2}){let a=F(e,this.locale),o=F(t,this.locale),s=F(n,this.locale),c=F(r,this.locale),l=F(i,this.locale);if(a<0)return new P(cZ(a));if(o<0)return new P(qZ(o));if(c<=0)return new P(RZ(c));if(s<=0)return new P(DZ(s));if(c>s)return new P(LZ(c,s));if(l<=0)return new P(fZ(l));if(a===0||o>=a)return{value:0,format:p$};let u=l/s;if(u>1)return{value:c===1?a-o:0,format:p$};if(c<=1)return{value:a*u,format:p$};let d=a*(1-u)**(c-1),f=a*(1-u)**c,p=f<o?d-o:d-f;return{value:Math.max(p,0),format:p$}},isExported:!0},h$={description:M(`Discount rate of a security based on price.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`price (number)`,M(`The price at which the security is bought per 100 face value.`)),V(`redemption (number)`,M(`The redemption amount per 100 face value, or par.`)),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(F(e,this.locale)),o=Math.trunc(F(t,this.locale)),s=F(n,this.locale),c=F(r,this.locale),l=Math.trunc(F(i,this.locale));if(a>=o)return new P(OZ(a,o));if(rQ(l))return new P(dZ(l));if(s<=0)return new P(BZ(s));if(c<=0)return new P(KZ(c));let u=oo(a,o,l);return{value:(c-s)/c/u}},isExported:!0},g$={description:M(`Convert a decimal fraction to decimal value.`),args:[V(`fractional_price (number)`,M(`The price quotation given using fractional decimal conventions.`)),V(`unit (number)`,M(`The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.`))],compute:function(e,t){let n=F(e,this.locale),r=Math.trunc(F(t,this.locale));if(r<=0)return new P(eQ(r));let i=Math.trunc(n);return{value:i+(n-i)*(10**Math.ceil(Math.log10(r))/r)}},isExported:!0},_$={description:M(`Convert a decimal value to decimal fraction.`),args:[V(`decimal_price (number)`,M(`The price quotation given as a decimal value.`)),V(`unit (number)`,M(`The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.`))],compute:function(e,t){let n=F(e,this.locale),r=Math.trunc(F(t,this.locale));if(r<=0)return new P(eQ(r));let i=Math.trunc(n);return{value:i+(n-i)*(r/10**Math.ceil(Math.log10(r)))}},isExported:!0},v$={description:M(`Number of periods for an investment to reach a value.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`rate (number)`,M(`The annualized rate of interest.`)),V(`yield (number)`,M(`The expected annual yield of the security.`)),V(`frequency (number)`,M(`The number of interest or coupon payments per year (1, 2, or 4).`),QQ),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i,a={value:0}){let o=Math.trunc(F(e,this.locale)),s=Math.trunc(F(t,this.locale)),c=F(n,this.locale),l=F(r,this.locale),u=Math.trunc(F(i,this.locale)),d=Math.trunc(F(a,this.locale));if(o>=s)return new P(OZ(o,s));if(iQ(u))return new P(uZ(u));if(rQ(d))return new P(dZ(d));if(c<0)return new P(WZ(c));if(l<0)return new P(tQ(l));let f=oo(o,s,d),p=f-Math.trunc(f)||1/u,m=Math.ceil(f*u),h=c/u,g=l/u,_=0,v=0;for(let e=1;e<=m;e++){let t=(h+ +(e===m))/(1+g)**e;v+=(p+(e-1)/u)*t,_+=t}return{value:_===0?0:v/_}},isExported:!0},y$={description:M(`Annual effective interest rate.`),args:[V(`nominal_rate (number)`,M(`The nominal interest rate per year.`)),V(`periods_per_year (number)`,M(`The number of compounding periods per year.`))],compute:function(e,t){let n=F(e,this.locale),r=Math.trunc(F(t,this.locale));return n<=0?new P(AZ(n)):r<=0?new P(IZ(r)):{value:(1+n/r)**+r-1}},isExported:!0};function b$(e,t,n,r,i){return e===0?-(r+n*t):-r*(1+e)**t-n*(1+e*i)*((1+e)**t-1)/e}let x$={description:M(`Future value of an annuity investment.`),args:[V(`rate (number)`,M(`The interest rate.`)),V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`payment_amount (number)`,M(`The amount per period to be paid.`)),V(`present_value (number, default=0)`,M(`The current value of the annuity.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q)],compute:function(e,t,n,r={value:0},i={value:0}){return r||=0,i||=0,{value:b$(F(e,this.locale),F(t,this.locale),F(n,this.locale),F(r,this.locale),+!!L(i)),format:`#,##0.00`}},isExported:!0},S$={description:M(`Future value of principal from series of rates.`),args:[V(`principal (number)`,M(`The amount of initial capital or value to compound against.`)),V(`rate_schedule (number, range<number>)`,M(`A series of interest rates to compound against the principal.`))],compute:function(e,t){let n=F(e,this.locale);return{value:ls([t],(e,t)=>e*(1+F(t,this.locale)),n)}},isExported:!0},C$={description:M(`Calculates effective interest rate.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`investment (number)`,M(`The amount invested in the security.`)),V(`redemption (number)`,M(`The amount to be received at maturity.`)),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i={value:0}){let a=Math.trunc(F(e,this.locale)),o=Math.trunc(F(t,this.locale)),s=F(r,this.locale),c=F(n,this.locale),l=Math.trunc(F(i,this.locale));if(a>=o)return new P(OZ(a,o));if(c<=0)return new P(CZ(c));if(s<=0)return new P(KZ(s));if(rQ(l))return new P(dZ(l));let u=oo(a,o,l);return{value:(s-c)/c/u}},isExported:!0};function w$(e,t,n,r,i,a){return I$(e,n,r,i,a)-R$(e,t,n,r,i,a)}let T$={description:M(`Payment on the principal of an investment.`),args:[V(`rate (number)`,M(`The annualized rate of interest.`)),V(`period (number)`,M(`The amortization period, in terms of number of periods.`)),V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`present_value (number)`,M(`The current value of the annuity.`)),V(`future_value (number, default=0)`,M(`The future value remaining after the final payment has been made.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q)],compute:function(e,t,n,r,i={value:0},a={value:0}){return{value:w$(F(e,this.locale),F(t,this.locale),F(n,this.locale),F(r,this.locale),F(i,this.locale),+!!L(a)),format:`#,##0.00`}},isExported:!0},E$=.1,D$={description:M(`Internal rate of return given periodic cashflows.`),args:[V(`cashflow_amounts (number, range<number>)`,M(`An array or range containing the income or payments associated with the investment.`)),V(`rate_guess (number, default=${E$})`,M(`An estimate for what the internal rate of return will be.`))],compute:function(e,t={value:E$}){let n=F(t,this.locale);if(n<=-1)return new P(UZ(n));let r=!1,i=!1,a=[];if(ss([e],({value:e})=>{e>0&&(r=!0),e<0&&(i=!0),a.push(e)},this.locale),!r||!i)return new P(sZ);let o=a.shift();function s(e,t,n){let r=n.length,i=0;return n.reduce((t,n)=>(i++,t+n*e**(r-i)),t*e**r)}function c(e,t,n){let r=n.length,i=0;return n.reduce((t,n)=>(i++,t+n*(r-i)*e**(r-i-1)),t*r*e**(r-1))}function l(e){return s(e,o,a)}function u(e){return c(e,o,a)}return{value:t$(l,u,n+1,20,1e-5)-1,format:`0%`}},isExported:!0},O$={description:M(`Returns the interest paid at a particular period of an investment.`),args:[V(`rate (number)`,M(`The interest rate.`)),V(`period (number)`,M(`The period for which you want to view the interest payment.`)),V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`present_value (number)`,M(`The current value of the annuity.`))],compute:function(e,t,n,r){let i=F(e,this.locale),a=F(t,this.locale),o=F(n,this.locale),s=F(r,this.locale);return o===0?new P(jZ(o)):{value:-1*(s-a/o*s)*i}},isExported:!0},k$={description:M(`Modified Macaulay duration.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`rate (number)`,M(`The annualized rate of interest.`)),V(`yield (number)`,M(`The expected annual yield of the security.`)),V(`frequency (number)`,M(`The number of interest or coupon payments per year (1, 2, or 4).`),QQ),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`))],compute:function(e,t,n,r,i,a={value:0}){let o=v$.compute.bind(this)(e,t,n,r,i,a),s=F(r,this.locale),c=Math.trunc(F(i,this.locale));return{value:F(o,this.locale)/(1+s/c)}},isExported:!0},A$={description:M(`Modified internal rate of return.`),args:[V(`cashflow_amounts (range<number>)`,M(`A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.`)),V(`financing_rate (number)`,M(`The interest rate paid on funds invested.`)),V(`reinvestment_return_rate (number)`,M(`The return (as a percentage) earned on reinvestment of income received from the investment.`))],compute:function(e,t,n){let r=F(t,this.locale),i=F(n,this.locale),a=hs(e).flat().filter(e=>e.value!==null).map(e=>F(e,this.locale)),o=a.length,s=0,c=0;for(let e of S(0,o)){let t=a[e];t>=0?s+=t*(i+1)**(o-e-1):c+=t/(r+1)**e}if(c===0||s===0)return new P(sZ);let l=1/(o-1);return{value:(-s/c)**l-1}},isExported:!0},j$={description:M(`Annual nominal interest rate.`),args:[V(`effective_rate (number)`,M(`The effective interest rate per year.`)),V(`periods_per_year (number)`,M(`The number of compounding periods per year.`))],compute:function(e,t){let n=F(e,this.locale),r=Math.trunc(F(t,this.locale));return n<=0?new P(gZ(n)):r<=0?new P(IZ(r)):{value:((n+1)**(1/r)-1)*r}},isExported:!0},M$={description:M(`Number of payment periods for an investment.`),args:[V(`rate (number)`,M(`The interest rate.`)),V(`payment_amount (number)`,M(`The amount of each payment made.`)),V(`present_value (number)`,M(`The current value of the annuity.`)),V(`future_value (number, default=0)`,M(`The future value remaining after the final payment has been made.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q)],compute:function(e,t,n,r={value:0},i={value:0}){r||=0,i||=0;let a=F(e,this.locale),o=F(t,this.locale),s=F(n,this.locale),c=F(r,this.locale),l=+!!L(i);if(a===0)return{value:-(c+s)/o};let u=o*(1+a*l)/a;return{value:Math.log((u-c)/(s+u))/Math.log(1+a)}},isExported:!0};function N$(e,t,n,r){let i=0;return us(n,(t,n)=>(i++,t+n/(1+e)**i),t,r)}let P$={description:M(`The net present value of an investment based on a series of periodic cash flows and a discount rate.`),args:[V(`discount (number)`,M(`The discount rate of the investment over one period.`)),V(`cashflow (number, range<number>, repeating)`,M(`The future cash flows.`))],compute:function(e,...t){let n=F(e,this.locale);return n===-1?new P(pZ(n)):{value:N$(n,0,t,this.locale),format:`#,##0.00`}},isExported:!0},F$={description:M(`Computes the number of periods needed for an investment to reach a value.`),args:[V(`rate (number)`,M(`The rate at which the investment grows each period.`)),V(`present_value (number)`,M(`The investment's current value.`)),V(`future_value (number)`,M(`The investment's desired future value.`))],compute:function(e,t,n){let r=F(e,this.locale),i=F(t,this.locale),a=F(n,this.locale);return r<=0?new P(GZ(r)):i<=0?new P(zZ(i)):a<=0?new P(SZ(a)):{value:(Math.log(a)-Math.log(i))/Math.log(1+r)}},isExported:!0};function I$(e,t,n,r,i){if(t<=0)throw new P(MZ(t));if(e===0)return-(r+n)/t;let a=-(n*(1+e)**t+r);return a=a*e/((1+e*i)*((1+e)**t-1)),a}let L$={description:M(`Periodic payment for an annuity investment.`),args:[V(`rate (number)`,M(`The annualized rate of interest.`)),V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`present_value (number)`,M(`The current value of the annuity.`)),V(`future_value (number, default=0)`,M(`The future value remaining after the final payment has been made.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q)],compute:function(e,t,n,r={value:0},i={value:0}){let a=F(t,this.locale),o=F(e,this.locale),s=+!!L(i),c=F(r,this.locale);return{value:I$(o,a,F(n,this.locale),c,s),format:`#,##0.00`}},isExported:!0};function R$(e,t,n,r,i,a){if(n<=0)throw new P(MZ(n));if(t<=0||t>n)throw new P(NZ(n));let o=I$(e,n,r,i,a);return a===1&&t===1?o:o+-b$(e,a===0?t-1:t-2,o,r+o*a,0)*e}let z$={description:M(`Payment on the principal of an investment.`),args:[V(`rate (number)`,M(`The annualized rate of interest.`)),V(`period (number)`,M(`The amortization period, in terms of number of periods.`)),V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`present_value (number)`,M(`The current value of the annuity.`)),V(`future_value (number, default=0)`,M(`The future value remaining after the final payment has been made.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q)],compute:function(e,t,n,r,i={value:0},a={value:0}){let o=F(n,this.locale),s=F(e,this.locale),c=F(t,this.locale),l=+!!L(a),u=F(i,this.locale);return{value:R$(s,c,o,F(r,this.locale),u,l),format:`#,##0.00`}},isExported:!0},B$={description:M(`Present value of an annuity investment.`),args:[V(`rate (number)`,M(`The interest rate.`)),V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`payment_amount (number)`,M(`The amount per period to be paid.`)),V(`future_value (number, default=0)`,M(`The future value remaining after the final payment has been made.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q)],compute:function(e,t,n,r={value:0},i={value:0}){r||=0,i||=0;let a=F(e,this.locale),o=F(t,this.locale),s=F(n,this.locale),c=F(r,this.locale),l=+!!L(i);return{value:a?-(s*(1+a*l)*((1+a)**o-1)/a+c)/(1+a)**o:-(c+s*o),format:`#,##0.00`}},isExported:!0},V$={description:M(`Price of a security paying periodic interest.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`rate (number)`,M(`The annualized rate of interest.`)),V(`yield (number)`,M(`The expected annual yield of the security.`)),V(`redemption (number)`,M(`The redemption amount per 100 face value, or par.`)),V(`frequency (number)`,M(`The number of interest or coupon payments per year (1, 2, or 4).`),QQ),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=Math.trunc(F(e,this.locale)),c=Math.trunc(F(t,this.locale)),l=F(n,this.locale),u=F(r,this.locale),d=F(i,this.locale),f=Math.trunc(F(a,this.locale)),p=Math.trunc(F(o,this.locale));if(s>=c)return new P(OZ(s,c));if(iQ(f))return new P(uZ(f));if(rQ(p))return new P(dZ(p));if(l<0)return new P(WZ(l));if(u<0)return new P(tQ(u));if(d<=0)return new P(KZ(d));let m=oo(s,c,p)*f,h=Math.ceil(m),g=m-Math.floor(m)||1,_=1+u/f,v=100*l/f;if(h===1)return{value:(v+d)/(g*u/f+1)-v*(1-g)};let ee=0;for(let e=1;e<=h;e++)ee+=v/_**(e-1+g);return{value:d/_**(h-1+g)+ee-v*(1-g)}},isExported:!0},H$={description:M(`Price of a discount security.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`discount (number)`,M(`The discount rate of the security at time of purchase.`)),V(`redemption (number)`,M(`The redemption amount per 100 face value, or par.`)),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(F(e,this.locale)),o=Math.trunc(F(t,this.locale)),s=F(n,this.locale),c=F(r,this.locale),l=Math.trunc(F(i,this.locale));if(a>=o)return new P(OZ(a,o));if(rQ(l))return new P(dZ(l));if(s<=0)return new P(mZ(s));if(c<=0)return new P(KZ(c));let u=oo(a,o,l);return{value:c-s*c*u}},isExported:!0},U$={description:M(`Calculates the price of a security paying interest at maturity, based on expected yield.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`issue (date)`,M(`The date the security was initially issued.`)),V(`rate (number)`,M(`The annualized rate of interest.`)),V(`yield (number)`,M(`The expected annual yield of the security.`)),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i,a={value:0}){a||=0;let o=Math.trunc(F(e,this.locale)),s=Math.trunc(F(t,this.locale)),c=Math.trunc(F(n,this.locale)),l=F(r,this.locale),u=F(i,this.locale),d=Math.trunc(F(a,this.locale));if(o<=c)return new P(ZZ(o,c));if(o>=s)return new P(OZ(o,s));if(rQ(d))return new P(dZ(d));if(l<0)return new P(WZ(l));if(u<0)return new P(tQ(u));let f=oo(o,s,d),p=oo(o,c,d),m=100+oo(c,s,d)*l*100,h=1+f*u,g=p*l*100;return{value:m/h-g}},isExported:!0},W$=.1,G$={description:M(`Interest rate of an annuity investment.`),args:[V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`payment_per_period (number)`,M(`The amount per period to be paid.`)),V(`present_value (number)`,M(`The current value of the annuity.`)),V(`future_value (number, default=0)`,M(`The future value remaining after the final payment has been made.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q),V(`rate_guess (number, default=${W$})`,M(`An estimate for what the interest rate will be.`))],compute:function(e,t,n,r={value:0},i={value:0},a={value:W$}){let o=F(e,this.locale),s=F(t,this.locale),c=+!!L(i),l=F(a,this.locale)||W$,u=F(r,this.locale),d=F(n,this.locale);return o<=0?new P(MZ(o)):nQ([s,d,u])?l<=-1?new P(UZ(l)):(u-=s*c,d+=s*c,{value:t$(e=>{let t=(1+e)**+o,n=(t-1)/e;return u+d*t+s*n},e=>{let t=(1+e)**(o-1),n=((1+e)**+o-1)/e,r=o*t/e-n/e;return d*o*t+s*r},l,40,1e-5),format:`0%`}):new P(M(`There must be both positive and negative values in [payment_amount, present_value, future_value].`))},isExported:!0},K$={description:M(`Amount received at maturity for a security.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`investment (number)`,M(`The amount invested (irrespective of face value of each security).`)),V(`discount (number)`,M(`The discount rate of the security invested in.`)),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(F(e,this.locale)),o=Math.trunc(F(t,this.locale)),s=F(n,this.locale),c=F(r,this.locale),l=Math.trunc(F(i,this.locale));return a>=o?new P(OZ(a,o)):rQ(l)?new P(dZ(l)):s<=0?new P(CZ(s)):c<=0?new P(mZ(c)):{value:s/(1-c*oo(a,o,l))}},isExported:!0},q$={description:M(`Computes the rate needed for an investment to reach a specific value within a specific number of periods.`),args:[V(`number_of_periods (number)`,M(`The number of periods.`)),V(`present_value (number)`,M(`The present value of the investment.`)),V(`future_value (number)`,M(`The future value of the investment.`))],compute:function(e,t,n){let r=F(e,this.locale),i=F(t,this.locale),a=F(n,this.locale);return r<=0?new P(MZ(r)):{value:(a/i)**(1/r)-1}},isExported:!0},J$={description:M(`Depreciation of an asset using the straight-line method.`),args:[V(`cost (number)`,M(`The initial cost of the asset.`)),V(`salvage (number)`,M(`The value of the asset at the end of depreciation.`)),V(`life (number)`,M(`The number of periods over which the asset is depreciated.`))],compute:function(e,t,n){let r=F(e,this.locale),i=F(t,this.locale),a=F(n,this.locale);return{value:(r-i)/a,format:`#,##0.00`}},isExported:!0},Y$={description:M(`Depreciation via sum of years digit method.`),args:[V(`cost (number)`,M(`The initial cost of the asset.`)),V(`salvage (number)`,M(`The value of the asset at the end of depreciation.`)),V(`life (number)`,M(`The number of periods over which the asset is depreciated.`)),V(`period (number)`,M(`The single period within life for which to calculate depreciation.`))],compute:function(e,t,n,r){let i=F(e,this.locale),a=F(t,this.locale),o=F(n,this.locale),s=F(r,this.locale);if(s<=0)return new P(RZ(s));if(o<=0)return new P(DZ(o));if(s>o)return new P(LZ(s,o));let c=o*(o+1)/2,l=o-s+1;return{value:(i-a)*(l/c),format:`#,##0.00`}},isExported:!0};function X$(e,t,n){return 100*(1-n*oo(e,t,2))}let Z$={description:M(`Price of a US Treasury bill.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`discount (number)`,M(`The discount rate of the bill at time of purchase.`))],compute:function(e,t,n){let r=Math.trunc(F(e,this.locale)),i=Math.trunc(F(t,this.locale)),a=F(n,this.locale);return r>=i?new P(OZ(r,i)):aQ(r,i,this.locale)?a<=0?new P(mZ(a)):a>=1?new P(hZ(a)):{value:X$(r,i,a)}:new P(XZ(r,i))},isExported:!0},Q$={description:M(`Equivalent rate of return for a US Treasury bill.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`discount (number)`,M(`The discount rate of the bill at time of purchase.`))],compute:function(e,t,n){let r=Math.trunc(F(e,this.locale)),i=Math.trunc(F(t,this.locale)),a=F(n,this.locale);if(r>=i)return new P(OZ(r,i));if(!aQ(r,i,this.locale))return new P(XZ(r,i));if(a<=0)return new P(mZ(a));if(a>=1)return new P(hZ(a));let o=pQ.compute.bind(this)({value:i},{value:r}).value;if(o<=182)return{value:365*a/(360-a*o)};let s=X$(r,i,a)/100,c=o/(o===366?366:365);return{value:(-2*c+2*Math.sqrt(c**2-(2*c-1)*(1-1/s)))/(2*c-1)}},isExported:!0},$$={description:M(`The yield of a US Treasury bill based on price.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`price (number)`,M(`The price at which the security is bought per 100 face value.`))],compute:function(e,t,n){let r=Math.trunc(F(e,this.locale)),i=Math.trunc(F(t,this.locale)),a=F(n,this.locale);if(r>=i)return new P(OZ(r,i));if(!aQ(r,i,this.locale))return new P(XZ(r,i));if(a<=0)return new P(BZ(a));let o=oo(r,i,2);return{value:(100-a)/a*(1/o)}},isExported:!0},e1={description:M(`Variable declining balance. WARNING : does not handle decimal periods.`),args:[V(`cost (number)`,M(`The initial cost of the asset.`)),V(`salvage (number)`,M(`The value of the asset at the end of depreciation.`)),V(`life (number)`,M(`The number of periods over which the asset is depreciated.`)),V(`start (number)`,M(`Starting period to calculate depreciation.`)),V(`end (number)`,M(`Ending period to calculate depreciation.`)),V(`factor (number, default=2)`,M(`The number of months in the first year of depreciation.`)),V(`no_switch (number, default=false)`,M(`Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.`),[{value:!1,label:M(`Switch to straight-line depreciation`)},{value:!0,label:M(`Do not switch to straight-line depreciation`)}])],compute:function(e,t,n,r,i,a={value:2},o={value:!1}){a||=0;let s=F(e,this.locale),c=F(t,this.locale),l=F(n,this.locale),u=Math.trunc(F(r,this.locale)),d=Math.trunc(F(i,this.locale)),f=F(a,this.locale),p=L(o);if(s<0)return new P(cZ(s));if(c<0)return new P(qZ(c));if(l<=0)return new P(DZ(l));if(u<0)return new P(QZ(u));if(d<0)return new P(_Z(d));if(u>d)return new P($Z(u,d));if(d>l)return new P(vZ(d,l));if(f<=0)return new P(fZ(f));if(s===0)return{value:0};if(c>=s)return{value:u<1?s-c:0};let m=f/l;if(m>=1)return{value:u<1?s-c:0};let h=s,g=0,_=0,v=!1;for(let e=0;e<d;e++){if(!v||p){let t=h*m,n=l-e,r=(h-c)/n;!p&&r>t?(v=!0,g=r):g=t}let t=Math.max(h-g,c);e>=u&&(_+=h-t),h=t}return{value:_}},isExported:!0},t1={description:M(`Internal rate of return given non-periodic cash flows.`),args:[V(`cashflow_amounts (range<number>)`,M(`An range containing the income or payments associated with the investment.`)),V(`cashflow_dates (range<number>)`,M(`An range with dates corresponding to the cash flows in cashflow_amounts.`)),V(`rate_guess (number, default=${W$})`,M(`An estimate for what the internal rate of return will be.`))],compute:function(e,t,n={value:W$}){let r=F(n,this.locale);if(!wv(e,t))return new P(oZ);let i=e.flat().map(e=>F(e,this.locale)),a=t.flat().map(e=>F(e,this.locale));if(!nQ(i))return new P(sZ);if(a.some(e=>e<a[0]))return new P(yZ(a[0]));if(r<=-1)return new P(UZ(r));let o=new Map;for(let e of S(0,a.length)){let t=a[e];o.has(t)?o.set(t,o.get(t)+i[e]):o.set(t,i[e])}let s=Array.from(o.keys()),c=s.map(e=>o.get(e));return{value:t$(e=>{let t=c[0];for(let n of S(1,c.length)){let r=(s[0]-s[n])/365;t+=c[n]*(1+e)**r}return t},e=>{let t=0;for(let n of S(1,c.length)){let r=(s[0]-s[n])/365;t+=r*c[n]*(1+e)**(r-1)}return t},r,40,1e-5,e=>e?e/10-.9:-.9)}},isExported:!0},n1={description:M(`Net present value given to non-periodic cash flows..`),args:[V(`discount (number)`,M(`The discount rate of the investment over one period.`)),V(`cashflow_amounts (number, range<number>)`,M(`An range containing the income or payments associated with the investment.`)),V(`cashflow_dates (number, range<number>)`,M(`An range with dates corresponding to the cash flows in cashflow_amounts.`))],compute:function(e,t,n){let r=F(e,this.locale);if(!wv(t,n))return new P(oZ);let i=R(t).flat().map(e=>Zo(e,this.locale)),a=R(n).flat().map(e=>Zo(e,this.locale));if(a.some(e=>e<a[0]))return new P(yZ(a[0]));if(r<=0)return new P(GZ(r));if(i.length===1)return{value:i[0]};let o=new Map;for(let e of S(0,a.length)){let t=a[e];o.has(t)?o.set(t,o.get(t)+i[e]):o.set(t,i[e])}let s=Array.from(o.keys()),c=s.map(e=>o.get(e)),l=c[0];for(let e of S(1,c.length)){let t=(s[0]-s[e])/365;l+=c[e]*(1+r)**t}return{value:l}},isExported:!0},r1={description:M(`Annual yield of a security paying periodic interest.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`rate (number)`,M(`The annualized rate of interest.`)),V(`price (number)`,M(`The price at which the security is bought per 100 face value.`)),V(`redemption (number)`,M(`The redemption amount per 100 face value, or par.`)),V(`frequency (number)`,M(`The number of interest or coupon payments per year (1, 2, or 4).`),QQ),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=Math.trunc(F(e,this.locale)),c=Math.trunc(F(t,this.locale)),l=F(n,this.locale),u=F(r,this.locale),d=F(i,this.locale),f=Math.trunc(F(a,this.locale)),p=Math.trunc(F(o,this.locale));if(s>=c)return new P(OZ(s,c));if(iQ(f))return new P(uZ(f));if(rQ(p))return new P(dZ(p));if(l<0)return new P(WZ(l));if(u<=0)return new P(BZ(u));if(d<=0)return new P(KZ(d));let m=oo(s,c,p)*f,h=Math.ceil(m),g=m-Math.floor(m)||1,_=100*l/f;if(h===1){let e=u+_*(1-g);return{value:(d+_-e)*f*(1/g)/e}}function v(e,t,n,r,i,a){let o=a-(e+i*(1-t))*r**(n-1+t);for(let e=1;e<=n;e++)o+=i*r**(e-1);return o}function ee(e,t,n,r,i){let a=-(e+i*(1-t))*(n-1+t)*r**(n-2+t);for(let e=1;e<=n;e++)a+=i*(e-1)*r**(e-2);return a}function y(e){return v(u,g,h,e,_,d)}function te(e){return ee(u,g,h,e,_)}return{value:(t$(y,te,1+(l+1)/f,100,1e-5)-1)*f}},isExported:!0},i1={description:M(`Annual yield of a discount security.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`price (number)`,M(`The price at which the security is bought per 100 face value.`)),V(`redemption (number)`,M(`The redemption amount per 100 face value, or par.`)),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(F(e,this.locale)),o=Math.trunc(F(t,this.locale)),s=F(n,this.locale),c=F(r,this.locale),l=Math.trunc(F(i,this.locale));if(a>=o)return new P(OZ(a,o));if(rQ(l))return new P(dZ(l));if(s<=0)return new P(BZ(s));if(c<=0)return new P(KZ(c));let u=oo(a,o,l);return{value:(c/s-1)/u}},isExported:!0},a1={description:M(`Annual yield of a security paying interest at maturity.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`issue (date)`,M(`The date the security was initially issued.`)),V(`rate (number)`,M(`The annualized rate of interest.`)),V(`price (number)`,M(`The price at which the security is bought.`)),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i,a={value:0}){a||=0;let o=Math.trunc(F(e,this.locale)),s=Math.trunc(F(t,this.locale)),c=Math.trunc(F(n,this.locale)),l=F(r,this.locale),u=F(i,this.locale),d=Math.trunc(F(a,this.locale));if(o>=s)return new P(OZ(o,s));if(rQ(d))return new P(dZ(d));if(o<c)return new P(YZ(o,c));if(l<0)return new P(WZ(l));if(u<=0)return new P(BZ(u));let f=oo(c,s,d),p=oo(c,o,d),m=oo(o,s,d);return{value:(100*(1+l*f)/(u+100*l*p)-1)/m}},isExported:!0};var o1=l({CELL:()=>c1,ISBLANK:()=>g1,ISERR:()=>l1,ISERROR:()=>u1,ISFORMULA:()=>v1,ISLOGICAL:()=>d1,ISNA:()=>f1,ISNONTEXT:()=>p1,ISNUMBER:()=>m1,ISTEXT:()=>h1,NA:()=>_1});let s1=[{value:`address`,label:M(`Returns an absolute reference as plain text of the top left cell in reference.`)},{value:`col`,label:M(`Returns the column number of the cell in reference.`)},{value:`contents`,label:M(`Returns the value contained in the top left cell in reference.`)},{value:`format`,label:M(`Returns the format of the top left cell in reference.`)},{value:`row`,label:M(`Returns the row number of the top left cell in reference.`)},{value:`type`,label:M(`Returns the type of data in the cell in reference. The following values are returned: "b" for a blank cell, "l" (for label) if the cell contains plain text, and "v" (for value) if the cell contains any other type of data.`)}],c1={description:M(`Gets information about a cell.`),args:[V(`info_type (string)`,M(`The type of information requested.`),s1),V(`reference (any, range<any>)`,M(`The reference to the cell.`))],compute:function(e,t){let n=I(e).toLowerCase();if(!s1.map(e=>e.value).includes(n))return new P(M(`The info_type should be one of %s.`,s1.join(`, `)));let r=R(t)[0][0],i=r.position;if(i===void 0)return new P(M(`The reference is invalid.`));switch(n){case`address`:return{value:(this.__originSheetId===i.sheetId?``:this.getters.getSheetName(i.sheetId)+`!`)+T(i.col,i.row,{colFixed:!0,rowFixed:!0})};case`col`:return{value:i.col+1};case`contents`:return{value:r.value};case`format`:return{value:r.format||``};case`row`:return{value:i.row+1};case`type`:return r.value===null?{value:`b`}:Wc(r.format)?{value:`l`}:typeof r.value==`number`||typeof r.value==`boolean`?{value:`v`}:{value:`l`}}return{value:``}},isExported:!0},l1={description:M(`Whether a value is an error other than #N/A.`),args:[V(`value (any)`,M(`The value to be verified as an error type.`))],compute:function(e){let t=e?.value;return{value:Uo(t)&&t!==N.NotAvailable}},isExported:!0},u1={description:M(`Whether a value is an error.`),args:[V(`value (any)`,M(`The value to be verified as an error type.`))],compute:function(e){let t=e?.value;return{value:Uo(t)}},isExported:!0},d1={description:M("Whether a value is `true` or `false`."),args:[V(`value (any)`,M(`The value to be verified as a logical TRUE or FALSE.`))],compute:function(e){return{value:typeof e?.value==`boolean`}},isExported:!0},f1={description:M(`Whether a value is the error #N/A.`),args:[V(`value (any)`,M(`The value to be verified as an error type.`))],compute:function(e){return{value:e?.value===N.NotAvailable}},isExported:!0},p1={description:M(`Whether a value is non-textual.`),args:[V(`value (any)`,M(`The value to be checked.`))],compute:function(e){return{value:!h1.compute.bind(this)(e).value}},isExported:!0},m1={description:M(`Whether a value is a number.`),args:[V(`value (any)`,M(`The value to be verified as a number.`))],compute:function(e){return{value:typeof e?.value==`number`}},isExported:!0},h1={description:M(`Whether a value is text.`),args:[V(`value (any)`,M(`The value to be verified as text.`))],compute:function(e){return{value:typeof e?.value==`string`&&Uo(e?.value)===!1}},isExported:!0},g1={description:M(`Whether the referenced cell is empty`),args:[V(`value (any)`,M(`Reference to the cell that will be checked for emptiness.`))],compute:function(e){return{value:e?.value===null}},isExported:!0},_1={description:M(`Returns the error value #N/A.`),args:[],compute:function(){return{value:N.NotAvailable}},isExported:!0},v1={description:M(`Checks whether there is a reference to a cell that contains a formula, and returns TRUE or FALSE.`),args:[V(`cell_reference (any)`,M(`A reference to a cell.`))],compute:function(e){return e?.position===void 0?new Fo(Ko):{value:this.getters.getCell(e.position)?.isFormula??!1}},isExported:!0};var y1=l({AND:()=>b1,FALSE:()=>x1,IF:()=>S1,IFERROR:()=>C1,IFNA:()=>w1,IFS:()=>T1,NOT:()=>E1,OR:()=>D1,SWITCH:()=>O1,TRUE:()=>k1,XOR:()=>A1});let b1={description:M("Logical `and` operator."),args:[V(`logical_expression (boolean, range<boolean>, repeating)`,M(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let{result:t,foundBoolean:n}=vv(e);return n?{value:t}:new P(ks)},isExported:!0},x1={description:M("Logical value `false`."),args:[],compute:function(){return{value:!1}},isExported:!0},S1={description:M(`Returns value depending on logical expression.`),args:[V(`logical_expression (boolean, range<boolean>)`,M(`An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.`)),V(`value_if_true (any, range)`,M(`The value the function returns if logical_expression is TRUE.`)),V(`value_if_false (any, range, default=FALSE)`,M(`The value the function returns if logical_expression is FALSE.`))],computeArray:function(e,t,n){if(Nv(e)){let r=ml.get(`IF`);return rl(this,r,[e,t,n],al(r,3),Pv([e,t,n]))}return(L(jv(e))?t:n)??{value:0}},isExported:!0},C1={description:M(`Value if it is not an error, otherwise 2nd argument.`),args:[V(`value (any, range)`,M(`The value to return if value itself is not an error.`)),V(`value_if_error (any, range, default="empty")`,M(`The value the function returns if value is an error.`))],computeArray:function(e,t){if(Nv(e)){let n=ml.get(`IFERROR`);return rl(this,n,[e,t],al(n,2),Pv([e,t]))}return(Uo(jv(e)?.value)?t:e)??{value:0}},isExported:!0},w1={description:M(`Value if it is not an #N/A error, otherwise 2nd argument.`),args:[V(`value (any, range)`,M(`The value to return if value itself is not #N/A an error.`)),V(`value_if_error (any, range, default="empty")`,M(`The value the function returns if value is an #N/A error.`))],computeArray:function(e,t){if(Nv(e)){let n=ml.get(`IFNA`);return rl(this,n,[e,t],al(n,2),Pv([e,t]))}return(jv(e)?.value===N.NotAvailable?t:e)??{value:0}},isExported:!0},T1={description:M(`Returns a value depending on multiple logical expressions.`),args:[V(`condition (any, range, repeating)`,M(`The condition to be evaluated. It can be a boolean, a number, an array, or a reference to any of those.`)),V(`value (any, range, repeating)`,M(`The value to be returned if its corresponding condition is TRUE.`))],computeArray:function(...e){if(e.length%2!=0)return new P(M(`Wrong number of arguments. Expected an even number of arguments.`));for(;e.length>0;){if(Nv(e[0])){let t=ml.get(`IFS`);return rl(this,t,e,al(t,e.length),Pv(e))}let t=L(jv(e.shift())),n=e.shift();if(t)return n??{value:0}}return new P(M(`No match.`))},isExported:!0},E1={description:M(`Returns opposite of provided logical value.`),args:[V(`logical_expression (boolean)`,M(`An expression or reference to a cell holding an expression that represents some logical value.`))],compute:function(e){return{value:!L(e)}},isExported:!0},D1={description:M("Logical `or` operator."),args:[V(`logical_expression (boolean, range<boolean>, repeating)`,M(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let{result:t,foundBoolean:n}=yv(e);return n?{value:t}:new P(ks)},isExported:!0},O1={description:M(`Returns a value by comparing cases to an expression.`),args:[V(`expression (number, boolean, string)`,M(`The value to be checked.`)),V(`case (any, repeating)`,M(`Case to be checked against expression.`)),V(`value (any, repeating)`,M(`Value to be returned if its corresponding case matches expression.`)),V(`default (any, default="empty")`,M(`An optional default value to be returned if none of the cases match expression.`))],compute:function(e,...t){let n=t.length%2==0?Wo(e):t.pop();for(let n=0;n<t.length;n+=2){let r=t[n];if(r&&Uo(r.value))return r;if(e?.value===r?.value)return t[n+1]||{value:0}}return n||{value:0}},isExported:!0},k1={description:M("Logical value `true`."),args:[],compute:function(){return{value:!0}},isExported:!0},A1={description:M("Logical `xor` operator."),args:[V(`logical_expression (boolean, range<boolean>, repeating)`,M(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let t=!1,n=!1;return _s(e,e=>(t=!0,n=n?!e:e,!0)),t?{value:n}:new P(ks)},isExported:!0};function j1(e,t){let n=t.getPivotId(e);if(!n)throw new P(M(`There is no pivot with id "%s"`,e));return n}function M1(e,t,n){let{measures:r}=n.getPivotCoreDefinition(e);if(!r.find(e=>e.id===t))throw new P(M(`The argument %s is not a valid measure. Here are the measures: %s`,t,`(${r.map(e=>e.id).join(`, `)})`))}function N1(e){if(e.length%2!=0)throw new P(M(`Function PIVOT takes an even number of arguments.`))}function P1(e,t,n){let r=[],i=e.getters.getPivotCoreDefinition(t);if(i.type===`SPREADSHEET`&&i.dataSet){let{sheetId:t,zone:n}=i.dataSet,a=tr(n),o=e.getters.getRangeFromSheetXC(t,a);if(o===void 0||o.invalidXc||o.invalidSheetName)throw new Fo;if(e.__originCellPosition&&o.sheetId===e.__originSheetId&&pr(E(e.__originCellPosition),n))throw new Po;r.push(o)}for(let i of n)i.computedBy&&r.push(...e.getters.getMeasureFullDependencies(t,i));let a=e.__originCellPosition;a&&r.length&&(e.updateDependencies?.(a),e.addDependencies?.(a,r))}var F1=l({ADDRESS:()=>R1,CHOOSE:()=>t0,COLUMN:()=>z1,COLUMNS:()=>B1,DROP:()=>n0,FORMULATEXT:()=>i0,HLOOKUP:()=>V1,INDEX:()=>H1,INDIRECT:()=>U1,LOOKUP:()=>W1,MATCH:()=>G1,OFFSET:()=>e0,PIVOT:()=>$1,PIVOT_HEADER:()=>Q1,PIVOT_VALUE:()=>Z1,ROW:()=>K1,ROWS:()=>q1,TAKE:()=>r0,VLOOKUP:()=>J1,XLOOKUP:()=>X1});let I1=[{value:!0,label:M(`A1 style (default)`)},{value:!1,label:M(`R1C1 style`)}],L1=[{value:!0,label:M(`Approximate match (default)`)},{value:!1,label:M(`Exact match`)}],R1={description:M(`Returns a cell reference as a string. `),args:[V(`row (number)`,M(`The row number of the cell reference. `)),V(`column (number)`,M(`The column number (not name) of the cell reference. A is column number 1. `)),V(`absolute_relative_mode (number, default=1)`,M(`An indicator of whether the reference is row/column absolute.`),[{value:1,label:M(`Absolute row and column (e.g. $A$1)`)},{value:2,label:M(`Absolute row, relative column (e.g. A$1)`)},{value:3,label:M(`Relative row, absolute column (e.g. $A1)`)},{value:4,label:M(`Relative row and column (e.g. A1)`)}]),V(`use_a1_notation (boolean, default=TRUE)`,M(`A boolean indicating whether to use A1 style notation or R1C1 style notation.`),I1),V(`sheet (string, optional)`,M(`A string indicating the name of the sheet into which the address points.`))],compute:function(e,t,n={value:1},r={value:!0},i){let a=$o(e,this.locale),o=$o(t,this.locale);if(a<1)return new P(Ev(a));if(o<1)return new P(Ev(o));let s=$o(n,this.locale);if(![1,2,3,4].includes(s))return new P(qo(1,4,s));let c=L(r),l;if(c){let e={rowFixed:[1,2].includes(s),colFixed:[1,3].includes(s)};l=T(o-1,a-1,e)}else l=([1,2].includes(s)?`R${a}`:`R[${a}]`)+([1,3].includes(s)?`C${o}`:`C[${o}]`);return i===void 0?{value:l}:{value:Ol(I(i),l)}},isExported:!0},z1={description:M(`Column number of a specified cell.`),args:[V(`cell_reference (any, range<any>, default='this cell')`,M(`The cell whose column number will be returned. Column A corresponds to 1. By default, the function use the cell in which the formula is entered.`))],computeArray:function(e){if(e===void 0)return this.__originCellPosition===void 0?new P(M(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):{value:this.__originCellPosition.col+1};let t=R(e),n=t[0][0];if(n===void 0)return new P(M(`The range is out of bounds.`));if(n.position===void 0)return new Fo(Ko);let r=n.position.col;return t.length===1?{value:r+1}:fs(t.length,1,e=>({value:r+e+1}))},isExported:!0},B1={description:M(`Number of columns in a specified array or range.`),args:[V(`range (any, range<any>)`,M(`The range whose column count will be returned.`))],compute:function(e){let t=R(e);return t[0][0]===void 0?new P(M(`The range is out of bounds.`)):t[0][0].value===N.InvalidReference?t[0][0]:{value:t.length}},isExported:!0},V1={description:M(`Horizontal lookup`),args:[V(`search_key (string, number, boolean)`,M(`The value to search for. For example, 42, 'Cats', or I24.`)),V(`range (any, range)`,M(`The range to consider for the search. The first row in the range is searched for the key specified in search_key.`)),V(`index (number)`,M(`The row index of the value to be returned, where the first row in range is numbered 1.`)),V(`is_sorted (boolean, default=true)`,M(`Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned.`),L1)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(F(n?.value,this.locale)),a=R(t);if(1>i||i>a[0].length)return new P(M(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[t][0].value,s=a[L(r.value)?Ss(a,e,`nextSmaller`,`asc`,a.length,o):Cs(a,e,`wildcard`,a.length,o,this.lookupCaches)];return s===void 0?Wo(e):s[i-1]},isExported:!0},H1={description:M(`Returns the content of a cell, specified by row and column offset.`),args:[V(`reference (any, range)`,M(`The range of cells from which the values are returned.`)),V(`row (number, default=0)`,M(`The index of the row to be returned from within the reference range of cells.`)),V(`column (number, default=0)`,M(`The index of the column to be returned from within the reference range of cells.`))],computeArray:function(e,t={value:0},n={value:0}){let r=R(e),i=F(t.value,this.locale),a=F(n.value,this.locale);return a<0||a-1>=r.length||i<0||i-1>=r[0].length?new P(M(`Index out of range.`)):i===0&&a===0?r:i===0?[r[a-1]]:a===0?r.map(e=>[e[i-1]]):r[a-1][i-1]},isExported:!0},U1={description:M(`Returns the content of a cell, specified by a string.`),args:[V(`reference (string)`,M(`The range of cells from which the values are returned.`)),V(`use_a1_notation (boolean, default=TRUE)`,M(`A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).`),I1)],computeArray:function(e,t={value:!0}){let n=e?.value?.toString();if(!n)return new Fo(M(`Reference should be defined.`));if(!L(t))return new P(M(`R1C1 notation is not supported.`));let r=this.__originSheetId,i=this.__originCellPosition;i&&this.updateDependencies?.(i);let a=this.getters.getNamedRange(n),o=a?a.range:this.getters.getRangeFromSheetXC(r,n);if(o===void 0||o.invalidXc||o.invalidSheetName)return new Fo;i&&this.addDependencies?.(i,[o]);let s=[];for(let e=o.zone.left;e<=o.zone.right;e++){let t=[];for(let n=o.zone.top;n<=o.zone.bottom;n++){let r={sheetId:o.sheetId,col:e,row:n};t.push(this.getFormulaResult(r))}s.push(t)}return s.length===1&&s[0].length===1?s[0][0]:s},isExported:!0},W1={description:M(`Look up a value.`),args:[V(`search_key (string, number, boolean)`,M(`The value to search for. For example, 42, 'Cats', or I24.`)),V(`search_array (any, range)`,M(`One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.`)),V(`result_range (any, range, optional)`,M(`The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method.`))],compute:function(e,t,n){let r=R(t),i=R(n),a=r.length,o=r[0].length,s=o>=a,c=Ss(r,e,`nextSmaller`,`asc`,s?o:a,s?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value);return c===-1||s&&r[0][c]===void 0||!s&&r[c][o-1]===void 0?Wo(e):i[0].length===0?s?r[a-1][c]:r[c][o-1]:(a=i.length,o=i[0].length,a!==1&&o!==1?new P(M(`The result_range must be a single row or a single column.`)):a>1?c>a-1?new P(M(`[[FUNCTION_NAME]] evaluates to an out of range row value %s.`,c+1)):i[c][0]:c>o-1?new P(M(`[[FUNCTION_NAME]] evaluates to an out of range column value %s.`,c+1)):i[0][c])},isExported:!0},G1={description:M(`Position of item in range that matches value.`),args:[V(`search_key (string, number, boolean)`,M(`The value to search for. For example, 42, 'Cats', or I24.`)),V(`range (any, range)`,M(`The one-dimensional array to be searched.`)),V(`search_type (number, default=1)`,M(`The search method is a number 1, 0 or -1 indicating which value to return. 1 finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order.`),[{value:1,label:M(`Ascending order (default)`)},{value:0,label:M(`Exact match`)},{value:-1,label:M(`Descending order`)}])],compute:function(e,t,n={value:1}){let r=F(n,this.locale),i=R(t),a=i.length,o=i[0].length;if(a!==1&&o!==1)return new P(M(`The range must be a single row or a single column.`));let s=-1,c=a===1?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,l=a===1?i[0].length:i.length;switch(r=Math.sign(r),r){case 1:s=Ss(i,e,`nextSmaller`,`asc`,l,c);break;case 0:s=Cs(i,e,`wildcard`,l,c,this.lookupCaches);break;case-1:s=Ss(i,e,`nextGreater`,`desc`,l,c);break}return a===1&&i[0][s]===void 0||a!==1&&i[s]===void 0?Wo(e):{value:s+1}},isExported:!0},K1={description:M(`Row number of a specified cell.`),args:[V(`cell_reference (any, range<any>, default='this cell')`,M(`The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered.`))],computeArray:function(e){if(e===void 0)return this.__originCellPosition?.row===void 0?new P(M(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):{value:this.__originCellPosition.row+1};let t=R(e),n=t[0][0];if(n===void 0)return new P(M(`The range is out of bounds.`));if(n.position===void 0)return new Fo(Ko);let r=n.position.row;return t[0].length===1?{value:r+1}:fs(1,t[0].length,(e,t)=>({value:r+t+1}))},isExported:!0},q1={description:M(`Number of rows in a specified array or range.`),args:[V(`range (any, range<any>)`,M(`The range whose row count will be returned.`))],compute:function(e){let t=R(e);return t[0][0]===void 0?new P(M(`The range is out of bounds.`)):t[0][0].value===N.InvalidReference?t[0][0]:{value:t[0].length}},isExported:!0},J1={description:M(`Vertical lookup.`),args:[V(`search_key (string, number, boolean)`,M(`The value to search for. For example, 42, 'Cats', or I24.`)),V(`range (any, range)`,M(`The range to consider for the search. The first column in the range is searched for the key specified in search_key.`)),V(`index (number)`,M(`The column index of the value to be returned, where the first column in range is numbered 1.`)),V(`is_sorted (boolean, default=true)`,M(`Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned.`),L1)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(F(n?.value,this.locale)),a=R(t);if(1>i||i>a.length)return new P(M(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[0][t].value,s=L(r.value)?Ss(a,e,`nextSmaller`,`asc`,a[0].length,o):Cs(a,e,`wildcard`,a[0].length,o,this.lookupCaches),c=a[i-1][s];return c===void 0?Wo(e):c},isExported:!0},Y1={0:`strict`,1:`nextGreater`,"-1":`nextSmaller`,2:`wildcard`},X1={description:M(`Search a range for a match and return the corresponding item from a second range.`),args:[V(`search_key (string,number,boolean)`,M(`The value to search for.`)),V(`lookup_range (any, range)`,M(`The range to consider for the search. Should be a single column or a single row.`)),V(`return_range (any, range)`,M(`The range containing the return value. Should have the same dimensions as lookup_range.`)),V(`if_not_found (any, optional)`,M(`If a valid match is not found, return this value.`)),V(`match_mode (any, default=0)`,M(`Specifies how to match search_key with the items in lookup_range. `),[{value:0,label:M(`Exact match (default)`)},{value:-1,label:M(`Exact match or next smaller item`)},{value:1,label:M(`Exact match or next larger item`)},{value:2,label:M(`Wildcard character match`)}]),V(`search_mode (any, default=1)`,M(`Specifies the search mode to use. By default, a first to last search will be used.`),[{value:1,label:M(`Search first to last (default)`)},{value:-1,label:M(`Search last to first`)},{value:2,label:M(`Binary search (sorted ascending order)`)},{value:-2,label:M(`Binary search (sorted descending order)`)}])],computeArray:function(e,t,n,r,i={value:0},a={value:1}){let o=Math.trunc(F(i.value,this.locale)),s=Math.trunc(F(a.value,this.locale)),c=R(t),l=R(n);if(c.length!==1&&c[0].length!==1)return new P(M(`lookup_range should be either a single row or single column.`));if(![1,-1,2,-2].includes(s))return new P(M(`search_mode should be a value in [-1, 1, -2, 2].`));if(![-1,0,1,2].includes(o))return new P(M(`match_mode should be a value in [-1, 0, 1, 2].`));let u=c.length===1?`col`:`row`;if(o===2&&[-2,2].includes(s))return new P(M(`The search and match mode combination is not supported for XLOOKUP evaluation.`));if(u===`col`?l[0].length!==c[0].length:l.length!==c.length)return new P(M(`return_range should have the same dimensions as lookup_range.`));let d=u===`col`?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,f=u===`col`?c[0].length:c.length,p=Y1[o],m=s===-1,h=s===2||s===-2?Ss(c,e,p,s===2?`asc`:`desc`,f,d):Cs(c,e,p,f,d,this.lookupCaches,m);return h===-1?r===void 0?Wo(e):[[r]]:u===`col`?l.map(e=>[e[h]]):[l[h]]},isExported:!0},Z1={description:M(`Get the value from a pivot.`),args:[V(`pivot_id (number,string)`,M(`ID of the pivot.`)),V(`measure_name (string)`,M(`Name of the measure.`)),V(`domain_field_name (string,repeating,optional)`,M(`Field name.`)),V(`domain_value (number,string,boolean,repeating,optional)`,M(`Value.`))],compute:function(e,t,...n){let r=I(e),i=I(t),a=j1(r,this.getters);M1(a,i,this.getters),N1(n);let o=this.getters.getPivot(a),s=this.getters.getPivotCoreDefinition(a);P1(this,a,s.measures.filter(e=>e.id===i)),o.init({reload:o.needsReevaluation});let c=o.assertIsValid({throwOnError:!1});if(c)return c;if(!o.areDomainArgsFieldsValid(n)){let e=M(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${r})`);return{value:N.GenericError,message:M(`Dimensions don't match the pivot definition`)+`. `+e}}let l=o.parseArgsToPivotDomain(n);return this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(a)?.trackValue(i,l),o.getPivotCellValueAndFormat(i,l)}},Q1={description:M(`Get the header of a pivot.`),args:[V(`pivot_id (number,string)`,M(`ID of the pivot.`)),V(`domain_field_name (string,repeating,optional)`,M(`Field name.`)),V(`domain_value (number,string,value,repeating,optional)`,M(`Value.`))],compute:function(e,...t){let n=I(e),r=j1(n,this.getters);N1(t);let i=this.getters.getPivot(r);P1(this,r,[]),i.init({reload:i.needsReevaluation});let a=i.assertIsValid({throwOnError:!1});if(a)return a;if(!i.areDomainArgsFieldsValid(t)){let e=M(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${n})`);return{value:N.GenericError,message:M(`Dimensions don't match the pivot definition`)+`. `+e}}let o=i.parseArgsToPivotDomain(t);this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(r)?.trackHeader(o);let s=o.at(-1);if(s?.field===`measure`)return i.getPivotMeasureValue(I(s.value),o);let{value:c,format:l}=i.getPivotHeaderValueAndFormat(o);return{value:c,format:!s||s.field===`measure`||s.value===`false`?void 0:l}}},$1={description:M(`Get a pivot table.`),args:[V(`pivot_id (string)`,M(`ID of the pivot.`)),V(`row_count (number, optional)`,M(`number of rows`)),V(`include_total (boolean, default=TRUE)`,M(`Whether to include total/sub-totals or not.`)),V(`include_column_titles (boolean, default=TRUE)`,M(`Whether to include the column titles or not.`)),V(`column_count (number, optional)`,M(`number of columns`)),V(`include_measure_titles (boolean, default=TRUE)`,M(`Whether to include the measure titles row or not.`))],computeArray:function(e,t,n,r,i,a){let o=j1(I(e),this.getters),s=this.getters.getPivot(o),c=this.getters.getPivotCoreDefinition(o),l=Yy(c,t,n,r,i,a,this.locale);if(l.numberOfRows<0)return new P(M(`The number of rows must be positive.`));if(l.numberOfColumns<0)return new P(M(`The number of columns must be positive.`));P1(this,o,c.measures),s.init({reload:s.needsReevaluation});let u=s.assertIsValid({throwOnError:!1});if(u)return u;let d=s.getCollapsedTableStructure();if(d.numberOfCells>5e5)return new P(ub(d.numberOfCells,this.locale));let f=d.getPivotCells(l),p=this.getters.getPivotName(o),{numberOfCols:m,numberOfRows:h}=d.getPivotTableDimensions(l);if(h===0)return[[{value:p}]];let g=[];for(let e of S(0,m)){g[e]=[];for(let t of S(0,h)){let n=f[e][t];switch(n.type){case`EMPTY`:g[e].push({value:``});break;case`HEADER`:let t=s.getPivotHeaderValueAndFormat(n.domain);g[e].push(By(n.domain,t));break;case`MEASURE_HEADER`:g[e].push(s.getPivotMeasureValue(n.measure,n.domain));break;case`VALUE`:g[e].push(s.getPivotCellValueAndFormat(n.measure,n.domain));break;case`ROW_GROUP_NAME`:let r=s.definition.rows.find(e=>e.nameWithGranularity===n.rowField)?.displayName;g[e].push({value:r||``});break}}}return(l.displayColumnHeaders||l.displayMeasuresRow)&&f[0][0].type===`EMPTY`&&(g[0][0]={value:p}),g}},e0={description:M(`Returns a range reference shifted by a specified number of rows and columns from a starting cell reference.`),args:[V(`cell_reference (any, range<any>)`,M(`The starting point from which to count the offset rows and columns.`)),V(`offset_rows (number)`,M(`The number of rows to offset by.`)),V(`offset_columns (number)`,M(`The number of columns to offset by.`)),V(`height (number, default='height of cell_reference')`,M(`The number of rows of the range to return starting at the offset target.`)),V(`width (number, default='width of cell_reference')`,M(`The number of columns of the range to return starting at the offset target.`))],computeArray:function(e,t,n,r,i){if(e===void 0)return new Fo(Ko);let a=R(e),o=a[0][0];if(o===void 0)return new P(M(`The range is out of bounds.`));if(o.position===void 0)return new Fo(Ko);let s=a[0].length,c=a.length;if(r){let e=F(r,this.locale);if(e<1)return new P(M(`Height value is %(_height)s. It should be greater than or equal to 1.`,{_height:e}));s=e}if(i){let e=F(i,this.locale);if(e<1)return new P(M(`Width value is %(_width)s. It should be greater than or equal to 1.`,{_width:e}));c=e}let l=F(t,this.locale),u=F(n,this.locale),d=this.__originCellPosition;d&&this.updateDependencies?.(d);let f=o.position.col+u,p=o.position.row+l;if(f<0||p<0)return new Fo(M(`OFFSET evaluates to an out of bounds range.`));let m={left:f,top:p,right:f+c-1,bottom:p+s-1},h=o.position.sheetId,g=this.getters.getRangeFromZone(h,m);return g.invalidXc||g.invalidSheetName?new Fo:(d&&this.addDependencies?.(d,[g]),fs(c,s,(e,t)=>this.getFormulaResult({sheetId:h,col:f+e,row:p+t})))}},t0={description:M(`Returns an element from a list of choices based on index.`),args:[V(`index (number)`,M(`Which choice to return.`)),V(`choice (any, range<any>, repeating)`,M(`A potential value to return. May be a reference to a cell or an individual value.`))],computeArray:function(e,...t){let n=Math.floor(F(e,this.locale))-1;return n<0||n>=t.length?new P(M(`Index for CHOOSE is invalid. Valid values are between 1 and %(choices)s inclusive.`,{choices:t.length})):t[n]??new P(M(`Choice is undefined.`))},isExported:!0},n0={description:M(`Excludes a specified number of rows or columns from the start or end of an array.`),args:[V(`array (range)`,M(`The array from which to drop rows or columns`)),V(`rows (number)`,M(`The number of rows to drop. A negative value drops from the end of the array.`)),V(`columns (number, optional)`,M(`The number of columns to exclude. A negative value drops from the end of the array.`))],computeArray:function(e,t,n){let r=F(t,this.locale),i=F(n,this.locale),a=e;if(Math.abs(i)>=e.length||Math.abs(r)>=e[0].length)return new P(M(`The number of rows or column to exclude must be smaller than the number of elements in the array.`));a=i>=0?a.slice(i):a.slice(0,a.length+i);for(let e=0;e<a.length;e++)r>=0?a[e]=a[e].slice(r):a[e]=a[e].slice(0,a[e].length+r);return a},isExported:!0},r0={description:M(`Returns a specified number of contiguous rows or columns from the start or end of an array.`),args:[V(`array (range)`,M(`The array from which to take rows or columns.`)),V(`rows (number)`,M(`The number of rows to take. A negative value takes from the end of the array.`)),V(`columns (number, optional)`,M(`The number of columns to take. A negative value takes from the end of the array.`))],computeArray:function(e,t,n){let r=t?F(t,this.locale):e[0].length,i=F(n,this.locale),a=e;if((Math.abs(i)>=e.length||i===0)&&(i=e.length),Math.abs(r)>=e[0].length&&(r=e[0].length),a=i>=0?a.slice(0,i):a.slice(a.length+i,a.length),r===0)return new P(M(`The number of rows can not be zero.`));for(let e=0;e<a.length;e++)r>0?a[e]=a[e].slice(0,r):a[e]=a[e].slice(a[e].length+r,a[e].length);return a},isExported:!0},i0={description:M(`Returns a formula as a string.`),args:[V(`cell_reference (any)`,M(`A reference to a cell.`))],compute:function(e){if(e?.position===void 0)return new Fo(Ko);let t=this.getters.getCell(e.position);return t?.isFormula?{value:t.compiledFormula.toFormulaString(this.getters)}:new Io(M(`The cell does not contain a formula.`))},isExported:!0};var a0=l({ADD:()=>o0,CONCAT:()=>s0,DIVIDE:()=>c0,EQ:()=>f0,GT:()=>h0,GTE:()=>g0,LT:()=>_0,LTE:()=>v0,MINUS:()=>y0,MULTIPLY:()=>b0,NE:()=>x0,POW:()=>S0,SPILLED_RANGE:()=>C0,UMINUS:()=>w0,UNARY_PERCENT:()=>T0,UPLUS:()=>E0});let o0={description:M(`Sum of two numbers.`),args:[V(`value1 (number)`,M(`The first addend.`)),V(`value2 (number)`,M(`The second addend.`))],compute:function(e,t){return{value:F(e,this.locale)+F(t,this.locale),format:e?.format||t?.format}}},s0={description:M(`Concatenation of two values.`),args:[V(`value1 (string)`,M(`The value to which value2 will be appended.`)),V(`value2 (string)`,M(`The value to append to value1.`))],compute:function(e,t){return{value:I(e)+I(t)}},isExported:!0},c0={description:M(`One number divided by another.`),args:[V(`dividend (number)`,M(`The number to be divided.`)),V(`divisor (number)`,M(`The number to divide by.`))],compute:function(e,t){let n=F(t,this.locale);return n===0?new zo(M(`The divisor must be different from zero.`)):{value:F(e,this.locale)/n,format:e?.format||t?.format}}};function l0(e){return e===void 0||e.value===null}let u0={number:0,string:``,boolean:!1};function d0(e,t,n=2e-16){return Math.abs(e-t)<n}let f0={description:M(`Equal.`),args:[V(`value1 (string, number, boolean)`,M(`The first value.`)),V(`value2 (string, number, boolean)`,M(`The value to test against value1 for equality.`))],compute:function(e,t){if(Uo(e?.value))return e;if(Uo(t?.value))return t;let n=l0(e)?u0[typeof t?.value]:e?.value,r=l0(t)?u0[typeof e?.value]:t?.value;return typeof n==`string`&&(n=n.toUpperCase()),typeof r==`string`&&(r=r.toUpperCase()),typeof n==`number`&&typeof r==`number`?{value:d0(n,r)}:{value:n===r}}};function p0(e,t,n){if(Uo(e?.value))return e;if(Uo(t?.value))return t;let r=l0(e)?u0[typeof t?.value]??``:e?.value,i=l0(t)?u0[typeof e?.value]??``:t?.value,a=m0[typeof r],o=m0[typeof i];if(a!==o)return{value:n(a,o)};switch(typeof r){case`string`:r=r.toUpperCase();break;case`boolean`:r=Number(r);break}switch(typeof i){case`string`:i=i.toUpperCase();break;case`boolean`:i=Number(i);break}return{value:n(r,i)}}let m0={number:0,string:1,boolean:2},h0={description:M(`Strictly greater than.`),args:[V(`value1 (number, string, boolean)`,M(`The value to test as being greater than value2.`)),V(`value2 (number, string, boolean)`,M(`The second value.`))],compute:function(e,t){return p0(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?!d0(e,t)&&e>t:e>t)}},g0={description:M(`Greater than or equal to.`),args:[V(`value1 (number, string, boolean)`,M(`The value to test as being greater than or equal to value2.`)),V(`value2 (number, string, boolean)`,M(`The second value.`))],compute:function(e,t){return p0(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?d0(e,t)||e>t:e>=t)}},_0={description:M(`Less than.`),args:[V(`value1 (number, string, boolean)`,M(`The value to test as being less than value2.`)),V(`value2 (number, string, boolean)`,M(`The second value.`))],compute:function(e,t){let n=g0.compute.bind(this)(e,t);return Uo(n.value)?n:{value:!n.value}}},v0={description:M(`Less than or equal to.`),args:[V(`value1 (number, string, boolean)`,M(`The value to test as being less than or equal to value2.`)),V(`value2 (number, string, boolean)`,M(`The second value.`))],compute:function(e,t){let n=h0.compute.bind(this)(e,t);return Uo(n.value)?n:{value:!n.value}}},y0={description:M(`Difference of two numbers.`),args:[V(`value1 (number)`,M(`The minuend, or number to be subtracted from.`)),V(`value2 (number)`,M(`The subtrahend, or number to subtract from value1.`))],compute:function(e,t){return{value:F(e,this.locale)-F(t,this.locale),format:e?.format||t?.format}}},b0={description:M(`Product of two numbers`),args:[V(`factor1 (number)`,M(`The first multiplicand.`)),V(`factor2 (number)`,M(`The second multiplicand.`))],compute:function(e,t){return{value:F(e,this.locale)*F(t,this.locale),format:e?.format||t?.format}}},x0={description:M(`Not equal.`),args:[V(`value1 (string, number, boolean)`,M(`The first value.`)),V(`value2 (string, number, boolean)`,M(`The value to test against value1 for inequality.`))],compute:function(e,t){let n=f0.compute.bind(this)(e,t);return Uo(n.value)?n:{value:!n.value}}},S0={description:M(`A number raised to a power.`),args:[V(`base (number)`,M(`The number to raise to the exponent power.`)),V(`exponent (number)`,M(`The exponent to raise base to.`))],compute:function(e,t){return JJ.compute.bind(this)(e,t)}},C0={description:M(`Gets the spilled range of an array formula.`),args:[V(`ref (any, range<any>)`,M(`The reference to get the spilled range from.`))],computeArray:function(e){if(e===void 0)return new Fo(Ko);let t=R(e);if(t.length!==1||t[0].length!==1)return new P(M(`Only single-cell references are allowed to get the spilled range.`));let n=t[0][0];if(Uo(n.value))return n;if(n.position===void 0)return new Fo(Ko);let r=this.__originCellPosition;r&&this.updateDependencies?.(r);let i=this.getters.getSpreadZone(n.position);if(i===void 0)return new Fo;let a=this.getters.getRangeFromZone(this.__originSheetId,i);return r&&this.addDependencies?.(r,[a]),fs(i.right-i.left+1,i.bottom-i.top+1,(e,t)=>this.getFormulaResult({sheetId:a.sheetId,col:i.left+e,row:i.top+t}))},hidden:!0},w0={description:M(`A number with the sign reversed.`),args:[V(`value (number)`,M(`The number to have its sign reversed. Equivalently, the number to multiply by -1.`))],compute:function(e){return{value:-F(e,this.locale),format:e?.format}}},T0={description:M(`Value interpreted as a percentage.`),args:[V(`percentage (number)`,M(`The value to interpret as a percentage.`))],compute:function(e){return{value:F(e,this.locale)/100}}},E0={description:M(`A specified number, unchanged.`),args:[V(`value (any)`,M(`The number to return.`))],compute:function(e={value:null}){return e}},$=e=>({transform:t=>t*e,inverseTransform:t=>t/e}),D0={transform:e=>e,inverseTransform:e=>e},O0=1e-10,k0=.0254,A0=k0/72,j0=.3048,M0=.9144,N0=1609.34,P0=1852,F0=946073047258e4,I0={g:{...D0,category:`weight`},u:{...$(166053e-29),category:`weight`},grain:{...$(.0647989),category:`weight`},ozm:{...$(28.3495),category:`weight`},lbm:{...$(453.592),category:`weight`},stone:{...$(6350.29),category:`weight`},sg:{...$(14593.90294),category:`weight`},cwt:{...$(45359.237),category:`weight`},uk_cwt:{...$(50802.3),category:`weight`},ton:{...$(907184.74),category:`weight`},uk_ton:{...$(1016046.9),category:`weight`},m:{...D0,category:`distance`},km:{...$(1e3),category:`distance`},ang:{...$(O0),category:`distance`},Picapt:{...$(A0),category:`distance`},pica:{...$(k0/6),category:`distance`},in:{...$(k0),category:`distance`},ft:{...$(j0),category:`distance`},yd:{...$(M0),category:`distance`},ell:{...$(1.143),category:`distance`},mi:{...$(N0),category:`distance`},survey_mi:{...$(1609.34),category:`distance`},Nmi:{...$(P0),category:`distance`},ly:{...$(F0),category:`distance`},parsec:{...$(0x6da012f95c9fd0),category:`distance`},sec:{...D0,category:`time`},min:{...$(60),category:`time`},hr:{...$(3600),category:`time`},day:{...$(86400),category:`time`},yr:{...$(31556952),category:`time`},Pa:{...D0,category:`pressure`},bar:{...$(1e5),category:`pressure`},mmHg:{...$(133.322),category:`pressure`},Torr:{...$(133.322),category:`pressure`},psi:{...$(6894.76),category:`pressure`},atm:{...$(101325),category:`pressure`},N:{...D0,category:`force`},dyn:{...$(1e-5),category:`force`},pond:{...$(.00980665),category:`force`},lbf:{...$(4.44822),category:`force`},J:{...D0,category:`energy`},eV:{...$(160218e-24),category:`energy`},e:{...$(1e-7),category:`energy`},flb:{...$(1.3558179483),category:`energy`},c:{...$(4.184),category:`energy`},cal:{...$(4.1868),category:`energy`},BTU:{...$(1055.06),category:`energy`},Wh:{...$(3600),category:`energy`},HPh:{...$(2684520),category:`energy`},W:{...D0,category:`power`},PS:{...$(735.499),category:`power`},HP:{...$(745.7),category:`power`},T:{...D0,category:`magnetism`},ga:{...$(1e-4),category:`magnetism`},K:{...D0,category:`temperature`},C:{transform:e=>e+273.15,inverseTransform:e=>e-273.15,category:`temperature`},F:{transform:e=>(e-32)*5/9+273.15,inverseTransform:e=>(e-273.15)*9/5+32,category:`temperature`},Rank:{...$(5/9),category:`temperature`},Reau:{transform:e=>e*1.25+273.15,inverseTransform:e=>(e-273.15)/1.25,category:`temperature`},"m^3":{...D0,category:`volume`,order:3},"ang^3":{...$(O0**3),category:`volume`,order:3},"Picapt^3":{...$(A0**3),category:`volume`,order:3},tsp:{...$(492892e-11),category:`volume`},tspm:{...$(5e-6),category:`volume`},tbs:{...$(14786764825785619e-21),category:`volume`},"in^3":{...$(k0**3),category:`volume`,order:3},oz:{...$(295735295625e-16),category:`volume`},cup:{...$(237e-6),category:`volume`},pt:{...$(.0004731765),category:`volume`},uk_pt:{...$(568261e-9),category:`volume`},qt:{...$(.0009463529),category:`volume`},l:{...$(.001),category:`volume`},uk_qt:{...$(.0011365225),category:`volume`},gal:{...$(.0037854118),category:`volume`},uk_gal:{...$(.00454609),category:`volume`},"ft^3":{...$(j0**3),category:`volume`,order:3},bushel:{...$(.0352390704),category:`volume`},barrel:{...$(.158987295),category:`volume`},"yd^3":{...$(M0**3),category:`volume`,order:3},MTON:{...$(1.13267386368),category:`volume`},GRT:{...$(2.83168),category:`volume`},"mi^3":{...$(N0**3),category:`volume`,order:3},"Nmi^3":{...$(P0**3),category:`volume`,order:3},"ly^3":{...$(F0**3),category:`volume`,order:3},"m^2":{...D0,category:`area`,order:2},"ang^2":{...$(O0**2),category:`area`,order:2},"Picapt^2":{...$(A0**2),category:`area`,order:2},"in^2":{...$(k0**2),category:`area`,order:2},"ft^2":{...$(j0**2),category:`area`,order:2},"yd^2":{...$(M0**2),category:`area`,order:2},ar:{...$(100),category:`area`},Morgen:{...$(2500),category:`area`},uk_acre:{...$(4046.8564224),category:`area`},us_acre:{...$(4046.8726098743),category:`area`},ha:{...$(1e4),category:`area`},"mi^2":{...$(N0**2),category:`area`,order:2},"Nmi^2":{...$(P0**2),category:`area`,order:2},"ly^2":{...$(F0**2),category:`area`,order:2},bit:{...D0,category:`information`},byte:{...$(8),category:`information`},"m/s":{...D0,category:`speed`},"m/hr":{...$(1/3600),category:`speed`},"km/hr":{...$(1/3.6),category:`speed`},mph:{...$(.44704),category:`speed`},kn:{...$(.5144444444),category:`speed`},admkn:{...$(.5147733333),category:`speed`}},L0={shweight:`cwt`,lcwt:`uk_cwt`,hweight:`uk_cwt`,LTON:`uk_ton`,brton:`uk_ton`,pc:`parsec`,Pica:`Picapt`,d:`day`,mn:`min`,s:`sec`,p:`Pa`,at:`atm`,dy:`dyn`,ev:`eV`,hh:`HPh`,wh:`Wh`,btu:`BTU`,h:`HP`,cel:`C`,fah:`F`,kel:`K`,us_pt:`pt`,L:`l`,lt:`l`,ang3:`ang^3`,ft3:`ft^3`,in3:`in^3`,ly3:`ly^3`,m3:`m^3`,mi3:`mi^3`,yd3:`yd^3`,Nmi3:`Nmi^3`,Picapt3:`Picapt^3`,"Pica^3":`Picapt^3`,Pica3:`Picapt^3`,regton:`GRT`,ang2:`ang^2`,ft2:`ft^2`,in2:`in^2`,ly2:`ly^2`,m2:`m^2`,mi2:`mi^2`,Nmi2:`Nmi^2`,Picapt2:`Picapt^2`,"Pica^2":`Picapt^2`,Pica2:`Picapt^2`,yd2:`yd^2`,"m/h":`m/hr`,"m/sec":`m/s`},R0={"":1,Y:1e24,Z:1e21,E:0xde0b6b3a7640000,P:0x38d7ea4c68000,T:0xe8d4a51000,G:1e9,M:1e6,k:1e3,h:100,da:10,e:10,d:.1,c:.01,m:.001,u:1e-6,n:1e-9,p:1e-12,f:1e-15,a:1e-18,z:1e-21,y:1e-21,Yi:2**80,Zi:2**70,Ei:2**60,Pi:2**50,Ti:2**40,Gi:2**30,Mi:2**20,ki:2**10},z0={weight:M(`Weight`),distance:M(`Distance`),time:M(`Time`),pressure:M(`Pressure`),force:M(`Force`),energy:M(`Energy`),power:M(`Power`),magnetism:M(`Magnetism`),temperature:M(`Temperature`),volume:M(`Volume`),area:M(`Area`),information:M(`Information`),speed:M(`Speed`)},B0=Object.entries(I0).map(([e,t])=>({value:e,label:V0(t.category)}));function V0(e){return z0[e]??``}function H0(e){for(let[t,n]of Object.entries(R0)){if(t&&!e.startsWith(t))continue;let r=e.slice(t.length),i=I0[r];if(!i&&L0[r]&&(i=I0[L0[r]]),i)return{...i,factor:i.order?n**+i.order:n}}}var U0=l({CONVERT:()=>W0});let W0={description:M(`Converts a numeric value to a different unit of measure.`),args:[V(`value (number)`,M(`the numeric value in start_unit to convert to end_unit`)),V(`start_unit (string)`,M(`The starting unit, the unit currently assigned to value`),B0),V(`end_unit (string)`,M(`The unit of measure into which to convert value`),B0)],compute:function(e,t,n){let r=F(e,this.locale),i=I(t),a=I(n),o=H0(i),s=H0(a);return o?s?o.category===s.category?{value:s.inverseTransform(o.factor*o.transform(r))/s.factor,format:e?.format}:{value:N.GenericError,message:M(`Incompatible units of measure ('%s' vs '%s')`,V0(o.category),V0(s.category))}:{value:N.GenericError,message:M(`Invalid units of measure ('%s')`,a)}:{value:N.GenericError,message:M(`Invalid units of measure ('%s')`,i)}},isExported:!0};var G0=l({CHAR:()=>Y0,CLEAN:()=>X0,CONCATENATE:()=>Z0,EXACT:()=>Q0,FIND:()=>$0,FORMAT_LARGE_NUMBER:()=>e2,JOIN:()=>t2,LEFT:()=>n2,LEN:()=>r2,LOWER:()=>i2,MID:()=>a2,PROPER:()=>o2,REGEXEXTRACT:()=>c2,REGEXREPLACE:()=>l2,REGEXTEST:()=>s2,REPLACE:()=>u2,RIGHT:()=>d2,SEARCH:()=>f2,SPLIT:()=>p2,SUBSTITUTE:()=>m2,TEXT:()=>y2,TEXTAFTER:()=>x2,TEXTBEFORE:()=>S2,TEXTJOIN:()=>h2,TEXTSPLIT:()=>g2,TRIM:()=>_2,UPPER:()=>v2,VALUE:()=>b2});let K0=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,q0=[{value:0,label:M(`Case-sensitive (default)`)},{value:1,label:M(`Case-insensitive`)}],J0=[{value:0,label:M(`Don't match to end (default)`)},{value:1,label:M(`Match to end`)}],Y0={description:M(`Gets character associated with number.`),args:[V(`table_number (number)`,M(`The number of the character to look up from the current Unicode table in decimal format.`))],compute:function(e){let t=Math.trunc(F(e,this.locale));return t<1?new P(M(`The table_number (%s) is out of range.`,t)):{value:String.fromCharCode(t)}},isExported:!0},X0={description:M(`Remove non-printable characters from a piece of text.`),args:[V(`text (string)`,M(`The text whose non-printable characters are to be removed.`))],compute:function(e){let t=I(e),n=``;for(let e of t)e&&e.charCodeAt(0)>31&&(n+=e);return{value:n}},isExported:!0},Z0={description:M(`Appends strings to one another.`),args:[V(`string (string, range<string>, repeating)`,M(`String to append in sequence.`))],compute:function(...e){return{value:ls(e,(e,t)=>e+I(t),``)}},isExported:!0},Q0={description:M(`Tests whether two strings are identical.`),args:[V(`string1 (string)`,M(`The first string to compare.`)),V(`string2 (string)`,M(`The second string to compare.`))],compute:function(e,t){return{value:I(e)===I(t)}},isExported:!0},$0={description:M(`First position of string found in text, case-sensitive.`),args:[V(`search_for (string)`,M(`The string to look for within text_to_search.`)),V(`text_to_search (string)`,M(`The text to search for the first occurrence of search_for.`)),V(`starting_at (number, default=1)`,M(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=I(e),i=I(t),a=F(n,this.locale);if(i===``)return new P(M(`The text_to_search must be non-empty.`));if(a<1)return new P(M(`The starting_at (%s) must be greater than or equal to 1.`,a));let o=i.indexOf(r,a-1);return o===-1?new P(M(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)):{value:o+1}},isExported:!0},e2={description:M(`Apply a large number format`),args:[V(`value (number)`,M(`The number.`)),V(`unit (string, optional)`,M(`The formatting unit. Use 'k', 'm', or 'b' to force the unit`),[{value:`k`,label:M(`Thousand`)},{value:`m`,label:M(`Million`)},{value:`b`,label:M(`Billion`)}])],compute:function(e,t){return{value:F(e,this.locale),format:Ic(e,t,this.locale)}}},t2={description:M(`Concatenates elements of arrays with delimiter.`),args:[V(`delimiter (string)`,M(`The character or string to place between each concatenated value.`)),V(`value_or_array (string, range<string>, repeating)`,M(`Value to be appended using delimiter.`))],compute:function(e,...t){let n=I(e);return{value:ls(t,(e,t)=>(e?e+n:``)+I(t),``)}}},n2={description:M(`Substring from beginning of specified string.`),args:[V(`text (string)`,M(`The string from which the left portion will be returned.`)),V(`number_of_characters (number, optional)`,M(`The number of characters to return from the left side of string.`))],compute:function(e,...t){let n=t.length?F(t[0],this.locale):1;return n<0?new P(M(`The number_of_characters (%s) must be positive or null.`,n)):{value:I(e).substring(0,n)}},isExported:!0},r2={description:M(`Length of a string.`),args:[V(`text (string)`,M(`The string whose length will be returned.`))],compute:function(e){return{value:I(e).length}},isExported:!0},i2={description:M(`Converts a specified string to lowercase.`),args:[V(`text (string)`,M(`The string to convert to lowercase.`))],compute:function(e){return{value:I(e).toLowerCase()}},isExported:!0},a2={description:M(`A segment of a string.`),args:[V(`text (string)`,M(`The string to extract a segment from.`)),V(`starting_at (number)`,M(`The index from the left of string from which to begin extracting. The first character in string has the index 1.`)),V(`extract_length (number)`,M(`The length of the segment to extract.`))],compute:function(e,t,n){let r=I(e),i=F(t,this.locale),a=F(n,this.locale);return i<1?new P(M(`The starting_at argument (%s) must be positive greater than one.`,i.toString())):a<0?new P(M(`The extract_length argument (%s) must be positive or null.`,a)):{value:r.slice(i-1,i+a-1)}},isExported:!0},o2={description:M(`Capitalizes each word in a specified string.`),args:[V(`text_to_capitalize (string)`,M(`The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase.`))],compute:function(e){return{value:I(e).replace(K0,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())}},isExported:!0},s2={description:M(`Checks whether a string matches the supplied regular expression.`),args:[V(`text (string)`,M(`The string to test.`)),V(`pattern (string)`,M(`The regular expression pattern to match against the text.`)),V(`case_sensitivity (number, default=0)`,M(`Whether the match is case-sensitive.`),[{value:0,label:M(`Case-sensitive`)},{value:1,label:M(`Case-insensitive`)}])],compute:function(e,t,n={value:0}){let r=I(e),i=I(t),a=F(n,this.locale);if(i===``)return{value:!0};if(r===``)return{value:!1};if(a!==0&&a!==1)return new P(M(`The case_sensitivity (%s) must be 0 or 1.`,a));let o=a===1?`gi`:`g`,s;try{s=new RegExp(i,o)}catch{return new P(M(`Invalid regular expression`))}return{value:s.test(r)}},isExported:!0},c2={description:M(`Extract text from a string based on the supplied regular expression.`),args:[V(`text (string)`,M(`The string on which you want to extract text.`)),V(`pattern (string)`,M(`The regular expression pattern to match against the text.`)),V(`return_mode (number, default=0)`,M(`0 = first match, 1 = all matches as an array, 2 = capturing groups from the first match as an array.`),[{value:0,label:M(`First match`)},{value:1,label:M(`All matches`)},{value:2,label:M(`Capture groups of first match`)}]),V(`case_sensitivity (number, default=0)`,M(`Whether the match is case-sensitive.`),[{value:0,label:M(`Case-sensitive`)},{value:1,label:M(`Case-insensitive`)}])],computeArray:function(e,t,n={value:0},r={value:0}){let i=I(e),a=I(t),o=F(n,this.locale),s=F(r,this.locale);if(i===``||a===``)return{value:``};if(o<0||o>2)return new P(M(`The return_mode (%s) must be 0, 1 or 2.`,o));if(s!==0&&s!==1)return new P(M(`The case_sensitivity (%s) must be 0 or 1.`,s));let c=s===1?`gi`:`g`,l;try{l=new RegExp(a,c)}catch{return new P(M(`Invalid regular expression`))}let u=[...i.matchAll(l)];return u.length===0?{value:N.NotAvailable,message:M(`No matches found.`)}:o===0?{value:u[0][0]}:o===1?u.map(e=>[{value:e[0]}]):u[0].length<2?new P(M(`No capturing groups found.`)):u[0].slice(1).map(e=>[{value:e}])},isExported:!0},l2={description:M(`Replace text in a string based on the supplied regular expression.`),args:[V(`text (string)`,M(`The string in which you want to replace text.`)),V(`pattern (string)`,M(`The regular expression pattern to match against the text.`)),V(`replacement (string)`,M(`The text to use as the replacement.`)),V(`occurrence (number, default=0)`,M(`0 = replace all matches. A negative number counts from the end.`)),V(`case_sensitivity (number, default=0)`,M(`Whether the match is case-sensitive.`),[{value:0,label:M(`Case-sensitive`)},{value:1,label:M(`Case-insensitive`)}])],compute:function(e,t,n,r={value:0},i={value:0}){let a=I(e),o=I(t),s=I(n),c=F(r,this.locale),l=F(i,this.locale);if(l!==0&&l!==1)return new P(M(`The case_sensitivity (%s) must be 0 or 1.`,l));let u=l===1?`gi`:`g`,d;try{d=new RegExp(o,u)}catch{return new P(M(`Invalid regular expression`))}if(c!==0){let e=[...a.matchAll(d)];if(e.length===0||Math.abs(c)>e.length)return{value:a};let t=c>0?c-1:e.length+c,n=e[t][0].length,r=e[t].index;return{value:a.substring(0,r)+s+a.substring(r+n)}}return{value:a.replace(d,s)}},isExported:!0},u2={description:M(`Replaces part of a text string with different text.`),args:[V(`text (string)`,M(`The text, a part of which will be replaced.`)),V(`position (number)`,M(`The position where the replacement will begin (starting from 1).`)),V(`length (number)`,M(`The number of characters in the text to be replaced.`)),V(`new_text (string)`,M(`The text which will be inserted into the original text.`))],compute:function(e,t,n,r){let i=F(t,this.locale);if(i<1)return new P(M(`The position (%s) must be greater than or equal to 1.`,i));let a=F(n,this.locale);if(a<0)return new P(M(`The length (%s) must be positive or zero.`,a));let o=I(e),s=I(r);return{value:o.substring(0,i-1)+s+o.substring(i-1+a)}},isExported:!0},d2={description:M(`A substring from the end of a specified string.`),args:[V(`text (string)`,M(`The string from which the right portion will be returned.`)),V(`number_of_characters (number, optional)`,M(`The number of characters to return from the right side of string.`))],compute:function(e,...t){let n=t.length?F(t[0],this.locale):1;if(n<0)return new P(M(`The number_of_characters (%s) must be positive or zero.`,n));let r=I(e),i=r.length;return{value:r.substring(i-n,i)}},isExported:!0},f2={description:M(`First position of string found in text, ignoring case.`),args:[V(`search_for (string)`,M(`The string to look for within text_to_search.`)),V(`text_to_search (string)`,M(`The text to search for the first occurrence of search_for.`)),V(`starting_at (number, default=1)`,M(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=I(e).toLowerCase(),i=I(t).toLowerCase(),a=F(n,this.locale);if(i===``)return{value:N.GenericError,message:M(`The text_to_search must be non-empty.`)};if(a<1)return{value:N.GenericError,message:M(`The starting_at (%s) must be greater than or equal to 1.`,a)};let o=i.indexOf(r,a-1);return o===-1?{value:N.GenericError,message:M(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)}:{value:o+1}},isExported:!0},p2={description:M(`Split text by specific character delimiter(s).`),args:[V(`text (string)`,M(`The text to divide.`)),V(`delimiter (string)`,M(`The character or characters to use to split text.`)),V(`split_by_each (boolean, default=true})`,M(`Whether or not to divide text around each character contained in delimiter.`)),V(`remove_empty_text (boolean, default=true)`,M(`Whether or not to remove empty text messages from the split results. The default behavior is to treat consecutive delimiters as one (if TRUE). If FALSE, empty cells values are added between consecutive delimiters.`))],computeArray:function(e,t,n={value:!0},r={value:!0}){let i=I(e),a=Tt(I(t)),o=L(n),s=L(r);if(a.length<=0)return new P(M(`The delimiter (%s) must be not be empty.`,a));let c=o?RegExp(`[${a}]`,`g`):new RegExp(a,`g`),l=i.split(c);return s&&(l=l.filter(e=>e!==``)),ps(hs([l]),e=>({value:e}))},isExported:!1},m2={description:M(`Replaces existing text with new text in a string.`),args:[V(`text_to_search (string)`,M(`The text within which to search and replace.`)),V(`search_for (string)`,M(`The string to search for within text_to_search.`)),V(`replace_with (string)`,M(`The string that will replace search_for.`)),V(`occurrence_number (number, optional)`,M(`The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced.`))],compute:function(e,t,n,r){let i=F(r,this.locale);if(i<0)return new P(M(`The occurrenceNumber (%s) must be positive or null.`,i));let a=I(e),o=I(t);if(o===``)return{value:a};let s=I(n),c=new RegExp(Tt(o),`g`);if(i===0)return{value:a.replace(c,s)};let l=0;return{value:a.replace(c,e=>++l===i?s:e)}},isExported:!0},h2={description:M(`Combines text from multiple strings and/or arrays.`),args:[V(`delimiter (string)`,M(`A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.`)),V(`ignore_empty (boolean)`,M(`A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.`),[{value:!0,label:M(`Ignore empty cells`)},{value:!1,label:M(`Include empty cells (default)`)}]),V(`texts (string, range<string>, repeating)`,M(`Text item to join.`))],compute:function(e,t={value:!0},...n){let r=I(e),i=L(t),a=0;return{value:ls(n,(e,t)=>i&&I(t)===``?e:(a++?e+r:``)+I(t),``)}},isExported:!0},g2={description:M(`Splits text into rows or columns using specified column and row delimiters.`),args:[V(`text (string)`,M(`The text to split.`)),V(`col_delimiter (string, range<string>)`,M(`Character or string to split columns by.`)),V(`row_delimiter (string, range<string>, optional)`,M(`Character or string to split rows by.`)),V(`ignore_empty (boolean, default=false)`,M(`Whether to ignore empty cells.`),[{value:!1,label:M(`Include empty cells (default)`)},{value:!0,label:M(`Ignore empty cells`)}]),V(`match_mode (number, default=0)`,M(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),q0),V(`pad_with (string, default="${N.NotAvailable}")`,M(`The value to use for padding empty cells.`))],computeArray:function(e,t,n,r={value:!1},i={value:0},a=new Io){let o=I(e);if(o.length<=0)return new P(M(`No text to split.`));if(t===void 0&&n===void 0)return new P(M(`At least one delimiter must be provided.`));let s=R(t).flat().map(e=>Tt(I(e))),c=R(n).flat().map(e=>Tt(I(e)));if(s.some(e=>e===``)||c.some(e=>e===``))return new P(M(`The delimiters cannot be empty values.`));let l=L(r),u=F(i,this.locale);if(![0,1].includes(u))return new P(M(`match_mode should be a value of 0 or 1.`));let d=[],f=u===1?`gi`:`g`,p=c.filter(e=>!s.includes(e)),m=p.length?o.split(new RegExp(p.join(`|`),f)):[o];l&&(m=m.filter(e=>e!==``));let h=new RegExp(s.join(`|`),f);for(let e of m){let t=s.length?e.split(h):[e];l&&(t=t.filter(e=>e!==``)),d.push(t.map(e=>({value:e})))}let g=Math.max(...d.map(e=>e.length));for(let e of d)for(;e.length<g;)e.push(a);return hs(d)},isExported:!0},_2={description:M(`Removes space characters.`),args:[V(`text (string)`,M(`The text or reference to a cell containing text to be trimmed.`))],compute:function(e){return{value:pn(I(e))}},isExported:!0},v2={description:M(`Converts a specified string to uppercase.`),args:[V(`text (string)`,M(`The string to convert to uppercase.`))],compute:function(e){return{value:I(e).toUpperCase()}},isExported:!0},y2={description:M(`Converts a number to text according to a specified format.`),args:[V(`number (number)`,M(`The number, date or time to format.`)),V(`format (string)`,M(`The case-sensitive format of the result, enclosed in quotation marks. Examples: "0.00" rounded to 2 decimal places, "hh:mm:ss" for hour:minutes:seconds.`))],compute:function(e,t){return{value:B(F(e,this.locale),{format:I(t),locale:this.locale})}},isExported:!0},b2={description:M(`Converts a string to a numeric value.`),args:[V(`value (number)`,M(`the string to be converted`))],compute:function(e){return{value:F(e,this.locale)}},isExported:!0},x2={description:M(`Returns text that occurs after a given substring or delimiter.`),args:[V(`text (string)`,M(`The source text.`)),V(`delimiter (string)`,M(`The substring after which text will be returned.`)),V(`instance_num (number, default=1)`,M(`The desired instance of the delimiter after which we extract the text. A negative number searches from the end.`)),V(`match_mode (number, default=0)`,M(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),q0),V(`match_end (number, default=0))`,M(`Whether to treat the end of text as a delimiter.`),J0),V(`if_not_found (string, default="${N.NotAvailable}")`,M(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new Io){let o=I(e),s=F(n,this.locale),c=F(r,this.locale),l=F(i,this.locale);if(s===0)return new P(M(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new P(M(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new P(M(`match_end should have a value of 0 or 1.`));let u=I(t);if(u===``)return Math.sign(s)>0?{value:o}:{value:``};let d=c===1?`gi`:`g`,f=Tt(u),p=new RegExp(f,d),m=[...o.matchAll(p)].map(e=>e.index+u.length);if(s<0&&(m=m.reverse()),l&&Math.abs(s)===m.length+1)return Math.sign(s)>0?{value:``}:{value:o};let h=m[Math.abs(s)-1];return h===void 0?a:{value:o.substring(h)}},isExported:!0},S2={description:M(`Returns text that occurs before a given substring or delimiter.`),args:[V(`text (string)`,M(`The source text.`)),V(`delimiter (string)`,M(`The substring after which text will be returned.`)),V(`instance_num (number, default=1)`,M(`The desired instance of the delimiter before which we extract the text. A negative number searches from the end.`)),V(`match_mode (number, default=0)`,M(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),q0),V(`match_end (number, default=0))`,M(`Whether to match a delimiter against the end of the text.`),J0),V(`if_not_found (string, default="${N.NotAvailable}")`,M(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new Io){let o=I(e),s=F(n,this.locale),c=F(r,this.locale),l=F(i,this.locale);if(s===0)return new P(M(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new P(M(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new P(M(`match_end should have a value of 0 or 1.`));let u=I(t);if(u===``)return Math.sign(s)>0?{value:``}:{value:o};let d=c===1?`gi`:`g`,f=Tt(u),p=new RegExp(f,d),m=[...o.matchAll(p)].map(e=>e.index+u.length);if(s<0&&(m=m.reverse()),l&&Math.abs(s)===m.length+1)return Math.sign(s)>0?{value:o}:{value:``};let h=m[Math.abs(s)-1];return h===void 0?a:{value:o.substring(0,h-u.length)}},isExported:!0};var C2=l({HYPERLINK:()=>w2});let w2={description:M(`Creates a hyperlink in a cell.`),args:[V(`url (string)`,M(`The full URL of the link enclosed in quotation marks.`)),V(`link_label (string, optional)`,M(`The text to display in the cell, enclosed in quotation marks.`))],compute:function(e,t){let n=I(e).trim(),r=I(t)||n;return n===``?{value:r}:{value:Rt(r,n)}},isExported:!0},T2=[{name:M(`Array`),functions:Oq},{name:M(`Database`),functions:GX},{name:M(`Date`),functions:sQ},{name:M(`Filter`),functions:GQ},{name:M(`Financial`),functions:ZQ},{name:M(`Info`),functions:o1},{name:M(`Lookup`),functions:F1},{name:M(`Logical`),functions:y1},{name:M(`Math`),functions:iJ},{name:M(`Operator`),functions:a0},{name:M(`Statistical`),functions:bY},{name:M(`Text`),functions:G0},{name:M(`Engineering`),functions:UQ},{name:M(`Web`),functions:C2},{name:M(`Parser`),functions:U0}];for(let e of T2){let t=e.functions;for(let n in t){let r=t[n];r.category=r.category||e.name,n=n.replace(/_/g,`.`),ml.add(n,{isExported:!1,...r})}}let E2={},D2={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:26,HEADER_WIDTH:48,DESKTOP_BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:96,DEFAULT_CELL_HEIGHT:23,SCROLLBAR_WIDTH:15},O2={autoCompleteProviders:wM,autofillModifiersRegistry:ER,autofillRulesRegistry:DR,cellMenuRegistry:KL,colMenuRegistry:fR,errorTypes:Mo,functionRegistry:ml,featurePluginRegistry:BH,iconsOnCellRegistry:KB,statefulUIPluginRegistry:VH,coreViewsPluginRegistry:HH,corePluginRegistry:zH,rowMenuRegistry:yR,sidePanelRegistry:zI,figureRegistry:HS,chartSidePanelComponentRegistry:XM,chartDataSourceSidePanelComponentRegistry:ak,chartComponentRegistry:A_,chartTypeRegistry:Iw,chartSubtypeRegistry:Dg,chartDataSourceRegistry:Fw,topbarMenuRegistry:dU,topbarComponentRegistry:AU,topBarToolBarRegistry:NW,clickableCellRegistry:Sx,otRegistry:gV,inverseCommandRegistry:UH,urlRegistry:Zd,cellPopoverRegistry:Kx,numberFormatMenuRegistry:sU,repeatLocalCommandTransformRegistry:uH,repeatCommandTransformRegistry:lH,clipboardHandlersRegistries:Vx,pivotRegistry:Zb,pivotTimeAdapterRegistry:ay,pivotSidePanelRegistry:BF,pivotNormalizationValueRegistry:Ly,supportedPivotPositionalFormulaRegistry:Wz,pivotToFunctionValueRegistry:Ry,migrationStepRegistry:vE,chartJsExtensionRegistry:Qr,onIterationEndEvaluationRegistry:IB,specificRangeTransformRegistry:_V,unusedDataSourceRegistry:MN},k2={arg:V,isEvaluationError:Uo,toBoolean:L,toJsDate:rs,toNumber:F,toString:I,toNormalizedPivotValue:Ny,toFunctionPivotValue:Fy,toXC:T,toZone:Xn,toUnboundedZone:Yn,toCartesian:Rn,numberToLetters:kn,lettersToNumber:An,UuidGenerator:K,formatValue:B,createCurrencyFormat:kc,ColorGenerator:fp,computeTextWidth:Ep,createEmptyWorkbookData:RE,createEmptySheet:LE,createEmptyExcelSheet:zE,doesCellContainFunction:wn,rgbaToHex:Rf,colorToRGBA:zf,positionToZone:E,isDefined:C,isMatrix:yt,lazy:Yt,genericRepeat:kU,createAction:we,createActions:be,transformRangeData:Br,deepEquals:w,overlap:ur,union:or,isInside:fr,deepCopy:b,expandZoneOnInsertion:nr,reduceZoneOnDeletion:ar,unquote:Ot,getMaxObjectId:Ty,getFirstPivotFunction:AF,getNumberOfPivotFunctions:MF,parseDimension:Oy,isDateOrDatetimeField:ky,makeFieldProposal:NF,periodYearToComparable:iy,insertTokenAfterArgSeparator:FF,insertTokenAfterLeftParenthesis:IF,mergeContiguousZones:Ir,getPivotHighlights:oF,pivotTimeAdapter:oy,UNDO_REDO_PIVOT_COMMANDS:lV,createPivotFormula:My,areDomainArgsFieldsValid:jy,splitReference:Dl,sanitizeSheetName:At,getUniqueText:xn,isNumber:bo,isDateTime:Va,createCustomFields:Wy,schemeToColorScale:hE,isDateTimeFormat:Sc,jsDateToNumber:to,numberToJsDate:$a,DateTime:Da,parseFormat:Ks,isFormula:Sn,domainToColRowDomain:tv,collapseHierarchicalDisplayName:Xy,getCanonicalSymbolName:kt,fuzzyLookup:CM,PositionMap:J_,replaceSymbolInFormula:od,isSingleCellReference:El,computeCachedTextDimension:Ap,createComputeFunction:ol,isMobileOS:_e},A2={isMarkdownLink:It,parseMarkdownLink:zt,markdownLink:Rt,openLink:nf,urlRepresentation:tf},j2={Checkbox:ok,Section:Q,Select:IS,RoundColorPicker:Ck,ChartDataSeries:ck,ChartErrorSection:dk,ChartLabelRange:lk,ChartRangeDataSourceComponent:Ij,ChartTitle:bk,ChartPanel:$M,ChartFigure:BS,ChartJsComponent:ng,ClickableCellSortIcon:X_,ZoomableChartJsComponent:S_,Grid:Uz,GridOverlay:Xx,ScorecardChart:Eg,GaugeChartComponent:O_,LineConfigPanel:FM,BarConfigPanel:pk,PieChartDesignPanel:RM,GenericChartConfigPanel:fk,ChartWithAxisDesignPanel:Ak,GenericZoomableChartDesignPanel:jk,LineChartDesignPanel:IM,GaugeChartConfigPanel:$j,GaugeChartDesignPanel:AM,ScorecardChartConfigPanel:VM,ScorecardChartDesignPanel:HM,GeoChartDesignPanel:NM,RadarChartDesignPanel:zM,WaterfallChartDesignPanel:YM,ComboChartDesignPanel:Xj,FunnelChartDesignPanel:Qj,SunburstChartDesignPanel:UM,TreeMapChartDesignPanel:JM,ChartTypePicker:ZM,FigureComponent:US,MenuPopover:q_,Popover:U_,SelectionInput:WO,StandaloneComposer:kM,ValidationMessages:Ox,AddDimensionButton:bF,PivotDimensionGranularity:SF,PivotDimensionOrder:CF,PivotDimension:_F,PivotLayoutConfigurator:DF,PivotHTMLRenderer:Kz,PivotDeferUpdate:cF,PivotTitleSection:OF,CogWheelMenu:rk,TextInput:JO,SidePanelCollapsible:hk,RadioSelection:Sk,GeoChartRegionSelectSection:jM,ChartMenu:RS,FullScreenFigure:Gz,NumberInput:_k,TopBar:PW,Composer:uM,CalendarButton:lN,Spreadsheet:LW},M2={useDragAndDropListItems:MO,useHighlights:nN,useHighlightsOnHover:tN},N2={Component:O,useExternalListener:Wi,EnvPlugin:Ki,App:Zi},P2={useStoreProvider:ta,DependencyContainer:$i,CellPopoverStore:qx,ComposerFocusStore:Zr,CellComposerStore:fz,FindAndReplaceStore:BN,HighlightStore:Ux,DelayedHoveredCellStore:Dx,HoveredTableStore:Y_,ModelStore:Wr,NotificationStore:TM,RendererStore:Jr,SelectionInputStore:UO,SpreadsheetStore:Yr,useStore:k,useLocalStore:ra,SidePanelStore:VI,PivotSidePanelStore:RF,PivotMeasureDisplayPanelStore:iF,TableAutofillStore:BR,AutofillStore:zR,ClientFocusStore:CR,GridRenderer:OS,ViewportsStore:H,globalStores:PU};function F2(e,t){return ml.add(e,t),{addFunction:(e,t)=>F2(e,t)}}let I2={DEFAULT_LOCALE:z,HIGHLIGHT_COLOR:Ae,PIVOT_STATIC_TABLE_CONFIG:dt,PIVOT_INSERT_TABLE_STYLE_ID:ft,ChartTerms:tb,FIGURE_ID_SPLITTER:`??`,GRID_ICON_EDGE_LENGTH:17,GRID_ICON_MARGIN:2,CHART_TYPES:mE,DARK_MODE_FILTER_STRING:Xf},L2={...Fj,...qz};e.AbstractCellClipboardHandler=TI,e.AbstractChart=rg,e.AbstractFigureClipboardHandler=KK,e.BadExpressionError=No,e.CHART_TYPES=mE,e.CellErrorType=N,e.CellValueType=kd,e.CircularDependencyError=Po,e.ClientDisconnectedError=QV,e.ClipboardMIMEType=Ax,e.CommandResult=Yd,e.CompiledFormula=Sd,e.CorePlugin=KS,e.CoreViewPlugin=CS,e.DEFAULT_LOCALE=z,e.DEFAULT_LOCALES=js,e.DEFAULT_LOCALE_DIGIT_GROUPING=`[3,0]`,e.DIRECTION=xt,e.DispatchResult=qd,e.DivisionByZeroError=zo,e.EvaluationError=P,e.InvalidReferenceError=Fo,e.LocalTransportService=jU,e.Model=UK,e.NEXT_VALUE=Q_,e.NotAvailableError=Io,e.NumberTooLargeError=Bo,e.OrderedLayers=Kr,e.PREVIOUS_VALUE=Z_,e.PivotRuntimeDefinition=Qy,e.Registry=D,e.Revision=ZV,e.SPREADSHEET_DIMENSIONS=D2,e.SplillBlockedError=Ro,e.Spreadsheet=LW,e.SpreadsheetPivotTable=Fb,e.UIPlugin=eH,e.UnknownFunctionError=Lo,e.__info__=E2,e.addFunction=F2,e.addRenderingLayer=qr,e.astToFormula=cz,e.availableConditionalFormatOperators=SN,e.availableDataValidationOperators=LN,e.availableFiltersOperators=lF,e.borderPositions=bt,e.borderStyles=vt,e.canExecuteInReadonly=Kd,e.categories=T2,e.chartHelpers=L2,e.compatibility=N2,e.components=j2,e.composerFocusTypes=St,e.constants=I2,e.convertAstNodes=Su,e.coreTypes=Wd,e.createAutocompleteArgumentsProvider=uq,e.errorTypes=Mo,e.filterDateCriterionOperators=fF,e.filterNumberCriterionOperators=dF,e.filterTextCriterionOperators=uF,e.findCellInNewZone=Cr,e.functionCache=yd,e.getCaretDownSvg=uS,e.getCaretUpSvg=dS,e.helpers=k2,e.hooks=M2,e.invalidSubtotalFormulasCommands=Vd,e.invalidateBordersCommands=Bd,e.invalidateCFEvaluationCommands=zd,e.invalidateChartEvaluationCommands=Ld,e.invalidateDependenciesCommands=Rd,e.invalidateEvaluationCommands=Id,e.isCoreCommand=Gd,e.isHeadersDependant=jd,e.isMatrix=yt,e.isPositionDependent=Pd,e.isRangeDependant=Nd,e.isSheetDependent=Ad,e.isTargetDependent=Md,e.isZoneDependent=Fd,e.iterateAstNodes=Cu,e.links=A2,e.load=CE,e.lockedSheetAllowedCommands=Ud,e.parse=bu,e.parseTokens=xu,e.readonlyAllowedCommands=Hd,e.registries=O2,e.schemeToColorScale=hE,e.setDefaultSheetViewSize=lt,e.setTranslationMethod=ko,e.stores=P2,e.tokenColors=_t,e.tokenize=zl,E2.version=`19.5.0-alpha.8`,E2.date=`2026-08-04T07:11:39.990Z`,E2.hash=`c1baebe`})(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|
|
957
|
+
`),`_rels/.rels`)}function VK(e){let t={},n=[];for(let r of e.sheets){let e=r.name.slice(0,31);e=xn(e,n,{compute:(e,t)=>e.slice(0,31-String(t).length)+t}),n.push(e),e!==r.name&&(t[r.name]=e,r.name=e)}if(!Object.keys(t).length)return e;let r=Object.keys(t).sort((e,t)=>t.length-e.length),i=JSON.stringify(e);for(let e of r){let n=RegExp(`'?${Tt(e)}'?!`,`g`);i=i.replaceAll(n,n=>{let r=t[e];return n.replace(e,r)})}return JSON.parse(i)}function HK(e){for(let t of e.sheets)t.tables=t.tables.filter(e=>mr(Xn(e.range)).numberOfRows>1);return e}var UK=class e extends Qi{corePlugins=[];statefulUIPlugins=[];range;formulasPlugin;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;coreViewPluginConfig;uiPluginConfig;state;selection;getters;coreGetters;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},t={},n=[],r=!1){let i=performance.now();console.debug(`##### Model creation #####`),super(),Ao(),n=jE(e,n);let a=CE(e,r);this.state=new tG,this.config=this.setupConfig(t),this.getters={isReadonly:()=>this.config.mode===`readonly`||this.config.mode===`dashboard`,isDashboard:()=>this.config.mode===`dashboard`},this.session=this.setupSession(a.revisionId),this.coreGetters={},this.range=new ZW(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.getRangeData=this.range.getRangeData.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.coreGetters.recomputeRanges=this.range.recomputeRanges.bind(this.range),this.coreGetters.isRangeValid=this.range.isRangeValid.bind(this.range),this.coreGetters.extendRange=this.range.extendRange.bind(this.range),this.coreGetters.getRangesUnion=this.range.getRangesUnion.bind(this.range),this.coreGetters.removeRangesSheetPrefix=this.range.removeRangesSheetPrefix.bind(this.range),this.coreGetters.copyFormulaStringForSheet=this.range.copyFormulaStringForSheet.bind(this.range),this.formulasPlugin=new XW,this.coreGetters.getAllFormulas=this.formulasPlugin.getAllFormulas.bind(this.formulasPlugin),this.selection=new $W(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.coreViewPluginConfig=this.setupCoreViewPluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of zH.getAll())this.setupCorePlugin(e,a);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(n);for(let e of HH.getAll()){let t=this.setupCoreViewPlugin(e);this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of VH.getAll()){let t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of BH.getAll()){let t=this.setupUiPlugin(e);this.handlers.push(t),this.uiHandlers.push(t)}if(this.config.mode!==`export_verification`&&(this.dispatch(`START`),this.selection.observe(this,{handleEvent:()=>this.trigger(`update`)}),this.setupSessionEvents(),this.joinSession(),t.snapshotRequested||e[`[Content_Types].xml`]&&!this.getters.isReadonly())){let e=performance.now();console.debug(`Snapshot requested`),this.session.snapshot(this.exportData()),console.debug(`Snapshot taken in`,performance.now()-e,`ms`)}console.debug(`Model created in`,performance.now()-i,`ms`),console.debug(`######`)}joinSession(){this.session.join(this.config.client)}async leaveSession({shouldSnapshot:e}={shouldSnapshot:!0}){let t=e&&!this.getters.isReadonly()?Yt(()=>this.exportData()):void 0;await this.session.leave(t)}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)}for(let n of e.layers)this.renderers[n]||(this.renderers[n]=[]),this.renderers[n].push(t);return t}setupCoreViewPlugin(e){let t=new e(this.coreViewPluginConfig);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)}return 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 $V(qW({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{if(!this.checkDispatchAllowedRemoteCommand(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,new RW(this.getters))}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:K.smallUuid(),name:M(`Anonymous`).toString()},n=e.transportService||new jU,r=e.mode===`readonly`||e.mode===`dashboard`||e.mode===`export_verification`;return{...e,mode:e.mode||`normal`,custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:r?new zW(n):n,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger(`notify-ui`,e),raiseBlockingErrorUI:e=>this.trigger(`raise-error-ui`,{text:e}),customColors:e.customColors||[]}}setupExternalConfig(e){let t=e.loadLocales||(()=>Promise.resolve(js));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,formulasPlugin:this.formulasPlugin,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,custom:this.config.custom,external:this.config.external}}setupCoreViewPluginConfig(){return{getters:this.getters,stateObserver:this.state,custom:this.config.custom,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,canDispatch:this.canDispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external,colorScheme:this.config.colorScheme}}checkDispatchAllowed(e){let t=Gd(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return this.processCommandResults(t)}processCommandResults(e){return e.some(e=>e!==`Success`)?new qd(e.flat()):qd.Success}checkDispatchAllowedRemoteCommand(e){let t=this.coreHandlers.map(t=>t.allowDispatch(e));return this.processCommandResults(t)}checkDispatchAllowedCoreCommand(e){return this.handlers.map(t=>t.allowDispatch(e))}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,this.trigger(`command-finalized`)}canDispatch=(e,t)=>this.checkDispatchAllowed(WK(e,t));dispatch=(e,t)=>{let n=WK(e,t),r=this.status;if(this.getters.isReadonly()&&!Kd(n))return new qd(`Readonly`);if(!this.session.canApplyOptimisticUpdate())return new qd(`WaitingSessionConfirmation`);switch(r){case 0:let t=this.checkDispatchAllowed(n);if(!t.isSuccessful)return this.trigger(`update`),this.trigger(`command-rejected`,{command:n,result:t}),t;this.status=1;let{changes:r,commands:i}=this.state.recordChanges(()=>{let t=performance.now();Gd(n)&&this.state.addCommand(n),this.dispatchToHandlers(this.handlers,n),this.finalize();let r=performance.now()-t;r>5&&console.debug(e,r,`ms`)});this.session.save(n,i,r),this.status=0,this.trigger(`update`);break;case 1:if(Gd(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(Gd(n))throw Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,n)}return qd.Success};dispatchFromCorePlugin=(e,t)=>{let n=WK(e,t),r=this.status;this.status=2;let i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,n),this.status=r,qd.Success};dispatchToHandlers(e,t){let n=Gd(t);for(let r of e)!n&&r instanceof KS||r.beforeHandle(t);for(let r of e)!n&&r instanceof KS||r.handle(t);this.trigger(`command-dispatched`,t)}drawLayer(e,t){let n=this.renderers[t];if(n)for(let r of n)e.ctx.save(),r.drawLayer(e,t),e.ctx.restore()}exportData(){let t=this._exportData(!0),n=this._exportData(!1),r={...this.config,mode:`export_verification`,client:{id:`exporter`,name:`exporter`},snapshotRequested:!1,transportService:new jU};return w(n,new e(b(t),r)._exportData(!1))?t:(n.isNotSquishable=!0,n)}_exportData(e){let t=RE();for(let n of this.handlers)n instanceof KS&&n.export(t,e);return t.revisionId=this.session.getRevisionId()||`START_REVISION`,t=b(t),t}updateMode(e){this.config.mode=e,this.trigger(`update`)}async exportXLSX(){this.dispatch(`EVALUATE_CELLS`);let e=BE();for(let t of this.handlers)t instanceof SS&&await t.exportForExcel(e);return e=b(e),MK(e)}};function WK(e,t={}){let n=b(t);return n.type=e,n}var GK=class extends TI{queuedBordersToAdd={};copy(e){let t=e.sheetId;if(e.zones.length===0)return;let{rowsIndexes:n,columnsIndexes:r}=e,i=[];for(let e of n){let n=[];for(let i of r){let r={col:i,row:e,sheetId:t};n.push(this.getters.getCellBorder(r))}i.push(n)}return{borders:i}}paste(e,t,n){let r=e.sheetId;if(n.pasteOption===`asValue`)return;let i=e.zones;if(!n.isCutOperation)this.pasteFromCopy(r,i,t.borders);else{let{left:e,top:n}=i[0];this.pasteZone(r,e,n,t.borders)}this.executeQueuedChanges(r)}pasteZone(e,t,n,r){for(let[i,a]of r.entries())for(let[r,o]of a.entries()){let a={col:t+r,row:n+i,sheetId:e};this.pasteBorder(o,a)}}pasteBorder(e,t){let n={...this.getters.getCellBorder(t),...e},r=JSON.stringify(n);this.queuedBordersToAdd[r]||(this.queuedBordersToAdd[r]=[]),this.queuedBordersToAdd[r].push(E(t))}executeQueuedChanges(e){for(let t in this.queuedBordersToAdd){let n=this.queuedBordersToAdd[t],r=JSON.parse(t),i=zn(n,[]);this.dispatch(`SET_BORDERS_ON_TARGET`,{sheetId:e,target:i,border:r})}this.queuedBordersToAdd={}}},KK=class extends wI{copy(e){}getCopyRect(e){return L_(...e.figureIds.map(t=>this.getters.getFigure(e.sheetId,t)).filter(C).map(t=>this.getters.getFigureUI(e.sheetId,t)))}},qK=class extends KK{copy(e){let t=e.sheetId,n=[],r=this.getCopyRect(e);for(let i of e.figureIds){let e=this.getters.getFigure(t,i);if(!e)throw Error(`No figure for the given id: ${i}`);if(e.tag!==`carousel`)continue;let a={...e},o=this.getters.getCarousel(i),{x:s,y:c}=this.getters.getFigureUI(t,e),l={};for(let e of o.items)if(e.type===`chart`){let t=this.getters.getChart(e.chartId);if(!t)throw Error(`No chart for the given id: ${e.chartId}`);l[e.chartId]=t}n.push({figureId:i,copiedFigure:a,copiedCarousel:o,copiedCharts:l,copiedSheetId:t,offset:{x:s-r.x,y:c-r.y}})}return{figures:n,figureIds:e.figureIds}}getPasteTarget(e,t,n,r){let i={};for(let e of n.figures)i[e.figureId]=K.smallUuid();return{zones:[],figureIds:i,sheetId:e}}paste(e,t,n){if(!e.figureIds)return;let{zones:r}=e,i=e.sheetId;for(let a of t.figures){let o=e.figureIds[a.figureId],{width:s,height:c}=a.copiedFigure,{col:l,row:u,offset:d}=a_(this.getters,i,{col:r[0].left,row:r[0].top},{...a.copiedFigure,offset:a.offset});this.dispatch(`CREATE_CAROUSEL`,{figureId:o,sheetId:i,definition:{items:[]},col:l,row:u,offset:d,size:{height:c,width:s}});let f=b(a.copiedCarousel.items);for(let e of f){if(e.type!==`chart`)continue;let t=a.copiedCharts[e.chartId],n=K.smallUuid(),r=jO.fromDefinition(this.getters,i,t.copyInSheetId(i)).getDefinition();this.dispatch(`CREATE_CHART`,{figureId:o,chartId:n,sheetId:i,definition:r}),e.chartId=n}this.dispatch(`UPDATE_CAROUSEL`,{sheetId:i,figureId:o,definition:this.getters.carouselToCarouselData({...a.copiedCarousel,items:f})}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:a.copiedSheetId,figureId:a.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:o,selectMultiple:t.figureIds.length>1})}}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},JK=class extends KK{copy(e){let t=e.sheetId,n=[],r=this.getCopyRect(e);for(let i of e.figureIds){let e=this.getters.getFigure(t,i);if(!e)throw Error(`No figure for the given id: ${i}`);if(e.tag!==`chart`)continue;let a={...e},{x:o,y:s}=this.getters.getFigureUI(t,e),c=this.getters.getChartFromFigureId(i);if(!c)throw Error(`No chart for the given id: ${i}`);n.push({figureId:i,copiedFigure:a,copiedChart:c,offset:{x:o-r.x,y:s-r.y}})}return{figures:n,figureIds:e.figureIds}}getPasteTarget(e,t,n,r){let i={};for(let e of n.figures)i[e.figureId]=K.smallUuid();return{zones:[],figureIds:i,sheetId:e}}paste(e,t,n){if(!e.figureIds)return;let{zones:r}=e,i=e.sheetId;for(let a of t.figures){let o=e.figureIds[a.figureId],{width:s,height:c}=a.copiedFigure,l=a.copiedChart,u=jO.fromDefinition(this.getters,i,l.copyInSheetId(i)).getDefinition();u=jO.fromStrDefinition(this.getters,i,u).getDefinition();let{col:d,row:f,offset:p}=a_(this.getters,i,{col:r[0].left,row:r[0].top},{...a.copiedFigure,offset:a.offset});this.dispatch(`CREATE_CHART`,{figureId:o,chartId:K.smallUuid(),sheetId:i,definition:u,col:d,row:f,offset:p,size:{height:c,width:s}}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:a.copiedChart.sheetId,figureId:a.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:o,selectMultiple:t.figureIds.length>1})}}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},YK=class extends TI{queuedChanges={};copy(e){if(!e.zones.length)return;let{rowsIndexes:t,columnsIndexes:n}=e,r=e.sheetId,i=[];for(let e of t){let t=[];for(let i of n){let n=Array.from(this.getters.getRulesByCell(r,i,e));t.push({position:{col:i,row:e,sheetId:r},rules:n})}i.push(t)}return{cfRules:i}}paste(e,t,n){if(this.queuedChanges={},n.pasteOption===`asValue`)return;let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t):this.pasteFromCopy(i,r,t.cfRules,n),this.executeQueuedChanges()}pasteFromCut(e,t,n){let r=t[0];this.pasteZone(e,r.left,r.top,n.cfRules,{isCutOperation:!0})}pasteZone(e,t,n,r,i){for(let[a,o]of r.entries())for(let[r,s]of o.entries()){let o={col:t+r,row:n+a,sheetId:e};this.pasteCf(s,o,i?.isCutOperation)}}pasteCf(e,t,n){if(e?.rules&&e.rules.length>0){let r=E(e.position),i=E(t);for(let a of e.rules){let o=[];if(n&&o.push(r),e.position.sheetId===t.sheetId)this.adaptCFRules(e.position.sheetId,a,[i],o);else{this.adaptCFRules(e.position.sheetId,a,[],o);let n=this.getCFToCopyTo(t.sheetId,a);this.adaptCFRules(t.sheetId,n,[i],[])}}}}adaptCFRules(e,t,n,r){this.queuedChanges[e]||(this.queuedChanges[e]=[]);let i=this.queuedChanges[e].find(e=>e.cf.id===t.id);i?(i.toAdd.push(...n),i.toRemove.push(...r)):this.queuedChanges[e].push({toAdd:n,toRemove:r,cf:t})}executeQueuedChanges(){for(let e in this.queuedChanges)for(let{toAdd:t,toRemove:n,cf:r}of this.queuedChanges[e]){let i=this.getters.getAdaptedCfRanges(e,r,t,n);if(i){if(i.length===0){this.dispatch(`REMOVE_CONDITIONAL_FORMAT`,{id:r.id,sheetId:e});continue}this.dispatch(`ADD_CONDITIONAL_FORMAT`,{cf:{id:r.id,rule:r.rule,stopIfTrue:r.stopIfTrue},ranges:i,sheetId:e})}}}getCFToCopyTo(e,t){let n=this.getters.getConditionalFormats(e).find(e=>e.stopIfTrue===t.stopIfTrue&&w(e.rule,t.rule)),r=this.queuedChanges[e];return!n&&r&&(n=r.find(e=>e.cf.stopIfTrue===t.stopIfTrue&&w(e.cf.rule,t.rule))?.cf),n||{...t,id:K.smallUuid(),ranges:[]}}},XK=class extends TI{queuedChanges={};copy(e){let{rowsIndexes:t,columnsIndexes:n}=e,r=e.sheetId,i=[];for(let e of t){let t=[];for(let i of n){let n={sheetId:r,col:i,row:e},a=this.getters.getValidationRuleForCell(n);t.push({position:n,rule:a})}i.push(t)}return{dvRules:i}}paste(e,t,n){if(this.queuedChanges={},n.pasteOption)return;let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t):this.pasteFromCopy(i,r,t.dvRules),this.executeQueuedChanges()}pasteFromCut(e,t,n){let r=t[0];this.pasteZone(e,r.left,r.top,n.dvRules,{isCutOperation:!0})}pasteZone(e,t,n,r,i){for(let[a,o]of r.entries())for(let[r,s]of o.entries()){let o={col:t+r,row:n+a,sheetId:e};this.pasteDataValidation(s,o,i?.isCutOperation)}}pasteDataValidation(e,t,n){if(e){let r=E(t),i=E(e.position),a=e.rule;if(!a){let e=this.getters.getValidationRuleForCell(t);e&&this.adaptDataValidationRule(t.sheetId,e,[],[r]);return}let o=[];if(n&&o.push(i),e.position.sheetId===t.sheetId){let n=this.getDataValidationRuleToCopyTo(t.sheetId,a,!1);this.adaptDataValidationRule(e.position.sheetId,n,[r],o)}else{let n=this.getters.getValidationRuleForCell(e.position);n&&this.adaptDataValidationRule(e.position.sheetId,n,[],o);let i=this.getDataValidationRuleToCopyTo(t.sheetId,a);this.adaptDataValidationRule(t.sheetId,i,[r],[])}}}getDataValidationRuleToCopyTo(e,t,n=!0){let r=this.getters.getDataValidationRules(e).find(e=>w(t.criterion,e.criterion)&&t.isBlocking===e.isBlocking),i=this.queuedChanges[e];return!r&&i&&(r=i.find(e=>w(t.criterion,e.rule.criterion)&&t.isBlocking===e.rule.isBlocking)?.rule),r||{...t,id:n?K.smallUuid():t.id,ranges:[]}}adaptDataValidationRule(e,t,n,r){this.queuedChanges[e]||(this.queuedChanges[e]=[]);let i=this.queuedChanges[e].find(e=>e.rule.id===t.id);i?(i.toAdd.push(...n),i.toRemove.push(...r)):this.queuedChanges[e].push({toAdd:n,toRemove:r,rule:t})}executeQueuedChanges(){for(let e in this.queuedChanges)for(let{toAdd:t,toRemove:n,rule:r}of this.queuedChanges[e]){let i=zn([...zn(r.ranges.map(e=>e.zone),n),...t],[]);if(i.length===0){this.dispatch(`REMOVE_DATA_VALIDATION_RULE`,{sheetId:e,id:r.id});continue}this.dispatch(`ADD_DATA_VALIDATION_RULE`,{rule:{id:r.id,criterion:r.criterion,isBlocking:r.isBlocking},ranges:i.map(t=>this.getters.getRangeDataFromZone(e,t)),sheetId:e})}}},ZK=class extends TI{copy(e){let t={style:{},format:{},width:e.columnsIndexes.length,height:e.rowsIndexes.length,sheetId:e.sheetId,zones:e.clippedZones};t.format={sheetDefault:this.getters.getDefaultFormat(e.sheetId,`SHEET`,void 0)??``,colDefault:[],rowDefault:[]};let n=0;for(let r of e.columnsIndexes){let i=this.getters.getDefaultFormat(e.sheetId,`COL`,r);i&&t.format.colDefault&&(t.format.colDefault[n]=i),n++}let r=0;for(let n of e.rowsIndexes){let i=this.getters.getDefaultFormat(e.sheetId,`ROW`,n);i&&t.format.rowDefault&&(t.format.rowDefault[r]=i),r++}for(let n in Ke){t.style[n]={sheetDefault:this.getters.getDefaultStyle(e.sheetId,n,`SHEET`,void 0)??Ke[n],colDefault:[],rowDefault:[]};let r=0;for(let i of e.columnsIndexes){let a=this.getters.getDefaultStyle(e.sheetId,n,`COL`,i);a!==void 0&&(t.style[n].colDefault[r]=a),r++}let i=0;for(let r of e.rowsIndexes){let a=this.getters.getDefaultStyle(e.sheetId,n,`ROW`,r);a!==void 0&&(t.style[n].rowDefault[i]=a),i++}}return t}adaptContentToZone(e,t){let n=Math.max(Math.floor((e.right-e.left+1)/t.width),1),r=Math.max(Math.floor((e.bottom-e.top+1)/t.height),1);if(n===1&&r===1)return t;let i=b(t);i.height*=r,i.width*=n,r>1&&i.format.rowDefault&&(i.format.rowDefault.length=t.height,i.format.rowDefault=On(i.format.rowDefault,r)),n>1&&i.format.colDefault&&(i.format.colDefault.length=t.width,i.format.colDefault=On(i.format.colDefault,n));for(let e in t.style)r>1&&i.style[e].rowDefault&&(i.style[e].rowDefault.length=t.height,i.style[e].rowDefault=On(i.style[e].rowDefault,r)),n>1&&i.style[e].colDefault&&(i.style[e].colDefault.length=t.width,i.style[e].colDefault=On(i.style[e].colDefault,n));return i}paste(e,t,n){let r=e.sheetId;if(n.pasteOption===`asValue`)return;let i=e.zones;if(n.isCutOperation){this.clearClippedZones(t);let{left:e,top:n}=i[0];this.pasteStyle(r,e,n,t.width,t.height,t.style),this.pasteFormat(r,e,n,t.width,t.height,t.format)}else for(let e of i){let n=this.adaptContentToZone(e,t);this.pasteStyle(r,e.left,e.top,n.width,n.height,n.style),this.pasteFormat(r,e.left,e.top,n.width,n.height,n.format)}}clearClippedZones(e){this.dispatch(`CLEAR_FORMATTING`,{sheetId:e.sheetId,target:e.zones})}pasteStyle(e,t,n,r,i,a){let o=En({}),s={},c=0;function l(e,t){let n=`${e.left}:${e.right}:${e.top}:${e.bottom}`;s[n]=[e,c++],o.set(n,{...o.get(n),...t})}l({left:t,right:t+r-1,top:n,bottom:n+i-1},Ke);for(let e in a)l({left:t,right:t+r-1,top:n,bottom:n+i-1},{[e]:a[e].sheetDefault});for(let e in a)for(let r in a[e].colDefault){let o=parseInt(r);l({left:t+o,right:t+o,top:n,bottom:n+i-1},{[e]:a[e].colDefault[r]})}for(let e in a)for(let i in a[e].rowDefault){let o=parseInt(i);l({left:t,right:t+r-1,top:n+o,bottom:n+o},{[e]:a[e].rowDefault[i]})}let u=[];for(let[e,[t,n]]of Object.entries(s)){let r=o.get(e);Wt(r)||u.push([n,t,r])}u.sort((e,t)=>e[0]-t[0]);for(let[t,n,r]of u)this.dispatch(`SET_FORMATTING`,{sheetId:e,target:[n],style:r})}pasteFormat(e,t,n,r,i,a){let o={},s={},c=0;function l(e,t){let n=`${e.left}:${e.right}:${e.top}:${e.bottom}`;s[n]=[e,c++],o[n]=t}l({left:t,right:t+r-1,top:n,bottom:n+i-1},a.sheetDefault??``);for(let e in a.colDefault){let r=parseInt(e);l({left:t+r,right:t+r,top:n,bottom:n+i-1},a.colDefault[e])}for(let e in a.rowDefault){let i=parseInt(e);l({left:t,right:t+r-1,top:n+i,bottom:n+i},a.rowDefault[e])}let u=[];for(let[e,[t,n]]of Object.entries(s)){let r=o[e];r!==void 0&&u.push([n,t,r])}u.sort((e,t)=>e[0]-t[0]);for(let[t,n,r]of u)this.dispatch(`SET_FORMATTING`,{sheetId:e,target:[n],format:r})}},QK=class extends KK{copy(e){let t=e.sheetId,n=[],r=this.getCopyRect(e);for(let i of e.figureIds){let e=this.getters.getFigure(t,i);if(!e)throw Error(`No figure for the given id: ${i}`);if(e.tag!==`image`)continue;let a={...e},{x:o,y:s}=this.getters.getFigureUI(t,e),c=b(this.getters.getImage(i));n.push({figureId:i,copiedFigure:a,copiedImage:c,sheetId:t,offset:{x:o-r.x,y:s-r.y}})}return{figures:n,figureIds:e.figureIds}}getPasteTarget(e,t,n,r){let i={};for(let e of n.figures)i[e.figureId]=K.smallUuid();return{sheetId:e,zones:[],figureIds:i}}paste(e,t,n){if(!e.figureIds)return;let{zones:r}=e;for(let i of t.figures){let a=e.figureIds[i.figureId],o=this.getters.getActiveSheetId(),{width:s,height:c}=i.copiedFigure,l=b(i.copiedImage),{col:u,row:d,offset:f}=a_(this.getters,o,{col:r[0].left,row:r[0].top},{...i.copiedFigure,offset:i.offset});this.dispatch(`CREATE_IMAGE`,{figureId:a,sheetId:o,col:u,row:d,offset:f,size:{height:c,width:s},definition:l}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:i.sheetId,figureId:i.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:a,selectMultiple:t.figureIds.length>1})}}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},$K=class extends TI{copy(e){let t=this.getters.getActiveSheetId(),{rowsIndexes:n,columnsIndexes:r}=e,i=[];for(let e of n){let n=[];for(let i of r){let r={col:i,row:e,sheetId:t};n.push(this.getters.getMerge(r))}i.push(n)}return{merges:i,sheetId:t}}paste(e,t,n){if(n.isCutOperation){let e=t.merges.flat().filter(C);this.dispatch(`REMOVE_MERGE`,{sheetId:t.sheetId,target:e})}this.pasteFromCopy(e.sheetId,e.zones,t.merges,n)}pasteZone(e,t,n,r){for(let[i,a]of r.entries())for(let[r,o]of a.entries()){let a={col:t+r,row:n+i,sheetId:e};this.pasteMerge(o,a)}}pasteMerge(e,t){if(!e||this.getters.isInMerge(t))return;let{sheetId:n,col:r,row:i}=t;this.dispatch(`ADD_MERGE`,{sheetId:n,force:!0,target:[{left:r,top:i,right:r+e.right-e.left,bottom:i+e.bottom-e.top}]})}},eq=class extends TI{copy(e){return{zones:e.clippedZones,sheetId:e.sheetId}}paste(e,t,n){if(n.isCutOperation){let n=e.zones[0];this.dispatch(`MOVE_RANGES`,{target:t.zones,sheetId:t.sheetId,sheetName:this.getters.getSheetName(t.sheetId),targetSheetId:e.sheetId,col:n.left,row:n.top})}}},tq=class extends TI{isPasteAllowed(e,t,n,r){if(!(`cells`in n))return`Success`;let{xSplit:i,ySplit:a}=this.getters.getPaneDivisions(e);return kr(Px(t,n.cells),i,a)?`FrozenPaneOverlap`:`Success`}},nq=class extends TI{copy(e,t,n=`copyPaste`){let r=e.sheetId,{rowsIndexes:i,columnsIndexes:a,zones:o}=e,s=new Set,c=[];for(let e of i){let l=[];c.push(l);for(let c of a){let a={col:c,row:e,sheetId:r},u=this.getters.getTable(a);if(!u){l.push({});continue}let d=this.getters.getCoreTable(a),f=d?.range.zone,p;if(!s.has(u.id)&&d&&f&&o.some(e=>pr(f,e))){s.add(u.id);let{numberOfRows:e}=mr(f);for(let n=f.top;n<=f.bottom;n++)!t&&!i.includes(n)&&e--;let n=d.range,r=this.getters.extendRange(d.range,`ROW`,n.zone.top+e-1-n.zone.bottom);p={range:this.getters.getRangeData(r),config:d.config,type:d.type}}if(u.isPivotTable){let t=u.range.zone.top===e&&u.range.zone.left===c,n=o.some(e=>pr(u.range.zone,e));(t||n)&&s.add(u.id)}n!==`shiftCells`&&l.push({table:p,style:this.getTableStyleToCopy(a),isWholeTableCopied:s.has(u.id)})}}return{tableCells:c,sheetId:e.sheetId}}getTableStyleToCopy(e){let t=tn({...this.getters.getCellTableStyle(e),hideGridLines:!1}),n=this.getters.getCellStyle(e),r=this.getters.getCellTableBorder(e),i=this.getters.getCellBorder(e);return{style:{...t,...tn(n)},border:{...r,...tn(i)}}}paste(e,t,n){let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t,n):this.pasteFromCopy(i,r,t.tableCells,n)}pasteFromCut(e,t,n,r){for(let e of n.tableCells)for(let t of e)t.table&&this.dispatch(`REMOVE_TABLE`,{sheetId:n.sheetId,target:[this.getters.getRangeFromRangeData(t.table.range).zone]});let i=t[0];this.pasteZone(e,i.left,i.top,n.tableCells,r)}pasteZone(e,t,n,r,i){for(let a=0;a<r.length;a++){let o=r[a];for(let r=0;r<o.length;r++){let s=o[r];if(!s)continue;let c={col:t+r,row:n+a,sheetId:e};this.pasteTableCell(e,s,c,i)}}if(r.length===1)for(let i=0;i<r[0].length;i++)this.dispatch(`AUTOFILL_TABLE_COLUMN`,{col:t+i,row:n,sheetId:e})}pasteTableCell(e,t,n,r){if(t.table&&!r?.pasteOption){let{range:r}=t.table,i=mr(this.getters.getRangeFromRangeData(r).zone),a={left:n.col,top:n.row,right:n.col+i.numberOfCols-1,bottom:n.row+i.numberOfRows-1};this.dispatch(`CREATE_TABLE`,{sheetId:n.sheetId,ranges:[this.getters.getRangeDataFromZone(e,a)],config:t.table.config,tableType:t.table.type})}this.getters.getCoreTable(n)||r?.pasteOption===`asValue`||(!r?.pasteOption&&!t.isWholeTableCopied||r?.pasteOption===`onlyFormat`)&&(t.style?.style&&this.dispatch(`UPDATE_CELL`,{...n,style:t.style.style}),t.style?.border&&this.dispatch(`SET_BORDER`,{...n,border:t.style.border}))}};Vx.figureHandlers.add(`chart`,JK).add(`image`,QK).add(`carousel`,qK),Vx.cellHandlers.add(`dataValidation`,XK).add(`default`,ZK).add(`cell`,EI).add(`sheet`,tq).add(`merge`,$K).add(`border`,GK).add(`table`,nq).add(`conditionalFormat`,YK).add(`references`,eq);var rq=class extends O{static maxSize={maxHeight:80};static template=`o-spreadsheet-ErrorToolTip`;props=(0,t.useProps)({cellPosition:j.CellPosition(),onClosed:j.function().optional()});viewStore;setup(){this.viewStore=k(H)}get dataValidationErrorMessage(){return this.env.model.getters.getInvalidDataValidationMessage(this.props.cellPosition)}get evaluationError(){let e=this.env.model.getters.getEvaluatedCell(this.props.cellPosition);if(e.message)return e}get errorOriginPositionString(){if(this.env.model.getters.isDashboard())return``;let e=this.evaluationError?.errorOriginPosition;if(!e||w(e,this.props.cellPosition))return``;let t=e.sheetId;return this.env.model.getters.getRangeString(this.env.model.getters.getRangeFromZone(t,E(e)),this.viewStore.displayedSheetId)}selectCell(){let e=this.evaluationError?.errorOriginPosition;if(!e)return;let t=this.env.model.getters.getActiveSheetId();e.sheetId!==t&&this.env.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:t,sheetIdTo:e.sheetId}),this.env.model.selection.selectCell(e.col,e.row)}get isSpillErrorBecauseOfMissingHeaders(){let e=this.evaluationError;return e?.value===N.SpilledBlocked&&!e.errorOriginPosition&&!this.env.model.getters.getSpreadZone(this.props.cellPosition,{ignoreSpillError:!0})}getMissingHeadersForSpread(){if(!this.isSpillErrorBecauseOfMissingHeaders)return;let e=this.env.model.getters.getCell(this.props.cellPosition);if(!e||!e.isFormula)return;let t=e.compiledFormula.toFormulaString(this.env.model.getters);return Tn(this.env.model.getters,this.props.cellPosition,t)}addMissingHeaders({missingCols:e,missingRows:t}){let n=this.props.cellPosition.sheetId;e>0&&this.env.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:n,sheetName:this.env.model.getters.getSheetName(n),dimension:`COL`,base:this.env.model.getters.getNumberCols(n)-1,position:`after`,quantity:e+20}),t>0&&this.env.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:n,sheetName:this.env.model.getters.getSheetName(n),dimension:`ROW`,base:this.env.model.getters.getNumberRows(n)-1,position:`after`,quantity:t+50})}getAddMissingHeadersButtonText(e){return e.missingCols>0&&e.missingRows>0?M(`Add missing columns and rows`):e.missingCols>0?M(`Add missing columns`):M(`Add missing rows`)}};let iq={onHover:(e,t)=>{let n=t.getEvaluatedCell(e);return n.type===`error`&&n.message||t.getInvalidDataValidationMessage(e)?{isOpen:!0,props:{cellPosition:e},Component:rq,cellCorner:`top-right`}:{isOpen:!1}}};var aq=class extends O{static template=`o-spreadsheet-FilterMenu`;static components={FilterMenuValueList:hF,SidePanelCollapsible:hk,FilterMenuCriterion:pF};props=(0,t.useProps)({filterPosition:j.Position(),onClosed:j.function().optional()});state;criterionCategory=`text`;updatedCriterionValue;viewStore;setup(){this.viewStore=k(H),(0,t.onWillUpdateProps)(e=>{w(e.filterPosition,this.props.filterPosition)||(this.updatedCriterionValue=void 0,this.criterionCategory=this.getCriterionCategory(e.filterPosition),this.state.values=this.getFilterHiddenValues(e.filterPosition))}),this.state=(0,t.proxy)({values:this.getFilterHiddenValues(this.props.filterPosition)}),this.criterionCategory=this.getCriterionCategory(this.props.filterPosition)}get isSortable(){if(!this.table)return!1;let e=this.env.model.getters.getCoreTableMatchingTopLeft(this.table.range.sheetId,this.table.range.zone);return!this.env.model.getters.isReadonly()&&e?.type!==`dynamic`}get table(){let e=this.viewStore.displayedSheetId,t=this.props.filterPosition;return this.env.model.getters.getTable({sheetId:e,...t})}get filterValueType(){let e=this.viewStore.displayedSheetId,t=this.props.filterPosition;return this.env.model.getters.getFilterValue({sheetId:e,...t})?.filterType}getCriterionCategory(e){let t=this.viewStore.displayedSheetId,n=this.env.model.getters.getFilter({sheetId:t,...e});if(!n||!n.filteredRange)return`text`;let r={text:0,number:0,date:0},i=n.filteredRange.zone;for(let n=i.top;n<=i.bottom&&!(n>100);n++){let i=this.env.model.getters.getEvaluatedCell({sheetId:t,row:n,col:e.col});i.type===`text`||i.type===`boolean`?r.text++:i.type===`number`&&(i.format&&Sc(i.format)?r.date++:r.number++)}let a=Math.max(r.text,r.number,r.date);return Object.keys(r).find(e=>r[e]===a)||`text`}onUpdateHiddenValues(e){this.updatedCriterionValue={filterType:`values`,hiddenValues:e}}onCriterionChanged(e){this.updatedCriterionValue=e}confirm(){if(!this.updatedCriterionValue){this.props.onClosed?.();return}let e=this.props.filterPosition;this.env.model.dispatch(`UPDATE_FILTER`,{...e,sheetId:this.viewStore.displayedSheetId,value:this.updatedCriterionValue}),this.props.onClosed?.()}get criterionOperators(){return this.criterionCategory===`date`?fF:this.criterionCategory===`number`?dF:uF}cancel(){this.props.onClosed?.()}sortFilterZone(e){let t=this.props.filterPosition,n=this.table?.range.zone;if(!t||!n||n.top===n.bottom)return;let r=this.viewStore.displayedSheetId,i={...n,top:n.top+1},a={col:t.col,row:i.top};JL(this.env,r,a,i,e,{emptyCellAsZero:!0,sortHeaders:!0}),this.props.onClosed?.()}getFilterHiddenValues(e){let t=this.viewStore.displayedSheetId,n=this.env.model.getters.getFilter({sheetId:t,...e});if(!n?.filteredRange)return[];let r=this.env.model.getters.getFilterValue({sheetId:t,...e}),i=_r(n.filteredRange.zone);r?.filterType!==`criterion`&&(i=i.filter(e=>!this.env.model.getters.isRowHidden(t,e.row)));let a=i.map(e=>this.env.model.getters.getEvaluatedCell({sheetId:t,...e}).formattedValue),o=r?.filterType===`values`?r.hiddenValues:[],s=new Set(o.map(Lp)),c=new Set,l=[],u=e=>{let t=Lp(e);c.has(t)||(l.push({string:e||``,checked:r?.filterType===`criterion`?!1:!s.has(t),normalizedValue:t}),c.add(t))};return a.forEach(u),o.forEach(u),l.sort((e,t)=>e.normalizedValue.localeCompare(t.normalizedValue,void 0,{numeric:!0,sensitivity:`base`}))}getFilterCriterionValue(e){let t=this.viewStore.displayedSheetId,n=this.env.model.getters.getFilterCriterionValue({sheetId:t,...e});return n?.filterType===`criterion`?b(n):{filterType:`criterion`,type:`none`,values:[]}}};let oq={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:aq,cellCorner:`bottom-left`})};var sq=class extends O{static template=`o-spreadsheet-LinkDisplay`;props=(0,t.useProps)({cellPosition:j.CellPosition(),onClosed:j.function().optional()});cellPopovers;viewStore;setup(){this.cellPopovers=k(qx),this.viewStore=k(H)}get cell(){let{col:e,row:t}=this.props.cellPosition,n=this.viewStore.displayedSheetId;return this.env.model.getters.getEvaluatedCell({sheetId:n,col:e,row:t})}get link(){if(this.cell.link)return this.cell.link;let{col:e,row:t}=this.props.cellPosition;throw Error(`LinkDisplay Component can only be used with link cells. ${T(e,t)} is not a link.`)}getUrlRepresentation(e){return tf(e,this.env.model.getters)}openLink(e){nf(this.link,this.env,de(e))}edit(){let{col:e,row:t}=this.props.cellPosition;this.env.model.selection.selectCell(e,t),this.cellPopovers.open({col:e,row:t},`LinkEditor`)}unlink(){let e=this.viewStore.displayedSheetId,{col:t,row:n}=this.props.cellPosition,r=this.env.model.getters.getCellComputedStyle({sheetId:e,col:t,row:n}),i=r?.textColor===`#017E84`?void 0:r?.textColor;this.env.model.dispatch(`UPDATE_CELL`,{col:t,row:n,sheetId:e,content:this.link.label,style:{...r,textColor:i,underline:void 0}})}};let cq={onHover:(e,t)=>{let n=t.getEvaluatedCell(e);return!t.isDashboard()&&n.link?{isOpen:!0,Component:sq,props:{cellPosition:e},cellCorner:`bottom-left`}:{isOpen:!1}}};var lq=class extends O{static template=`o-spreadsheet-LinkEditor`;static components={MenuPopover:q_};props=(0,t.useProps)({cellPosition:j.CellPosition(),onClosed:j.function().optional()});static size={maxHeight:500};urlInput=(0,t.signal)(null);suggestionListRef=(0,t.signal)(null);urlInputContainer=(0,t.signal)(null);state;viewStore;setup(){this.viewStore=k(H),this.state=(0,t.proxy)(this.defaultState),this.computeLinks(),(0,t.onMounted)(()=>this.urlInput()?.focus())}computeLinks(){this.state.selectedIndex=null,this.state.linksByCategory=this.linkProposalByCategory,this.state.linksList=Object.values(this.state.linksByCategory).flat()}get linkProposalByCategory(){let e={},t=-1,n=this.state.url;for(let r of Zd.getKeys()){let i=Zd.get(r),a=i.getLinkProposals?.(this.env)||[],o=n&&this.state.isUrlEditable?CM(n,a,e=>i.urlRepresentation(e.url,this.env.model.getters)):a;o.length!==0&&(e[i.title]=o.map(e=>{t++;let n=i.urlRepresentation(e.url,this.env.model.getters),r=t;return{text:n,icon:e.icon,index:r,onSelect:()=>{this.state.url=e.url,this.state.label=e.label,this.state.isUrlEditable=e.isUrlEditable,this.state.selectedIndex=r,this.urlInputContainer()?.focus()}}}))}return e}get defaultState(){let{col:e,row:t}=this.props.cellPosition,n=this.viewStore.displayedSheetId,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,selectedIndex:null,linksByCategory:{},linksList:[]}:{label:r.formattedValue,url:``,isUrlEditable:!0,selectedIndex:null,linksByCategory:{},linksList:[]}}getUrlRepresentation(e){return tf(e,this.env.model.getters)}removeLink(){this.state.url=``,this.state.isUrlEditable=!0,this.computeLinks()}save(){let{col:e,row:t}=this.props.cellPosition,n=this.env.model.getters.getLocale(),r=this.state.label?hb(this.state.label,n):this.state.url;this.env.model.dispatch(`UPDATE_CELL`,{col:e,row:t,sheetId:this.viewStore.displayedSheetId,content:Rt(r,this.state.url)}),this.props.onClosed?.()}cancel(){this.props.onClosed?.()}onKeyDown(e){switch(e.key){case`Enter`:this.state.url&&this.save(),e.stopPropagation(),e.preventDefault();break;case`Escape`:this.cancel(),e.stopPropagation();break}}onInputKeyDown(e){switch(e.key){case`Enter`:if(this.state.selectedIndex!==null){let t=this.state.linksList[this.state.selectedIndex];if(t){let n=this.state.url;t.onSelect(),this.state.url!==n&&(e.stopPropagation(),e.preventDefault())}}break;case`ArrowDown`:this.state.selectedIndex=this.state.selectedIndex===null||this.state.selectedIndex===this.state.linksList.length-1?0:(this.state.selectedIndex+1)%this.state.linksList.length,this.showSelectedProposal(),e.stopPropagation(),e.preventDefault();break;case`ArrowUp`:this.state.selectedIndex!==null&&(this.state.selectedIndex=this.state.selectedIndex===0?this.state.linksList.length-1:(this.state.selectedIndex-1)%this.state.linksList.length,this.showSelectedProposal(),e.stopPropagation(),e.preventDefault());break}}showSelectedProposal(){this.suggestionListRef()?.querySelector(`.suggestion-item[data-index="${this.state.selectedIndex}"]`)?.scrollIntoView({block:`nearest`})}};Kx.add(`ErrorToolTip`,iq).add(`LinkCell`,cq).add(`LinkEditor`,{onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:lq,cellCorner:`bottom-left`})}).add(`FilterMenu`,oq),wM.add(`dataValidation`,{displayAllOnInitialContent:!0,canBeToggled:!1,getProposals(e,t){if(Sn(t)||!this.composer.currentEditedCell)return[];let n=this.composer.currentEditedCell,r=this.getters.getValidationRuleForCell(n);if(!r||r.criterion.type!==`isValueInList`&&r.criterion.type!==`isValueInRange`)return[];let i=this.composer.currentEditedCell.sheetId,a=r.criterion.type===`isValueInRange`?this.getters.getDataValidationRangeValues(i,r.criterion):r.criterion.values.map(e=>({label:e,value:e}));if(r.criterion.displayStyle!==`chip`)return a.map(e=>({text:e.value,fuzzySearchKey:e.label,htmlContent:[{value:e.label}]}));let o=r.criterion.colors;return a.map(e=>{let t=o?.[e.value];return{text:e.value,htmlContent:[{value:e.label,color:ep(t||`#E7E9ED`),backgroundColor:t||`#E7E9ED`,classes:[`badge rounded-pill fs-6 fw-normal w-100 mt-1 text-start`]}],fuzzySearchKey:e.label}})},selectProposal(e,t){this.composer.setCurrentContent(t.text),this.composer.stopEdition()}}),wM.add(`functions_and_named_ranges`,{sequence:100,autoSelectFirstProposal:!0,maxDisplayedProposals:10,getProposals(e){if(e.type!==`SYMBOL`)return[];let t=e.value;if(!Sn(this.composer.currentContent))return[];let n=Object.entries(ml.content).filter(([e,{hidden:t}])=>!t).map(([e,{description:n}])=>({type:`function`,text:e,icon:`o-spreadsheet-Icon.FX_SVG`,description:n,htmlContent:yF(t,e,Fe,`o-semi-bold`)}));return n.push(...this.getters.getNamedRanges().map(e=>({type:`named_range`,text:e.name,description:this.getters.getRangeString(e.range),icon:`o-spreadsheet-Icon.NAMED_RANGE`,htmlContent:yF(t,e.name,Fe,`o-semi-bold`)}))),n.sort((e,t)=>e.text.length-t.text.length||e.text.localeCompare(t.text)),n},selectProposal(e,t){let n=e.end,r=e.end;[`SYMBOL`,`FUNCTION`].includes(e.type)&&(n=e.start);let i=this.composer.currentTokens,a=t.text;if(t.type===`function`){a+=`(`;let t=i.map(e=>e.start).indexOf(e.start);t+1<i.length&&i[t+1]?.type===`LEFT_PAREN`&&r++}this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(a)}});function uq(e,t){for(let n=0;n<t.length;n++){let r=t[n].proposalValues;r===void 0||r.length===0||wM.add(`${e}_function_${t[n].name}_argument_proposals`,{sequence:50,autoSelectFirstProposal:!0,selectProposal:dq,getProposals:t=>{let i=t.functionContext;if(!i||i.parent.toUpperCase()!==e.toUpperCase()||i.argPosition!==n)return;let a=[],o=``;for(let{value:e,label:t}of r){switch(typeof e){case`string`:o=`"${e}"`;break;case`number`:o=e.toString();break;case`boolean`:o=e?`TRUE`:`FALSE`;break;default:}a.push({text:o,description:t,htmlContent:[{value:o,color:typeof e==`string`?_t.STRING:_t.NUMBER}],fuzzySearchKey:o,alwaysExpanded:!0})}return a}})}}function dq(e,t){let n=e.end,r=e.end;[`LEFT_PAREN`,`ARG_SEPARATOR`].includes(e.type)||(n=e.start),this.composer.stopComposerRangeSelection(),this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t.text)}ml.getAll().forEach(e=>uq(e.name,e.args)),wM.add(`pivot_ids`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||![`PIVOT.VALUE`,`PIVOT.HEADER`,`PIVOT`].includes(t.parent.toUpperCase())||t.argPosition!==0)return;let n=this.getters.getPivotIds();if(!n.includes(e.value))return n.map(e=>{let t=this.getters.getPivotCoreDefinition(e),n=`${this.getters.getPivotFormulaId(e)}`;return{text:n,description:t.name,htmlContent:[{value:n,color:_t.NUMBER}],fuzzySearchKey:n+t.name,alwaysExpanded:!0}}).filter(C)},selectProposal:dq}),wM.add(`pivot_measures`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(t?.parent.toUpperCase()!==`PIVOT.VALUE`||t.argPosition!==1)return[];let n=LF(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return[];let i=this.getters.getPivot(r);return i.init(),i.isValid()?i.definition.measures.map(e=>{if(e.fieldName===`__count`){let e=`"__count"`;return{text:e,description:M(`Count`),htmlContent:[{value:e,color:_t.STRING}],fuzzySearchKey:M(`Count`)+e}}return PF(e)}).filter(C):[]},selectProposal:dq}),wM.add(`pivot_group_fields`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!fq(e)&&!pq(e))return;let n=LF(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return;let i=this.getters.getPivot(r);i.init();let a=i.getFields(),{columns:o,rows:s}=i.definition,c=t.args;t?.parent.toUpperCase()===`PIVOT.VALUE`?(c=c.filter((e,t)=>t%2==0),c=c.slice(1,t.argPosition)):c=c.filter((e,t)=>t%2==1);let l=c.map(e=>e?.value).filter(C),u=o.map(e=>e.nameWithGranularity),d=s.map(e=>e.nameWithGranularity),f=[],p=[`ARG_SEPARATOR`,`SPACE`].includes(e.type)?l.at(-1):l.at(-2),m=Wz.get(i.type);if(m&&p?.startsWith(`#`)&&(p=p.slice(1)),p===void 0&&(f.push(u[0]),f.push(d[0])),d.includes(p)){let e=d[d.indexOf(p)+1];f.push(e),f.push(u[0])}if(u.includes(p)){let e=u[u.indexOf(p)+1];f.push(e)}let h=f.filter(C);return h.map(e=>{let[t,n]=e.split(`:`),r=a[t];return r?NF(r,n):void 0}).concat(h.map(e=>{if(!m)return;let t=a[e.split(`:`)[0]];if(!t)return;let n=`"#${e}"`;return{text:n,description:M(`%s (positional)`,t.string)+(t.help?` (${t.help})`:``),htmlContent:[{value:n,color:_t.STRING}],fuzzySearchKey:t.string+n}})).filter(C)},selectProposal:dq});function fq(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==0}function pq(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==1}wM.add(`pivot_group_values`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!e||!mq(e)&&!hq(e))return;let n=LF(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return;let i=this.getters.getPivot(r);if(!i.isValid())return;let a=t.argPosition,o=e.functionContext?.args[a-1]?.value;if(!o)return;let s;try{s=i.definition.getDimension(o)}catch{return}return s.granularity===`month_number`?Object.values(oc).map((e,t)=>({text:`${t+1}`,fuzzySearchKey:e.toString(),description:e.toString(),htmlContent:[{value:`${t+1}`,color:_t.NUMBER}]})):s.granularity===`quarter_number`?[1,2,3,4].map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:M(`Quarter %s`,e),htmlContent:[{value:`${e}`,color:_t.NUMBER}]})):s.granularity===`day_of_month`?S(1,32).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:_t.NUMBER}]})):s.granularity===`iso_week_number`?S(0,54).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:_t.NUMBER}]})):s.granularity===`day_of_week`?S(1,8).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:_t.NUMBER}]})):s.granularity===`hour_number`?S(0,24).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:_t.NUMBER}]})):s.granularity===`minute_number`?S(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:_t.NUMBER}]})):s.granularity===`second_number`?S(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:_t.NUMBER}]})):i.getPossibleFieldValues(s).map(({value:e,label:t})=>{let n=typeof e==`string`,r=n?`"${e}"`:e.toString(),i=n?_t.STRING:_t.NUMBER,a=t===e?``:t;return{text:r,description:a,htmlContent:[{value:r,color:i}],fuzzySearchKey:r+a}})},selectProposal:dq});function mq(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==1}function hq(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==0}wM.add(`sheet_names`,{sequence:150,autoSelectFirstProposal:!0,getProposals(e){return e.type===`SYMBOL`||e.type===`UNKNOWN`&&e.value.startsWith(`'`)?this.getters.getSheetIds().map(e=>{let t=kt(this.getters.getSheetName(e));return{text:t,fuzzySearchKey:t.startsWith(`'`)?t:`'`+t}}):[]},selectProposal(e,t){let n=e.start,r=e.end;this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t.text+`!`)}});function gq(e){return e.yRanges.length&&!xl.test(e.yRanges[0])?`InvalidYRange`:e.xRange&&!xl.test(e.xRange)?`InvalidXRange`:e.labelRange&&!xl.test(e.labelRange)?`InvalidLabelRange`:e.sizeRange&&!xl.test(e.sizeRange)?`InvalidBubbleSizeRange`:`Success`}let _q={sequence:40,allowedDefinitionKeys:[...rg.commonKeys,`yRanges`,`xRange`,`labelRange`,`sizeRange`,`dataSetsHaveTitle`,`verticalAxisPosition`,`labelsAsText`,`bubbleColor`,`legendPosition`,`axesDesign`,`showValues`],fromStrDefinition(e,t,n){let r=e.yRanges.map(e=>Pu(n,t,e)).filter(C),i=Pu(n,t,e.xRange),a=Pu(n,t,e.labelRange),o=Pu(n,t,e.sizeRange);return{...e,yRanges:r,xRange:i,labelRange:a,sizeRange:o}},toStrDefinition(e,t,n){return{...e,yRanges:e.yRanges.map(e=>n.getRangeString(e,t)),xRange:e.xRange?n.getRangeString(e.xRange,t):void 0,labelRange:e.labelRange?n.getRangeString(e.labelRange,t):void 0,sizeRange:e.sizeRange?n.getRangeString(e.sizeRange,t):void 0}},validateDefinition(e,t){return e.checkValidations(t,gq)},transformDefinition(e,t,{adaptRangeString:n}){let r=e=>{if(!e)return;let{changeType:r,range:i}=n(t,e);return r===`REMOVE`?void 0:i};return{...e,yRanges:e.yRanges.map(r).filter(C),xRange:r(e.xRange),sizeRange:r(e.sizeRange),labelRange:r(e.labelRange)}},getFormulas:()=>[],getDefinitionFromContextCreation(e,t){let n=e.dataSource?.type===`range`;return{background:e.background,yRanges:n?e.dataSource.dataSets?.map(e=>e.dataRange)??[]:[],verticalAxisPosition:e.dataSetStyles?.[0]?.verticalAxisPosition,dataSetsHaveTitle:n?e.dataSource.dataSetsHaveTitle??!1:!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`bubble`,labelRange:e.bubbleLabelRange||void 0,labelsAsText:e.labelsAsText??!1,xRange:e.auxiliaryRange||void 0,sizeRange:e.bubbleSizeRange||void 0,axesDesign:e.axesDesign,showValues:e.showValues,humanize:e.humanize,annotationText:e.annotationText,annotationLink:e.annotationLink,bubbleColor:e.bubbleColorMode||{color:`multiple`}}},getContextCreation(e,t){return{...e,dataSource:{type:`range`,dataSets:e.yRanges.map((e,t)=>({dataSetId:`${t}`,dataRange:e}))},bubbleLabelRange:e.labelRange,auxiliaryRange:e.xRange,bubbleSizeRange:e.sizeRange,bubbleColorMode:e.bubbleColor}},getDefinitionForExcel:()=>void 0,updateRanges(e,t){let n=e.yRanges.map(e=>pm(e,t)).filter(C),r=pm(e.xRange,t),i=pm(e.labelRange,t),a=pm(e.sizeRange,t);return{...e,yRanges:n,xRange:r,labelRange:i,sizeRange:a}},duplicateInDuplicatedSheet(e,t,n){let r=e=>fm(t,n,e);return{...e,yRanges:e.yRanges.map(r).filter(C),xRange:r(e.xRange),labelRange:r(e.labelRange),sizeRange:r(e.sizeRange)}},copyInSheetId:e=>e,getRuntime(e,t){let n=Yk(t,e);return{chartJsConfig:{type:`line`,data:{datasets:Dh(t,n),labels:n.labels},options:{...Jg,layout:bA(t,n),scales:ch(t,n),plugins:{title:nj(t,e),legend:zA(t,n),tooltip:lj(t,n),chartShowValuesPlugin:XA(t,n),background:{color:t.background}}}}}}};function vq(e){return!Gj.includes(e.horizontalGroupBy)||!Gj.includes(e.verticalGroupBy)?`InvalidChartDefinition`:`Success`}let yq={sequence:110,dataSeriesLimit:1,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`dataSetStyles`,`showValues`,`colorScale`,`missingValueColor`,`axesDesign`,`horizontalGroupBy`,`verticalGroupBy`,`legendPosition`],validateDefinition(e,t){return e.checkValidations(t,vq)},fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,updateRanges:e=>e,getContextCreation:e=>e,getFormulas:()=>[],getDefinitionFromContextCreation(e,t){let n=`left`;return e.legendPosition===`right`&&(n=`right`),{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},title:e.title||{text:``},type:`calendar`,showValues:e.showValues,axesDesign:e.axesDesign,legendPosition:n,horizontalGroupBy:`day_of_week`,verticalGroupBy:`month_number`,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractData:n}){let r=Vk(t,n(),e),{labels:i,datasets:a}=Ch(t,r);return{chartJsConfig:{type:`calendar`,data:{labels:i,datasets:a},options:{...Jg,indexAxis:`x`,layout:xA(t,r),scales:nh(t,a),plugins:{title:nj(t,e),legend:{display:!1},tooltip:sj(t,r),chartShowValuesPlugin:ZA(t,r),chartColorScalePlugin:rh(t,r),background:{color:r.background}}}}}}},bq={sequence:15,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`aggregated`,`axesDesign`,`showValues`,`hideDataMarkers`,`zoomable`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getFormulas:()=>[],getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){return{...t,backgroundColor:Fk(t.background||`#FFFFFF`),fontColor:Fk(vm(t.background)),dataSets:n,labelRange:r,verticalAxis:Cm(t)}},getDefinitionFromContextCreation(e,t){let n=e.dataSetStyles??{};if(e.dataSource?.type===`range`){let t=e.dataSource?.dataSets?.[0]?.dataSetId;for(let r of e.dataSource?.dataSets||[])n[r.dataSetId]={...e.dataSetStyles?.[r.dataSetId]||{},type:r.dataSetId===t?`bar`:`line`}}return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:n,aggregated:e.aggregated,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`combo`,axesDesign:e.axesDesign,showValues:e.showValues,hideDataMarkers:e.hideDataMarkers,zoomable:e.zoomable,humanize:e.humanize,annotationText:e.annotationText,annotationLink:e.annotationLink}},getRuntime(e,t,{extractData:n},r,i){let a=Rk(t,n(),e);return{chartJsConfig:{type:`bar`,data:{labels:a.labels,datasets:Ah(t,a)},options:{...Jg,layout:bA(t,a),scales:th(t,a),plugins:{title:nj(t,e),legend:BA(t,a),tooltip:oj(t,a),chartShowValuesPlugin:XA(t,a),background:{color:a.background}},...i}},customizableSeries:a.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},xq={sequence:100,dataSeriesLimit:1,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`dataSetStyles`,`axesDesign`,`legendPosition`,`horizontal`,`aggregated`,`showValues`,`funnelColors`,`cumulative`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getFormulas:()=>[],getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},aggregated:e.aggregated??!1,legendPosition:`none`,title:e.title||{text:``},type:`funnel`,showValues:e.showValues,axesDesign:e.axesDesign,funnelColors:e.funnelColors,horizontal:!0,cumulative:e.cumulative??!0,humanize:e.humanize,annotationText:e.annotationText,annotationLink:e.annotationLink}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractData:n},r,i){let a=qk(t,n(),e);return{chartJsConfig:{type:`funnel`,data:{labels:a.labels,datasets:Nh(t,a)},options:{...Jg,indexAxis:`y`,layout:bA(t,a),scales:ph(t,a),plugins:{title:nj(t,e),legend:{display:!1},tooltip:hj(t,a),chartShowValuesPlugin:XA(t,a),background:{color:a.background}},...i}}}}},Sq={sequence:90,dataSeriesLimit:1,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`colorScale`,`missingValueColor`,`region`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getFormulas:()=>[],getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`geo`,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractData:n},r,i){let a=Kk(t,n(),e);return{chartJsConfig:{type:`choropleth`,data:{datasets:Mh(t,a)},options:{...Jg,layout:bA(t,a),scales:fh(t,a),plugins:{title:nj(t,e),tooltip:mj(t,a),legend:{display:!1},background:{color:a.background}},...i}}}}},Cq={sequence:80,dataSeriesLimit:2,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showValues`,`aggregated`,`axesDesign`,`stacked`,`horizontal`],fromStrDefinition:e=>({...e,horizontal:!0,stacked:!0}),toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getFormulas:()=>[],getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},aggregated:e.aggregated??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`pyramid`,axesDesign:e.axesDesign,horizontal:!0,stacked:!0,showValues:e.showValues,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){if(t.dataSource.type!==`range`)return;let i=Hk(t,Bj(e,t.dataSource),e),{dataSetsValues:a}=i,o=Math.max(...a.map(e=>Math.max(...e.data.map(e=>pf(e)?Math.abs(e.value):-1/0))));return{...t,horizontal:!0,backgroundColor:Fk(i.background||`#FFFFFF`),fontColor:Fk(vm(i.background)),dataSets:n,labelRange:r,verticalAxis:Cm(t),maxValue:o}},getRuntime(e,t,{extractData:n},r,i){let a=Hk(t,n(),e);return{chartJsConfig:{type:`bar`,data:{labels:a.labels,datasets:xh(t,a)},options:{...Jg,indexAxis:`y`,layout:bA(t,a),scales:uh(t,a),plugins:{title:nj(t,e),legend:FA(t,a),tooltip:fj(t,a),chartShowValuesPlugin:$A(t,a),background:{color:a.background}},...i}},customizableSeries:a.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},wq={sequence:80,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showValues`,`aggregated`,`stacked`,`fillArea`,`hideDataMarkers`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getFormulas:()=>[],getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},stacked:e.stacked??!1,aggregated:e.aggregated??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`radar`,fillArea:e.fillArea??!1,showValues:e.showValues??!1,hideDataMarkers:e.hideDataMarkers,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){return{...t,backgroundColor:Fk(t.background||`#FFFFFF`),fontColor:Fk(vm(t.background)),dataSets:n,labelRange:r}},getRuntime(e,t,{extractData:n},r,i){let a=Gk(t,n(),e);return{chartJsConfig:{type:`radar`,data:{labels:a.labels,datasets:jh(t,a)},options:{...Jg,layout:bA(t,a),scales:dh(t,a),plugins:{title:nj(t,e),legend:HA(t,a),tooltip:pj(t,a),chartShowValuesPlugin:XA(t,a),background:{color:a.background}},...i}},customizableSeries:a.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},Tq={sequence:60,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showValues`,`labelsAsText`,`aggregated`,`axesDesign`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getFormulas:()=>[],getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},labelsAsText:e.labelsAsText??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`scatter`,aggregated:e.aggregated??!1,axesDesign:e.axesDesign,showValues:e.showValues,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){return{...t,backgroundColor:Fk(t.background||`#FFFFFF`),fontColor:Fk(vm(t.background)),dataSets:n,labelRange:r,verticalAxis:Cm(t)}},getRuntime(e,t,{extractData:n},r,i){let a=Uk(t,n(),e);return{chartJsConfig:{type:`line`,data:{labels:a.labels,datasets:Eh(t,a)},options:{...Jg,layout:bA(t,a),scales:sh(t,a),plugins:{title:nj(t,e),legend:RA(t,a),tooltip:cj(t,a),chartShowValuesPlugin:XA(t,a),background:{color:a.background}},...i}},customizableSeries:a.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},Eq={sequence:30,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showValues`,`showLabels`,`valuesDesign`,`groupColors`,`pieHolePercentage`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getFormulas:()=>[],getDefinitionFromContextCreation(e,t){return{background:e.background,dataSetStyles:e.dataSetStyles??{},dataSource:t.fromHierarchicalContextCreation(e),legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`sunburst`,showValues:e.showValues,showLabels:e.showLabels,valuesDesign:e.valuesDesign,groupColors:e.groupColors,humanize:e.humanize,pieHolePercentage:e.pieHolePercentage,annotationLink:e.annotationLink,annotationText:e.annotationText}},getContextCreation(e,t,n){return{...e,...t.getHierarchicalContextCreation(n)}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractHierarchicalData:n},r,i){let a=Jk(t,n(),e);return{chartJsConfig:{type:`doughnut`,data:{datasets:Fh(t,a)},options:{cutout:t.pieHolePercentage===void 0?`25%`:`${t.pieHolePercentage}%`,...Jg,layout:bA(t,a),plugins:{title:nj(t,e),legend:UA(t,a),tooltip:gj(t,a),sunburstLabelsPlugin:QA(t,a),sunburstHoverPlugin:{enabled:!0},background:{color:a.background}},...i}}}}},Dq={sequence:100,allowedDefinitionKeys:[...rg.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showHeaders`,`headerDesign`,`showLabels`,`valuesDesign`,`coloringOptions`,`showValues`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getFormulas:()=>[],getDefinitionFromContextCreation(e,t){return{background:e.background,dataSetStyles:e.dataSetStyles??{},dataSource:t.fromHierarchicalContextCreation(e),legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`treemap`,showValues:e.showValues,showHeaders:e.showHeaders,headerDesign:e.headerDesign,showLabels:e.showLabels,valuesDesign:e.valuesDesign,coloringOptions:e.treemapColoringOptions,humanize:e.humanize,annotationText:e.annotationText,annotationLink:e.annotationLink}},getContextCreation(e,t,n){return{...e,treemapColoringOptions:e.coloringOptions,...t.getHierarchicalContextCreation(n)}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractHierarchicalData:n},r,i){let a=Jk(t,n(),e);return{chartJsConfig:{type:`treemap`,data:{labels:a.labels,datasets:Bh(t,a)},options:{...Jg,layout:bA(t,a),plugins:{title:nj(t,e),legend:{display:!1},tooltip:_j(t,a),background:{color:a.background}},...i}}}}};Iw.add(`bar`,xj),Iw.add(`combo`,bq),Iw.add(`line`,Mj),Iw.add(`pie`,Nj),Iw.add(`scorecard`,pg),Iw.add(`gauge`,Dj),Iw.add(`scatter`,Tq),Iw.add(`waterfall`,Pj),Iw.add(`pyramid`,Cq),Iw.add(`radar`,wq),Iw.add(`geo`,Sq),Iw.add(`funnel`,xq),Iw.add(`sunburst`,Eq),Iw.add(`treemap`,Dq),Iw.add(`calendar`,yq),Iw.add(`bubble`,_q),Dg.add(`line`,{matcher:e=>e.type===`line`&&!e.stacked&&!e.fillArea,displayName:M(`Line`),chartType:`line`,chartSubtype:`line`,subtypeDefinition:{stacked:!1,fillArea:!1},category:`line`,preview:`o-spreadsheet-ChartPreview.LINE_CHART`}).add(`stacked_line`,{matcher:e=>e.type===`line`&&!e.fillArea&&!!e.stacked,displayName:M(`Stacked Line`),chartType:`line`,chartSubtype:`stacked_line`,subtypeDefinition:{stacked:!0,fillArea:!1},category:`line`,preview:`o-spreadsheet-ChartPreview.STACKED_LINE_CHART`}).add(`area`,{matcher:e=>e.type===`line`&&!e.stacked&&!!e.fillArea,displayName:M(`Area`),chartType:`line`,chartSubtype:`area`,subtypeDefinition:{stacked:!1,fillArea:!0},category:`area`,preview:`o-spreadsheet-ChartPreview.AREA_CHART`}).add(`stacked_area`,{matcher:e=>e.type===`line`&&e.stacked&&!!e.fillArea,displayName:M(`Stacked Area`),chartType:`line`,chartSubtype:`stacked_area`,subtypeDefinition:{stacked:!0,fillArea:!0},category:`area`,preview:`o-spreadsheet-ChartPreview.STACKED_AREA_CHART`}).add(`scatter`,{displayName:M(`Scatter`),chartType:`scatter`,chartSubtype:`scatter`,category:`misc`,preview:`o-spreadsheet-ChartPreview.SCATTER_CHART`}).add(`bubble`,{displayName:M(`Bubble`),chartType:`bubble`,chartSubtype:`bubble`,category:`misc`,preview:`o-spreadsheet-ChartPreview.BUBBLE_CHART`}).add(`column`,{matcher:e=>e.type===`bar`&&!e.stacked&&!e.horizontal,displayName:M(`Column`),chartType:`bar`,chartSubtype:`column`,subtypeDefinition:{stacked:!1,horizontal:!1},category:`column`,preview:`o-spreadsheet-ChartPreview.COLUMN_CHART`}).add(`stacked_column`,{matcher:e=>e.type===`bar`&&e.stacked&&!e.horizontal,displayName:M(`Stacked Column`),chartType:`bar`,chartSubtype:`stacked_column`,subtypeDefinition:{stacked:!0,horizontal:!1},category:`column`,preview:`o-spreadsheet-ChartPreview.STACKED_COLUMN_CHART`}).add(`bar`,{matcher:e=>e.type===`bar`&&!e.stacked&&!!e.horizontal,displayName:M(`Bar`),chartType:`bar`,chartSubtype:`bar`,subtypeDefinition:{horizontal:!0,stacked:!1},category:`bar`,preview:`o-spreadsheet-ChartPreview.BAR_CHART`}).add(`stacked_bar`,{matcher:e=>e.type===`bar`&&e.stacked&&!!e.horizontal,displayName:M(`Stacked Bar`),chartType:`bar`,chartSubtype:`stacked_bar`,subtypeDefinition:{horizontal:!0,stacked:!0},category:`bar`,preview:`o-spreadsheet-ChartPreview.STACKED_BAR_CHART`}).add(`combo`,{displayName:M(`Combo`),chartSubtype:`combo`,chartType:`combo`,category:`line`,preview:`o-spreadsheet-ChartPreview.COMBO_CHART`}).add(`pie`,{matcher:e=>e.type===`pie`&&!e.isDoughnut,displayName:M(`Pie`),chartSubtype:`pie`,chartType:`pie`,subtypeDefinition:{isDoughnut:!1},category:`pie`,preview:`o-spreadsheet-ChartPreview.PIE_CHART`}).add(`doughnut`,{matcher:e=>e.type===`pie`&&!!e.isDoughnut,displayName:M(`Doughnut`),chartSubtype:`doughnut`,chartType:`pie`,subtypeDefinition:{isDoughnut:!0},category:`pie`,preview:`o-spreadsheet-ChartPreview.DOUGHNUT_CHART`}).add(`gauge`,{displayName:M(`Gauge`),chartSubtype:`gauge`,chartType:`gauge`,category:`misc`,preview:`o-spreadsheet-ChartPreview.GAUGE_CHART`}).add(`scorecard`,{displayName:M(`Scorecard`),chartSubtype:`scorecard`,chartType:`scorecard`,category:`misc`,preview:`o-spreadsheet-ChartPreview.SCORECARD_CHART`}).add(`waterfall`,{displayName:M(`Waterfall`),chartSubtype:`waterfall`,chartType:`waterfall`,category:`misc`,preview:`o-spreadsheet-ChartPreview.WATERFALL_CHART`}).add(`pyramid`,{displayName:M(`Population Pyramid`),chartSubtype:`pyramid`,chartType:`pyramid`,category:`misc`,preview:`o-spreadsheet-ChartPreview.POPULATION_PYRAMID_CHART`}).add(`radar`,{matcher:e=>e.type===`radar`&&!e.fillArea,displayName:M(`Radar`),chartSubtype:`radar`,chartType:`radar`,subtypeDefinition:{fillArea:!1},category:`misc`,preview:`o-spreadsheet-ChartPreview.RADAR_CHART`}).add(`filled_radar`,{matcher:e=>e.type===`radar`&&!!e.fillArea,displayName:M(`Filled Radar`),chartType:`radar`,chartSubtype:`filled_radar`,subtypeDefinition:{fillArea:!0},category:`misc`,preview:`o-spreadsheet-ChartPreview.FILLED_RADAR_CHART`}).add(`geo`,{displayName:M(`Geo Chart`),chartSubtype:`geo`,chartType:`geo`,category:`misc`,preview:`o-spreadsheet-ChartPreview.GEO_CHART`}).add(`funnel`,{displayName:M(`Funnel`),chartSubtype:`funnel`,chartType:`funnel`,category:`misc`,preview:`o-spreadsheet-ChartPreview.FUNNEL_CHART`}).add(`sunburst`,{matcher:e=>e.type===`sunburst`,displayName:M(`Sunburst`),chartSubtype:`sunburst`,chartType:`sunburst`,category:`hierarchical`,preview:`o-spreadsheet-ChartPreview.SUNBURST_CHART`}).add(`treemap`,{matcher:e=>e.type===`treemap`,displayName:M(`Tree Map`),chartType:`treemap`,chartSubtype:`treemap`,category:`hierarchical`,preview:`o-spreadsheet-ChartPreview.TREE_MAP_CHART`}).add(`calendar`,{displayName:M(`Calendar`),chartSubtype:`calendar`,chartType:`calendar`,category:`misc`,preview:`o-spreadsheet-ChartPreview.CALENDAR_CHART`}),KB.add(`filter_icon`,(e,t)=>{if(e.isFilterHeader(t)){let n=e.isFilterActive(t),r=If(e.getCellComputedStyle(t).fillColor||`#fff`)<.45;return{type:`filter_icon`,svg:_S(n,r,!1),hoverSvg:_S(n,r,!0),priority:3,horizontalAlign:`right`,size:17,margin:2,position:t,onClick:(e,t)=>{let n=t.getStore(qx),r=n.persistentCellPopover;if(r.isOpen&&r.col===e.col&&r.row===e.row&&r.type===`FilterMenu`){n.close();return}n.open(e,`FilterMenu`)}}}});var Oq=l({ARRAYTOTEXT:()=>rJ,ARRAY_CONSTRAIN:()=>jq,ARRAY_LITERAL:()=>Mq,ARRAY_ROW:()=>Nq,CHOOSECOLS:()=>Pq,CHOOSEROWS:()=>Fq,EXPAND:()=>Iq,FLATTEN:()=>Lq,FREQUENCY:()=>Rq,HSTACK:()=>zq,MDETERM:()=>Bq,MINVERSE:()=>Vq,MMULT:()=>Hq,SUMPRODUCT:()=>Uq,SUMX2MY2:()=>Gq,SUMX2PY2:()=>Kq,SUMXMY2:()=>qq,TOCOL:()=>Xq,TOROW:()=>Zq,TRANSPOSE:()=>Qq,VSTACK:()=>$q,WRAPCOLS:()=>eJ,WRAPROWS:()=>tJ});function kq(e,t){let n=e.map(R),r=n.map(e=>e?.[0]?.length??0),i=Math.max(...r);if(t?.requireSameRowCount){let e=r[0];if(r.some(t=>t!==e))return new P(M(`All ranges in [[FUNCTION_NAME]] must have the same number of rows (got %s).`,r.join(`, `)))}let a=[];for(let e of n)for(let t=0;t<e.length;t++){let n=Array(i).fill({value:null});for(let r=0;r<e[t].length;r++)n[r]=e[t][r];a.push(n)}return a}function Aq(e,t){let n=e.map(R),r=n.map(e=>e?.length??0),i=Math.max(...r);if(t?.requireSameColCount){let e=r[0];if(r.some(t=>t!==e))return new P(M(`All ranges in [[FUNCTION_NAME]] must have the same number of columns (got %s).`,r.join(`, `)))}let a=fs(i,n.reduce((e,t)=>e+(t?.[0]?.length??0),0),()=>({value:null})),o=0;for(let e of n){for(let t=0;t<e.length;t++)for(let n=0;n<e[t].length;n++)a[t][o+n]=e[t][n];o+=e[0]?.length??0}return a}let jq={description:M(`Returns a result array constrained to a specific width and height.`),args:[V(`input_range (any, range<any>)`,M(`The range to constrain.`)),V(`rows (number)`,M(`The number of rows in the constrained array.`)),V(`columns (number)`,M(`The number of columns in the constrained array.`))],computeArray:function(e,t,n){let r=R(e),i=Qo(t?.value,this.locale),a=Qo(n?.value,this.locale);if(i<=0)return new P(M(`The rows argument (%s) must be strictly positive.`,i.toString()));if(a<=0)return new P(M(`The columns argument (%s) must be strictly positive.`,a.toString()));let o=Math.min(i,r[0].length);return fs(Math.min(a,r.length),o,(e,t)=>r[e][t])},isExported:!1},Mq={description:M(`Appends ranges vertically and in sequence to return a larger array. All ranges must have the same number of columns.`),args:[V(`range (any, range<any>, repeating)`,M(`The range to be appended.`))],computeArray:function(...e){return Aq(e,{requireSameColCount:!0})},isExported:!1,hidden:!0},Nq={description:M(`Appends ranges horizontally and in sequence to return a larger array. All ranges must have the same number of rows.`),args:[V(`range (any, range<any>, repeating)`,M(`The range to be appended.`))],computeArray:function(...e){return kq(e,{requireSameRowCount:!0})},isExported:!1,hidden:!0},Pq={description:M(`Creates a new array from the selected columns in the existing range.`),args:[V(`array (any, range<any>)`,M(`The array that contains the columns to be returned.`)),V(`col_num (number, range<number>, repeating)`,M(`The column index of the column to be returned.`))],computeArray:function(e,...t){let n=R(e),r=Ds(t,e=>Qo(e?.value,this.locale)),i=r.filter(e=>e===0||n.length<Math.abs(e));if(i.length!==0)return new P(M(`The columns arguments must be between -%s and %s (got %s), excluding 0.`,n.length.toString(),n.length.toString(),i.join(`,`)));let a=Array(r.length);for(let e=0;e<r.length;e++)r[e]>0?a[e]=n[r[e]-1]:a[e]=n[n.length+r[e]];return a},isExported:!0},Fq={description:M(`Creates a new array from the selected rows in the existing range.`),args:[V(`array (any, range<any>)`,M(`The array that contains the rows to be returned.`)),V(`row_num (number, range<number>, repeating)`,M(`The row index of the row to be returned.`))],computeArray:function(e,...t){let n=R(e),r=Ds(t,e=>Qo(e?.value,this.locale)),i=n.length,a=r.filter(e=>e===0||n[0].length<Math.abs(e));return a.length===0?fs(i,r.length,(e,t)=>r[t]>0?n[e][r[t]-1]:n[e][n[e].length+r[t]]):new P(M(`The rows arguments must be between -%s and %s (got %s), excluding 0.`,n[0].length.toString(),n[0].length.toString(),a.join(`,`)))},isExported:!0},Iq={description:M(`Expands or pads an array to specified row and column dimensions.`),args:[V(`array (any, range<any>)`,M(`The array to expand.`)),V(`rows (number)`,M(`The number of rows in the expanded array. If missing, rows will not be expanded.`)),V(`columns (number, optional)`,M(`The number of columns in the expanded array. If missing, columns will not be expanded.`)),V(`pad_with (any, default=0)`,M(`The value with which to pad.`))],computeArray:function(e,t,n,r={value:0}){let i=R(e),a=Qo(t?.value,this.locale),o=n===void 0?i.length:Qo(n.value,this.locale);return a<i[0].length?new P(M(`The rows arguments (%s) must be greater or equal than the number of rows of the array.`,a.toString())):o<i.length?new P(M(`The columns arguments (%s) must be greater or equal than the number of columns of the array.`,o.toString())):fs(o,a,(e,t)=>e>=i.length||t>=i[e].length?r:i[e][t])},isExported:!0},Lq={description:M(`Flattens all the values from one or more ranges into a single column.`),args:[V(`range (any, range<any>, repeating)`,M(`The range to flatten.`))],computeArray:function(...e){return[Ds(e,e=>e===void 0?{value:``}:e)]},isExported:!1},Rq={description:M(`Calculates the frequency distribution of a range.`),args:[V(`data (range<number>)`,M(`The array of ranges containing the values to be counted.`)),V(`classes (number, range<number>)`,M(`The range containing the set of classes.`))],computeArray:function(e,t){let n=Ds([e],e=>e.value).filter(e=>typeof e==`number`),r=Ds([t],e=>e.value).filter(e=>typeof e==`number`).map((e,t)=>({initialIndex:t,value:e,count:0})).sort((e,t)=>e.value-t.value);r.push({initialIndex:r.length,value:1/0,count:0});let i=n.sort((e,t)=>e-t),a=0;for(let e of i){for(;e>r[a].value&&a<r.length-1;)a++;r[a].count++}return[r.sort((e,t)=>e.initialIndex-t.initialIndex).map(e=>({value:e.count}))]},isExported:!0},zq={description:M(`Appends ranges horizontally and in sequence to return a larger array.`),args:[V(`range (any, range<any>, repeating)`,M(`The range to be appended.`))],computeArray:function(...e){return kq(e)},isExported:!0},Bq={description:M(`Returns the matrix determinant of a square matrix.`),args:[V(`square_matrix (number, range<number>)`,M(`An range with an equal number of rows and columns representing a matrix whose determinant will be calculated.`))],compute:function(e){let t=Xo(e,`square_matrix`);return Tv(t)?{value:Ov(t).determinant}:new P(M(`The argument square_matrix must have the same number of columns and rows.`))},isExported:!0},Vq={description:M(`Returns the multiplicative inverse of a square matrix.`),args:[V(`square_matrix (number, range<number>)`,M(`An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated.`))],computeArray:function(e){let t=Xo(e,`square_matrix`);if(!Tv(t))return new P(M(`The argument square_matrix must have the same number of columns and rows.`));let{inverted:n}=Ov(t);return n?ps(n,e=>({value:e})):new P(M(`The matrix is not invertible.`))},isExported:!0},Hq={description:M(`Calculates the matrix product of two matrices.`),args:[V(`matrix1 (number, range<number>)`,M(`The first matrix in the matrix multiplication operation.`)),V(`matrix2 (number, range<number>)`,M(`The second matrix in the matrix multiplication operation.`))],computeArray:function(e,t){let n=Xo(e,`matrix1`),r=Xo(t,`matrix2`);return n.length===0||r.length===0?new P(M(`The first and second arguments of [[FUNCTION_NAME]] must be non-empty matrices.`)):n.length===r[0].length?ps(Av(n,r),e=>({value:e})):new P(M(`In [[FUNCTION_NAME]], the number of columns of the first matrix (%s) must be equal to the number of rows of the second matrix (%s).`,n.length.toString(),r[0].length.toString()))},isExported:!0},Uq={description:M(`Calculates the sum of the products of corresponding entries in equal-sized ranges.`),args:[V(`range (number, range<number>, repeating)`,M(`The range whose entries will be multiplied with corresponding entries in the other range.`))],compute:function(...e){if(!wv(...e))return new P(M(`All the ranges must have the same dimensions.`));let t=e.map(R),n=0;for(let e=0;e<t[0].length;e++)for(let r=0;r<t[0][e].length;r++){if(!t.every(t=>typeof t[e][r].value==`number`))continue;let i=1;for(let n of t)i*=F(n[e][r],this.locale);n+=i}return{value:n}},isExported:!0};function Wq(e,t,n){if(!wv(e,t))return new P(M(`The arguments array_x and array_y must have the same dimensions.`));let r=R(e),i=R(t),a=!1,o=0;for(let e in r)for(let t in r[e]){let s=r[e][t].value,c=i[e][t].value;typeof s!=`number`||typeof c!=`number`||(a=!0,o+=n(s,c))}return a?o:new P(M(`The arguments array_x and array_y must contain at least one pair of numbers.`))}let Gq={description:M(`Calculates the sum of the difference of the squares of the values in two array.`),args:[V(`array_x (number, range<number>)`,M(`The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.`)),V(`array_y (number, range<number>)`,M(`The array or range of values whose squares will be subtracted from the squares of corresponding entries in array_x and added together.`))],compute:function(e,t){let n=Wq(e,t,(e,t)=>e**2-t**2);return n instanceof P?n:{value:n}},isExported:!0},Kq={description:M(`Calculates the sum of the sum of the squares of the values in two array.`),args:[V(`array_x (number, range<number>)`,M(`The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.`)),V(`array_y (number, range<number>)`,M(`The array or range of values whose squares will be added to the squares of corresponding entries in array_x and added together.`))],compute:function(e,t){let n=Wq(e,t,(e,t)=>e**2+t**2);return n instanceof P?n:{value:n}},isExported:!0},qq={description:M(`Calculates the sum of squares of the differences of values in two array.`),args:[V(`array_x (number, range<number>)`,M(`The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.`)),V(`array_y (number, range<number>)`,M(`The array or range of values that will be subtracted from corresponding entries in array_x, the result squared, and all such results added together.`))],compute:function(e,t){let n=Wq(e,t,(e,t)=>(e-t)**2);return n instanceof P?n:{value:n}},isExported:!0},Jq=[V(`array (any, range<any>)`,M(`The array which will be transformed.`)),V(`ignore (number, default=0)`,M(`Whether to ignore certain types of values. By default, no values are ignored.`),[{value:0,label:M(`Keep all values (default)`)},{value:1,label:M(`Ignore blanks`)},{value:2,label:M(`Ignore errors`)},{value:3,label:M(`Ignore blanks and errors`)}]),V(`scan_by_column (number, default=false)`,M(`Scan the array by column. By default, the array is scanned by row.`),[{value:!1,label:M(`Scan by row (default)`)},{value:!0,label:M(`Scan by column`)}])];function Yq(e){let t=Math.trunc(e);if(t===0)return()=>!0;if(t===1)return e=>e.value!==null;if(t===2)return e=>!Uo(e.value);if(t===3)return e=>e.value!==null&&!Uo(e.value);throw new P(M(`Argument ignore must be between 0 and 3`))}let Xq={description:M(`Transforms a range of cells into a single column.`),args:Jq,computeArray:function(e,t={value:0},n={value:!1}){let r=R(e),i=F(t.value,this.locale),a=(L(n.value)?r:hs(r)).flat().filter(Yq(i));return a.length===0?new Io(M(`No results for the given arguments of TOCOL.`)):[a]},isExported:!0},Zq={description:M(`Transforms a range of cells into a single row.`),args:Jq,computeArray:function(e,t={value:0},n={value:!1}){let r=R(e),i=F(t.value,this.locale),a=(L(n.value)?r:hs(r)).flat().filter(Yq(i)).map(e=>[e]);return a.length===0||a[0].length===0?new Io(M(`No results for the given arguments of TOROW.`)):a},isExported:!0},Qq={description:M(`Transposes the rows and columns of a range.`),args:[V(`range (any, range<any>)`,M(`The range to be transposed.`))],computeArray:function(e){let t=R(e),n=t[0].length,r=t.length;return fs(n,r,(e,n)=>t[n][e])},isExported:!0},$q={description:M(`Appends ranges vertically and in sequence to return a larger array.`),args:[V(`range (any, range<any>, repeating)`,M(`The range to be appended.`))],computeArray:function(...e){return Aq(e)},isExported:!0},eJ={description:M(`Wraps the provided row or column of cells by columns after a specified number of elements to form a new array.`),args:[V(`range (any, range<any>)`,M(`The range to wrap.`)),V(`wrap_count (number)`,M(`The maximum number of cells for each column, rounded down to the nearest whole number.`)),V(`pad_with (any, default=0)`,M(`The value with which to fill the extra cells in the range.`))],computeArray:function(e,t,n={value:0}){let r=R(e),i=Qo(t?.value,this.locale);if(!Cv(r))return new P(M(`Argument range must be a single row or column.`));if(i<1)return new P(M(`The wrap_count (%s) must be strictly positive.`,i),N.InvalidNumber);let a=r.flat();return fs(Math.ceil(a.length/i),i,(e,t)=>{let r=e*i+t;return r<a.length?a[r]:n})},isExported:!0},tJ={description:M(`Wraps the provided row or column of cells by rows after a specified number of elements to form a new array.`),args:[V(`range (any, range<any>)`,M(`The range to wrap.`)),V(`wrap_count (number)`,M(`The maximum number of cells for each row, rounded down to the nearest whole number.`)),V(`pad_with (any, default=0)`,M(`The value with which to fill the extra cells in the range.`))],computeArray:function(e,t,n={value:0}){let r=R(e),i=Qo(t?.value,this.locale);if(!Cv(r))return new P(M(`Argument range must be a single row or column.`));if(i<1)return new P(M(`The wrap_count (%s) must be strictly positive.`,i),N.InvalidNumber);let a=r.flat();return fs(i,Math.ceil(a.length/i),(e,t)=>{let r=t*i+e;return r<a.length?a[r]:n})},isExported:!0},nJ=[{value:0,label:M(`Concise format\xA0(default)`)},{value:1,label:M(`Strict format`)}],rJ={description:M(`returns an array of text values from any specified range. It passes text values unchanged, and converts non-text values to text.`),args:[V(`array (range)`,M(`The array to convert into text`)),V(`format (number, default=0)`,M(`The format of the returned data.`),nJ)],compute:function(e,t={value:0}){let n=F(t,this.locale),r=R(e);if(n===1)return{value:yM(r,``,this.locale)};if(n===0){let e=this.locale.decimalSeparator===`,`?`/`:`,`;return{value:hs(r).flatMap(e=>e.map(e=>Uo(e.value)?e.value:I(e))).join(e)}}else return new P(M(`Format must be 0 or 1`))},isExported:!0};var iJ=l({ABS:()=>oJ,ACOS:()=>sJ,ACOSH:()=>cJ,ACOT:()=>lJ,ACOTH:()=>uJ,ASIN:()=>dJ,ASINH:()=>fJ,ATAN:()=>pJ,ATAN2:()=>mJ,ATANH:()=>hJ,CEILING:()=>gJ,CEILING_MATH:()=>vJ,CEILING_PRECISE:()=>yJ,COS:()=>bJ,COSH:()=>xJ,COT:()=>SJ,COTH:()=>CJ,COUNTBLANK:()=>wJ,COUNTIF:()=>TJ,COUNTIFS:()=>EJ,COUNTUNIQUE:()=>DJ,COUNTUNIQUEIFS:()=>OJ,CSC:()=>kJ,CSCH:()=>AJ,DECIMAL:()=>jJ,DEGREES:()=>MJ,EXP:()=>NJ,FLOOR:()=>PJ,FLOOR_MATH:()=>IJ,FLOOR_PRECISE:()=>LJ,INT:()=>yY,ISEVEN:()=>RJ,ISODD:()=>BJ,ISO_CEILING:()=>zJ,LN:()=>VJ,LOG:()=>HJ,MOD:()=>WJ,MUNIT:()=>GJ,ODD:()=>KJ,PI:()=>qJ,POWER:()=>JJ,PRODUCT:()=>YJ,RAND:()=>XJ,RANDARRAY:()=>ZJ,RANDBETWEEN:()=>QJ,ROUND:()=>$J,ROUNDDOWN:()=>eY,ROUNDUP:()=>tY,SEC:()=>nY,SECH:()=>rY,SEQUENCE:()=>iY,SIN:()=>aY,SINH:()=>oY,SQRT:()=>sY,SUBTOTAL:()=>dY,SUM:()=>fY,SUMIF:()=>pY,SUMIFS:()=>mY,TAN:()=>hY,TANH:()=>gY,TRUNC:()=>vY});let aJ=/^-?[a-z0-9]+$/i,oJ={description:M(`Absolute value of a number.`),args:[V(`value (number)`,M(`The number of which to return the absolute value.`))],compute:function(e){return{value:Math.abs(F(e,this.locale))}},isExported:!0},sJ={description:M(`Inverse cosine of a value, in radians.`),args:[V(`value (number)`,M(`The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.`))],compute:function(e){let t=F(e,this.locale);return Math.abs(t)>1?new P(M(`The value (%s) must be between -1 and 1 inclusive.`,t)):{value:Math.acos(t)}},isExported:!0},cJ={description:M(`Inverse hyperbolic cosine of a number.`),args:[V(`value (number)`,M(`The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.`))],compute:function(e){let t=F(e,this.locale);return t<1?new P(M(`The value (%s) must be greater than or equal to 1.`,t)):{value:Math.acosh(t)}},isExported:!0},lJ={description:M(`Inverse cotangent of a value.`),args:[V(`value (number)`,M(`The value for which to calculate the inverse cotangent.`))],compute:function(e){let t=F(e,this.locale);return{value:(Math.sign(t)||1)*Math.PI/2-Math.atan(t)}},isExported:!0},uJ={description:M(`Inverse hyperbolic cotangent of a value.`),args:[V(`value (number)`,M(`The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.`))],compute:function(e){let t=F(e,this.locale);return Math.abs(t)<=1?new P(M(`The value (%s) cannot be between -1 and 1 inclusive.`,t)):{value:Math.log((t+1)/(t-1))/2}},isExported:!0},dJ={description:M(`Inverse sine of a value, in radians.`),args:[V(`value (number)`,M(`The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.`))],compute:function(e){let t=F(e,this.locale);return Math.abs(t)>1?new P(M(`The value (%s) must be between -1 and 1 inclusive.`,t)):{value:Math.asin(t)}},isExported:!0},fJ={description:M(`Inverse hyperbolic sine of a number.`),args:[V(`value (number)`,M(`The value for which to calculate the inverse hyperbolic sine.`))],compute:function(e){return{value:Math.asinh(F(e,this.locale))}},isExported:!0},pJ={description:M(`Inverse tangent of a value, in radians.`),args:[V(`value (number)`,M(`The value for which to calculate the inverse tangent.`))],compute:function(e){return{value:Math.atan(F(e,this.locale))}},isExported:!0},mJ={description:M(`Angle from the X axis to a point (x,y), in radians.`),args:[V(`x (number)`,M(`The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.`)),V(`y (number)`,M(`The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.`))],compute:function(e,t){let n=F(e,this.locale),r=F(t,this.locale);return n===0&&r===0?new zo(M(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:Math.atan2(r,n)}},isExported:!0},hJ={description:M(`Inverse hyperbolic tangent of a number.`),args:[V(`value (number)`,M(`The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.`))],compute:function(e){let t=F(e,this.locale);return Math.abs(t)>=1?new P(M(`The value (%s) must be between -1 and 1 exclusive.`,t)):{value:Math.atanh(t)}},isExported:!0},gJ={description:M(`Rounds number up to nearest multiple of factor.`),args:[V(`value (number)`,M(`The value to round up to the nearest integer multiple of factor.`)),V(`factor (number, default=1)`,M(`The number to whose multiples value will be rounded.`))],compute:function(e,t={value:1}){let n=F(e,this.locale),r=F(t,this.locale);return r<0&&n>0?new P(M(`The factor (%s) must be positive when the value (%s) is positive.`,r,n)):{value:r?Math.ceil(n/r)*r:0,format:e?.format}},isExported:!0};function _J(e,t,n=0){return t===0?0:(t=Math.abs(t),e>=0?Math.ceil(e/t)*t:n===0?-Math.floor(Math.abs(e)/t)*t:-Math.ceil(Math.abs(e)/t)*t)}let vJ={description:M(`Rounds number up to nearest multiple of factor.`),args:[V(`number (number)`,M(`The value to round up to the nearest integer multiple of significance.`)),V(`significance (number, default=1)`,M(`The number to whose multiples number will be rounded. The sign of significance will be ignored.`)),V(`mode (number, default=0)`,M(`If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero.`))],compute:function(e,t={value:1},n={value:0}){let r=F(t,this.locale);return{value:_J(F(e,this.locale),r,F(n,this.locale)),format:e?.format}},isExported:!0},yJ={description:M(`Rounds number up to nearest multiple of factor.`),args:[V(`number (number)`,M(`The value to round up to the nearest integer multiple of significance.`)),V(`significance (number, default=1)`,M(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){let n=F(t,this.locale);return{value:_J(F(e,this.locale),n),format:e?.format}},isExported:!0},bJ={description:M(`Cosine of an angle provided in radians.`),args:[V(`angle (number)`,M(`The angle to find the cosine of, in radians.`))],compute:function(e){return{value:Math.cos(F(e,this.locale))}},isExported:!0},xJ={description:M(`Hyperbolic cosine of any real number.`),args:[V(`value (number)`,M(`Any real value to calculate the hyperbolic cosine of.`))],compute:function(e){return{value:Math.cosh(F(e,this.locale))}},isExported:!0},SJ={description:M(`Cotangent of an angle provided in radians.`),args:[V(`angle (number)`,M(`The angle to find the cotangent of, in radians.`))],compute:function(e){let t=F(e,this.locale);return t===0?new zo(M(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:1/Math.tan(t)}},isExported:!0},CJ={description:M(`Hyperbolic cotangent of any real number.`),args:[V(`value (number)`,M(`Any real value to calculate the hyperbolic cotangent of.`))],compute:function(e){let t=F(e,this.locale);return t===0?new zo(M(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:1/Math.tanh(t)}},isExported:!0},wJ={description:M(`Number of empty values.`),args:[V(`value (any, range, repeating)`,M(`Value or range in which to count the number of blanks.`))],compute:function(...e){return{value:ls(e,(e,t)=>t===void 0||t.value===null||t.value===``?e+1:e,0)}},isExported:!0},TJ={description:M(`A conditional count across a range.`),args:[V(`range (range)`,M(`The range that is tested against criterion.`)),V(`criterion (string)`,M(`The pattern or test to apply to range.`))],compute:function(...e){let t=0;return xs(e,(e,n)=>{t+=1},this.locale),{value:t}},isExported:!0},EJ={description:M(`Count values depending on multiple criteria.`),args:[V(`criteria_range (any, range, repeating)`,M(`Range over which to evaluate criteria.`)),V(`criterion (string, repeating)`,M(`Criteria to check.`))],compute:function(...e){let t=0;return xs(e,(e,n)=>{t+=1},this.locale),{value:t}},isExported:!0},DJ={description:M(`Counts number of unique values in a range.`),args:[V(`value (any, range, repeating)`,M(`Value or range to consider for uniqueness.`))],compute:function(...e){return{value:xv(e)}}},OJ={description:M(`Counts number of unique values in a range, filtered by a set of criteria.`),args:[V(`range (range)`,M(`The range of cells from which the number of unique values will be counted.`)),V(`criteria_range (any, range, repeating)`,M(`Range over which to evaluate criteria.`)),V(`criterion (string, repeating)`,M(`Criteria to check.`))],compute:function(e,...t){let n=new Set;return xs(t,(t,r)=>{let i=e[t]?.[r];Os(i)&&n.add(i.value)},this.locale),{value:n.size}}},kJ={description:M(`Cosecant of an angle provided in radians.`),args:[V(`angle (number)`,M(`The angle to find the cosecant of, in radians.`))],compute:function(e){let t=F(e,this.locale);return t===0?new zo(M(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:1/Math.sin(t)}},isExported:!0},AJ={description:M(`Hyperbolic cosecant of any real number.`),args:[V(`value (number)`,M(`Any real value to calculate the hyperbolic cosecant of.`))],compute:function(e){let t=F(e,this.locale);return t===0?new zo(M(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:1/Math.sinh(t)}},isExported:!0},jJ={description:M(`Converts from another base to decimal.`),args:[V(`value (string)`,M(`The number to convert.`)),V(`base (number)`,M(`The base to convert the value from.`))],compute:function(e,t){let n=F(t,this.locale);if(n=Math.floor(n),2>n||n>36)return new P(M(`The base (%s) must be between 2 and 36 inclusive.`,n));let r=I(e);if(r===``)return{value:0};if(!aJ.test(r))return new P(M(`The value (%s) must be a valid base %s representation.`,r,n));let i=r.replace(`-`,``);for(let e of i)if(parseInt(e,36)>=n)return new P(M(`The value (%s) must be a valid base %s representation.`,r,n));let a=parseInt(r,n);return isNaN(a)?new P(M(`The value (%s) must be a valid base %s representation.`,r,n)):{value:a}},isExported:!0},MJ={description:M(`Converts an angle value in radians to degrees.`),args:[V(`angle (number)`,M(`The angle to convert from radians to degrees.`))],compute:function(e){return{value:F(e,this.locale)*180/Math.PI}},isExported:!0},NJ={description:M(`Euler's number, e (~2.718) raised to a power.`),args:[V(`value (number)`,M(`The exponent to raise e.`))],compute:function(e){return{value:Math.exp(F(e,this.locale))}},isExported:!0},PJ={description:M(`Rounds number down to nearest multiple of factor.`),args:[V(`value (number)`,M(`The value to round down to the nearest integer multiple of factor.`)),V(`factor (number, default=1)`,M(`The number to whose multiples value will be rounded.`))],compute:function(e,t={value:1}){let n=F(e,this.locale),r=F(t,this.locale);return r<0&&n>0?new P(M(`The factor (%s) must be positive when the value (%s) is positive.`,r,n)):{value:r?Math.floor(n/r)*r:0,format:e?.format}},isExported:!0};function FJ(e,t,n=0){return t===0?0:(t=Math.abs(t),e>=0?Math.floor(e/t)*t:n===0?-Math.ceil(Math.abs(e)/t)*t:-Math.floor(Math.abs(e)/t)*t)}let IJ={description:M(`Rounds number down to nearest multiple of factor.`),args:[V(`number (number)`,M(`The value to round down to the nearest integer multiple of significance.`)),V(`significance (number, default=1)`,M(`The number to whose multiples number will be rounded. The sign of significance will be ignored.`)),V(`mode (number, default=0)`,M(`If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero.`))],compute:function(e,t={value:1},n={value:0}){let r=F(t,this.locale);return{value:FJ(F(e,this.locale),r,F(n,this.locale)),format:e?.format}},isExported:!0},LJ={description:M(`Rounds number down to nearest multiple of factor.`),args:[V(`number (number)`,M(`The value to round down to the nearest integer multiple of significance.`)),V(`significance (number, default=1)`,M(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){let n=F(t,this.locale);return{value:FJ(F(e,this.locale),n),format:e?.format}},isExported:!0},RJ={description:M(`Whether the provided value is even.`),args:[V(`value (number)`,M(`The value to be verified as even.`))],compute:function(e){let t=Zo(e,this.locale);return{value:!(Math.floor(Math.abs(t))&1)}},isExported:!0},zJ={description:M(`Rounds number up to nearest multiple of factor.`),args:[V(`number (number)`,M(`The value to round up to the nearest integer multiple of significance.`)),V(`significance (number, default=1)`,M(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){return{value:_J(F(e,this.locale),F(t,this.locale)),format:e?.format}},isExported:!0},BJ={description:M(`Whether the provided value is even.`),args:[V(`value (number)`,M(`The value to be verified as even.`))],compute:function(e){let t=Zo(e,this.locale);return{value:!!(Math.floor(Math.abs(t))&1)}},isExported:!0},VJ={description:M(`The logarithm of a number, base e (euler's number).`),args:[V(`value (number)`,M(`The value for which to calculate the logarithm, base e.`))],compute:function(e){let t=F(e,this.locale);return t<=0?new P(M(`The value (%s) must be strictly positive.`,t)):{value:Math.log(t)}},isExported:!0},HJ={description:M(`The logarithm of a number, for a given base.`),args:[V(`value (number)`,M(`The value for which to calculate the logarithm.`)),V(`base (number, default=10)`,M(`The base of the logarithm.`))],compute:function(e,t={value:10}){let n=F(e,this.locale),r=F(t,this.locale);return n<=0?new P(M(`The value (%s) must be strictly positive.`,n)):r<=0?new P(M(`The base (%s) must be strictly positive.`,r)):r===1?new P(M(`The base must be different from 1.`)):{value:Math.log10(n)/Math.log10(r)}},isExported:!0};function UJ(e,t){Sv(t,M(`The divisor must be different from 0.`));let n=e%t;return n>0&&t<0||n<0&&t>0?n+t:n}let WJ={description:M(`Modulo (remainder) operator.`),args:[V(`dividend (number)`,M(`The number to be divided to find the remainder.`)),V(`divisor (number)`,M(`The number to divide by.`))],compute:function(e,t){let n=F(t,this.locale);return{value:UJ(F(e,this.locale),n),format:e?.format}},isExported:!0},GJ={description:M(`Returns a n x n unit matrix, where n is the input dimension.`),args:[V(`dimension (number)`,M(`An integer specifying the dimension size of the unit matrix. It must be positive.`))],computeArray:function(e){let t=Qo(e,this.locale);return t<1?new P(M(`The argument dimension must be positive`)):ps(Dv(t),e=>({value:e}))},isExported:!0},KJ={description:M(`Rounds a number up to the nearest odd integer.`),args:[V(`value (number)`,M(`The value to round to the next greatest odd number.`))],compute:function(e){let t=F(e,this.locale),n=Math.ceil(Math.abs(t));return n=n&1?n:n+1,{value:t<0?-n:n,format:e?.format}},isExported:!0},qJ={description:M(`The number pi.`),args:[],compute:function(){return{value:Math.PI}},isExported:!0},JJ={description:M(`A number raised to a power.`),args:[V(`base (number)`,M(`The number to raise to the exponent power.`)),V(`exponent (number)`,M(`The exponent to raise base to.`))],compute:function(e,t){let n=F(e,this.locale),r=F(t,this.locale);return n<0&&!Number.isInteger(r)?new P(M(`The exponent (%s) must be an integer when the base is negative.`,r)):{value:n**+r,format:e?.format}},isExported:!0},YJ={description:M(`Result of multiplying a series of numbers together.`),args:[V(`factor (number, range<number>, repeating)`,M(`Number or range to calculate for the product.`))],compute:function(...e){let t=0,n=1;for(let r of e)if(yt(r))for(let e of r)for(let r of e){let e=r.value;if(typeof e==`number`&&(n*=e,t+=1),Uo(e))return r}else r!==void 0&&r.value!==null&&(n*=Zo(r,this.locale),t+=1);return{value:t===0?0:n,format:Ho(e[0])}},isExported:!0},XJ={description:M(`A random number between 0 inclusive and 1 exclusive.`),args:[],compute:function(){return{value:Math.random()}},isExported:!0},ZJ={description:M(`Returns a grid of random numbers between 0 inclusive and 1 exclusive.`),args:[V(`rows (number, default=1)`,M(`The number of rows to be returned.`)),V(`columns (number, default=1)`,M(`The number of columns to be returned.`)),V(`min (number, default=0)`,M(`The minimum number you would like returned.`)),V(`max (number, default=1)`,M(`The maximum number you would like returned.`)),V(`whole_number (boolean, default=FALSE)`,M(`Return a whole number or a decimal value.`),[{value:!1,label:M(`Decimal (default)`)},{value:!0,label:M(`Integer`)}])],computeArray:function(e={value:1},t={value:1},n={value:0},r={value:1},i={value:!1}){let a=Qo(t,this.locale),o=Qo(e,this.locale),s=F(n,this.locale),c=F(r,this.locale),l=L(i);if(a<1)return new P(M(`The number of columns (%s) must be positive.`,a));if(o<1)return new P(M(`The number of rows (%s) must be positive.`,o));if(s>c)return new P(M(`The maximum (%s) must be greater than or equal to the minimum (%s).`,c,s));if(l&&(!Number.isInteger(s)||!Number.isInteger(c)))return new P(M(`The maximum (%s) and minimum (%s) must be integers when whole_number is TRUE.`,c.toString(),s.toString()));let u=Array(a);for(let e=0;e<a;e++){u[e]=Array(o);for(let t=0;t<o;t++)l?u[e][t]=Math.floor(Math.random()*(c-s+1)+s):u[e][t]=s+Math.random()*(c-s)}return ps(u,e=>({value:e}))},isExported:!0},QJ={description:M(`Random integer between two values, inclusive.`),args:[V(`low (number)`,M(`The low end of the random range.`)),V(`high (number)`,M(`The high end of the random range.`))],compute:function(e,t){let n=F(e,this.locale);Number.isInteger(n)||(n=Math.ceil(n));let r=F(t,this.locale);return Number.isInteger(r)||(r=Math.floor(r)),n>r?new P(M(`The high (%s) must be greater than or equal to the low (%s).`,r,n)):{value:n+Math.floor((r-n+1)*Math.random()),format:e?.format}},isExported:!0},$J={description:M(`Rounds a number according to standard rules.`),args:[V(`value (number)`,M(`The value to round to places number of places.`)),V(`places (number, default=0)`,M(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=F(e,this.locale),r=F(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.round(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.round(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},eY={description:M(`Rounds down a number.`),args:[V(`value (number)`,M(`The value to round to places number of places, always rounding down.`)),V(`places (number, default=0)`,M(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=F(e,this.locale),r=F(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.floor(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.floor(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},tY={description:M(`Rounds up a number.`),args:[V(`value (number)`,M(`The value to round to places number of places, always rounding up.`)),V(`places (number, default=0)`,M(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=F(e,this.locale),r=F(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.ceil(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.ceil(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},nY={description:M(`Secant of an angle provided in radians.`),args:[V(`angle (number)`,M(`The angle to find the secant of, in radians.`))],compute:function(e){return{value:1/Math.cos(F(e,this.locale))}},isExported:!0},rY={description:M(`Hyperbolic secant of any real number.`),args:[V(`value (number)`,M(`Any real value to calculate the hyperbolic secant of.`))],compute:function(e){return{value:1/Math.cosh(F(e,this.locale))}},isExported:!0},iY={description:M(`Returns a sequence of numbers.`),args:[V(`rows (number)`,M(`The number of rows to return`)),V(`columns (number, optional, default=1)`,M(`The number of columns to return`)),V(`start (number, optional, default=1)`,M(`The first number in the sequence`)),V(`step (number, optional, default=1)`,M(`The amount to increment each value in the sequence`))],computeArray:function(e,t={value:1},n={value:1},r={value:1}){let i=F(n,this.locale),a=F(r,this.locale),o=Qo(e,this.locale),s=Qo(t,this.locale);return s<1?new P(M(`The number of columns (%s) must be positive.`,s)):o<1?new P(M(`The number of rows (%s) must be positive.`,o)):fs(s,o,(e,t)=>({value:i+t*s*a+e*a}))},isExported:!0},aY={description:M(`Sine of an angle provided in radians.`),args:[V(`angle (number)`,M(`The angle to find the sine of, in radians.`))],compute:function(e){return{value:Math.sin(F(e,this.locale))}},isExported:!0},oY={description:M(`Hyperbolic sine of any real number.`),args:[V(`value (number)`,M(`Any real value to calculate the hyperbolic sine of.`))],compute:function(e){return{value:Math.sinh(F(e,this.locale))}},isExported:!0},sY={description:M(`Positive square root of a positive number.`),args:[V(`value (number)`,M(`The number for which to calculate the positive square root.`))],compute:function(e){let t=F(e,this.locale);return t<0?new P(M(`The value (%s) must be positive or null.`,t)):{value:Math.sqrt(t),format:e?.format}},isExported:!0},cY={1:`AVERAGE`,2:`COUNT`,3:`COUNTA`,4:`MAX`,5:`MIN`,6:`PRODUCT`,7:`STDEV`,8:`STDEVP`,9:`SUM`,10:`VAR`,11:`VARP`},lY=Object.entries(cY).map(([e,t])=>({value:parseInt(e),label:M(`%s (include manually-hidden rows)`,t)})),uY=Object.entries(cY).map(([e,t])=>({value:parseInt(e)+100,label:M(`%s (exclude manually-hidden rows)`,t)})),dY={description:M(`Returns a subtotal for a vertical range of cells using a specified aggregation function.`),args:[V(`function_code (number)`,M(`The function to use in subtotal aggregation.`),[...lY,...uY]),V(`ref (any, range<any>, repeating)`,M(`Range or reference for which you want the subtotal.`))],compute:function(e,...t){let n=Qo(e,this.locale),r=!0;if(n>100&&(n-=100,r=!1),n<1||n>11)return new P(M(`The function code (%s) must be between 1 to 11 or 101 to 111.`,n));let i=[];for(let e of t){let t=R(e),n=t[0][0]?.position;if(n===void 0)return new Fo(Ko);let a=n.col+t.length-1,o=n.row+t[0].length-1,s=n.sheetId;for(let e=n.row;e<=o;e++)if(!this.getters.isRowFiltered(s,e)&&!(!r&&this.getters.isRowHiddenByUser(s,e)))for(let t=n.col;t<=a;t++){let n=this.getters.getCorrespondingFormulaCell({sheetId:s,col:t,row:e});(!n||!wn(n,`SUBTOTAL`))&&i.push(this.getFormulaResult({sheetId:s,col:t,row:e}))}}let a=cY[n],o=[i];return jv(ol(ml.get(a),o.length)(this,o))},isExported:!0},fY={description:M(`Sum of a series of numbers and/or cells.`),args:[V(`value (number, range<number>, repeating)`,M(`Number or range to add together.`))],compute:function(...e){let t=e[0];return{value:bv(e,this.locale),format:Ho(t)}},isExported:!0},pY={description:M(`A conditional sum across a range.`),args:[V(`criteria_range (range)`,M(`The range which is tested against criterion.`)),V(`criterion (string)`,M(`The pattern or test to apply to range.`)),V(`sum_range (range, default=criteria_range)`,M(`The range to be summed, if different from range.`))],compute:function(e,t,n){n===void 0&&(n=e);let r=0;return xs([e,t],(e,t)=>{let i=n[e]?.[t]?.value;typeof i==`number`&&(r+=i)},this.locale),{value:r}},isExported:!0},mY={description:M(`Sums a range depending on multiple criteria.`),args:[V(`sum_range (range)`,M(`The range to sum.`)),V(`criteria_range (any, range, repeating)`,M(`Range to check.`)),V(`criterion (string, repeating)`,M(`Criteria to check.`))],compute:function(e,...t){let n=0;return xs(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n+=i)},this.locale),{value:n}},isExported:!0},hY={description:M(`Tangent of an angle provided in radians.`),args:[V(`angle (number)`,M(`The angle to find the tangent of, in radians.`))],compute:function(e){return{value:Math.tan(F(e,this.locale))}},isExported:!0},gY={description:M(`Hyperbolic tangent of any real number.`),args:[V(`value (number)`,M(`Any real value to calculate the hyperbolic tangent of.`))],compute:function(e){return{value:Math.tanh(F(e,this.locale))}},isExported:!0};function _Y(e,t){return t===0?Math.trunc(e):(Number.isInteger(t)||(t=Math.trunc(t)),Math.trunc(e*10**t)/10**t)}let vY={description:M(`Truncates a number.`),args:[V(`value (number)`,M(`The value to be truncated.`)),V(`places (number, default=0)`,M(`The number of significant digits to the right of the decimal point to retain.`))],compute:function(e,t={value:0}){return{value:_Y(F(e,this.locale),F(t,this.locale)),format:e?.format}},isExported:!0},yY={description:M(`Rounds a number down to the nearest integer that is less than or equal to it.`),args:[V(`value (number)`,M(`The number to round down to the nearest integer.`))],compute:function(e){return{value:Math.floor(F(e,this.locale))}},isExported:!0};var bY=l({AVEDEV:()=>AY,AVERAGE:()=>jY,AVERAGEA:()=>FY,AVERAGEIF:()=>IY,AVERAGEIFS:()=>LY,AVERAGE_WEIGHTED:()=>PY,CHISQ_DIST_RT:()=>UY,CHISQ_TEST:()=>WY,CONFIDENCE_NORM:()=>GY,CONFIDENCE_T:()=>KY,CORREL:()=>pX,COUNT:()=>RY,COUNTA:()=>zY,COVAR:()=>BY,COVARIANCE_P:()=>VY,COVARIANCE_S:()=>HY,FORECAST:()=>JY,F_TEST:()=>qY,GEOMEAN:()=>YY,GROWTH:()=>XY,HARMEAN:()=>ZY,INTERCEPT:()=>QY,KURT:()=>$Y,LARGE:()=>eX,LINEST:()=>tX,LOGEST:()=>nX,MATTHEWS:()=>rX,MAX:()=>iX,MAXA:()=>aX,MAXIFS:()=>oX,MEDIAN:()=>sX,MIN:()=>cX,MINA:()=>lX,MINIFS:()=>uX,PEARSON:()=>fX,PERCENTILE:()=>mX,PERCENTILE_EXC:()=>hX,PERCENTILE_INC:()=>gX,POLYFIT_COEFFS:()=>_X,POLYFIT_FORECAST:()=>vX,QUARTILE:()=>yX,QUARTILE_EXC:()=>bX,QUARTILE_INC:()=>xX,RANK:()=>SX,RSQ:()=>CX,SKEW:()=>TX,SKEW_P:()=>EX,SLOPE:()=>wX,SMALL:()=>DX,SPEARMAN:()=>OX,STDEV:()=>kX,STDEVA:()=>MX,STDEVP:()=>NX,STDEVPA:()=>PX,STDEV_P:()=>AX,STDEV_S:()=>jX,STEYX:()=>IX,TREND:()=>LX,TRIMMEAN:()=>RX,T_TEST:()=>FX,VAR:()=>zX,VARA:()=>HX,VARP:()=>UX,VARPA:()=>WX,VAR_P:()=>BX,VAR_S:()=>VX});let xY=[{value:!0,label:M(`b is calculated normally`)},{value:!1,label:M(`b is forced to 1`)}],SY=[{value:!1,label:M(`do not return additional regression statistics`)},{value:!0,label:M(`return additional regression statistics`)}],CY=[{value:1,label:M(`order 1 (Linear)`)},{value:2,label:M(`order 2 (Quadratic)`)},{value:3,label:M(`order 3 (Cubic)`)},{value:4,label:M(`order 4 (Quartic)`)},{value:5,label:M(`order 5 (Quintic)`)},{value:6,label:M(`order 6 (Sextic)`)}],wY=[{value:!0,label:M(`Compute intercept`)},{value:!1,label:M(`Force intercept to 0`)}],TY=[{value:0,label:M(`Minimum value`)},{value:1,label:M(`First quartile (25th percentile)`)},{value:2,label:M(`Median value (50th percentile)`)},{value:3,label:M(`Third quartile (75th percentile)`)},{value:4,label:M(`Maximum value`)}];function EY(e,t){let n=[],r=[],i=0,a=0;os([e],e=>{n.push(e),i+=1}),os([t],e=>{r.push(e),a+=1}),W(i===a,M(`[[FUNCTION_NAME]] has mismatched argument count %s vs %s.`,i,a));let o=[],s=[];for(let e=0;e<i;e++){let t=n[e]?.value,i=r[e]?.value;typeof t==`number`&&typeof i==`number`&&(s.push(t),o.push(i))}return{flatDataX:o,flatDataY:s}}function DY(e,t,n){let{flatDataX:r,flatDataY:i}=EY(e,t),a=i.length;Sv(a),n&&Sv(a-1);let o=0,s=0;for(let e=0;e<a;e++)o+=i[e],s+=r[e];let c=o/a,l=s/a,u=0;for(let e=0;e<a;e++)u+=(i[e]-c)*(r[e]-l);return u/(a-+!!n)}function OY(e,t,n,r){let i=0,a=n?ds:us,o=a(e,(e,t)=>(i+=1,e+t),0,r);Sv(i),t&&Sv(i-1);let s=o/i;return a(e,(e,t)=>e+(t-s)**2,0,r)/(i-+!!t)}function kY(e,t,n,r){let i=F(t,r);W(n?0<=i&&i<=1:0<i&&i<1,M(`Function [[FUNCTION_NAME]] parameter 2 value is out of range.`));let a=[],o,s=0;return os(e,e=>{let t=e?.value;typeof t==`number`&&(o=Ss(a,e,`nextSmaller`,`asc`,a.length,(e,t)=>e[t]),a.splice(o+1,0,t),s++)}),W(s!==0,ks),n||W(1/(s+1)<=i&&i<=s/(s+1),M(`Function [[FUNCTION_NAME]] parameter 2 value is out of range.`)),Co(a,i,n)}let AY={description:M(`Average magnitude of deviations from mean.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the sample.`))],compute:function(...e){let t=0,n=us(e,(e,n)=>(t+=1,e+n),0,this.locale);if(t===0)return new zo(M(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`));let r=n/t;return{value:us(e,(e,t)=>e+Math.abs(r-t),0,this.locale)/t}},isExported:!0},jY={description:M(`Numerical average value in a dataset, ignoring text.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to consider when calculating the average value.`))],compute:function(...e){return{value:Iv(e,this.locale),format:Ho(e[0])}},isExported:!0},MY=M(`[[FUNCTION_NAME]] has mismatched range sizes.`),NY=M(`[[FUNCTION_NAME]] expects the weight to be positive or equal to 0.`),PY={description:M(`Weighted average.`),args:[V(`values (number, range<number>, repeating)`,M(`Value to average.`)),V(`weights (number, range<number>, repeating)`,M(`Weight for each corresponding value.`))],compute:function(...e){let t=0,n=0;for(let r=0;r<e.length-1;r+=2){let i=e[r],a=e[r+1];if(!wv(i,a))return new P(MY);if(yt(i))for(let e=0;e<i.length;e++)for(let r=0;r<i[0].length;r++){let o=i[e][r].value,s=yt(a)?a?.[e][r].value:F(a,this.locale),c=typeof o==`number`,l=typeof s==`number`;if(c&&l){if(s<0)return new P(NY);t+=o*s,n+=s;continue}if(c!==l)return new P(M(`[[FUNCTION_NAME]] expects number values.`))}else{let e=F(i,this.locale),r=yt(a)?a?.[0][0].value:F(a,this.locale);if(typeof r==`number`){if(r<0)return new P(NY);t+=e*r,n+=r}}}return n===0?new zo(M(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:t/n,format:Ho(e[0])}}},FY={description:M(`Numerical average value in a dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to consider when calculating the average value.`))],compute:function(...e){let t=0,n=ds(e,(e,n)=>(t+=1,e+n),0,this.locale);return t===0?new zo(M(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:n/t,format:Ho(e[0])}},isExported:!0},IY={description:M(`Average of values depending on criteria.`),args:[V(`criteria_range (number, range<number>)`,M(`The range to check against criterion.`)),V(`criterion (string)`,M(`The pattern or test to apply to criteria_range.`)),V(`average_range (number, range<number>, default=criteria_range)`,M(`The range to average. If not included, criteria_range is used for the average instead.`))],compute:function(e,t,n){let r=R(n===void 0?e:n),i=0,a=0;return xs([e,t],(e,t)=>{let n=r[e]?.[t]?.value;typeof n==`number`&&(i+=1,a+=n)},this.locale),i===0?new zo(M(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:a/i}},isExported:!0},LY={description:M(`Average of values depending on multiple criteria.`),args:[V(`average_range (range)`,M(`The range to average.`)),V(`criteria_range (any, range, repeating)`,M(`Range to check.`)),V(`criterion (string, repeating)`,M(`Criterion to check.`))],compute:function(e,...t){let n=R(e),r=0,i=0;return xs(t,(e,t)=>{let a=n[e]?.[t]?.value;typeof a==`number`&&(r+=1,i+=a)},this.locale),r===0?new zo(M(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:i/r}},isExported:!0},RY={description:M(`The number of numeric values in dataset.`),args:[V(`value (number, any, range<number>, repeating)`,M(`Value or range to consider when counting.`))],compute:function(...e){return{value:Rv(e,this.locale)}},isExported:!0},zY={description:M(`The number of values in a dataset.`),args:[V(`value (any, range, repeating)`,M(`Value or range to consider when counting.`))],compute:function(...e){return{value:zv(e)}},isExported:!0},BY={description:M(`The covariance of a dataset.`),args:[V(`data_y (any, range)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (any, range)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return{value:DY(e,t,!1)}},isExported:!0},VY={description:M(`The covariance of a dataset.`),args:[V(`data_y (any, range)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (any, range)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return{value:DY(e,t,!1)}},isExported:!0},HY={description:M(`The sample covariance of a dataset.`),args:[V(`data_y (any, range)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (any, range)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return{value:DY(e,t,!0)}},isExported:!0},UY={description:M(`Upper tail of the chi-square distribution.`),args:[V(`x (number)`,M(`The value to evaluate.`)),V(`degrees_of_freedom (number)`,M(`The degrees of freedom.`))],compute:function(e,t){let n=F(e,this.locale),r=Math.round(F(t,this.locale));return W(n>=0,M(`x must be non-negative.`)),W(r>=1,M(`Degrees of freedom must be >= 1.`)),{value:Qv(r/2,n/2)}},isExported:!0},WY={description:M(`Returns the p-value of a chi-square test for independence, comparing actual to expected values.`),args:[V(`actual_range (range<number>)`,M(`The range containing the observed values.`)),V(`expected_range (range<number>)`,M(`The range containing the expected values.`))],compute:function(e,t){W(wv(e,t),M(`The two ranges must have the same dimensions.`));let n=Xo(e,`actual_range`),r=Xo(t,`expected_range`),i=n.length,a=n[0]?.length??0;W(i*a>0,ks);let o=0;for(let e=0;e<i;e++)for(let t=0;t<a;t++){let i=r[e][t];Sv(i);let a=n[e][t]-i;o+=a*a/i}let s;return s=a>1&&i>1?(a-1)*(i-1):a===1?i-1:a-1,W(s>=1,M(`The ranges must contain at least 2 values.`)),{value:Qv(s/2,o/2)}},isExported:!0},GY={description:M(`Half-width of the confidence interval for a population mean (normal distribution).`),args:[V(`alpha (number)`,M(`The significance level (e.g. 0.05 for 95% CI).`)),V(`standard_deviation (number)`,M(`The population standard deviation.`)),V(`size (number)`,M(`The sample size.`))],compute:function(e,t,n){let r=F(e,this.locale),i=F(t,this.locale),a=Math.round(F(n,this.locale));return W(r>0&&r<1,M(`Alpha must be between 0 and 1.`)),W(i>0,M(`Standard deviation must be positive.`)),W(a>=1,M(`Size must be >= 1.`)),{value:-ty(r/2)*i/Math.sqrt(a)}},isExported:!0},KY={description:M(`Half-width of the confidence interval for a population mean (t-distribution).`),args:[V(`alpha (number)`,M(`The significance level (e.g. 0.05 for 95% CI).`)),V(`standard_deviation (number)`,M(`The sample standard deviation.`)),V(`size (number)`,M(`The sample size.`))],compute:function(e,t,n){let r=F(e,this.locale),i=F(t,this.locale),a=Math.round(F(n,this.locale));return W(r>0&&r<1,M(`Alpha must be between 0 and 1.`)),W(i>0,M(`Standard deviation must be positive.`)),W(a>=2,M(`Size must be >= 2.`)),{value:ry(r,a-1)*i/Math.sqrt(a)}},isExported:!0},qY={description:M(`Returns the two-tailed p-value of an F-test comparing the variances of two datasets.`),args:[V(`range1 (range<number>)`,M(`The first sample.`)),V(`range2 (range<number>)`,M(`The second sample.`))],compute:function(e,t){let n=[],r=[];ss([e],e=>n.push(e.value),this.locale),ss([t],e=>r.push(e.value),this.locale);let i=n.length,a=r.length;W(i>=2&&a>=2,M(`Each range must contain at least 2 numeric values.`));let o=n.reduce((e,t)=>e+t,0)/i,s=r.reduce((e,t)=>e+t,0)/a,c=n.reduce((e,t)=>e+(t-o)**2,0)/(i-1),l=r.reduce((e,t)=>e+(t-s)**2,0)/(a-1);Sv(c),Sv(l);let u=c/l,d=i-1,f=a-1,p=$v(d*u/(d*u+f),d/2,f/2);return{value:2*Math.min(p,1-p)}},isExported:!0},JY={description:M(`Calculates the expected y-value for a specified x based on a linear regression of a dataset.`),args:[V(`x (number, range<number>)`,M(`The value(s) on the x-axis to forecast.`)),V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`))],computeArray:function(e,t,n){let{flatDataX:r,flatDataY:i}=EY(t,n);return r.length===0||i.length===0?new Io(ks):ps(Yv([i],[r],ps(R(e),e=>F(e,this.locale)),!0),e=>({value:e}))},isExported:!0},YY={description:M(`Geometric mean of a dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Values to include.`))],compute:function(...e){let t=0,n=0;return ss(e,e=>{W(e.value>0,M(`GEOMEAN requires strictly positive values.`)),t+=Math.log(e.value),n++},this.locale),W(n>0,ks),{value:Math.exp(t/n)}},isExported:!0},XY={description:M(`Fits points to exponential growth trend.`),args:[V(`known_data_y (range<number>)`,M(`The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.`)),V(`known_data_x (range<number>, default={1;2;3;...})`,M(`The values of the independent variable(s) corresponding with known_data_y.`)),V(`new_data_x (any, range, default=known_data_x)`,M(`The data points to return the y values for on the ideal curve fit.`)),V(`b (boolean, default=TRUE)`,M(`Given a general exponential form of y = b*m^x for a curve fit, calculates b if TRUE or forces b to be 1 and only calculates the m values if FALSE.`),xY)],computeArray:function(e,t=[[]],n=[[]],r={value:!0}){return e.length===0||e[0].length===0?new P(As(`known_data_y`)):ps(qv(Yv(Jv(Xo(e,`known_data_y`)),Xo(t,`known_data_x`),Xo(n,`new_data_y`),L(r))),e=>({value:e}))}},ZY={description:M(`Harmonic mean of a dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Values to include.`))],compute:function(...e){let t=0,n=0;return ss(e,e=>{W(e.value>0,M(`HARMEAN requires strictly positive values.`)),t+=1/e.value,n++},this.locale),W(n>0,ks),{value:n/t}},isExported:!0},QY={description:M(`Compute the intercept of the linear regression.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=EY(e,t);if(n.length===0||r.length===0)return new Io(ks);let[[],[i]]=Uv([n],[r]);return{value:i}},isExported:!0},$Y={description:M(`Excess kurtosis of a dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Values to include.`))],compute:function(...e){let t=[];ss(e,e=>t.push(e.value),this.locale);let n=t.length;W(n>=4,M(`KURT requires at least 4 values.`));let r=t.reduce((e,t)=>e+t,0)/n,i=t.reduce((e,t)=>e+(t-r)**2,0)/(n-1);W(i>0,M(`KURT requires non-constant data.`));let a=Math.sqrt(i),o=t.reduce((e,t)=>e+((t-r)/a)**4,0);return{value:n*(n+1)/((n-1)*(n-2)*(n-3))*o-3*(n-1)**2/((n-2)*(n-3))}},isExported:!0},eX={description:M(`Nth largest element from a data set.`),args:[V(`data (any, range)`,M(`Array or range containing the dataset to consider.`)),V(`n (number)`,M(`The rank from largest to smallest of the element to return.`))],compute:function(e,t){let n=Math.trunc(F(t?.value,this.locale)),r=[],i,a=0;os([e],e=>{typeof e?.value==`number`&&(i=Ss(r,e,`nextSmaller`,`asc`,r.length,(e,t)=>e[t].value),r.splice(i+1,0,e),a++,a>n&&(r.shift(),a--))});let o=r.shift();return o===void 0?new P(ks):a<n?new P(M(`Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.`,n)):o},isExported:!0},tX={description:M(`Given partial data about a linear trend, calculates various parameters about the ideal linear trend using the least-squares method.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>, default={1;2;3;...})`,M(`The range representing the array or matrix of independent data.`)),V(`calculate_b (boolean, default=TRUE)`,M(`A flag specifying whether to compute the slope or not`),xY),V(`verbose (boolean, default=FALSE)`,M(`A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept`),SY)],computeArray:function(e,t=[[]],n={value:!0},r={value:!1}){return e.length===0||e[0].length===0?new P(As(`data_y`)):ps(Uv(Xo(t,`data_x`),Xo(e,`data_y`),L(n),L(r)),e=>({value:e}))},isExported:!0},nX={description:M(`Given partial data about an exponential growth curve, calculates various parameters about the best fit ideal exponential growth curve.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>, optional, default={1;2;3;...})`,M(`The range representing the array or matrix of independent data.`)),V(`calculate_b (boolean, default=TRUE)`,M(`A flag specifying whether to compute the slope or not`),xY),V(`verbose (boolean, default=FALSE)`,M(`A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept`),SY)],computeArray:function(e,t=[[]],n={value:!0},r={value:!1}){if(e.length===0||e[0].length===0)return new P(As(`data_y`));let i=Uv(Xo(t,`data_x`),Jv(Xo(e,`data_y`)),L(n),L(r));for(let e=0;e<i.length;e++)i[e][0]=Math.exp(i[e][0]);return ps(i,e=>({value:e}))},isExported:!0},rX={description:M(`Compute the Matthews correlation coefficient of a dataset.`),args:[V(`data_x (range)`,M(`The range representing the array or matrix of observed data.`)),V(`data_y (range)`,M(`The range representing the array or matrix of predicted data.`))],compute:function(e,t){let n=e.flat(),r=t.flat();if(Fv(n,r),n.length===0||r.length===0)return new Io(ks);let i=n.length,a=0,o=0,s=0,c=0;for(let e=0;e<i;++e){let t=L(n[e]);t===L(r[e])?t?o++:a++:t?c++:s++}return{value:(o*a-s*c)/Math.sqrt((o+s)*(o+c)*(a+s)*(a+c))}},isExported:!1},iX={description:M(`Maximum value in a numeric dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to consider when calculating the maximum value.`))],compute:function(...e){return Bv(e,this.locale)},isExported:!0},aX={description:M(`Maximum numeric value in a dataset.`),args:[V(`value (any, range, repeating)`,M(`Value or range to consider when calculating the maximum value.`))],compute:function(...e){let t=ds(e,(e,t)=>Math.max(t,e),-1/0,this.locale);return{value:t===-1/0?0:t,format:Ho(e[0])}},isExported:!0},oX={description:M(`Returns the maximum value in a range of cells, filtered by a set of criteria.`),args:[V(`range (range)`,M(`The range of cells from which the maximum will be determined.`)),V(`criteria_range (any, range, repeating)`,M(`Range to evaluate criteria.`)),V(`criterion (string, repeating)`,M(`Criteria to check.`))],compute:function(e,...t){let n=-1/0;return xs(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n=n<i?i:n)},this.locale),{value:n===-1/0?0:n}},isExported:!0},sX={description:M(`Median value in a numeric dataset.`),args:[V(`value (any, range, repeating)`,M(`Value or range to consider when calculating the median value.`))],compute:function(...e){let t=[];return ss(e,e=>{t.push(e)},this.locale),{value:kY(t,{value:.5},!0,this.locale),format:Ho(t[0])}},isExported:!0},cX={description:M(`Minimum value in a numeric dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to consider when calculating the minimum value.`))],compute:function(...e){return Vv(e,this.locale)},isExported:!0},lX={description:M(`Minimum numeric value in a dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to consider when calculating the minimum value.`))],compute:function(...e){let t=ds(e,(e,t)=>Math.min(t,e),1/0,this.locale);return{value:t===1/0?0:t,format:Ho(e[0])}},isExported:!0},uX={description:M(`Returns the minimum value in a range of cells, filtered by a set of criteria.`),args:[V(`range (range)`,M(`The range of cells from which the minimum will be determined.`)),V(`criteria_range (any, range, repeating)`,M(`Range to evaluate criteria.`)),V(`criterion (string, repeating)`,M(`Criterion to check.`))],compute:function(e,...t){let n=1/0;return xs(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n=n>i?i:n)},this.locale),{value:n===1/0?0:n}},isExported:!0};function dX(e,t){let{flatDataX:n,flatDataY:r}=EY(e,t);if(n.length===0||r.length===0)return new Io(ks);let i=n.length,a=0,o=0,s=0,c=0,l=0;for(let e=0;e<i;e++){let t=n[e],i=r[e];a+=t,o+=i,s+=t*i,c+=t*t,l+=i*i}let u=Math.sqrt((i*c-a*a)*(i*l-o*o));return u===0?new zo:(i*s-a*o)/u}let fX={description:M(`Compute the Pearson product-moment correlation coefficient of a dataset.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let n=dX(e,t);return n instanceof zo||n instanceof Io?n:{value:n}},isExported:!0},pX=fX,mX={description:M(`Value at a given percentile of a dataset.`),args:[V(`data (any, range)`,M(`The array or range containing the dataset to consider.`)),V(`percentile (number)`,M(`The percentile whose value within data will be calculated and returned.`))],compute:function(e,t){return gX.compute.bind(this)(e,t)},isExported:!0},hX={description:M(`Value at a given percentile of a dataset exclusive of 0 and 1.`),args:[V(`data (any, range)`,M(`The array or range containing the dataset to consider.`)),V(`percentile (number)`,M(`The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.`))],compute:function(e,t){return{value:kY([e],t,!1,this.locale),format:Ho(e)}},isExported:!0},gX={description:M(`Value at a given percentile of a dataset.`),args:[V(`data (any, range)`,M(`The array or range containing the dataset to consider.`)),V(`percentile (number)`,M(`The percentile whose value within data will be calculated and returned.`))],compute:function(e,t){return{value:kY([e],t,!0,this.locale),format:Ho(e)}},isExported:!0},_X={description:M(`Compute the coefficients of polynomial regression of the dataset.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`)),V(`order (number)`,M(`The order of the polynomial to fit the data, between 1 and 6.`),CY),V(`intercept (boolean, default=TRUE)`,M(`A flag specifying whether to compute the intercept or not.`),wY)],computeArray:function(e,t,n,r={value:!0}){let{flatDataX:i,flatDataY:a}=EY(e,t);return i.length===0||a.length===0?new Io(ks):ps(Wv(a,i,F(n,this.locale),L(r)),e=>({value:e}))},isExported:!1},vX={description:M(`Predict value by computing a polynomial regression of the dataset.`),args:[V(`x (number, range<number>)`,M(`The value(s) on the x-axis to forecast.`)),V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`)),V(`order (number)`,M(`The order of the polynomial to fit the data, between 1 and 6.`),CY),V(`intercept (boolean, default=TRUE)`,M(`A flag specifying whether to compute the intercept or not.`),wY)],computeArray:function(e,t,n,r,i={value:!0}){let a=F(r,this.locale),{flatDataX:o,flatDataY:s}=EY(t,n);if(o.length===0||s.length===0)return new Io(ks);let c=Wv(s,o,a,L(i)).flat();return ps(R(e),e=>({value:Kv(c,F(e,this.locale),a)}))},isExported:!1},yX={description:M(`Value nearest to a specific quartile of a dataset.`),args:[V(`data (any, range)`,M(`The array or range containing the dataset to consider.`)),V(`quartile_number (number)`,M(`Which quartile value to return.`),TY)],compute:function(e,t){return xX.compute.bind(this)(e,t)},isExported:!0},bX={description:M(`Value nearest to a specific quartile of a dataset exclusive of 0 and 4.`),args:[V(`data (any, range)`,M(`The array or range containing the dataset to consider.`)),V(`quartile_number (number)`,M(`Which quartile value, exclusive of 0 and 4, to return.`),[{value:1,label:M(`First quartile (25th percentile)`)},{value:2,label:M(`Median value (50th percentile)`)},{value:3,label:M(`Third quartile (75th percentile)`)}])],compute:function(e,t){let n={value:.25*Math.trunc(F(t,this.locale))};return{value:kY([e],n,!1,this.locale),format:Ho(e)}},isExported:!0},xX={description:M(`Value nearest to a specific quartile of a dataset.`),args:[V(`data (any, range)`,M(`The array or range containing the dataset to consider.`)),V(`quartile_number (number)`,M(`Which quartile value to return.`),TY)],compute:function(e,t){let n={value:.25*Math.trunc(F(t,this.locale))};return{value:kY([e],n,!0,this.locale),format:Ho(e)}},isExported:!0},SX={description:M(`Returns the rank of a specified value in a dataset.`),args:[V(`value (number)`,M(`The value whose rank will be determined.`)),V(`data (range)`,M(`The range containing the dataset to consider.`)),V(`is_ascending (boolean, default=FALSE)`,M(`Whether to consider the values in data in descending or ascending order.`),[{value:!1,label:M(`Descending`)},{value:!0,label:M(`Ascending`)}])],compute:function(e,t,n={value:!1}){let r=L(n),i=F(e,this.locale),a=1,o=!1;for(let e of t)for(let t of e){if(typeof t.value!=`number`)continue;let e=F(t,this.locale);e===i?o=!0:e>i!==r&&a++}return o?{value:a}:new Io(M(`Value not found in the given data.`))},isExported:!0},CX={description:M(`Compute the square of r, the Pearson product-moment correlation coefficient of a dataset.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let n=dX(e,t);return n instanceof zo||n instanceof Io?n:{value:n**2}},isExported:!0},wX={description:M(`Compute the slope of the linear regression.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=EY(e,t);if(n.length===0||r.length===0)return new Io(ks);let[[i]]=Uv([n],[r]);return{value:i}},isExported:!0},TX={description:M(`Skewness of a dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Values to include.`))],compute:function(...e){let t=[];ss(e,e=>t.push(e.value),this.locale);let n=t.length;W(n>=3,M(`SKEW requires at least 3 values.`));let r=t.reduce((e,t)=>e+t,0)/n,i=t.reduce((e,t)=>e+(t-r)**2,0)/(n-1);W(i>0,M(`SKEW requires non-constant data.`));let a=Math.sqrt(i),o=t.reduce((e,t)=>e+((t-r)/a)**3,0);return{value:n/((n-1)*(n-2))*o}},isExported:!0},EX={description:M(`Population skewness of a dataset.`),args:[V(`value (number, range<number>, repeating)`,M(`Values to include.`))],compute:function(...e){let t=[];ss(e,e=>t.push(e.value),this.locale);let n=t.length;W(n>=3,M(`SKEW.P requires at least 3 values.`));let r=t.reduce((e,t)=>e+t,0)/n,i=t.reduce((e,t)=>e+(t-r)**2,0)/n;W(i>0,M(`SKEW.P requires non-constant data.`));let a=Math.sqrt(i);return{value:t.reduce((e,t)=>e+((t-r)/a)**3,0)/n}},isExported:!0},DX={description:M(`Nth smallest element in a data set.`),args:[V(`data (any, range)`,M(`The array or range containing the dataset to consider.`)),V(`n (number)`,M(`The rank from smallest to largest of the element to return.`))],compute:function(e,t){let n=Math.trunc(F(t?.value,this.locale)),r=[],i,a=0;os([e],e=>{typeof e?.value==`number`&&(i=Ss(r,e,`nextSmaller`,`asc`,r.length,(e,t)=>e[t].value),r.splice(i+1,0,e),a++,a>n&&(r.pop(),a--))});let o=r.pop();return o===void 0?new P(ks):a<n?new P(M(`Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.`,n)):o},isExported:!0},OX={description:M(`Compute the Spearman rank correlation coefficient of a dataset.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=EY(t,e);if(n.length===0||r.length===0)return new Io(ks);let i=n.length,a=n.map((e,t)=>[e,r[t]]);a.sort((e,t)=>e[0]-t[0]);for(let e=0;e<i;++e)a[e][0]=e;a.sort((e,t)=>e[1]-t[1]);let o=0;for(let e=0;e<i;++e)o+=(a[e][0]-e)**2;return{value:1-6*o/(i**3-i)}},isExported:!1},kX={description:M(`Standard deviation.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the sample.`))],compute:function(...e){return{value:Math.sqrt(zX.compute.bind(this)(...e).value)}},isExported:!0},AX={description:M(`Standard deviation of entire population.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the population.`))],compute:function(...e){return{value:Math.sqrt(BX.compute.bind(this)(...e).value)}},isExported:!0},jX={description:M(`Standard deviation.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the sample.`))],compute:function(...e){return{value:Math.sqrt(VX.compute.bind(this)(...e).value)}},isExported:!0},MX={description:M(`Standard deviation of sample (text as 0).`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the sample.`))],compute:function(...e){return{value:Math.sqrt(HX.compute.bind(this)(...e).value)}},isExported:!0},NX={description:M(`Standard deviation of entire population.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the population.`))],compute:function(...e){return{value:Math.sqrt(UX.compute.bind(this)(...e).value)}},isExported:!0},PX={description:M(`Standard deviation of entire population (text as 0).`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the population.`))],compute:function(...e){return{value:Math.sqrt(WX.compute.bind(this)(...e).value)}},isExported:!0},FX={description:M(`Returns the p-value of a Student's t-test.`),args:[V(`range1 (range<number>)`,M(`The first sample.`)),V(`range2 (range<number>)`,M(`The second sample.`)),V(`tails (number)`,M(`1 for one-tailed, 2 for two-tailed.`)),V(`type (number)`,M(`1 = paired, 2 = two-sample equal variance, 3 = two-sample unequal variance (Welch).`))],compute:function(e,t,n,r){let i=Math.round(F(n,this.locale)),a=Math.round(F(r,this.locale));W(i===1||i===2,M(`Tails must be 1 or 2.`)),W(a>=1&&a<=3,M(`Type must be 1, 2, or 3.`));let o=[],s=[];ss([e],e=>o.push(e.value),this.locale),ss([t],e=>s.push(e.value),this.locale);let c,l;if(a===1){W(o.length===s.length,M(`Paired t-test requires equal-length ranges.`));let e=o.map((e,t)=>e-s[t]),t=e.length;W(t>=2,M(`Paired t-test requires at least 2 pairs.`));let n=e.reduce((e,t)=>e+t,0)/t,r=e.reduce((e,t)=>e+(t-n)**2,0)/(t-1);if(r===0){let e=+(n===0);return{value:i===1?e/2:e}}c=Math.abs(n)/Math.sqrt(r/t),l=t-1}else{let e=o.length,t=s.length;W(e>=2&&t>=2,M(`Each range must contain at least 2 numeric values.`));let n=o.reduce((e,t)=>e+t,0)/e,r=s.reduce((e,t)=>e+t,0)/t,i=o.reduce((e,t)=>e+(t-n)**2,0)/(e-1),u=s.reduce((e,t)=>e+(t-r)**2,0)/(t-1);if(a===2){let a=((e-1)*i+(t-1)*u)/(e+t-2);W(a>0,M(`T.TEST requires non-constant data.`)),c=Math.abs(n-r)/Math.sqrt(a*(1/e+1/t)),l=e+t-2}else{let a=i/e,o=u/t;W(a+o>0,M(`T.TEST requires non-constant data.`)),c=Math.abs(n-r)/Math.sqrt(a+o),l=(a+o)**2/(a**2/(e-1)+o**2/(t-1))}}let u=ny(c,l);return{value:i===1?u/2:u}},isExported:!0},IX={description:M(`Calculates the standard error of the predicted y-value for each x in the regression of a dataset.`),args:[V(`data_y (range<number>)`,M(`The range representing the array or matrix of dependent data.`)),V(`data_x (range<number>)`,M(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=EY(e,t);return n.length===0||r.length===0?new Io(ks):{value:Uv([n],[r],!0,!0)[1][2]}},isExported:!0},LX={description:M(`Fits points to linear trend derived via least-squares.`),args:[V(`known_data_y (number, range<number>)`,M(`The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.`)),V(`known_data_x (number, range<number>, optional, default={1;2;3;...})`,M(`The values of the independent variable(s) corresponding with known_data_y.`)),V(`new_data_x (number, range<number>, optional, default=known_data_x)`,M(`The data points to return the y values for on the ideal curve fit.`)),V(`b (boolean, optional, default=TRUE)`,M(`Given a general linear form of y = m*x+b for a curve fit, calculates b if TRUE or forces b to be 0 and only calculates the m values if FALSE, i.e. forces the curve fit to pass through the origin.`),xY)],computeArray:function(e,t=[[]],n=[[]],r={value:!0}){return e.length===0||e[0].length===0?new P(As(`known_data_y`)):ps(Yv(Xo(e,`known_data_y`),Xo(t,`known_data_x`),Xo(n,`new_data_y`),L(r)),e=>({value:e}))}},RX={description:M(`Average of a dataset after discarding a fraction of data from the ends.`),args:[V(`range (number, range<number>)`,M(`The data to average.`)),V(`percent (number)`,M(`Fraction of data to trim from each end (0 to 0.5).`))],compute:function(e,t){let n=F(t,this.locale);W(n>=0&&n<.5,M(`Percent must be between 0 (inclusive) and 0.5 (exclusive).`));let r=[];ss([e],e=>r.push(e.value),this.locale),W(r.length>0,ks),r.sort((e,t)=>e-t);let i=Math.floor(r.length*n/2),a=r.slice(i,r.length-i);return{value:a.reduce((e,t)=>e+t,0)/a.length}},isExported:!0},zX={description:M(`Variance.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the sample.`))],compute:function(...e){return{value:OY(e,!0,!1,this.locale)}},isExported:!0},BX={description:M(`Variance of entire population.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the population.`))],compute:function(...e){return{value:OY(e,!1,!1,this.locale)}},isExported:!0},VX={description:M(`Variance.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the sample.`))],compute:function(...e){return{value:OY(e,!0,!1,this.locale)}},isExported:!0},HX={description:M(`Variance of sample (text as 0).`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the sample.`))],compute:function(...e){return{value:OY(e,!0,!0,this.locale)}},isExported:!0},UX={description:M(`Variance of entire population.`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the population.`))],compute:function(...e){return{value:OY(e,!1,!1,this.locale)}},isExported:!0},WX={description:M(`Variance of entire population (text as 0).`),args:[V(`value (number, range<number>, repeating)`,M(`Value or range to include in the population.`))],compute:function(...e){return{value:OY(e,!1,!0,this.locale)}},isExported:!0};var GX=l({DAVERAGE:()=>JX,DCOUNT:()=>YX,DCOUNTA:()=>XX,DGET:()=>ZX,DMAX:()=>QX,DMIN:()=>$X,DPRODUCT:()=>eZ,DSTDEV:()=>tZ,DSTDEVP:()=>nZ,DSUM:()=>rZ,DVAR:()=>iZ,DVARP:()=>aZ});function KX(e,t,n,r){let i=new Map,a=e.length;for(let t=a-1;t>=0;t--)i.set(I(e[t][0]).toUpperCase(),t);let o=t?.value;if(typeof o!=`number`&&typeof o!=`string`)throw new P(M(`The field must be a number or a string`));let s;if(typeof o==`number`){if(s=Math.trunc(o)-1,s<0||a-1<s)throw new P(M(`The field (%(fieldValue)s) must be one of %(dimRowDB)s or must be a number between 1 and %s inclusive.`,{fieldValue:o.toString(),dimRowDB:a.toString()}))}else{let e=I(t).toUpperCase();if(s=i.get(e)??-1,s===-1)throw new P(M(`The field (%s) must be one of %s.`,I(t),[...i.keys()].toString()))}let c=n[0].length;if(c<2)throw new P(M(`The criteria range contains %s row, it must be at least 2 rows.`,c.toString()));let l=new Set,u=e[0].length;for(let t=1;t<c;t++){let a=[],o=!0;for(let r=0;r<n.length;r++){let s=I(n[r][0]).toUpperCase(),c=i.get(s),l=n[r][t];if(l.value!==null)if(c!==void 0)a.push([e[c].slice(1,u)]),a.push(l);else{o=!1;break}}if(o)if(a.length>0)xs(a,(e,t)=>{l.add(t)},r,!0);else{l=new Set(Array(u-1).keys());break}}let d=e[s];return[...l].map(e=>d[e+1])}let qX=[V(`database (range)`,M(`The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.`)),V(`field (number, string)`,M(`Indicates which column in database contains the values to be extracted and operated on.`)),V(`criteria (range)`,M(`An array or range containing zero or more criteria to filter the database values by before operating.`))],JX={description:M(`Average of a set of values from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return jY.compute.bind(this)([r])},isExported:!0},YX={description:M(`Counts values from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return RY.compute.bind(this)([r])},isExported:!0},XX={description:M(`Counts values and text from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return zY.compute.bind(this)([r])},isExported:!0},ZX={description:M(`Single value from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return r.length===0?new P(M(`No match found in DGET evaluation.`)):r.length>1?new P(M(`More than one match found in DGET evaluation.`)):r[0]},isExported:!0},QX={description:M(`Maximum of values from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return iX.compute.bind(this)([r])},isExported:!0},$X={description:M(`Minimum of values from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return cX.compute.bind(this)([r])},isExported:!0},eZ={description:M(`Product of values from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return YJ.compute.bind(this)([r])},isExported:!0},tZ={description:M(`Standard deviation of population sample from table.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return kX.compute.bind(this)([r])},isExported:!0},nZ={description:M(`Standard deviation of entire population from table.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return NX.compute.bind(this)([r])},isExported:!0},rZ={description:M(`Sum of values from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return fY.compute.bind(this)([r])},isExported:!0},iZ={description:M(`Variance of population sample from table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return zX.compute.bind(this)([r])},isExported:!0},aZ={description:M(`Variance of a population from a table-like range.`),args:qX,compute:function(e,t,n){let r=KX(e,t,n,this.locale);return UX.compute.bind(this)([r])},isExported:!0},oZ=M(`The cashflow_amounts and cashflow_dates ranges must have the same dimensions.`),sZ=M(`There must be both positive and negative values in cashflow_amounts.`),cZ=e=>M(`The cost (%s) must be positive or null.`,e),lZ=e=>M(`The cost (%s) must be strictly positive.`,e),uZ=e=>M(`The frequency (%s) must be one of %s`,e,[1,2,4].toString()),dZ=e=>M(`The day_count_convention (%s) must be between 0 and 4 inclusive.`,e),fZ=e=>M(`The depreciation factor (%s) must be strictly positive.`,e),pZ=e=>M(`The discount (%s) must be different from -1.`,e),mZ=e=>M(`The discount (%s) must be strictly positive.`,e),hZ=e=>M(`The discount (%s) must be smaller than 1.`,e),gZ=e=>M(`The effective_rate (%s) must be strictly positive.`,e),_Z=e=>M(`The end_period (%s) must be positive or null.`,e),vZ=(e,t)=>M(`The end_period (%(end)s) must be smaller or equal to the life (%(life)s).`,{end:e,life:t}),yZ=e=>M(`All the dates should be greater or equal to the first date in cashflow_dates (%s).`,e),bZ=(e,t)=>M(`The first_period (%(first)s) must be smaller or equal to the last_period (%(last)s).`,{first:e,last:t}),xZ=e=>M(`The first_period (%s) must be strictly positive.`,e),SZ=e=>M(`The future_value (%s) must be strictly positive.`,e),CZ=e=>M(`The investment (%s) must be strictly positive.`,e),wZ=e=>M(`The issue (%s) must be positive or null.`,e),TZ=(e,t)=>M(`The last_period (%(last)s) must be smaller or equal to the number_of_periods (%(nPeriods)s).`,{last:e,nPeriods:t}),EZ=e=>M(`The last_period (%s) must be strictly positive.`,e),DZ=e=>M(`The life (%s) must be strictly positive.`,e),OZ=(e,t)=>M(`The maturity (%(maturity)s) must be strictly greater than the settlement (%(settlement)s).`,{maturity:t,settlement:e}),kZ=e=>M(`The month (%s) must be between 1 and 12 inclusive.`,e),AZ=e=>M(`The nominal_rate (%s) must be strictly positive.`,e),jZ=e=>M(`The number_of_periods (%s) must be different from zero.`,e),MZ=e=>M(`The number_of_periods (%s) must be strictly positive.`,e),NZ=e=>M(`The period must be between 1 and number_of_periods (%s)`,e),PZ=(e,t)=>M(`The period (%(period)s) must be less than or equal to %(lifeLimit)s.`,{period:e,lifeLimit:t}),FZ=e=>M(`The period (%s) must be positive or null.`,e),IZ=e=>M(`The periods_by_year (%s) must be strictly positive.`,e),LZ=(e,t)=>M(`The period (%(period)s) must be less than or equal life (%(life)s).`,{period:e,life:t}),RZ=e=>M(`The period (%s) must be strictly positive.`,e),zZ=e=>M(`The present_value (%s) must be strictly positive.`,e),BZ=e=>M(`The price (%s) must be strictly positive.`,e),VZ=(e,t)=>M(`The purchase_date (%(purchaseDate)s) must be before the first_period_end (%(firstPeriodEnd)s).`,{purchaseDate:e,firstPeriodEnd:t}),HZ=e=>M(`The purchase_date (%s) must be positive or null.`,e),UZ=e=>M(`The rate_guess (%s) must be strictly greater than -1.`,e),WZ=e=>M(`The rate (%s) must be positive or null.`,e),GZ=e=>M(`The rate (%s) must be strictly positive.`,e),KZ=e=>M(`The redemption (%s) must be strictly positive.`,e),qZ=e=>M(`The salvage (%s) must be positive or null.`,e),JZ=(e,t)=>M(`The salvage (%(salvage)s) must be smaller or equal than the cost (%(cost)s).`,{salvage:e,cost:t}),YZ=(e,t)=>M(`The settlement date (%(settlement)s) must be greater or equal to the issue date (%(issue)s).`,{settlement:e,issue:t}),XZ=(e,t)=>M(`The settlement date (%(settlement)s) must at most one year after the maturity date (%(maturity)s).`,{settlement:e,maturity:t}),ZZ=(e,t)=>M(`The settlement date (%(settlement)s) must be strictly greater than the issue date (%(issue)s).`,{settlement:e,issue:t}),QZ=e=>M(`The start_period (%s) must be positive or null.`,e),$Z=(e,t)=>M(`The start_period (%(start)s) must be smaller or equal to the end_period (%(end)s).`,{start:e,end:t}),eQ=e=>M(`The unit (%s) must be strictly positive.`,e),tQ=e=>M(`The yield (%s) must be positive or null.`,e);function nQ(e){return e.some(e=>e>0)&&e.some(e=>e<0)}function rQ(e){return![0,1,2,3,4].includes(e)}function iQ(e){return![1,2,4].includes(e)}function aQ(e,t,n){let r=rs(e,n),i=rs(t,n),a=rs(e,n);return a.setFullYear(r.getFullYear()+1),i.getTime()<=a.getTime()}let oQ=[{value:0,label:M(`US (NASD) 30/360`)},{value:1,label:M(`Actual/Actual`)},{value:2,label:M(`Actual/360`)},{value:3,label:M(`Actual/365`)},{value:4,label:M(`European 30/360`)}];var sQ=l({DATE:()=>lQ,DATEDIF:()=>uQ,DATEVALUE:()=>dQ,DAY:()=>fQ,DAYS:()=>pQ,DAYS360:()=>mQ,EDATE:()=>hQ,EOMONTH:()=>gQ,HOUR:()=>_Q,ISOWEEKNUM:()=>vQ,MINUTE:()=>yQ,MONTH:()=>bQ,MONTH_END:()=>LQ,MONTH_START:()=>IQ,NETWORKDAYS:()=>xQ,NETWORKDAYS_INTL:()=>wQ,NOW:()=>TQ,QUARTER:()=>RQ,QUARTER_END:()=>BQ,QUARTER_START:()=>zQ,SECOND:()=>EQ,TIME:()=>DQ,TIMEVALUE:()=>OQ,TODAY:()=>kQ,WEEKDAY:()=>AQ,WEEKNUM:()=>jQ,WORKDAY:()=>MQ,WORKDAY_INTL:()=>NQ,YEAR:()=>PQ,YEARFRAC:()=>FQ,YEAR_END:()=>HQ,YEAR_START:()=>VQ}),cQ=function(e){return e.WHOLE_YEARS=`Y`,e.WHOLE_MONTHS=`M`,e.WHOLE_DAYS=`D`,e.DAYS_WITHOUT_WHOLE_MONTHS=`MD`,e.MONTH_WITHOUT_WHOLE_YEARS=`YM`,e.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR=`YD`,e}(cQ||{});let lQ={description:M(`Converts year/month/day into a date.`),args:[V(`year (number)`,M(`The year component of the date.`)),V(`month (number)`,M(`The month component of the date.`)),V(`day (number)`,M(`The day component of the date.`))],compute:function(e,t,n){let r=Math.trunc(F(e,this.locale)),i=Math.trunc(F(t,this.locale)),a=Math.trunc(F(n,this.locale));if(r<0||r>9999)return new P(M(`The year (%s) must be between 0 and 9999 inclusive.`,r.toString()));r<1900&&(r+=1900);let o=eo(new Da(r,i-1,a));return o<0?new P(M(`The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.`)):{value:o,format:this.locale.dateFormat}},isExported:!0},uQ={description:M(`Calculates the number of days, months, or years between two dates.`),args:[V(`start_date (date)`,M(`The start date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.`)),V(`end_date (date)`,M(`The end date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.`)),V(`unit (string)`,M(`A text abbreviation for unit of time.`),[{value:`Y`,label:M(`The number of whole years between start_date and end_date`)},{value:`M`,label:M(`The number of whole months between start_date and end_date`)},{value:`D`,label:M(`The number of days between start_date and end_date`)},{value:`MD`,label:M(`The number of days between start_date and end_date after subtracting whole months`)},{value:`YM`,label:M(`The number of whole months between start_date and end_date after subtracting whole years`)},{value:`YD`,label:M(`The number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart`)}])],compute:function(e,t,n){let r=I(n).toUpperCase();if(!Object.values(cQ).includes(r))return new P(Jo(Object.values(cQ),I(n)));let i=Math.trunc(F(e,this.locale)),a=Math.trunc(F(t,this.locale)),o=$a(i),s=$a(a);if(a<i)return new P(M(`start_date (%s) should be on or before end_date (%s).`,o.toLocaleDateString(),s.toLocaleDateString()));switch(r){case`Y`:return{value:lo(o,s)};case`M`:return{value:so(o,s)};case`D`:return{value:co(o,s)};case`YM`:return{value:so(o,s)-lo(o,s)*12};case`MD`:let e=s.getDate()-o.getDate();return e<0&&(e=no(new Da(s.getFullYear(),s.getMonth()-1,1))-Math.abs(e)),{value:e};case`YD`:{if(uo(i,a))return{value:co(o,s)};let e=new Da(o.getFullYear(),s.getMonth(),s.getDate()),t=co(o,e);return t<0&&(e.setFullYear(o.getFullYear()+1),t=co(o,e)),{value:t}}}},isExported:!0},dQ={description:M(`Converts a date string to a date value.`),args:[V(`date_string (string)`,M(`The string representing the date.`))],compute:function(e){let t=I(e),n=Ua(t,this.locale);return n===null?new P(M(`The date_string (%s) cannot be parsed to date/time.`,t.toString())):{value:Math.trunc(n.value)}},isExported:!0},fQ={description:M(`Day of the month that a specific date falls on.`),args:[V(`date (string)`,M(`The date from which to extract the day.`))],compute:function(e){return{value:rs(e,this.locale).getDate()}},isExported:!0},pQ={description:M(`Number of days between two dates.`),args:[V(`end_date (date)`,M(`The end of the date range.`)),V(`start_date (date)`,M(`The start of the date range.`))],compute:function(e,t){let n=rs(e,this.locale),r=rs(t,this.locale),i=n.getTime()-r.getTime();return{value:Math.round(i/ka)}},isExported:!0},mQ={description:M(`Number of days between two dates on a 360-day year (months of 30 days).`),args:[V(`start_date (date)`,M(`The start date to consider in the calculation.`)),V(`end_date (date)`,M(`The end date to consider in the calculation.`)),V(`method (boolean, default=false)`,M(`An indicator of what day count method to use.`),[{value:!1,label:M(`U.S. NASD method (default)`)},{value:!0,label:M(`European method`)}])],compute:function(e,t,n={value:!1}){let r=Math.trunc(F(e,this.locale)),i=Math.trunc(F(t,this.locale)),a=oo(r,i,L(n)?4:0);return{value:Math.sign(i-r)*Math.round(a*360)}},isExported:!0},hQ={description:M(`Date a number of months before/after another date.`),args:[V(`start_date (date)`,M(`The date from which to calculate the result.`)),V(`months (number)`,M(`The number of months before (negative) or after (positive) 'start_date' to calculate.`))],compute:function(e,t){return{value:eo(io(rs(e,this.locale),Math.trunc(F(t,this.locale)),!1)),format:this.locale.dateFormat}},isExported:!0},gQ={description:M(`Last day of a month before or after a date.`),args:[V(`start_date (date)`,M(`The date from which to calculate the result.`)),V(`months (number)`,M(`The number of months before (negative) or after (positive) 'start_date' to consider.`))],compute:function(e,t){let n=rs(e,this.locale),r=Math.trunc(F(t,this.locale));return{value:eo(new Da(n.getFullYear(),n.getMonth()+r+1,0)),format:this.locale.dateFormat}},isExported:!0},_Q={description:M(`Hour component of a specific time.`),args:[V(`time (date)`,M(`The time from which to calculate the hour component.`))],compute:function(e){return{value:rs(e,this.locale).getHours()}},isExported:!0},vQ={description:M(`ISO week number of the year.`),args:[V(`date (date)`,M(`The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.`))],compute:function(e){let t=rs(e,this.locale),n=t.getFullYear(),r=1;for(;new Da(n,0,r).getDay()!==4;)r+=1;let i=new Da(n,0,r-3),a=31;for(;new Da(n,11,a).getDay()!==4;)--a;let o=new Da(n,11,a+3),s;s=i.getTime()<=t.getTime()?t.getTime()<=o.getTime()?0:1:-1;let c;switch(s){case 0:c=i;break;case 1:c=new Da(n,11,a+3+1);break;case-1:let e=1;for(;new Da(n-1,0,e).getDay()!==4;)e+=1;c=new Da(n-1,0,e-3);break}let l=(t.getTime()-c.getTime())/ka;return{value:Math.floor(l/7)+1}},isExported:!0},yQ={description:M(`Minute component of a specific time.`),args:[V(`time (date)`,M(`The time from which to calculate the minute component.`))],compute:function(e){return{value:rs(e,this.locale).getMinutes()}},isExported:!0},bQ={description:M(`Month of the year a specific date falls in`),args:[V(`date (date)`,M(`The date from which to extract the month.`))],compute:function(e){return{value:rs(e,this.locale).getMonth()+1}},isExported:!0},xQ={description:M(`Net working days between two provided days.`),args:[V(`start_date (date)`,M(`The start date of the period from which to calculate the number of net working days.`)),V(`end_date (date)`,M(`The end date of the period from which to calculate the number of net working days.`)),V(`holidays (date, range<date>, optional)`,M(`A range or array constant containing the date serial numbers to consider holidays.`))],compute:function(e,t,n){return wQ.compute.bind(this)(e,t,{value:1},n)},isExported:!0};function SQ(e){let t=e?.value;if(typeof t==`string`){W(t.length===7&&[...t].every(e=>e===`0`||e===`1`),M(`When weekend is a string (%s) it must be composed of "0" or "1".`,t));let e=[];for(let n=0;n<7;n++)t[n]===`1`&&e.push((n+1)%7);return e}if(typeof t==`number`)return W(1<=t&&t<=7||11<=t&&t<=17,M(`The weekend (%s) must be a string or a number in the range 1-7 or 11-17.`,t.toString())),t<=7?[t-2==-1?6:t-2,t-1]:[t-11];throw new P(M(`The weekend must be a number or a string.`))}let CQ=[{value:1,label:M(`Saturday/Sunday are weekends`)},{value:2,label:M(`Sunday/Monday are weekends`)},{value:3,label:M(`Monday/Tuesday are weekends`)},{value:4,label:M(`Tuesday/Wednesday are weekends`)},{value:5,label:M(`Wednesday/Thursday are weekends`)},{value:6,label:M(`Thursday/Friday are weekends`)},{value:7,label:M(`Friday/Saturday are weekends`)},{value:11,label:M(`Sunday is the only weekend`)},{value:12,label:M(`Monday is the only weekend`)},{value:13,label:M(`Tuesday is the only weekend`)},{value:14,label:M(`Wednesday is the only weekend`)},{value:15,label:M(`Thursday is the only weekend`)},{value:16,label:M(`Friday is the only weekend`)},{value:17,label:M(`Saturday is the only weekend`)}],wQ={description:M(`Net working days between two dates (specifying weekends).`),args:[V(`start_date (date)`,M(`The start date of the period from which to calculate the number of net working days.`)),V(`end_date (date)`,M(`The end date of the period from which to calculate the number of net working days.`)),V(`weekend (any, default=1)`,M(`A number or string representing which days of the week are considered weekends.`),CQ),V(`holidays (date, range<date>, optional)`,M(`A range or array constant containing the dates to consider as holidays.`))],compute:function(e,t,n={value:1},r){let i=rs(e,this.locale),a=rs(t,this.locale),o=SQ(n),s=new Set;r!==void 0&&os([r],e=>{let t=rs(e,this.locale);s.add(t.getTime())});let c=i.getTime()>a.getTime(),l=Da.fromTimestamp((c?i:a).getTime()),u=Da.fromTimestamp((c?a:i).getTime()),d=l.getTime(),f=u.getTime(),p=0;for(;f<=d;)!o.includes(u.getDay())&&!s.has(f)&&(p+=1),u.setDate(u.getDate()+1),f=u.getTime();return{value:c?-p:p}},isExported:!0},TQ={description:M(`Current date and time as a date value.`),args:[],compute:function(){let e=Da.now(),t=e.getTime()-Oa.getTime(),n=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return{value:Math.floor(t/ka)+n,format:Eb(this.locale)}},isExported:!0},EQ={description:M(`Minute component of a specific time.`),args:[V(`time (date)`,M(`The time from which to calculate the second component.`))],compute:function(e){return{value:rs(e,this.locale).getSeconds()}},isExported:!0},DQ={description:M(`Converts hour/minute/second into a time.`),args:[V(`hour (number)`,M(`The hour component of the time.`)),V(`minute (number)`,M(`The minute component of the time.`)),V(`second (number)`,M(`The second component of the time.`))],compute:function(e,t,n){let r=Math.trunc(F(e,this.locale)),i=Math.trunc(F(t,this.locale)),a=Math.trunc(F(n,this.locale));return i+=Math.floor(a/60),a=a%60+(a<0?60:0),r+=Math.floor(i/60),i=i%60+(i<0?60:0),r%=24,r<0?new P(M(`The function [[FUNCTION_NAME]] result cannot be negative`)):{value:r/24+i/1440+a/(1440*60),format:this.locale.timeFormat}},isExported:!0},OQ={description:M(`Converts a time string into its serial number representation.`),args:[V(`time_string (string)`,M(`The string that holds the time representation.`))],compute:function(e){let t=I(e),n=Ua(t,this.locale);if(n===null)return new P(M(`The time_string (%s) cannot be parsed to date/time.`,t));let r=n.value-Math.trunc(n.value);return{value:r<0?1+r:r}},isExported:!0},kQ={description:M(`Current date as a date value.`),args:[],compute:function(){let e=Da.now();return{value:eo(new Da(e.getFullYear(),e.getMonth(),e.getDate())),format:this.locale.dateFormat}},isExported:!0},AQ={description:M(`Day of the week of the date provided (as number).`),args:[V(`date (date)`,M(`The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),V(`type (number, default=1)`,M(`A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.`),[{value:1,label:M(`Numbers 1 (Sunday) trough 7 (Saturday)`)},{value:2,label:M(`Numbers 1 (Monday) trough 7 (Sunday)`)},{value:3,label:M(`Numbers 0 (Monday) trough 6 (Sunday)`)},{value:11,label:M(`Numbers 1 (Monday) trough 7 (Sunday)`)},{value:12,label:M(`Numbers 1 (Tuesday) trough 7 (Monday)`)},{value:13,label:M(`Numbers 1 (Wednesday) trough 7 (Tuesday)`)},{value:14,label:M(`Numbers 1 (Thursday) trough 7 (Wednesday)`)},{value:15,label:M(`Numbers 1 (Friday) trough 7 (Thursday)`)},{value:16,label:M(`Numbers 1 (Saturday) trough 7 (Friday)`)},{value:17,label:M(`Numbers 1 (Sunday) trough 7 (Saturday)`)}])],compute:function(e,t={value:1}){let n=rs(e,this.locale),r=Math.round(F(t,this.locale)),i=n.getDay();if(!(1<=r&&r<=3)&&!(11<=r&&r<=17))return new P(M(`The type (%s) must be between 1 and 3 or between 11 and 17.`,r));switch(r){case 1:return{value:i+1};case 2:return{value:i===0?7:i};case 3:return{value:i===0?6:i-1}}let a=r-10,o=(i+1-a+7)%7;return{value:o===0?7:o}},isExported:!0},jQ={description:M(`Week number of the year.`),args:[V(`date (date)`,M(`The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),V(`type (number, default=1)`,M(`A number representing the day that a week starts on. Sunday = 1.`),[{value:1,label:M(`Sunday`)},{value:2,label:M(`Monday`)},{value:11,label:M(`Monday`)},{value:12,label:M(`Tuesday`)},{value:13,label:M(`Wednesday`)},{value:14,label:M(`Thursday`)},{value:15,label:M(`Friday`)},{value:16,label:M(`Saturday`)},{value:17,label:M(`Sunday`)},{value:21,label:M(`ISO week number (Monday as first day of the week)`)}])],compute:function(e,t={value:1}){let n=rs(e,this.locale),r=Math.round(F(t,this.locale));if(![1,2,11,12,13,14,15,16,17,21].includes(r))return new P(M(`The type (%s) is out of range.`,r.toString()));if(r===21)return vQ.compute.bind(this)(e);let i;i=r===1||r===2?r-1:r-10==7?0:r-10;let a=n.getFullYear(),o=1,s=new Da(a,0,o);for(;s.getDay()!==i;)o+=1,s=new Da(a,0,o);let c=(n.getTime()-s.getTime())/ka;return c<0?{value:1}:{value:Math.floor(c/7)+(o===1?1:2)}},isExported:!0},MQ={description:M(`Date after a number of workdays.`),args:[V(`start_date (date)`,M(`The date from which to begin counting.`)),V(`num_days (number)`,M(`The number of working days to advance from start_date. If negative, counts backwards.`)),V(`holidays (date, range<date>, optional)`,M(`A range or array constant containing the dates to consider holidays.`))],compute:function(e,t,n={value:null}){return NQ.compute.bind(this)(e,t,{value:1},n)},isExported:!0},NQ={description:M(`Date after a number of workdays (specifying weekends).`),args:[V(`start_date (date)`,M(`The date from which to begin counting.`)),V(`num_days (number)`,M(`The number of working days to advance from start_date. If negative, counts backwards.`)),V(`weekend (any, default=1)`,M(`A number or string representing which days of the week are considered weekends.`),CQ),V(`holidays (date, range<date>, optional)`,M(`A range or array constant containing the dates to consider holidays.`))],compute:function(e,t,n={value:1},r){let i=rs(e,this.locale),a=Math.trunc(F(t,this.locale));if(n.value===`1111111`)return new P(M(`The weekend must be different from '1111111'.`));let o=SQ(n),s=new Set;r!==void 0&&os([r],e=>{let t=rs(e,this.locale);s.add(t.getTime())});let c=Da.fromTimestamp(i.getTime()),l=c.getTime(),u=Math.sign(a),d=Math.abs(a);for(;d>0;)c.setDate(c.getDate()+u),l=c.getTime(),!o.includes(c.getDay())&&!s.has(l)&&--d;let f=l-Oa.getTime();return{value:Math.round(f/ka),format:this.locale.dateFormat}},isExported:!0},PQ={description:M(`Year specified by a given date.`),args:[V(`date (date)`,M(`The date from which to extract the year.`))],compute:function(e){return{value:rs(e,this.locale).getFullYear()}},isExported:!0},FQ={description:M(`Exact number of years between two dates.`),args:[V(`start_date (date)`,M(`The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),V(`end_date (date)`,M(`The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),V(`day_count_convention (number, default=0)`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n={value:0}){let r=Math.trunc(F(e,this.locale)),i=Math.trunc(F(t,this.locale)),a=Math.trunc(F(n,this.locale));return r<0?new P(M(`The start_date (%s) must be positive or null.`,r)):i<0?new P(M(`The end_date (%s) must be positive or null.`,i)):0>a||a>4?new P(M(`The day_count_convention (%s) must be between 0 and 4 inclusive.`,a)):{value:oo(r,i,a)}}},IQ={description:M(`First day of the month a date falls in.`),args:[V(`date (date)`,M(`The date from which to calculate the result.`))],compute:function(e){let t=rs(e,this.locale);return{value:eo(new Da(t.getFullYear(),t.getMonth(),1)),format:this.locale.dateFormat}}},LQ={description:M(`Last day of the month a date falls in.`),args:[V(`date (date)`,M(`The date from which to calculate the result.`))],compute:function(e){return gQ.compute.bind(this)(e,{value:0})}},RQ={description:M(`Quarter of the year a specific date falls in`),args:[V(`date (date)`,M(`The date from which to extract the quarter.`))],compute:function(e){return{value:Math.ceil((rs(e,this.locale).getMonth()+1)/3)}}},zQ={description:M(`First day of the quarter of the year a specific date falls in.`),args:[V(`date (date)`,M(`The date from which to calculate the start of quarter.`))],compute:function(e){let t=RQ.compute.bind(this)(e).value,n=PQ.compute.bind(this)(e).value;return{value:eo(new Da(n,(t-1)*3,1)),format:this.locale.dateFormat}}},BQ={description:M(`Last day of the quarter of the year a specific date falls in.`),args:[V(`date (date)`,M(`The date from which to calculate the end of quarter.`))],compute:function(e){let t=RQ.compute.bind(this)(e).value,n=PQ.compute.bind(this)(e).value;return{value:eo(new Da(n,t*3,0)),format:this.locale.dateFormat}}},VQ={description:M(`First day of the year a specific date falls in.`),args:[V(`date (date)`,M(`The date from which to calculate the start of the year.`))],compute:function(e){let t=PQ.compute.bind(this)(e).value;return{value:eo(new Da(t,0,1)),format:this.locale.dateFormat}}},HQ={description:M(`Last day of the year a specific date falls in.`),args:[V(`date (date)`,M(`The date from which to calculate the end of the year.`))],compute:function(e){let t=PQ.compute.bind(this)(e).value;return{value:eo(new Da(t+1,0,0)),format:this.locale.dateFormat}}};var UQ=l({DELTA:()=>WQ});let WQ={description:M(`Compare two numeric values, returning 1 if they're equal.`),args:[V(`number1 (number)`,M(`The first number to compare.`)),V(`number2 (number, default=0)`,M(`The second number to compare.`))],compute:function(e,t={value:0}){return{value:+(F(e,this.locale)===F(t,this.locale))}},isExported:!0};var GQ=l({FILTER:()=>qQ,SORT:()=>JQ,SORTN:()=>YQ,UNIQUE:()=>XQ});function KQ(e,t,...n){for(let e=0;e<n.length;e++){let t=e%2==0?`sort_column`:`is_ascending`;W(n[e]!==void 0,M(`Value for parameter %s is missing in [[FUNCTION_NAME]].`,t))}let r=[],i=[],a=e.length;for(let o=0;o<n.length;o+=2){r.push(L(jv(n[o+1])?.value)?`asc`:`desc`);let s=n[o];if(yt(s)&&(s.length>1||s[0].length>1))W(s.length===1&&s[0].length===a,M(`Wrong size for %s. Expected a range of size 1x%s. Got %sx%s.`,`sort_column${o+1}`,a,s.length,s[0].length)),i.push(s.flat().map(e=>e.value));else{let n=F(jv(s)?.value,t);if(n<1||n>e[0].length)return e;i.push(e.map(e=>e[n-1].value))}}if(i.length===0)for(let t=0;t<e[0].length;t++)i.push(e.map(e=>e[t].value)),r.push(`asc`);let o={desc:bH(`desc`),asc:bH(`asc`)},s=S(0,e.length);return s.sort((e,t)=>{for(let[n,a]of i.entries()){let i=a[e],s=a[t],c={value:i,type:i===null?`empty`:typeof i==`string`?`text`:typeof i},l={value:s,type:s===null?`empty`:typeof s==`string`?`text`:typeof s},u=o[r[n]](c,l);if(u!==0)return u}return 0}),s.map(t=>e[t])}let qQ={description:M(`Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions.`),args:[V(`range (any, range<any>)`,M(`The data to be filtered.`)),V(`condition (boolean, range<boolean>, repeating)`,M(`Column or row containing true or false values corresponding to the range.`))],computeArray:function(e,...t){let n=R(e),r=t.map(e=>ps(R(e),e=>e.value));for(let e of r)if(!Cv(e))return new P(M(`The arguments condition must be a single column or row.`));if(!wv(...t))return new P(M(`The arguments conditions must have the same dimensions.`));let i=r.map(e=>e.flat()),a=r[0].length===1?`row`:`col`;if(n=a===`row`?hs(n):n,i.some(e=>e.length!==n.length))return new P(M(`FILTER has mismatched sizes on the range and conditions.`));let o=[];for(let e=0;e<n.length;e++){let t=n[e];i.every(t=>(typeof t[e]==`boolean`||typeof t[e]==`number`)&&t[e])&&o.push(t)}return o.length?a===`row`?hs(o):o:new Io(M(`No match found in FILTER evaluation`))},isExported:!1},JQ={description:M(`Sorts the rows of a given array or range by the values in one or more columns.`),args:[V(`range (range)`,M(`The data to be sorted.`)),V(`sort_column (any, range<number>, repeating, optional)`,M(`The index of the column in range or a range outside of range containing the value by which to sort.`)),V(`is_ascending (boolean, repeating, optional)`,M(`TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.`),[{value:!0,label:M(`Ascending`)},{value:!1,label:M(`Descending`)}])],computeArray:function(e,...t){return hs(KQ(hs(e),this.locale,...t))},isExported:!0},YQ={description:M(`Returns the first n items in a data set after performing a sort.`),args:[V(`range (range)`,M(`The data to be sorted.`)),V(`n (number)`,M(`The number of items to return.`)),V(`display_ties_mode (number, default=0)`,M(`A number representing the way to display ties.`)),V(`sort_column (number, range<number>, repeating, optional)`,M(`The index of the column in range or a range outside of range containing the value by which to sort.`)),V(`is_ascending (boolean, repeating, optional)`,M(`TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.`),[{value:!0,label:M(`Ascending`)},{value:!1,label:M(`Descending`)}])],compute:function(e,t,...n){let r=F(t?.value??1,this.locale),i=n.length%2==0?0:F(n[0]?.value,this.locale),a=n.length%2==0?n:n.slice(1);if(r<0)return new P(M(`Wrong value of 'n'. Expected a positive number. Got %s.`,r));if(i<0||i>3)return new P(M(`Wrong value of 'display_ties_mode'. Expected a positive number between 0 and 3. Got %s.`,i));let o=KQ(hs(e),this.locale,...a),s=(e,t)=>JSON.stringify(o[e].map(e=>e.value))===JSON.stringify(o[t].map(e=>e.value));switch(i){case 0:return hs(o.slice(0,r));case 1:for(let e=r;e<o.length;e++)if(!s(e,r-1))return hs(o.slice(0,e));return hs(o);case 2:{let e=[o[0]];for(let t=1;t<o.length;t++)for(let n=0;n<t&&!s(t,n);n++)n===t-1&&e.push(o[t]);return hs(e.slice(0,r))}case 3:{let e=[o[0]],t=1;for(let n=1;n<o.length&&(s(n,n-1)||t++,!(t>r));n++)e.push(o[n]);return hs(e)}}},isExported:!1},XQ={description:M(`Unique rows in the provided source range.`),args:[V(`range (any, range<any>)`,M(`The data to filter by unique entries.`)),V(`by_column (boolean, default=FALSE)`,M(`Whether to filter the data by columns or by rows.`),[{value:!0,label:M(`Return unique columns`)},{value:!1,label:M(`Return unique rows`)}]),V(`exactly_once (boolean, default=FALSE)`,M(`Whether to return only entries with no duplicates.`),[{value:!0,label:M(`Return items that appear exactly once`)},{value:!1,label:M(`Return every distinct item`)}])],computeArray:function(e={value:``},t,n){if(!yt(e))return[[e]];let r=L(t?.value)||!1,i=L(n?.value)||!1;r||(e=hs(e));let a=new Map;for(let t of e){let e=JSON.stringify(t.map(e=>e.value)),n=a.get(e);n?n.count++:a.set(e,{data:t,count:1})}let o=[];for(let e of a.values())i&&e.count>1||o.push(e.data);return o.length?r?o:hs(o):new P(M(`No unique values found`))},isExported:!0};var ZQ=l({ACCRINTM:()=>n$,AMORLINC:()=>r$,COUPDAYBS:()=>a$,COUPDAYS:()=>i$,COUPDAYSNC:()=>o$,COUPNCD:()=>s$,COUPNUM:()=>c$,COUPPCD:()=>l$,CUMIPMT:()=>u$,CUMPRINC:()=>d$,DB:()=>f$,DDB:()=>m$,DISC:()=>h$,DOLLARDE:()=>g$,DOLLARFR:()=>_$,DURATION:()=>v$,EFFECT:()=>y$,FV:()=>x$,FVSCHEDULE:()=>S$,INTRATE:()=>C$,IPMT:()=>T$,IRR:()=>D$,ISPMT:()=>O$,MDURATION:()=>k$,MIRR:()=>A$,NOMINAL:()=>j$,NPER:()=>M$,NPV:()=>P$,PDURATION:()=>F$,PMT:()=>L$,PPMT:()=>z$,PRICE:()=>V$,PRICEDISC:()=>H$,PRICEMAT:()=>U$,PV:()=>B$,RATE:()=>G$,RECEIVED:()=>K$,RRI:()=>q$,SLN:()=>J$,SYD:()=>Y$,TBILLEQ:()=>Q$,TBILLPRICE:()=>Z$,TBILLYIELD:()=>$$,VDB:()=>e1,XIRR:()=>t1,XNPV:()=>n1,YIELD:()=>r1,YIELDDISC:()=>i1,YIELDMAT:()=>a1});let QQ=[{value:1,label:M(`Annual`)},{value:2,label:M(`Semi-annual`)},{value:4,label:M(`Quarterly`)}],$Q=[{value:0,label:M(`End of period (default)`)},{value:1,label:M(`Beginning of period`)}],e$=[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`frequency (number)`,M(`The number of interest or coupon payments per year (1, 2, or 4).`),QQ),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)];function t$(e,t,n,r,i=1e-10,a){let o=n,s,c,l,u=!1,d=0,f;do{if(l=e(o),isNaN(l)){W(d<r&&a!==void 0,M(`Function [[FUNCTION_NAME]] didn't find any result.`)),d++,o=a(f),f=o;continue}s=o-l/t(o),c=Math.abs(s-o),o=s,u=c<i||Math.abs(l)<i,W(d<r,M(`Function [[FUNCTION_NAME]] didn't find any result.`)),d++}while(!u);return o}let n$={description:M(`Accrued interest of security paying at maturity.`),args:[V(`issue (date)`,M(`The date the security was initially issued.`)),V(`maturity (date)`,M(`The maturity date of the security.`)),V(`rate (number)`,M(`The annualized rate of interest.`)),V(`redemption (number)`,M(`The redemption amount per 100 face value, or par.`)),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i={value:0}){let a=Math.trunc(F(e,this.locale)),o=Math.trunc(F(t,this.locale)),s=F(r,this.locale),c=F(n,this.locale),l=Math.trunc(F(i,this.locale));if(a<0)return new P(wZ(a));if(a>=o)return new P(OZ(a,o));if(rQ(l))return new P(dZ(l));if(s<=0)return new P(KZ(s));if(c<=0)return new P(GZ(c));let u=oo(a,o,l);return{value:s*c*u}},isExported:!0},r$={description:M(`Depreciation for an accounting period.`),args:[V(`cost (number)`,M(`The initial cost of the asset.`)),V(`purchase_date (date)`,M(`The date the asset was purchased.`)),V(`first_period_end (date)`,M(`The date the first period ended.`)),V(`salvage (number)`,M(`The value of the asset at the end of depreciation.`)),V(`period (number)`,M(`The single period within life for which to calculate depreciation.`)),V(`rate (number)`,M(`The deprecation rate.`)),V(`day_count_convention (number, optional)`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=F(e,this.locale),c=Math.trunc(F(t,this.locale)),l=Math.trunc(F(n,this.locale)),u=F(r,this.locale),d=F(i,this.locale),f=F(a,this.locale),p=Math.trunc(F(o,this.locale));if(s<=0)return new P(lZ(s));if(c<0)return new P(HZ(c));if(u<0)return new P(qZ(u));if(u>s)return new P(JZ(u,s));if(d<0)return new P(FZ(d));if(f<=0)return new P(GZ(f));if(rQ(p))return new P(dZ(p));if(c>l)return new P(VZ(c,l));let m=d<1&&d>0?1:Math.trunc(d),h=s*f,g=oo(c,l,p),_=c===l?h:h*g,v=s-_-h*m;return v>=u?{value:m===0?_:h}:{value:u-v<h?h-(u-v):0}},isExported:!0},i$={description:M(`Days in coupon period containing settlement date.`),args:e$,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(F(e,this.locale)),a=Math.trunc(F(t,this.locale)),o=Math.trunc(F(n,this.locale)),s=Math.trunc(F(r,this.locale));if(i>=a)return new P(OZ(i,a));if(iQ(o))return new P(uZ(o));if(rQ(s))return new P(dZ(s));if(s===1){let i=l$.compute.bind(this)(e,t,n,r).value,a=s$.compute.bind(this)(e,t,n,r).value;return{value:F(a,this.locale)-F(i,this.locale)}}return{value:(s===3?365:360)/o}},isExported:!0},a$={description:M(`Days from settlement until next coupon.`),args:e$,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(F(e,this.locale)),a=Math.trunc(F(t,this.locale)),o=Math.trunc(F(n,this.locale)),s=Math.trunc(F(r,this.locale));if(i>=a)return new P(OZ(i,a));if(iQ(o))return new P(uZ(o));if(rQ(s))return new P(dZ(s));let c=l$.compute.bind(this)(e,t,n,r).value,l=F(c,this.locale);if([1,2,3].includes(s))return{value:i-l};if(s===4){let e=oo(l,i,s);return{value:Math.round(e*360)}}let u=rs(i,this.locale),d=rs(l,this.locale),f=d.getFullYear(),p=u.getFullYear(),m=d.getMonth()+1,h=u.getMonth()+1,g=d.getDate(),_=u.getDate();return m===2&&h===2&&ro(d)&&ro(u)&&(_=30),_===31&&(g===30||g===31)&&(_=30),m===2&&ro(d)&&(g=30),g===31&&(g=30),{value:(p-f)*360+(h-m)*30+(_-g)}},isExported:!0},o$={description:M(`Days from settlement until next coupon.`),args:e$,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(F(e,this.locale)),a=Math.trunc(F(t,this.locale)),o=Math.trunc(F(n,this.locale)),s=Math.trunc(F(r,this.locale));if(i>=a)return new P(OZ(i,a));if(iQ(o))return new P(uZ(o));if(rQ(s))return new P(dZ(s));let c=s$.compute.bind(this)(e,t,n,r).value,l=F(c,this.locale);if([1,2,3].includes(s))return{value:l-i};if(s===4){let e=oo(i,l,s);return{value:Math.round(e*360)}}let u=a$.compute.bind(this)(e,t,n,r);return{value:F(i$.compute.bind(this)(e,t,n,r),this.locale)-F(u,this.locale)}},isExported:!0},s$={description:M(`Next coupon date after the settlement date.`),args:e$,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(F(e,this.locale)),a=Math.trunc(F(t,this.locale)),o=Math.trunc(F(n,this.locale)),s=Math.trunc(F(r,this.locale));if(i>=a)return new P(OZ(i,a));if(iQ(o))return new P(uZ(o));if(rQ(s))return new P(dZ(s));let c=12/o,l=c$.compute.bind(this)(e,t,n,r);return{value:eo(io(rs(a,this.locale),-(F(l,this.locale)-1)*c,!0)),format:this.locale.dateFormat}},isExported:!0},c$={description:M(`Number of coupons between settlement and maturity.`),args:e$,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(F(e,this.locale)),a=Math.trunc(F(t,this.locale)),o=Math.trunc(F(n,this.locale)),s=Math.trunc(F(r,this.locale));if(i>=a)return new P(OZ(i,a));if(iQ(o))return new P(uZ(o));if(rQ(s))return new P(dZ(s));let c=1,l=a,u=12/o;for(;l>i;)l=eo(io(rs(l,this.locale),-u,!1)),c++;return{value:c-1}},isExported:!0},l$={description:M(`Last coupon date prior to or on the settlement date.`),args:e$,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(F(e,this.locale)),a=Math.trunc(F(t,this.locale)),o=Math.trunc(F(n,this.locale)),s=Math.trunc(F(r,this.locale));if(i>=a)return new P(OZ(i,a));if(iQ(o))return new P(uZ(o));if(rQ(s))return new P(dZ(s));let c=12/o,l=c$.compute.bind(this)(e,t,n,r).value;return{value:eo(io(rs(a,this.locale),-l*c,!0)),format:this.locale.dateFormat}},isExported:!0},u$={description:M(`Cumulative interest paid over a set of periods.`),args:[V(`rate (number)`,M(`The interest rate.`)),V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`present_value (number)`,M(`The current value of the annuity.`)),V(`first_period (number)`,M(`The number of the payment period to begin the cumulative calculation.`)),V(`last_period (number)`,M(`The number of the payment period to end the cumulative calculation.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q)],compute:function(e,t,n,r,i,a={value:0}){let o=F(r,this.locale),s=F(i,this.locale),c=F(e,this.locale),l=F(n,this.locale),u=F(t,this.locale),d=+!!L(a);if(u<=0)return new P(MZ(u));if(o<=0)return new P(xZ(o));if(s<=0)return new P(EZ(s));if(o>s)return new P(bZ(o,s));if(s>u)return new P(TZ(s,u));if(c<=0)return new P(GZ(c));if(l<=0)return new P(zZ(l));let f=0;for(let e=o;e<=s;e++)f+=w$(c,e,u,l,0,d);return{value:f}},isExported:!0},d$={description:M(`Cumulative principal paid over a set of periods.`),args:[V(`rate (number)`,M(`The interest rate.`)),V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`present_value (number)`,M(`The current value of the annuity.`)),V(`first_period (number)`,M(`The number of the payment period to begin the cumulative calculation.`)),V(`last_period (number)`,M(`The number of the payment period to end the cumulative calculation.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q)],compute:function(e,t,n,r,i,a={value:0}){let o=F(r,this.locale),s=F(i,this.locale),c=F(e,this.locale),l=F(n,this.locale),u=F(t,this.locale),d=+!!L(a);if(u<=0)return new P(MZ(u));if(o<=0)return new P(xZ(o));if(s<=0)return new P(EZ(s));if(o>s)return new P(bZ(o,s));if(s>u)return new P(TZ(s,u));if(c<=0)return new P(GZ(c));if(l<=0)return new P(zZ(l));let f=0;for(let e=o;e<=s;e++)f+=R$(c,e,u,l,0,d);return{value:f}},isExported:!0},f$={description:M(`Depreciation via declining balance method.`),args:[V(`cost (number)`,M(`The initial cost of the asset.`)),V(`salvage (number)`,M(`The value of the asset at the end of depreciation.`)),V(`life (number)`,M(`The number of periods over which the asset is depreciated.`)),V(`period (number)`,M(`The single period within life for which to calculate depreciation.`)),V(`month (number, optional)`,M(`The number of months in the first year of depreciation.`))],compute:function(e,t,n,r,...i){let a=F(e,this.locale),o=F(t,this.locale),s=F(n,this.locale),c=Math.trunc(F(r,this.locale)),l=i.length?Math.trunc(F(i[0],this.locale)):12,u=s+(l===12?0:1);if(a<0)return new P(cZ(a));if(o<0)return new P(qZ(o));if(c<=0)return new P(RZ(c));if(s<=0)return new P(DZ(s));if(1>l||l>12)return new P(kZ(l));if(c>u)return new P(PZ(c,u));let d=l/12,f=1-(o/a)**(1/s);f=Math.round(f*1e3)/1e3;let p=a,m=a*(1-f*d);for(let e=1;e<c;e++)p=m,m=p*(1-f),e===s&&(m=p*(1-f*(1-d)));return{value:p-m,format:`#,##0.00`}},isExported:!0},p$=`#,##0.00`,m$={description:M(`Depreciation via double-declining balance method.`),args:[V(`cost (number)`,M(`The initial cost of the asset.`)),V(`salvage (number)`,M(`The value of the asset at the end of depreciation.`)),V(`life (number)`,M(`The number of periods over which the asset is depreciated.`)),V(`period (number)`,M(`The single period within life for which to calculate depreciation.`)),V(`factor (number, default=2)`,M(`The factor by which depreciation decreases.`))],compute:function(e,t,n,r,i={value:2}){let a=F(e,this.locale),o=F(t,this.locale),s=F(n,this.locale),c=F(r,this.locale),l=F(i,this.locale);if(a<0)return new P(cZ(a));if(o<0)return new P(qZ(o));if(c<=0)return new P(RZ(c));if(s<=0)return new P(DZ(s));if(c>s)return new P(LZ(c,s));if(l<=0)return new P(fZ(l));if(a===0||o>=a)return{value:0,format:p$};let u=l/s;if(u>1)return{value:c===1?a-o:0,format:p$};if(c<=1)return{value:a*u,format:p$};let d=a*(1-u)**(c-1),f=a*(1-u)**c,p=f<o?d-o:d-f;return{value:Math.max(p,0),format:p$}},isExported:!0},h$={description:M(`Discount rate of a security based on price.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`price (number)`,M(`The price at which the security is bought per 100 face value.`)),V(`redemption (number)`,M(`The redemption amount per 100 face value, or par.`)),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(F(e,this.locale)),o=Math.trunc(F(t,this.locale)),s=F(n,this.locale),c=F(r,this.locale),l=Math.trunc(F(i,this.locale));if(a>=o)return new P(OZ(a,o));if(rQ(l))return new P(dZ(l));if(s<=0)return new P(BZ(s));if(c<=0)return new P(KZ(c));let u=oo(a,o,l);return{value:(c-s)/c/u}},isExported:!0},g$={description:M(`Convert a decimal fraction to decimal value.`),args:[V(`fractional_price (number)`,M(`The price quotation given using fractional decimal conventions.`)),V(`unit (number)`,M(`The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.`))],compute:function(e,t){let n=F(e,this.locale),r=Math.trunc(F(t,this.locale));if(r<=0)return new P(eQ(r));let i=Math.trunc(n);return{value:i+(n-i)*(10**Math.ceil(Math.log10(r))/r)}},isExported:!0},_$={description:M(`Convert a decimal value to decimal fraction.`),args:[V(`decimal_price (number)`,M(`The price quotation given as a decimal value.`)),V(`unit (number)`,M(`The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.`))],compute:function(e,t){let n=F(e,this.locale),r=Math.trunc(F(t,this.locale));if(r<=0)return new P(eQ(r));let i=Math.trunc(n);return{value:i+(n-i)*(r/10**Math.ceil(Math.log10(r)))}},isExported:!0},v$={description:M(`Number of periods for an investment to reach a value.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`rate (number)`,M(`The annualized rate of interest.`)),V(`yield (number)`,M(`The expected annual yield of the security.`)),V(`frequency (number)`,M(`The number of interest or coupon payments per year (1, 2, or 4).`),QQ),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i,a={value:0}){let o=Math.trunc(F(e,this.locale)),s=Math.trunc(F(t,this.locale)),c=F(n,this.locale),l=F(r,this.locale),u=Math.trunc(F(i,this.locale)),d=Math.trunc(F(a,this.locale));if(o>=s)return new P(OZ(o,s));if(iQ(u))return new P(uZ(u));if(rQ(d))return new P(dZ(d));if(c<0)return new P(WZ(c));if(l<0)return new P(tQ(l));let f=oo(o,s,d),p=f-Math.trunc(f)||1/u,m=Math.ceil(f*u),h=c/u,g=l/u,_=0,v=0;for(let e=1;e<=m;e++){let t=(h+ +(e===m))/(1+g)**e;v+=(p+(e-1)/u)*t,_+=t}return{value:_===0?0:v/_}},isExported:!0},y$={description:M(`Annual effective interest rate.`),args:[V(`nominal_rate (number)`,M(`The nominal interest rate per year.`)),V(`periods_per_year (number)`,M(`The number of compounding periods per year.`))],compute:function(e,t){let n=F(e,this.locale),r=Math.trunc(F(t,this.locale));return n<=0?new P(AZ(n)):r<=0?new P(IZ(r)):{value:(1+n/r)**+r-1}},isExported:!0};function b$(e,t,n,r,i){return e===0?-(r+n*t):-r*(1+e)**t-n*(1+e*i)*((1+e)**t-1)/e}let x$={description:M(`Future value of an annuity investment.`),args:[V(`rate (number)`,M(`The interest rate.`)),V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`payment_amount (number)`,M(`The amount per period to be paid.`)),V(`present_value (number, default=0)`,M(`The current value of the annuity.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q)],compute:function(e,t,n,r={value:0},i={value:0}){return r||=0,i||=0,{value:b$(F(e,this.locale),F(t,this.locale),F(n,this.locale),F(r,this.locale),+!!L(i)),format:`#,##0.00`}},isExported:!0},S$={description:M(`Future value of principal from series of rates.`),args:[V(`principal (number)`,M(`The amount of initial capital or value to compound against.`)),V(`rate_schedule (number, range<number>)`,M(`A series of interest rates to compound against the principal.`))],compute:function(e,t){let n=F(e,this.locale);return{value:ls([t],(e,t)=>e*(1+F(t,this.locale)),n)}},isExported:!0},C$={description:M(`Calculates effective interest rate.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`investment (number)`,M(`The amount invested in the security.`)),V(`redemption (number)`,M(`The amount to be received at maturity.`)),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i={value:0}){let a=Math.trunc(F(e,this.locale)),o=Math.trunc(F(t,this.locale)),s=F(r,this.locale),c=F(n,this.locale),l=Math.trunc(F(i,this.locale));if(a>=o)return new P(OZ(a,o));if(c<=0)return new P(CZ(c));if(s<=0)return new P(KZ(s));if(rQ(l))return new P(dZ(l));let u=oo(a,o,l);return{value:(s-c)/c/u}},isExported:!0};function w$(e,t,n,r,i,a){return I$(e,n,r,i,a)-R$(e,t,n,r,i,a)}let T$={description:M(`Payment on the principal of an investment.`),args:[V(`rate (number)`,M(`The annualized rate of interest.`)),V(`period (number)`,M(`The amortization period, in terms of number of periods.`)),V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`present_value (number)`,M(`The current value of the annuity.`)),V(`future_value (number, default=0)`,M(`The future value remaining after the final payment has been made.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q)],compute:function(e,t,n,r,i={value:0},a={value:0}){return{value:w$(F(e,this.locale),F(t,this.locale),F(n,this.locale),F(r,this.locale),F(i,this.locale),+!!L(a)),format:`#,##0.00`}},isExported:!0},E$=.1,D$={description:M(`Internal rate of return given periodic cashflows.`),args:[V(`cashflow_amounts (number, range<number>)`,M(`An array or range containing the income or payments associated with the investment.`)),V(`rate_guess (number, default=${E$})`,M(`An estimate for what the internal rate of return will be.`))],compute:function(e,t={value:E$}){let n=F(t,this.locale);if(n<=-1)return new P(UZ(n));let r=!1,i=!1,a=[];if(ss([e],({value:e})=>{e>0&&(r=!0),e<0&&(i=!0),a.push(e)},this.locale),!r||!i)return new P(sZ);let o=a.shift();function s(e,t,n){let r=n.length,i=0;return n.reduce((t,n)=>(i++,t+n*e**(r-i)),t*e**r)}function c(e,t,n){let r=n.length,i=0;return n.reduce((t,n)=>(i++,t+n*(r-i)*e**(r-i-1)),t*r*e**(r-1))}function l(e){return s(e,o,a)}function u(e){return c(e,o,a)}return{value:t$(l,u,n+1,20,1e-5)-1,format:`0%`}},isExported:!0},O$={description:M(`Returns the interest paid at a particular period of an investment.`),args:[V(`rate (number)`,M(`The interest rate.`)),V(`period (number)`,M(`The period for which you want to view the interest payment.`)),V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`present_value (number)`,M(`The current value of the annuity.`))],compute:function(e,t,n,r){let i=F(e,this.locale),a=F(t,this.locale),o=F(n,this.locale),s=F(r,this.locale);return o===0?new P(jZ(o)):{value:-1*(s-a/o*s)*i}},isExported:!0},k$={description:M(`Modified Macaulay duration.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`rate (number)`,M(`The annualized rate of interest.`)),V(`yield (number)`,M(`The expected annual yield of the security.`)),V(`frequency (number)`,M(`The number of interest or coupon payments per year (1, 2, or 4).`),QQ),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`))],compute:function(e,t,n,r,i,a={value:0}){let o=v$.compute.bind(this)(e,t,n,r,i,a),s=F(r,this.locale),c=Math.trunc(F(i,this.locale));return{value:F(o,this.locale)/(1+s/c)}},isExported:!0},A$={description:M(`Modified internal rate of return.`),args:[V(`cashflow_amounts (range<number>)`,M(`A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.`)),V(`financing_rate (number)`,M(`The interest rate paid on funds invested.`)),V(`reinvestment_return_rate (number)`,M(`The return (as a percentage) earned on reinvestment of income received from the investment.`))],compute:function(e,t,n){let r=F(t,this.locale),i=F(n,this.locale),a=hs(e).flat().filter(e=>e.value!==null).map(e=>F(e,this.locale)),o=a.length,s=0,c=0;for(let e of S(0,o)){let t=a[e];t>=0?s+=t*(i+1)**(o-e-1):c+=t/(r+1)**e}if(c===0||s===0)return new P(sZ);let l=1/(o-1);return{value:(-s/c)**l-1}},isExported:!0},j$={description:M(`Annual nominal interest rate.`),args:[V(`effective_rate (number)`,M(`The effective interest rate per year.`)),V(`periods_per_year (number)`,M(`The number of compounding periods per year.`))],compute:function(e,t){let n=F(e,this.locale),r=Math.trunc(F(t,this.locale));return n<=0?new P(gZ(n)):r<=0?new P(IZ(r)):{value:((n+1)**(1/r)-1)*r}},isExported:!0},M$={description:M(`Number of payment periods for an investment.`),args:[V(`rate (number)`,M(`The interest rate.`)),V(`payment_amount (number)`,M(`The amount of each payment made.`)),V(`present_value (number)`,M(`The current value of the annuity.`)),V(`future_value (number, default=0)`,M(`The future value remaining after the final payment has been made.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q)],compute:function(e,t,n,r={value:0},i={value:0}){r||=0,i||=0;let a=F(e,this.locale),o=F(t,this.locale),s=F(n,this.locale),c=F(r,this.locale),l=+!!L(i);if(a===0)return{value:-(c+s)/o};let u=o*(1+a*l)/a;return{value:Math.log((u-c)/(s+u))/Math.log(1+a)}},isExported:!0};function N$(e,t,n,r){let i=0;return us(n,(t,n)=>(i++,t+n/(1+e)**i),t,r)}let P$={description:M(`The net present value of an investment based on a series of periodic cash flows and a discount rate.`),args:[V(`discount (number)`,M(`The discount rate of the investment over one period.`)),V(`cashflow (number, range<number>, repeating)`,M(`The future cash flows.`))],compute:function(e,...t){let n=F(e,this.locale);return n===-1?new P(pZ(n)):{value:N$(n,0,t,this.locale),format:`#,##0.00`}},isExported:!0},F$={description:M(`Computes the number of periods needed for an investment to reach a value.`),args:[V(`rate (number)`,M(`The rate at which the investment grows each period.`)),V(`present_value (number)`,M(`The investment's current value.`)),V(`future_value (number)`,M(`The investment's desired future value.`))],compute:function(e,t,n){let r=F(e,this.locale),i=F(t,this.locale),a=F(n,this.locale);return r<=0?new P(GZ(r)):i<=0?new P(zZ(i)):a<=0?new P(SZ(a)):{value:(Math.log(a)-Math.log(i))/Math.log(1+r)}},isExported:!0};function I$(e,t,n,r,i){if(t<=0)throw new P(MZ(t));if(e===0)return-(r+n)/t;let a=-(n*(1+e)**t+r);return a=a*e/((1+e*i)*((1+e)**t-1)),a}let L$={description:M(`Periodic payment for an annuity investment.`),args:[V(`rate (number)`,M(`The annualized rate of interest.`)),V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`present_value (number)`,M(`The current value of the annuity.`)),V(`future_value (number, default=0)`,M(`The future value remaining after the final payment has been made.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q)],compute:function(e,t,n,r={value:0},i={value:0}){let a=F(t,this.locale),o=F(e,this.locale),s=+!!L(i),c=F(r,this.locale);return{value:I$(o,a,F(n,this.locale),c,s),format:`#,##0.00`}},isExported:!0};function R$(e,t,n,r,i,a){if(n<=0)throw new P(MZ(n));if(t<=0||t>n)throw new P(NZ(n));let o=I$(e,n,r,i,a);return a===1&&t===1?o:o+-b$(e,a===0?t-1:t-2,o,r+o*a,0)*e}let z$={description:M(`Payment on the principal of an investment.`),args:[V(`rate (number)`,M(`The annualized rate of interest.`)),V(`period (number)`,M(`The amortization period, in terms of number of periods.`)),V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`present_value (number)`,M(`The current value of the annuity.`)),V(`future_value (number, default=0)`,M(`The future value remaining after the final payment has been made.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q)],compute:function(e,t,n,r,i={value:0},a={value:0}){let o=F(n,this.locale),s=F(e,this.locale),c=F(t,this.locale),l=+!!L(a),u=F(i,this.locale);return{value:R$(s,c,o,F(r,this.locale),u,l),format:`#,##0.00`}},isExported:!0},B$={description:M(`Present value of an annuity investment.`),args:[V(`rate (number)`,M(`The interest rate.`)),V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`payment_amount (number)`,M(`The amount per period to be paid.`)),V(`future_value (number, default=0)`,M(`The future value remaining after the final payment has been made.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q)],compute:function(e,t,n,r={value:0},i={value:0}){r||=0,i||=0;let a=F(e,this.locale),o=F(t,this.locale),s=F(n,this.locale),c=F(r,this.locale),l=+!!L(i);return{value:a?-(s*(1+a*l)*((1+a)**o-1)/a+c)/(1+a)**o:-(c+s*o),format:`#,##0.00`}},isExported:!0},V$={description:M(`Price of a security paying periodic interest.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`rate (number)`,M(`The annualized rate of interest.`)),V(`yield (number)`,M(`The expected annual yield of the security.`)),V(`redemption (number)`,M(`The redemption amount per 100 face value, or par.`)),V(`frequency (number)`,M(`The number of interest or coupon payments per year (1, 2, or 4).`),QQ),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=Math.trunc(F(e,this.locale)),c=Math.trunc(F(t,this.locale)),l=F(n,this.locale),u=F(r,this.locale),d=F(i,this.locale),f=Math.trunc(F(a,this.locale)),p=Math.trunc(F(o,this.locale));if(s>=c)return new P(OZ(s,c));if(iQ(f))return new P(uZ(f));if(rQ(p))return new P(dZ(p));if(l<0)return new P(WZ(l));if(u<0)return new P(tQ(u));if(d<=0)return new P(KZ(d));let m=oo(s,c,p)*f,h=Math.ceil(m),g=m-Math.floor(m)||1,_=1+u/f,v=100*l/f;if(h===1)return{value:(v+d)/(g*u/f+1)-v*(1-g)};let ee=0;for(let e=1;e<=h;e++)ee+=v/_**(e-1+g);return{value:d/_**(h-1+g)+ee-v*(1-g)}},isExported:!0},H$={description:M(`Price of a discount security.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`discount (number)`,M(`The discount rate of the security at time of purchase.`)),V(`redemption (number)`,M(`The redemption amount per 100 face value, or par.`)),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(F(e,this.locale)),o=Math.trunc(F(t,this.locale)),s=F(n,this.locale),c=F(r,this.locale),l=Math.trunc(F(i,this.locale));if(a>=o)return new P(OZ(a,o));if(rQ(l))return new P(dZ(l));if(s<=0)return new P(mZ(s));if(c<=0)return new P(KZ(c));let u=oo(a,o,l);return{value:c-s*c*u}},isExported:!0},U$={description:M(`Calculates the price of a security paying interest at maturity, based on expected yield.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`issue (date)`,M(`The date the security was initially issued.`)),V(`rate (number)`,M(`The annualized rate of interest.`)),V(`yield (number)`,M(`The expected annual yield of the security.`)),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i,a={value:0}){a||=0;let o=Math.trunc(F(e,this.locale)),s=Math.trunc(F(t,this.locale)),c=Math.trunc(F(n,this.locale)),l=F(r,this.locale),u=F(i,this.locale),d=Math.trunc(F(a,this.locale));if(o<=c)return new P(ZZ(o,c));if(o>=s)return new P(OZ(o,s));if(rQ(d))return new P(dZ(d));if(l<0)return new P(WZ(l));if(u<0)return new P(tQ(u));let f=oo(o,s,d),p=oo(o,c,d),m=100+oo(c,s,d)*l*100,h=1+f*u,g=p*l*100;return{value:m/h-g}},isExported:!0},W$=.1,G$={description:M(`Interest rate of an annuity investment.`),args:[V(`number_of_periods (number)`,M(`The number of payments to be made.`)),V(`payment_per_period (number)`,M(`The amount per period to be paid.`)),V(`present_value (number)`,M(`The current value of the annuity.`)),V(`future_value (number, default=0)`,M(`The future value remaining after the final payment has been made.`)),V(`end_or_beginning (number, default=0)`,M(`The timing of the payment payments are due for each period.`),$Q),V(`rate_guess (number, default=${W$})`,M(`An estimate for what the interest rate will be.`))],compute:function(e,t,n,r={value:0},i={value:0},a={value:W$}){let o=F(e,this.locale),s=F(t,this.locale),c=+!!L(i),l=F(a,this.locale)||W$,u=F(r,this.locale),d=F(n,this.locale);return o<=0?new P(MZ(o)):nQ([s,d,u])?l<=-1?new P(UZ(l)):(u-=s*c,d+=s*c,{value:t$(e=>{let t=(1+e)**+o,n=(t-1)/e;return u+d*t+s*n},e=>{let t=(1+e)**(o-1),n=((1+e)**+o-1)/e,r=o*t/e-n/e;return d*o*t+s*r},l,40,1e-5),format:`0%`}):new P(M(`There must be both positive and negative values in [payment_amount, present_value, future_value].`))},isExported:!0},K$={description:M(`Amount received at maturity for a security.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`investment (number)`,M(`The amount invested (irrespective of face value of each security).`)),V(`discount (number)`,M(`The discount rate of the security invested in.`)),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(F(e,this.locale)),o=Math.trunc(F(t,this.locale)),s=F(n,this.locale),c=F(r,this.locale),l=Math.trunc(F(i,this.locale));return a>=o?new P(OZ(a,o)):rQ(l)?new P(dZ(l)):s<=0?new P(CZ(s)):c<=0?new P(mZ(c)):{value:s/(1-c*oo(a,o,l))}},isExported:!0},q$={description:M(`Computes the rate needed for an investment to reach a specific value within a specific number of periods.`),args:[V(`number_of_periods (number)`,M(`The number of periods.`)),V(`present_value (number)`,M(`The present value of the investment.`)),V(`future_value (number)`,M(`The future value of the investment.`))],compute:function(e,t,n){let r=F(e,this.locale),i=F(t,this.locale),a=F(n,this.locale);return r<=0?new P(MZ(r)):{value:(a/i)**(1/r)-1}},isExported:!0},J$={description:M(`Depreciation of an asset using the straight-line method.`),args:[V(`cost (number)`,M(`The initial cost of the asset.`)),V(`salvage (number)`,M(`The value of the asset at the end of depreciation.`)),V(`life (number)`,M(`The number of periods over which the asset is depreciated.`))],compute:function(e,t,n){let r=F(e,this.locale),i=F(t,this.locale),a=F(n,this.locale);return{value:(r-i)/a,format:`#,##0.00`}},isExported:!0},Y$={description:M(`Depreciation via sum of years digit method.`),args:[V(`cost (number)`,M(`The initial cost of the asset.`)),V(`salvage (number)`,M(`The value of the asset at the end of depreciation.`)),V(`life (number)`,M(`The number of periods over which the asset is depreciated.`)),V(`period (number)`,M(`The single period within life for which to calculate depreciation.`))],compute:function(e,t,n,r){let i=F(e,this.locale),a=F(t,this.locale),o=F(n,this.locale),s=F(r,this.locale);if(s<=0)return new P(RZ(s));if(o<=0)return new P(DZ(o));if(s>o)return new P(LZ(s,o));let c=o*(o+1)/2,l=o-s+1;return{value:(i-a)*(l/c),format:`#,##0.00`}},isExported:!0};function X$(e,t,n){return 100*(1-n*oo(e,t,2))}let Z$={description:M(`Price of a US Treasury bill.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`discount (number)`,M(`The discount rate of the bill at time of purchase.`))],compute:function(e,t,n){let r=Math.trunc(F(e,this.locale)),i=Math.trunc(F(t,this.locale)),a=F(n,this.locale);return r>=i?new P(OZ(r,i)):aQ(r,i,this.locale)?a<=0?new P(mZ(a)):a>=1?new P(hZ(a)):{value:X$(r,i,a)}:new P(XZ(r,i))},isExported:!0},Q$={description:M(`Equivalent rate of return for a US Treasury bill.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`discount (number)`,M(`The discount rate of the bill at time of purchase.`))],compute:function(e,t,n){let r=Math.trunc(F(e,this.locale)),i=Math.trunc(F(t,this.locale)),a=F(n,this.locale);if(r>=i)return new P(OZ(r,i));if(!aQ(r,i,this.locale))return new P(XZ(r,i));if(a<=0)return new P(mZ(a));if(a>=1)return new P(hZ(a));let o=pQ.compute.bind(this)({value:i},{value:r}).value;if(o<=182)return{value:365*a/(360-a*o)};let s=X$(r,i,a)/100,c=o/(o===366?366:365);return{value:(-2*c+2*Math.sqrt(c**2-(2*c-1)*(1-1/s)))/(2*c-1)}},isExported:!0},$$={description:M(`The yield of a US Treasury bill based on price.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`price (number)`,M(`The price at which the security is bought per 100 face value.`))],compute:function(e,t,n){let r=Math.trunc(F(e,this.locale)),i=Math.trunc(F(t,this.locale)),a=F(n,this.locale);if(r>=i)return new P(OZ(r,i));if(!aQ(r,i,this.locale))return new P(XZ(r,i));if(a<=0)return new P(BZ(a));let o=oo(r,i,2);return{value:(100-a)/a*(1/o)}},isExported:!0},e1={description:M(`Variable declining balance. WARNING : does not handle decimal periods.`),args:[V(`cost (number)`,M(`The initial cost of the asset.`)),V(`salvage (number)`,M(`The value of the asset at the end of depreciation.`)),V(`life (number)`,M(`The number of periods over which the asset is depreciated.`)),V(`start (number)`,M(`Starting period to calculate depreciation.`)),V(`end (number)`,M(`Ending period to calculate depreciation.`)),V(`factor (number, default=2)`,M(`The number of months in the first year of depreciation.`)),V(`no_switch (number, default=false)`,M(`Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.`),[{value:!1,label:M(`Switch to straight-line depreciation`)},{value:!0,label:M(`Do not switch to straight-line depreciation`)}])],compute:function(e,t,n,r,i,a={value:2},o={value:!1}){a||=0;let s=F(e,this.locale),c=F(t,this.locale),l=F(n,this.locale),u=Math.trunc(F(r,this.locale)),d=Math.trunc(F(i,this.locale)),f=F(a,this.locale),p=L(o);if(s<0)return new P(cZ(s));if(c<0)return new P(qZ(c));if(l<=0)return new P(DZ(l));if(u<0)return new P(QZ(u));if(d<0)return new P(_Z(d));if(u>d)return new P($Z(u,d));if(d>l)return new P(vZ(d,l));if(f<=0)return new P(fZ(f));if(s===0)return{value:0};if(c>=s)return{value:u<1?s-c:0};let m=f/l;if(m>=1)return{value:u<1?s-c:0};let h=s,g=0,_=0,v=!1;for(let e=0;e<d;e++){if(!v||p){let t=h*m,n=l-e,r=(h-c)/n;!p&&r>t?(v=!0,g=r):g=t}let t=Math.max(h-g,c);e>=u&&(_+=h-t),h=t}return{value:_}},isExported:!0},t1={description:M(`Internal rate of return given non-periodic cash flows.`),args:[V(`cashflow_amounts (range<number>)`,M(`An range containing the income or payments associated with the investment.`)),V(`cashflow_dates (range<number>)`,M(`An range with dates corresponding to the cash flows in cashflow_amounts.`)),V(`rate_guess (number, default=${W$})`,M(`An estimate for what the internal rate of return will be.`))],compute:function(e,t,n={value:W$}){let r=F(n,this.locale);if(!wv(e,t))return new P(oZ);let i=e.flat().map(e=>F(e,this.locale)),a=t.flat().map(e=>F(e,this.locale));if(!nQ(i))return new P(sZ);if(a.some(e=>e<a[0]))return new P(yZ(a[0]));if(r<=-1)return new P(UZ(r));let o=new Map;for(let e of S(0,a.length)){let t=a[e];o.has(t)?o.set(t,o.get(t)+i[e]):o.set(t,i[e])}let s=Array.from(o.keys()),c=s.map(e=>o.get(e));return{value:t$(e=>{let t=c[0];for(let n of S(1,c.length)){let r=(s[0]-s[n])/365;t+=c[n]*(1+e)**r}return t},e=>{let t=0;for(let n of S(1,c.length)){let r=(s[0]-s[n])/365;t+=r*c[n]*(1+e)**(r-1)}return t},r,40,1e-5,e=>e?e/10-.9:-.9)}},isExported:!0},n1={description:M(`Net present value given to non-periodic cash flows..`),args:[V(`discount (number)`,M(`The discount rate of the investment over one period.`)),V(`cashflow_amounts (number, range<number>)`,M(`An range containing the income or payments associated with the investment.`)),V(`cashflow_dates (number, range<number>)`,M(`An range with dates corresponding to the cash flows in cashflow_amounts.`))],compute:function(e,t,n){let r=F(e,this.locale);if(!wv(t,n))return new P(oZ);let i=R(t).flat().map(e=>Zo(e,this.locale)),a=R(n).flat().map(e=>Zo(e,this.locale));if(a.some(e=>e<a[0]))return new P(yZ(a[0]));if(r<=0)return new P(GZ(r));if(i.length===1)return{value:i[0]};let o=new Map;for(let e of S(0,a.length)){let t=a[e];o.has(t)?o.set(t,o.get(t)+i[e]):o.set(t,i[e])}let s=Array.from(o.keys()),c=s.map(e=>o.get(e)),l=c[0];for(let e of S(1,c.length)){let t=(s[0]-s[e])/365;l+=c[e]*(1+r)**t}return{value:l}},isExported:!0},r1={description:M(`Annual yield of a security paying periodic interest.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`rate (number)`,M(`The annualized rate of interest.`)),V(`price (number)`,M(`The price at which the security is bought per 100 face value.`)),V(`redemption (number)`,M(`The redemption amount per 100 face value, or par.`)),V(`frequency (number)`,M(`The number of interest or coupon payments per year (1, 2, or 4).`),QQ),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=Math.trunc(F(e,this.locale)),c=Math.trunc(F(t,this.locale)),l=F(n,this.locale),u=F(r,this.locale),d=F(i,this.locale),f=Math.trunc(F(a,this.locale)),p=Math.trunc(F(o,this.locale));if(s>=c)return new P(OZ(s,c));if(iQ(f))return new P(uZ(f));if(rQ(p))return new P(dZ(p));if(l<0)return new P(WZ(l));if(u<=0)return new P(BZ(u));if(d<=0)return new P(KZ(d));let m=oo(s,c,p)*f,h=Math.ceil(m),g=m-Math.floor(m)||1,_=100*l/f;if(h===1){let e=u+_*(1-g);return{value:(d+_-e)*f*(1/g)/e}}function v(e,t,n,r,i,a){let o=a-(e+i*(1-t))*r**(n-1+t);for(let e=1;e<=n;e++)o+=i*r**(e-1);return o}function ee(e,t,n,r,i){let a=-(e+i*(1-t))*(n-1+t)*r**(n-2+t);for(let e=1;e<=n;e++)a+=i*(e-1)*r**(e-2);return a}function y(e){return v(u,g,h,e,_,d)}function te(e){return ee(u,g,h,e,_)}return{value:(t$(y,te,1+(l+1)/f,100,1e-5)-1)*f}},isExported:!0},i1={description:M(`Annual yield of a discount security.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`price (number)`,M(`The price at which the security is bought per 100 face value.`)),V(`redemption (number)`,M(`The redemption amount per 100 face value, or par.`)),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(F(e,this.locale)),o=Math.trunc(F(t,this.locale)),s=F(n,this.locale),c=F(r,this.locale),l=Math.trunc(F(i,this.locale));if(a>=o)return new P(OZ(a,o));if(rQ(l))return new P(dZ(l));if(s<=0)return new P(BZ(s));if(c<=0)return new P(KZ(c));let u=oo(a,o,l);return{value:(c/s-1)/u}},isExported:!0},a1={description:M(`Annual yield of a security paying interest at maturity.`),args:[V(`settlement (date)`,M(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),V(`maturity (date)`,M(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),V(`issue (date)`,M(`The date the security was initially issued.`)),V(`rate (number)`,M(`The annualized rate of interest.`)),V(`price (number)`,M(`The price at which the security is bought.`)),V(`day_count_convention (number, default=0 )`,M(`An indicator of what day count method to use.`),oQ)],compute:function(e,t,n,r,i,a={value:0}){a||=0;let o=Math.trunc(F(e,this.locale)),s=Math.trunc(F(t,this.locale)),c=Math.trunc(F(n,this.locale)),l=F(r,this.locale),u=F(i,this.locale),d=Math.trunc(F(a,this.locale));if(o>=s)return new P(OZ(o,s));if(rQ(d))return new P(dZ(d));if(o<c)return new P(YZ(o,c));if(l<0)return new P(WZ(l));if(u<=0)return new P(BZ(u));let f=oo(c,s,d),p=oo(c,o,d),m=oo(o,s,d);return{value:(100*(1+l*f)/(u+100*l*p)-1)/m}},isExported:!0};var o1=l({CELL:()=>c1,ISBLANK:()=>g1,ISERR:()=>l1,ISERROR:()=>u1,ISFORMULA:()=>v1,ISLOGICAL:()=>d1,ISNA:()=>f1,ISNONTEXT:()=>p1,ISNUMBER:()=>m1,ISTEXT:()=>h1,NA:()=>_1});let s1=[{value:`address`,label:M(`Returns an absolute reference as plain text of the top left cell in reference.`)},{value:`col`,label:M(`Returns the column number of the cell in reference.`)},{value:`contents`,label:M(`Returns the value contained in the top left cell in reference.`)},{value:`format`,label:M(`Returns the format of the top left cell in reference.`)},{value:`row`,label:M(`Returns the row number of the top left cell in reference.`)},{value:`type`,label:M(`Returns the type of data in the cell in reference. The following values are returned: "b" for a blank cell, "l" (for label) if the cell contains plain text, and "v" (for value) if the cell contains any other type of data.`)}],c1={description:M(`Gets information about a cell.`),args:[V(`info_type (string)`,M(`The type of information requested.`),s1),V(`reference (any, range<any>)`,M(`The reference to the cell.`))],compute:function(e,t){let n=I(e).toLowerCase();if(!s1.map(e=>e.value).includes(n))return new P(M(`The info_type should be one of %s.`,s1.join(`, `)));let r=R(t)[0][0],i=r.position;if(i===void 0)return new P(M(`The reference is invalid.`));switch(n){case`address`:return{value:(this.__originSheetId===i.sheetId?``:this.getters.getSheetName(i.sheetId)+`!`)+T(i.col,i.row,{colFixed:!0,rowFixed:!0})};case`col`:return{value:i.col+1};case`contents`:return{value:r.value};case`format`:return{value:r.format||``};case`row`:return{value:i.row+1};case`type`:return r.value===null?{value:`b`}:Wc(r.format)?{value:`l`}:typeof r.value==`number`||typeof r.value==`boolean`?{value:`v`}:{value:`l`}}return{value:``}},isExported:!0},l1={description:M(`Whether a value is an error other than #N/A.`),args:[V(`value (any)`,M(`The value to be verified as an error type.`))],compute:function(e){let t=e?.value;return{value:Uo(t)&&t!==N.NotAvailable}},isExported:!0},u1={description:M(`Whether a value is an error.`),args:[V(`value (any)`,M(`The value to be verified as an error type.`))],compute:function(e){let t=e?.value;return{value:Uo(t)}},isExported:!0},d1={description:M("Whether a value is `true` or `false`."),args:[V(`value (any)`,M(`The value to be verified as a logical TRUE or FALSE.`))],compute:function(e){return{value:typeof e?.value==`boolean`}},isExported:!0},f1={description:M(`Whether a value is the error #N/A.`),args:[V(`value (any)`,M(`The value to be verified as an error type.`))],compute:function(e){return{value:e?.value===N.NotAvailable}},isExported:!0},p1={description:M(`Whether a value is non-textual.`),args:[V(`value (any)`,M(`The value to be checked.`))],compute:function(e){return{value:!h1.compute.bind(this)(e).value}},isExported:!0},m1={description:M(`Whether a value is a number.`),args:[V(`value (any)`,M(`The value to be verified as a number.`))],compute:function(e){return{value:typeof e?.value==`number`}},isExported:!0},h1={description:M(`Whether a value is text.`),args:[V(`value (any)`,M(`The value to be verified as text.`))],compute:function(e){return{value:typeof e?.value==`string`&&Uo(e?.value)===!1}},isExported:!0},g1={description:M(`Whether the referenced cell is empty`),args:[V(`value (any)`,M(`Reference to the cell that will be checked for emptiness.`))],compute:function(e){return{value:e?.value===null}},isExported:!0},_1={description:M(`Returns the error value #N/A.`),args:[],compute:function(){return{value:N.NotAvailable}},isExported:!0},v1={description:M(`Checks whether there is a reference to a cell that contains a formula, and returns TRUE or FALSE.`),args:[V(`cell_reference (any)`,M(`A reference to a cell.`))],compute:function(e){return e?.position===void 0?new Fo(Ko):{value:this.getters.getCell(e.position)?.isFormula??!1}},isExported:!0};var y1=l({AND:()=>b1,FALSE:()=>x1,IF:()=>S1,IFERROR:()=>C1,IFNA:()=>w1,IFS:()=>T1,NOT:()=>E1,OR:()=>D1,SWITCH:()=>O1,TRUE:()=>k1,XOR:()=>A1});let b1={description:M("Logical `and` operator."),args:[V(`logical_expression (boolean, range<boolean>, repeating)`,M(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let{result:t,foundBoolean:n}=vv(e);return n?{value:t}:new P(ks)},isExported:!0},x1={description:M("Logical value `false`."),args:[],compute:function(){return{value:!1}},isExported:!0},S1={description:M(`Returns value depending on logical expression.`),args:[V(`logical_expression (boolean, range<boolean>)`,M(`An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.`)),V(`value_if_true (any, range)`,M(`The value the function returns if logical_expression is TRUE.`)),V(`value_if_false (any, range, default=FALSE)`,M(`The value the function returns if logical_expression is FALSE.`))],computeArray:function(e,t,n){if(Nv(e)){let r=ml.get(`IF`);return rl(this,r,[e,t,n],al(r,3),Pv([e,t,n]))}return(L(jv(e))?t:n)??{value:0}},isExported:!0},C1={description:M(`Value if it is not an error, otherwise 2nd argument.`),args:[V(`value (any, range)`,M(`The value to return if value itself is not an error.`)),V(`value_if_error (any, range, default="empty")`,M(`The value the function returns if value is an error.`))],computeArray:function(e,t){if(Nv(e)){let n=ml.get(`IFERROR`);return rl(this,n,[e,t],al(n,2),Pv([e,t]))}return(Uo(jv(e)?.value)?t:e)??{value:0}},isExported:!0},w1={description:M(`Value if it is not an #N/A error, otherwise 2nd argument.`),args:[V(`value (any, range)`,M(`The value to return if value itself is not #N/A an error.`)),V(`value_if_error (any, range, default="empty")`,M(`The value the function returns if value is an #N/A error.`))],computeArray:function(e,t){if(Nv(e)){let n=ml.get(`IFNA`);return rl(this,n,[e,t],al(n,2),Pv([e,t]))}return(jv(e)?.value===N.NotAvailable?t:e)??{value:0}},isExported:!0},T1={description:M(`Returns a value depending on multiple logical expressions.`),args:[V(`condition (any, range, repeating)`,M(`The condition to be evaluated. It can be a boolean, a number, an array, or a reference to any of those.`)),V(`value (any, range, repeating)`,M(`The value to be returned if its corresponding condition is TRUE.`))],computeArray:function(...e){if(e.length%2!=0)return new P(M(`Wrong number of arguments. Expected an even number of arguments.`));for(;e.length>0;){if(Nv(e[0])){let t=ml.get(`IFS`);return rl(this,t,e,al(t,e.length),Pv(e))}let t=L(jv(e.shift())),n=e.shift();if(t)return n??{value:0}}return new P(M(`No match.`))},isExported:!0},E1={description:M(`Returns opposite of provided logical value.`),args:[V(`logical_expression (boolean)`,M(`An expression or reference to a cell holding an expression that represents some logical value.`))],compute:function(e){return{value:!L(e)}},isExported:!0},D1={description:M("Logical `or` operator."),args:[V(`logical_expression (boolean, range<boolean>, repeating)`,M(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let{result:t,foundBoolean:n}=yv(e);return n?{value:t}:new P(ks)},isExported:!0},O1={description:M(`Returns a value by comparing cases to an expression.`),args:[V(`expression (number, boolean, string)`,M(`The value to be checked.`)),V(`case (any, repeating)`,M(`Case to be checked against expression.`)),V(`value (any, repeating)`,M(`Value to be returned if its corresponding case matches expression.`)),V(`default (any, default="empty")`,M(`An optional default value to be returned if none of the cases match expression.`))],compute:function(e,...t){let n=t.length%2==0?Wo(e):t.pop();for(let n=0;n<t.length;n+=2){let r=t[n];if(r&&Uo(r.value))return r;if(e?.value===r?.value)return t[n+1]||{value:0}}return n||{value:0}},isExported:!0},k1={description:M("Logical value `true`."),args:[],compute:function(){return{value:!0}},isExported:!0},A1={description:M("Logical `xor` operator."),args:[V(`logical_expression (boolean, range<boolean>, repeating)`,M(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let t=!1,n=!1;return _s(e,e=>(t=!0,n=n?!e:e,!0)),t?{value:n}:new P(ks)},isExported:!0};function j1(e,t){let n=t.getPivotId(e);if(!n)throw new P(M(`There is no pivot with id "%s"`,e));return n}function M1(e,t,n){let{measures:r}=n.getPivotCoreDefinition(e);if(!r.find(e=>e.id===t))throw new P(M(`The argument %s is not a valid measure. Here are the measures: %s`,t,`(${r.map(e=>e.id).join(`, `)})`))}function N1(e){if(e.length%2!=0)throw new P(M(`Function PIVOT takes an even number of arguments.`))}function P1(e,t,n){let r=[],i=e.getters.getPivotCoreDefinition(t);if(i.type===`SPREADSHEET`&&i.dataSet){let{sheetId:t,zone:n}=i.dataSet,a=tr(n),o=e.getters.getRangeFromSheetXC(t,a);if(o===void 0||o.invalidXc||o.invalidSheetName)throw new Fo;if(e.__originCellPosition&&o.sheetId===e.__originSheetId&&pr(E(e.__originCellPosition),n))throw new Po;r.push(o)}for(let i of n)i.computedBy&&r.push(...e.getters.getMeasureFullDependencies(t,i));let a=e.__originCellPosition;a&&r.length&&(e.updateDependencies?.(a),e.addDependencies?.(a,r))}var F1=l({ADDRESS:()=>R1,CHOOSE:()=>t0,COLUMN:()=>z1,COLUMNS:()=>B1,DROP:()=>n0,FORMULATEXT:()=>i0,HLOOKUP:()=>V1,INDEX:()=>H1,INDIRECT:()=>U1,LOOKUP:()=>W1,MATCH:()=>G1,OFFSET:()=>e0,PIVOT:()=>$1,PIVOT_HEADER:()=>Q1,PIVOT_VALUE:()=>Z1,ROW:()=>K1,ROWS:()=>q1,TAKE:()=>r0,VLOOKUP:()=>J1,XLOOKUP:()=>X1});let I1=[{value:!0,label:M(`A1 style (default)`)},{value:!1,label:M(`R1C1 style`)}],L1=[{value:!0,label:M(`Approximate match (default)`)},{value:!1,label:M(`Exact match`)}],R1={description:M(`Returns a cell reference as a string. `),args:[V(`row (number)`,M(`The row number of the cell reference. `)),V(`column (number)`,M(`The column number (not name) of the cell reference. A is column number 1. `)),V(`absolute_relative_mode (number, default=1)`,M(`An indicator of whether the reference is row/column absolute.`),[{value:1,label:M(`Absolute row and column (e.g. $A$1)`)},{value:2,label:M(`Absolute row, relative column (e.g. A$1)`)},{value:3,label:M(`Relative row, absolute column (e.g. $A1)`)},{value:4,label:M(`Relative row and column (e.g. A1)`)}]),V(`use_a1_notation (boolean, default=TRUE)`,M(`A boolean indicating whether to use A1 style notation or R1C1 style notation.`),I1),V(`sheet (string, optional)`,M(`A string indicating the name of the sheet into which the address points.`))],compute:function(e,t,n={value:1},r={value:!0},i){let a=$o(e,this.locale),o=$o(t,this.locale);if(a<1)return new P(Ev(a));if(o<1)return new P(Ev(o));let s=$o(n,this.locale);if(![1,2,3,4].includes(s))return new P(qo(1,4,s));let c=L(r),l;if(c){let e={rowFixed:[1,2].includes(s),colFixed:[1,3].includes(s)};l=T(o-1,a-1,e)}else l=([1,2].includes(s)?`R${a}`:`R[${a}]`)+([1,3].includes(s)?`C${o}`:`C[${o}]`);return i===void 0?{value:l}:{value:Ol(I(i),l)}},isExported:!0},z1={description:M(`Column number of a specified cell.`),args:[V(`cell_reference (any, range<any>, default='this cell')`,M(`The cell whose column number will be returned. Column A corresponds to 1. By default, the function use the cell in which the formula is entered.`))],computeArray:function(e){if(e===void 0)return this.__originCellPosition===void 0?new P(M(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):{value:this.__originCellPosition.col+1};let t=R(e),n=t[0][0];if(n===void 0)return new P(M(`The range is out of bounds.`));if(n.position===void 0)return new Fo(Ko);let r=n.position.col;return t.length===1?{value:r+1}:fs(t.length,1,e=>({value:r+e+1}))},isExported:!0},B1={description:M(`Number of columns in a specified array or range.`),args:[V(`range (any, range<any>)`,M(`The range whose column count will be returned.`))],compute:function(e){let t=R(e);return t[0][0]===void 0?new P(M(`The range is out of bounds.`)):t[0][0].value===N.InvalidReference?t[0][0]:{value:t.length}},isExported:!0},V1={description:M(`Horizontal lookup`),args:[V(`search_key (string, number, boolean)`,M(`The value to search for. For example, 42, 'Cats', or I24.`)),V(`range (any, range)`,M(`The range to consider for the search. The first row in the range is searched for the key specified in search_key.`)),V(`index (number)`,M(`The row index of the value to be returned, where the first row in range is numbered 1.`)),V(`is_sorted (boolean, default=true)`,M(`Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned.`),L1)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(F(n?.value,this.locale)),a=R(t);if(1>i||i>a[0].length)return new P(M(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[t][0].value,s=a[L(r.value)?Ss(a,e,`nextSmaller`,`asc`,a.length,o):Cs(a,e,`wildcard`,a.length,o,this.lookupCaches)];return s===void 0?Wo(e):s[i-1]},isExported:!0},H1={description:M(`Returns the content of a cell, specified by row and column offset.`),args:[V(`reference (any, range)`,M(`The range of cells from which the values are returned.`)),V(`row (number, default=0)`,M(`The index of the row to be returned from within the reference range of cells.`)),V(`column (number, default=0)`,M(`The index of the column to be returned from within the reference range of cells.`))],computeArray:function(e,t={value:0},n={value:0}){let r=R(e),i=F(t.value,this.locale),a=F(n.value,this.locale);return a<0||a-1>=r.length||i<0||i-1>=r[0].length?new P(M(`Index out of range.`)):i===0&&a===0?r:i===0?[r[a-1]]:a===0?r.map(e=>[e[i-1]]):r[a-1][i-1]},isExported:!0},U1={description:M(`Returns the content of a cell, specified by a string.`),args:[V(`reference (string)`,M(`The range of cells from which the values are returned.`)),V(`use_a1_notation (boolean, default=TRUE)`,M(`A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).`),I1)],computeArray:function(e,t={value:!0}){let n=e?.value?.toString();if(!n)return new Fo(M(`Reference should be defined.`));if(!L(t))return new P(M(`R1C1 notation is not supported.`));let r=this.__originSheetId,i=this.__originCellPosition;i&&this.updateDependencies?.(i);let a=this.getters.getNamedRange(n),o=a?a.range:this.getters.getRangeFromSheetXC(r,n);if(o===void 0||o.invalidXc||o.invalidSheetName)return new Fo;i&&this.addDependencies?.(i,[o]);let s=[];for(let e=o.zone.left;e<=o.zone.right;e++){let t=[];for(let n=o.zone.top;n<=o.zone.bottom;n++){let r={sheetId:o.sheetId,col:e,row:n};t.push(this.getFormulaResult(r))}s.push(t)}return s.length===1&&s[0].length===1?s[0][0]:s},isExported:!0},W1={description:M(`Look up a value.`),args:[V(`search_key (string, number, boolean)`,M(`The value to search for. For example, 42, 'Cats', or I24.`)),V(`search_array (any, range)`,M(`One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.`)),V(`result_range (any, range, optional)`,M(`The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method.`))],compute:function(e,t,n){let r=R(t),i=R(n),a=r.length,o=r[0].length,s=o>=a,c=Ss(r,e,`nextSmaller`,`asc`,s?o:a,s?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value);return c===-1||s&&r[0][c]===void 0||!s&&r[c][o-1]===void 0?Wo(e):i[0].length===0?s?r[a-1][c]:r[c][o-1]:(a=i.length,o=i[0].length,a!==1&&o!==1?new P(M(`The result_range must be a single row or a single column.`)):a>1?c>a-1?new P(M(`[[FUNCTION_NAME]] evaluates to an out of range row value %s.`,c+1)):i[c][0]:c>o-1?new P(M(`[[FUNCTION_NAME]] evaluates to an out of range column value %s.`,c+1)):i[0][c])},isExported:!0},G1={description:M(`Position of item in range that matches value.`),args:[V(`search_key (string, number, boolean)`,M(`The value to search for. For example, 42, 'Cats', or I24.`)),V(`range (any, range)`,M(`The one-dimensional array to be searched.`)),V(`search_type (number, default=1)`,M(`The search method is a number 1, 0 or -1 indicating which value to return. 1 finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order.`),[{value:1,label:M(`Ascending order (default)`)},{value:0,label:M(`Exact match`)},{value:-1,label:M(`Descending order`)}])],compute:function(e,t,n={value:1}){let r=F(n,this.locale),i=R(t),a=i.length,o=i[0].length;if(a!==1&&o!==1)return new P(M(`The range must be a single row or a single column.`));let s=-1,c=a===1?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,l=a===1?i[0].length:i.length;switch(r=Math.sign(r),r){case 1:s=Ss(i,e,`nextSmaller`,`asc`,l,c);break;case 0:s=Cs(i,e,`wildcard`,l,c,this.lookupCaches);break;case-1:s=Ss(i,e,`nextGreater`,`desc`,l,c);break}return a===1&&i[0][s]===void 0||a!==1&&i[s]===void 0?Wo(e):{value:s+1}},isExported:!0},K1={description:M(`Row number of a specified cell.`),args:[V(`cell_reference (any, range<any>, default='this cell')`,M(`The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered.`))],computeArray:function(e){if(e===void 0)return this.__originCellPosition?.row===void 0?new P(M(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):{value:this.__originCellPosition.row+1};let t=R(e),n=t[0][0];if(n===void 0)return new P(M(`The range is out of bounds.`));if(n.position===void 0)return new Fo(Ko);let r=n.position.row;return t[0].length===1?{value:r+1}:fs(1,t[0].length,(e,t)=>({value:r+t+1}))},isExported:!0},q1={description:M(`Number of rows in a specified array or range.`),args:[V(`range (any, range<any>)`,M(`The range whose row count will be returned.`))],compute:function(e){let t=R(e);return t[0][0]===void 0?new P(M(`The range is out of bounds.`)):t[0][0].value===N.InvalidReference?t[0][0]:{value:t[0].length}},isExported:!0},J1={description:M(`Vertical lookup.`),args:[V(`search_key (string, number, boolean)`,M(`The value to search for. For example, 42, 'Cats', or I24.`)),V(`range (any, range)`,M(`The range to consider for the search. The first column in the range is searched for the key specified in search_key.`)),V(`index (number)`,M(`The column index of the value to be returned, where the first column in range is numbered 1.`)),V(`is_sorted (boolean, default=true)`,M(`Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned.`),L1)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(F(n?.value,this.locale)),a=R(t);if(1>i||i>a.length)return new P(M(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[0][t].value,s=L(r.value)?Ss(a,e,`nextSmaller`,`asc`,a[0].length,o):Cs(a,e,`wildcard`,a[0].length,o,this.lookupCaches),c=a[i-1][s];return c===void 0?Wo(e):c},isExported:!0},Y1={0:`strict`,1:`nextGreater`,"-1":`nextSmaller`,2:`wildcard`},X1={description:M(`Search a range for a match and return the corresponding item from a second range.`),args:[V(`search_key (string,number,boolean)`,M(`The value to search for.`)),V(`lookup_range (any, range)`,M(`The range to consider for the search. Should be a single column or a single row.`)),V(`return_range (any, range)`,M(`The range containing the return value. Should have the same dimensions as lookup_range.`)),V(`if_not_found (any, optional)`,M(`If a valid match is not found, return this value.`)),V(`match_mode (any, default=0)`,M(`Specifies how to match search_key with the items in lookup_range. `),[{value:0,label:M(`Exact match (default)`)},{value:-1,label:M(`Exact match or next smaller item`)},{value:1,label:M(`Exact match or next larger item`)},{value:2,label:M(`Wildcard character match`)}]),V(`search_mode (any, default=1)`,M(`Specifies the search mode to use. By default, a first to last search will be used.`),[{value:1,label:M(`Search first to last (default)`)},{value:-1,label:M(`Search last to first`)},{value:2,label:M(`Binary search (sorted ascending order)`)},{value:-2,label:M(`Binary search (sorted descending order)`)}])],computeArray:function(e,t,n,r,i={value:0},a={value:1}){let o=Math.trunc(F(i.value,this.locale)),s=Math.trunc(F(a.value,this.locale)),c=R(t),l=R(n);if(c.length!==1&&c[0].length!==1)return new P(M(`lookup_range should be either a single row or single column.`));if(![1,-1,2,-2].includes(s))return new P(M(`search_mode should be a value in [-1, 1, -2, 2].`));if(![-1,0,1,2].includes(o))return new P(M(`match_mode should be a value in [-1, 0, 1, 2].`));let u=c.length===1?`col`:`row`;if(o===2&&[-2,2].includes(s))return new P(M(`The search and match mode combination is not supported for XLOOKUP evaluation.`));if(u===`col`?l[0].length!==c[0].length:l.length!==c.length)return new P(M(`return_range should have the same dimensions as lookup_range.`));let d=u===`col`?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,f=u===`col`?c[0].length:c.length,p=Y1[o],m=s===-1,h=s===2||s===-2?Ss(c,e,p,s===2?`asc`:`desc`,f,d):Cs(c,e,p,f,d,this.lookupCaches,m);return h===-1?r===void 0?Wo(e):[[r]]:u===`col`?l.map(e=>[e[h]]):[l[h]]},isExported:!0},Z1={description:M(`Get the value from a pivot.`),args:[V(`pivot_id (number,string)`,M(`ID of the pivot.`)),V(`measure_name (string)`,M(`Name of the measure.`)),V(`domain_field_name (string,repeating,optional)`,M(`Field name.`)),V(`domain_value (number,string,boolean,repeating,optional)`,M(`Value.`))],compute:function(e,t,...n){let r=I(e),i=I(t),a=j1(r,this.getters);M1(a,i,this.getters),N1(n);let o=this.getters.getPivot(a),s=this.getters.getPivotCoreDefinition(a);P1(this,a,s.measures.filter(e=>e.id===i)),o.init({reload:o.needsReevaluation});let c=o.assertIsValid({throwOnError:!1});if(c)return c;if(!o.areDomainArgsFieldsValid(n)){let e=M(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${r})`);return{value:N.GenericError,message:M(`Dimensions don't match the pivot definition`)+`. `+e}}let l=o.parseArgsToPivotDomain(n);return this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(a)?.trackValue(i,l),o.getPivotCellValueAndFormat(i,l)}},Q1={description:M(`Get the header of a pivot.`),args:[V(`pivot_id (number,string)`,M(`ID of the pivot.`)),V(`domain_field_name (string,repeating,optional)`,M(`Field name.`)),V(`domain_value (number,string,value,repeating,optional)`,M(`Value.`))],compute:function(e,...t){let n=I(e),r=j1(n,this.getters);N1(t);let i=this.getters.getPivot(r);P1(this,r,[]),i.init({reload:i.needsReevaluation});let a=i.assertIsValid({throwOnError:!1});if(a)return a;if(!i.areDomainArgsFieldsValid(t)){let e=M(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${n})`);return{value:N.GenericError,message:M(`Dimensions don't match the pivot definition`)+`. `+e}}let o=i.parseArgsToPivotDomain(t);this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(r)?.trackHeader(o);let s=o.at(-1);if(s?.field===`measure`)return i.getPivotMeasureValue(I(s.value),o);let{value:c,format:l}=i.getPivotHeaderValueAndFormat(o);return{value:c,format:!s||s.field===`measure`||s.value===`false`?void 0:l}}},$1={description:M(`Get a pivot table.`),args:[V(`pivot_id (string)`,M(`ID of the pivot.`)),V(`row_count (number, optional)`,M(`number of rows`)),V(`include_total (boolean, default=TRUE)`,M(`Whether to include total/sub-totals or not.`)),V(`include_column_titles (boolean, default=TRUE)`,M(`Whether to include the column titles or not.`)),V(`column_count (number, optional)`,M(`number of columns`)),V(`include_measure_titles (boolean, default=TRUE)`,M(`Whether to include the measure titles row or not.`))],computeArray:function(e,t,n,r,i,a){let o=j1(I(e),this.getters),s=this.getters.getPivot(o),c=this.getters.getPivotCoreDefinition(o),l=Yy(c,t,n,r,i,a,this.locale);if(l.numberOfRows<0)return new P(M(`The number of rows must be positive.`));if(l.numberOfColumns<0)return new P(M(`The number of columns must be positive.`));P1(this,o,c.measures),s.init({reload:s.needsReevaluation});let u=s.assertIsValid({throwOnError:!1});if(u)return u;let d=s.getCollapsedTableStructure();if(d.numberOfCells>5e5)return new P(ub(d.numberOfCells,this.locale));let f=d.getPivotCells(l),p=this.getters.getPivotName(o),{numberOfCols:m,numberOfRows:h}=d.getPivotTableDimensions(l);if(h===0)return[[{value:p}]];let g=[];for(let e of S(0,m)){g[e]=[];for(let t of S(0,h)){let n=f[e][t];switch(n.type){case`EMPTY`:g[e].push({value:``});break;case`HEADER`:let t=s.getPivotHeaderValueAndFormat(n.domain);g[e].push(By(n.domain,t));break;case`MEASURE_HEADER`:g[e].push(s.getPivotMeasureValue(n.measure,n.domain));break;case`VALUE`:g[e].push(s.getPivotCellValueAndFormat(n.measure,n.domain));break;case`ROW_GROUP_NAME`:let r=s.definition.rows.find(e=>e.nameWithGranularity===n.rowField)?.displayName;g[e].push({value:r||``});break}}}return(l.displayColumnHeaders||l.displayMeasuresRow)&&f[0][0].type===`EMPTY`&&(g[0][0]={value:p}),g}},e0={description:M(`Returns a range reference shifted by a specified number of rows and columns from a starting cell reference.`),args:[V(`cell_reference (any, range<any>)`,M(`The starting point from which to count the offset rows and columns.`)),V(`offset_rows (number)`,M(`The number of rows to offset by.`)),V(`offset_columns (number)`,M(`The number of columns to offset by.`)),V(`height (number, default='height of cell_reference')`,M(`The number of rows of the range to return starting at the offset target.`)),V(`width (number, default='width of cell_reference')`,M(`The number of columns of the range to return starting at the offset target.`))],computeArray:function(e,t,n,r,i){if(e===void 0)return new Fo(Ko);let a=R(e),o=a[0][0];if(o===void 0)return new P(M(`The range is out of bounds.`));if(o.position===void 0)return new Fo(Ko);let s=a[0].length,c=a.length;if(r){let e=F(r,this.locale);if(e<1)return new P(M(`Height value is %(_height)s. It should be greater than or equal to 1.`,{_height:e}));s=e}if(i){let e=F(i,this.locale);if(e<1)return new P(M(`Width value is %(_width)s. It should be greater than or equal to 1.`,{_width:e}));c=e}let l=F(t,this.locale),u=F(n,this.locale),d=this.__originCellPosition;d&&this.updateDependencies?.(d);let f=o.position.col+u,p=o.position.row+l;if(f<0||p<0)return new Fo(M(`OFFSET evaluates to an out of bounds range.`));let m={left:f,top:p,right:f+c-1,bottom:p+s-1},h=o.position.sheetId,g=this.getters.getRangeFromZone(h,m);return g.invalidXc||g.invalidSheetName?new Fo:(d&&this.addDependencies?.(d,[g]),fs(c,s,(e,t)=>this.getFormulaResult({sheetId:h,col:f+e,row:p+t})))}},t0={description:M(`Returns an element from a list of choices based on index.`),args:[V(`index (number)`,M(`Which choice to return.`)),V(`choice (any, range<any>, repeating)`,M(`A potential value to return. May be a reference to a cell or an individual value.`))],computeArray:function(e,...t){let n=Math.floor(F(e,this.locale))-1;return n<0||n>=t.length?new P(M(`Index for CHOOSE is invalid. Valid values are between 1 and %(choices)s inclusive.`,{choices:t.length})):t[n]??new P(M(`Choice is undefined.`))},isExported:!0},n0={description:M(`Excludes a specified number of rows or columns from the start or end of an array.`),args:[V(`array (range)`,M(`The array from which to drop rows or columns`)),V(`rows (number)`,M(`The number of rows to drop. A negative value drops from the end of the array.`)),V(`columns (number, optional)`,M(`The number of columns to exclude. A negative value drops from the end of the array.`))],computeArray:function(e,t,n){let r=F(t,this.locale),i=F(n,this.locale),a=e;if(Math.abs(i)>=e.length||Math.abs(r)>=e[0].length)return new P(M(`The number of rows or column to exclude must be smaller than the number of elements in the array.`));a=i>=0?a.slice(i):a.slice(0,a.length+i);for(let e=0;e<a.length;e++)r>=0?a[e]=a[e].slice(r):a[e]=a[e].slice(0,a[e].length+r);return a},isExported:!0},r0={description:M(`Returns a specified number of contiguous rows or columns from the start or end of an array.`),args:[V(`array (range)`,M(`The array from which to take rows or columns.`)),V(`rows (number)`,M(`The number of rows to take. A negative value takes from the end of the array.`)),V(`columns (number, optional)`,M(`The number of columns to take. A negative value takes from the end of the array.`))],computeArray:function(e,t,n){let r=t?F(t,this.locale):e[0].length,i=F(n,this.locale),a=e;if((Math.abs(i)>=e.length||i===0)&&(i=e.length),Math.abs(r)>=e[0].length&&(r=e[0].length),a=i>=0?a.slice(0,i):a.slice(a.length+i,a.length),r===0)return new P(M(`The number of rows can not be zero.`));for(let e=0;e<a.length;e++)r>0?a[e]=a[e].slice(0,r):a[e]=a[e].slice(a[e].length+r,a[e].length);return a},isExported:!0},i0={description:M(`Returns a formula as a string.`),args:[V(`cell_reference (any)`,M(`A reference to a cell.`))],compute:function(e){if(e?.position===void 0)return new Fo(Ko);let t=this.getters.getCell(e.position);return t?.isFormula?{value:t.compiledFormula.toFormulaString(this.getters)}:new Io(M(`The cell does not contain a formula.`))},isExported:!0};var a0=l({ADD:()=>o0,CONCAT:()=>s0,DIVIDE:()=>c0,EQ:()=>f0,GT:()=>h0,GTE:()=>g0,LT:()=>_0,LTE:()=>v0,MINUS:()=>y0,MULTIPLY:()=>b0,NE:()=>x0,POW:()=>S0,SPILLED_RANGE:()=>C0,UMINUS:()=>w0,UNARY_PERCENT:()=>T0,UPLUS:()=>E0});let o0={description:M(`Sum of two numbers.`),args:[V(`value1 (number)`,M(`The first addend.`)),V(`value2 (number)`,M(`The second addend.`))],compute:function(e,t){return{value:F(e,this.locale)+F(t,this.locale),format:e?.format||t?.format}}},s0={description:M(`Concatenation of two values.`),args:[V(`value1 (string)`,M(`The value to which value2 will be appended.`)),V(`value2 (string)`,M(`The value to append to value1.`))],compute:function(e,t){return{value:I(e)+I(t)}},isExported:!0},c0={description:M(`One number divided by another.`),args:[V(`dividend (number)`,M(`The number to be divided.`)),V(`divisor (number)`,M(`The number to divide by.`))],compute:function(e,t){let n=F(t,this.locale);return n===0?new zo(M(`The divisor must be different from zero.`)):{value:F(e,this.locale)/n,format:e?.format||t?.format}}};function l0(e){return e===void 0||e.value===null}let u0={number:0,string:``,boolean:!1};function d0(e,t,n=2e-16){return Math.abs(e-t)<n}let f0={description:M(`Equal.`),args:[V(`value1 (string, number, boolean)`,M(`The first value.`)),V(`value2 (string, number, boolean)`,M(`The value to test against value1 for equality.`))],compute:function(e,t){if(Uo(e?.value))return e;if(Uo(t?.value))return t;let n=l0(e)?u0[typeof t?.value]:e?.value,r=l0(t)?u0[typeof e?.value]:t?.value;return typeof n==`string`&&(n=n.toUpperCase()),typeof r==`string`&&(r=r.toUpperCase()),typeof n==`number`&&typeof r==`number`?{value:d0(n,r)}:{value:n===r}}};function p0(e,t,n){if(Uo(e?.value))return e;if(Uo(t?.value))return t;let r=l0(e)?u0[typeof t?.value]??``:e?.value,i=l0(t)?u0[typeof e?.value]??``:t?.value,a=m0[typeof r],o=m0[typeof i];if(a!==o)return{value:n(a,o)};switch(typeof r){case`string`:r=r.toUpperCase();break;case`boolean`:r=Number(r);break}switch(typeof i){case`string`:i=i.toUpperCase();break;case`boolean`:i=Number(i);break}return{value:n(r,i)}}let m0={number:0,string:1,boolean:2},h0={description:M(`Strictly greater than.`),args:[V(`value1 (number, string, boolean)`,M(`The value to test as being greater than value2.`)),V(`value2 (number, string, boolean)`,M(`The second value.`))],compute:function(e,t){return p0(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?!d0(e,t)&&e>t:e>t)}},g0={description:M(`Greater than or equal to.`),args:[V(`value1 (number, string, boolean)`,M(`The value to test as being greater than or equal to value2.`)),V(`value2 (number, string, boolean)`,M(`The second value.`))],compute:function(e,t){return p0(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?d0(e,t)||e>t:e>=t)}},_0={description:M(`Less than.`),args:[V(`value1 (number, string, boolean)`,M(`The value to test as being less than value2.`)),V(`value2 (number, string, boolean)`,M(`The second value.`))],compute:function(e,t){let n=g0.compute.bind(this)(e,t);return Uo(n.value)?n:{value:!n.value}}},v0={description:M(`Less than or equal to.`),args:[V(`value1 (number, string, boolean)`,M(`The value to test as being less than or equal to value2.`)),V(`value2 (number, string, boolean)`,M(`The second value.`))],compute:function(e,t){let n=h0.compute.bind(this)(e,t);return Uo(n.value)?n:{value:!n.value}}},y0={description:M(`Difference of two numbers.`),args:[V(`value1 (number)`,M(`The minuend, or number to be subtracted from.`)),V(`value2 (number)`,M(`The subtrahend, or number to subtract from value1.`))],compute:function(e,t){return{value:F(e,this.locale)-F(t,this.locale),format:e?.format||t?.format}}},b0={description:M(`Product of two numbers`),args:[V(`factor1 (number)`,M(`The first multiplicand.`)),V(`factor2 (number)`,M(`The second multiplicand.`))],compute:function(e,t){return{value:F(e,this.locale)*F(t,this.locale),format:e?.format||t?.format}}},x0={description:M(`Not equal.`),args:[V(`value1 (string, number, boolean)`,M(`The first value.`)),V(`value2 (string, number, boolean)`,M(`The value to test against value1 for inequality.`))],compute:function(e,t){let n=f0.compute.bind(this)(e,t);return Uo(n.value)?n:{value:!n.value}}},S0={description:M(`A number raised to a power.`),args:[V(`base (number)`,M(`The number to raise to the exponent power.`)),V(`exponent (number)`,M(`The exponent to raise base to.`))],compute:function(e,t){return JJ.compute.bind(this)(e,t)}},C0={description:M(`Gets the spilled range of an array formula.`),args:[V(`ref (any, range<any>)`,M(`The reference to get the spilled range from.`))],computeArray:function(e){if(e===void 0)return new Fo(Ko);let t=R(e);if(t.length!==1||t[0].length!==1)return new P(M(`Only single-cell references are allowed to get the spilled range.`));let n=t[0][0];if(Uo(n.value))return n;if(n.position===void 0)return new Fo(Ko);let r=this.__originCellPosition;r&&this.updateDependencies?.(r);let i=this.getters.getSpreadZone(n.position);if(i===void 0)return new Fo;let a=this.getters.getRangeFromZone(this.__originSheetId,i);return r&&this.addDependencies?.(r,[a]),fs(i.right-i.left+1,i.bottom-i.top+1,(e,t)=>this.getFormulaResult({sheetId:a.sheetId,col:i.left+e,row:i.top+t}))},hidden:!0},w0={description:M(`A number with the sign reversed.`),args:[V(`value (number)`,M(`The number to have its sign reversed. Equivalently, the number to multiply by -1.`))],compute:function(e){return{value:-F(e,this.locale),format:e?.format}}},T0={description:M(`Value interpreted as a percentage.`),args:[V(`percentage (number)`,M(`The value to interpret as a percentage.`))],compute:function(e){return{value:F(e,this.locale)/100}}},E0={description:M(`A specified number, unchanged.`),args:[V(`value (any)`,M(`The number to return.`))],compute:function(e={value:null}){return e}},$=e=>({transform:t=>t*e,inverseTransform:t=>t/e}),D0={transform:e=>e,inverseTransform:e=>e},O0=1e-10,k0=.0254,A0=k0/72,j0=.3048,M0=.9144,N0=1609.34,P0=1852,F0=946073047258e4,I0={g:{...D0,category:`weight`},u:{...$(166053e-29),category:`weight`},grain:{...$(.0647989),category:`weight`},ozm:{...$(28.3495),category:`weight`},lbm:{...$(453.592),category:`weight`},stone:{...$(6350.29),category:`weight`},sg:{...$(14593.90294),category:`weight`},cwt:{...$(45359.237),category:`weight`},uk_cwt:{...$(50802.3),category:`weight`},ton:{...$(907184.74),category:`weight`},uk_ton:{...$(1016046.9),category:`weight`},m:{...D0,category:`distance`},km:{...$(1e3),category:`distance`},ang:{...$(O0),category:`distance`},Picapt:{...$(A0),category:`distance`},pica:{...$(k0/6),category:`distance`},in:{...$(k0),category:`distance`},ft:{...$(j0),category:`distance`},yd:{...$(M0),category:`distance`},ell:{...$(1.143),category:`distance`},mi:{...$(N0),category:`distance`},survey_mi:{...$(1609.34),category:`distance`},Nmi:{...$(P0),category:`distance`},ly:{...$(F0),category:`distance`},parsec:{...$(0x6da012f95c9fd0),category:`distance`},sec:{...D0,category:`time`},min:{...$(60),category:`time`},hr:{...$(3600),category:`time`},day:{...$(86400),category:`time`},yr:{...$(31556952),category:`time`},Pa:{...D0,category:`pressure`},bar:{...$(1e5),category:`pressure`},mmHg:{...$(133.322),category:`pressure`},Torr:{...$(133.322),category:`pressure`},psi:{...$(6894.76),category:`pressure`},atm:{...$(101325),category:`pressure`},N:{...D0,category:`force`},dyn:{...$(1e-5),category:`force`},pond:{...$(.00980665),category:`force`},lbf:{...$(4.44822),category:`force`},J:{...D0,category:`energy`},eV:{...$(160218e-24),category:`energy`},e:{...$(1e-7),category:`energy`},flb:{...$(1.3558179483),category:`energy`},c:{...$(4.184),category:`energy`},cal:{...$(4.1868),category:`energy`},BTU:{...$(1055.06),category:`energy`},Wh:{...$(3600),category:`energy`},HPh:{...$(2684520),category:`energy`},W:{...D0,category:`power`},PS:{...$(735.499),category:`power`},HP:{...$(745.7),category:`power`},T:{...D0,category:`magnetism`},ga:{...$(1e-4),category:`magnetism`},K:{...D0,category:`temperature`},C:{transform:e=>e+273.15,inverseTransform:e=>e-273.15,category:`temperature`},F:{transform:e=>(e-32)*5/9+273.15,inverseTransform:e=>(e-273.15)*9/5+32,category:`temperature`},Rank:{...$(5/9),category:`temperature`},Reau:{transform:e=>e*1.25+273.15,inverseTransform:e=>(e-273.15)/1.25,category:`temperature`},"m^3":{...D0,category:`volume`,order:3},"ang^3":{...$(O0**3),category:`volume`,order:3},"Picapt^3":{...$(A0**3),category:`volume`,order:3},tsp:{...$(492892e-11),category:`volume`},tspm:{...$(5e-6),category:`volume`},tbs:{...$(14786764825785619e-21),category:`volume`},"in^3":{...$(k0**3),category:`volume`,order:3},oz:{...$(295735295625e-16),category:`volume`},cup:{...$(237e-6),category:`volume`},pt:{...$(.0004731765),category:`volume`},uk_pt:{...$(568261e-9),category:`volume`},qt:{...$(.0009463529),category:`volume`},l:{...$(.001),category:`volume`},uk_qt:{...$(.0011365225),category:`volume`},gal:{...$(.0037854118),category:`volume`},uk_gal:{...$(.00454609),category:`volume`},"ft^3":{...$(j0**3),category:`volume`,order:3},bushel:{...$(.0352390704),category:`volume`},barrel:{...$(.158987295),category:`volume`},"yd^3":{...$(M0**3),category:`volume`,order:3},MTON:{...$(1.13267386368),category:`volume`},GRT:{...$(2.83168),category:`volume`},"mi^3":{...$(N0**3),category:`volume`,order:3},"Nmi^3":{...$(P0**3),category:`volume`,order:3},"ly^3":{...$(F0**3),category:`volume`,order:3},"m^2":{...D0,category:`area`,order:2},"ang^2":{...$(O0**2),category:`area`,order:2},"Picapt^2":{...$(A0**2),category:`area`,order:2},"in^2":{...$(k0**2),category:`area`,order:2},"ft^2":{...$(j0**2),category:`area`,order:2},"yd^2":{...$(M0**2),category:`area`,order:2},ar:{...$(100),category:`area`},Morgen:{...$(2500),category:`area`},uk_acre:{...$(4046.8564224),category:`area`},us_acre:{...$(4046.8726098743),category:`area`},ha:{...$(1e4),category:`area`},"mi^2":{...$(N0**2),category:`area`,order:2},"Nmi^2":{...$(P0**2),category:`area`,order:2},"ly^2":{...$(F0**2),category:`area`,order:2},bit:{...D0,category:`information`},byte:{...$(8),category:`information`},"m/s":{...D0,category:`speed`},"m/hr":{...$(1/3600),category:`speed`},"km/hr":{...$(1/3.6),category:`speed`},mph:{...$(.44704),category:`speed`},kn:{...$(.5144444444),category:`speed`},admkn:{...$(.5147733333),category:`speed`}},L0={shweight:`cwt`,lcwt:`uk_cwt`,hweight:`uk_cwt`,LTON:`uk_ton`,brton:`uk_ton`,pc:`parsec`,Pica:`Picapt`,d:`day`,mn:`min`,s:`sec`,p:`Pa`,at:`atm`,dy:`dyn`,ev:`eV`,hh:`HPh`,wh:`Wh`,btu:`BTU`,h:`HP`,cel:`C`,fah:`F`,kel:`K`,us_pt:`pt`,L:`l`,lt:`l`,ang3:`ang^3`,ft3:`ft^3`,in3:`in^3`,ly3:`ly^3`,m3:`m^3`,mi3:`mi^3`,yd3:`yd^3`,Nmi3:`Nmi^3`,Picapt3:`Picapt^3`,"Pica^3":`Picapt^3`,Pica3:`Picapt^3`,regton:`GRT`,ang2:`ang^2`,ft2:`ft^2`,in2:`in^2`,ly2:`ly^2`,m2:`m^2`,mi2:`mi^2`,Nmi2:`Nmi^2`,Picapt2:`Picapt^2`,"Pica^2":`Picapt^2`,Pica2:`Picapt^2`,yd2:`yd^2`,"m/h":`m/hr`,"m/sec":`m/s`},R0={"":1,Y:1e24,Z:1e21,E:0xde0b6b3a7640000,P:0x38d7ea4c68000,T:0xe8d4a51000,G:1e9,M:1e6,k:1e3,h:100,da:10,e:10,d:.1,c:.01,m:.001,u:1e-6,n:1e-9,p:1e-12,f:1e-15,a:1e-18,z:1e-21,y:1e-21,Yi:2**80,Zi:2**70,Ei:2**60,Pi:2**50,Ti:2**40,Gi:2**30,Mi:2**20,ki:2**10},z0={weight:M(`Weight`),distance:M(`Distance`),time:M(`Time`),pressure:M(`Pressure`),force:M(`Force`),energy:M(`Energy`),power:M(`Power`),magnetism:M(`Magnetism`),temperature:M(`Temperature`),volume:M(`Volume`),area:M(`Area`),information:M(`Information`),speed:M(`Speed`)},B0=Object.entries(I0).map(([e,t])=>({value:e,label:V0(t.category)}));function V0(e){return z0[e]??``}function H0(e){for(let[t,n]of Object.entries(R0)){if(t&&!e.startsWith(t))continue;let r=e.slice(t.length),i=I0[r];if(!i&&L0[r]&&(i=I0[L0[r]]),i)return{...i,factor:i.order?n**+i.order:n}}}var U0=l({CONVERT:()=>W0});let W0={description:M(`Converts a numeric value to a different unit of measure.`),args:[V(`value (number)`,M(`the numeric value in start_unit to convert to end_unit`)),V(`start_unit (string)`,M(`The starting unit, the unit currently assigned to value`),B0),V(`end_unit (string)`,M(`The unit of measure into which to convert value`),B0)],compute:function(e,t,n){let r=F(e,this.locale),i=I(t),a=I(n),o=H0(i),s=H0(a);return o?s?o.category===s.category?{value:s.inverseTransform(o.factor*o.transform(r))/s.factor,format:e?.format}:{value:N.GenericError,message:M(`Incompatible units of measure ('%s' vs '%s')`,V0(o.category),V0(s.category))}:{value:N.GenericError,message:M(`Invalid units of measure ('%s')`,a)}:{value:N.GenericError,message:M(`Invalid units of measure ('%s')`,i)}},isExported:!0};var G0=l({CHAR:()=>Y0,CLEAN:()=>X0,CONCATENATE:()=>Z0,EXACT:()=>Q0,FIND:()=>$0,FORMAT_LARGE_NUMBER:()=>e2,JOIN:()=>t2,LEFT:()=>n2,LEN:()=>r2,LOWER:()=>i2,MID:()=>a2,PROPER:()=>o2,REGEXEXTRACT:()=>c2,REGEXREPLACE:()=>l2,REGEXTEST:()=>s2,REPLACE:()=>u2,RIGHT:()=>d2,SEARCH:()=>f2,SPLIT:()=>p2,SUBSTITUTE:()=>m2,TEXT:()=>y2,TEXTAFTER:()=>x2,TEXTBEFORE:()=>S2,TEXTJOIN:()=>h2,TEXTSPLIT:()=>g2,TRIM:()=>_2,UPPER:()=>v2,VALUE:()=>b2});let K0=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,q0=[{value:0,label:M(`Case-sensitive (default)`)},{value:1,label:M(`Case-insensitive`)}],J0=[{value:0,label:M(`Don't match to end (default)`)},{value:1,label:M(`Match to end`)}],Y0={description:M(`Gets character associated with number.`),args:[V(`table_number (number)`,M(`The number of the character to look up from the current Unicode table in decimal format.`))],compute:function(e){let t=Math.trunc(F(e,this.locale));return t<1?new P(M(`The table_number (%s) is out of range.`,t)):{value:String.fromCharCode(t)}},isExported:!0},X0={description:M(`Remove non-printable characters from a piece of text.`),args:[V(`text (string)`,M(`The text whose non-printable characters are to be removed.`))],compute:function(e){let t=I(e),n=``;for(let e of t)e&&e.charCodeAt(0)>31&&(n+=e);return{value:n}},isExported:!0},Z0={description:M(`Appends strings to one another.`),args:[V(`string (string, range<string>, repeating)`,M(`String to append in sequence.`))],compute:function(...e){return{value:ls(e,(e,t)=>e+I(t),``)}},isExported:!0},Q0={description:M(`Tests whether two strings are identical.`),args:[V(`string1 (string)`,M(`The first string to compare.`)),V(`string2 (string)`,M(`The second string to compare.`))],compute:function(e,t){return{value:I(e)===I(t)}},isExported:!0},$0={description:M(`First position of string found in text, case-sensitive.`),args:[V(`search_for (string)`,M(`The string to look for within text_to_search.`)),V(`text_to_search (string)`,M(`The text to search for the first occurrence of search_for.`)),V(`starting_at (number, default=1)`,M(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=I(e),i=I(t),a=F(n,this.locale);if(i===``)return new P(M(`The text_to_search must be non-empty.`));if(a<1)return new P(M(`The starting_at (%s) must be greater than or equal to 1.`,a));let o=i.indexOf(r,a-1);return o===-1?new P(M(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)):{value:o+1}},isExported:!0},e2={description:M(`Apply a large number format`),args:[V(`value (number)`,M(`The number.`)),V(`unit (string, optional)`,M(`The formatting unit. Use 'k', 'm', or 'b' to force the unit`),[{value:`k`,label:M(`Thousand`)},{value:`m`,label:M(`Million`)},{value:`b`,label:M(`Billion`)}])],compute:function(e,t){return{value:F(e,this.locale),format:Ic(e,t,this.locale)}}},t2={description:M(`Concatenates elements of arrays with delimiter.`),args:[V(`delimiter (string)`,M(`The character or string to place between each concatenated value.`)),V(`value_or_array (string, range<string>, repeating)`,M(`Value to be appended using delimiter.`))],compute:function(e,...t){let n=I(e);return{value:ls(t,(e,t)=>(e?e+n:``)+I(t),``)}}},n2={description:M(`Substring from beginning of specified string.`),args:[V(`text (string)`,M(`The string from which the left portion will be returned.`)),V(`number_of_characters (number, optional)`,M(`The number of characters to return from the left side of string.`))],compute:function(e,...t){let n=t.length?F(t[0],this.locale):1;return n<0?new P(M(`The number_of_characters (%s) must be positive or null.`,n)):{value:I(e).substring(0,n)}},isExported:!0},r2={description:M(`Length of a string.`),args:[V(`text (string)`,M(`The string whose length will be returned.`))],compute:function(e){return{value:I(e).length}},isExported:!0},i2={description:M(`Converts a specified string to lowercase.`),args:[V(`text (string)`,M(`The string to convert to lowercase.`))],compute:function(e){return{value:I(e).toLowerCase()}},isExported:!0},a2={description:M(`A segment of a string.`),args:[V(`text (string)`,M(`The string to extract a segment from.`)),V(`starting_at (number)`,M(`The index from the left of string from which to begin extracting. The first character in string has the index 1.`)),V(`extract_length (number)`,M(`The length of the segment to extract.`))],compute:function(e,t,n){let r=I(e),i=F(t,this.locale),a=F(n,this.locale);return i<1?new P(M(`The starting_at argument (%s) must be positive greater than one.`,i.toString())):a<0?new P(M(`The extract_length argument (%s) must be positive or null.`,a)):{value:r.slice(i-1,i+a-1)}},isExported:!0},o2={description:M(`Capitalizes each word in a specified string.`),args:[V(`text_to_capitalize (string)`,M(`The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase.`))],compute:function(e){return{value:I(e).replace(K0,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())}},isExported:!0},s2={description:M(`Checks whether a string matches the supplied regular expression.`),args:[V(`text (string)`,M(`The string to test.`)),V(`pattern (string)`,M(`The regular expression pattern to match against the text.`)),V(`case_sensitivity (number, default=0)`,M(`Whether the match is case-sensitive.`),[{value:0,label:M(`Case-sensitive`)},{value:1,label:M(`Case-insensitive`)}])],compute:function(e,t,n={value:0}){let r=I(e),i=I(t),a=F(n,this.locale);if(i===``)return{value:!0};if(r===``)return{value:!1};if(a!==0&&a!==1)return new P(M(`The case_sensitivity (%s) must be 0 or 1.`,a));let o=a===1?`gi`:`g`,s;try{s=new RegExp(i,o)}catch{return new P(M(`Invalid regular expression`))}return{value:s.test(r)}},isExported:!0},c2={description:M(`Extract text from a string based on the supplied regular expression.`),args:[V(`text (string)`,M(`The string on which you want to extract text.`)),V(`pattern (string)`,M(`The regular expression pattern to match against the text.`)),V(`return_mode (number, default=0)`,M(`0 = first match, 1 = all matches as an array, 2 = capturing groups from the first match as an array.`),[{value:0,label:M(`First match`)},{value:1,label:M(`All matches`)},{value:2,label:M(`Capture groups of first match`)}]),V(`case_sensitivity (number, default=0)`,M(`Whether the match is case-sensitive.`),[{value:0,label:M(`Case-sensitive`)},{value:1,label:M(`Case-insensitive`)}])],computeArray:function(e,t,n={value:0},r={value:0}){let i=I(e),a=I(t),o=F(n,this.locale),s=F(r,this.locale);if(i===``||a===``)return{value:``};if(o<0||o>2)return new P(M(`The return_mode (%s) must be 0, 1 or 2.`,o));if(s!==0&&s!==1)return new P(M(`The case_sensitivity (%s) must be 0 or 1.`,s));let c=s===1?`gi`:`g`,l;try{l=new RegExp(a,c)}catch{return new P(M(`Invalid regular expression`))}let u=[...i.matchAll(l)];return u.length===0?{value:N.NotAvailable,message:M(`No matches found.`)}:o===0?{value:u[0][0]}:o===1?u.map(e=>[{value:e[0]}]):u[0].length<2?new P(M(`No capturing groups found.`)):u[0].slice(1).map(e=>[{value:e}])},isExported:!0},l2={description:M(`Replace text in a string based on the supplied regular expression.`),args:[V(`text (string)`,M(`The string in which you want to replace text.`)),V(`pattern (string)`,M(`The regular expression pattern to match against the text.`)),V(`replacement (string)`,M(`The text to use as the replacement.`)),V(`occurrence (number, default=0)`,M(`0 = replace all matches. A negative number counts from the end.`)),V(`case_sensitivity (number, default=0)`,M(`Whether the match is case-sensitive.`),[{value:0,label:M(`Case-sensitive`)},{value:1,label:M(`Case-insensitive`)}])],compute:function(e,t,n,r={value:0},i={value:0}){let a=I(e),o=I(t),s=I(n),c=F(r,this.locale),l=F(i,this.locale);if(l!==0&&l!==1)return new P(M(`The case_sensitivity (%s) must be 0 or 1.`,l));let u=l===1?`gi`:`g`,d;try{d=new RegExp(o,u)}catch{return new P(M(`Invalid regular expression`))}if(c!==0){let e=[...a.matchAll(d)];if(e.length===0||Math.abs(c)>e.length)return{value:a};let t=c>0?c-1:e.length+c,n=e[t][0].length,r=e[t].index;return{value:a.substring(0,r)+s+a.substring(r+n)}}return{value:a.replace(d,s)}},isExported:!0},u2={description:M(`Replaces part of a text string with different text.`),args:[V(`text (string)`,M(`The text, a part of which will be replaced.`)),V(`position (number)`,M(`The position where the replacement will begin (starting from 1).`)),V(`length (number)`,M(`The number of characters in the text to be replaced.`)),V(`new_text (string)`,M(`The text which will be inserted into the original text.`))],compute:function(e,t,n,r){let i=F(t,this.locale);if(i<1)return new P(M(`The position (%s) must be greater than or equal to 1.`,i));let a=F(n,this.locale);if(a<0)return new P(M(`The length (%s) must be positive or zero.`,a));let o=I(e),s=I(r);return{value:o.substring(0,i-1)+s+o.substring(i-1+a)}},isExported:!0},d2={description:M(`A substring from the end of a specified string.`),args:[V(`text (string)`,M(`The string from which the right portion will be returned.`)),V(`number_of_characters (number, optional)`,M(`The number of characters to return from the right side of string.`))],compute:function(e,...t){let n=t.length?F(t[0],this.locale):1;if(n<0)return new P(M(`The number_of_characters (%s) must be positive or zero.`,n));let r=I(e),i=r.length;return{value:r.substring(i-n,i)}},isExported:!0},f2={description:M(`First position of string found in text, ignoring case.`),args:[V(`search_for (string)`,M(`The string to look for within text_to_search.`)),V(`text_to_search (string)`,M(`The text to search for the first occurrence of search_for.`)),V(`starting_at (number, default=1)`,M(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=I(e).toLowerCase(),i=I(t).toLowerCase(),a=F(n,this.locale);if(i===``)return{value:N.GenericError,message:M(`The text_to_search must be non-empty.`)};if(a<1)return{value:N.GenericError,message:M(`The starting_at (%s) must be greater than or equal to 1.`,a)};let o=i.indexOf(r,a-1);return o===-1?{value:N.GenericError,message:M(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)}:{value:o+1}},isExported:!0},p2={description:M(`Split text by specific character delimiter(s).`),args:[V(`text (string)`,M(`The text to divide.`)),V(`delimiter (string)`,M(`The character or characters to use to split text.`)),V(`split_by_each (boolean, default=true})`,M(`Whether or not to divide text around each character contained in delimiter.`)),V(`remove_empty_text (boolean, default=true)`,M(`Whether or not to remove empty text messages from the split results. The default behavior is to treat consecutive delimiters as one (if TRUE). If FALSE, empty cells values are added between consecutive delimiters.`))],computeArray:function(e,t,n={value:!0},r={value:!0}){let i=I(e),a=Tt(I(t)),o=L(n),s=L(r);if(a.length<=0)return new P(M(`The delimiter (%s) must be not be empty.`,a));let c=o?RegExp(`[${a}]`,`g`):new RegExp(a,`g`),l=i.split(c);return s&&(l=l.filter(e=>e!==``)),ps(hs([l]),e=>({value:e}))},isExported:!1},m2={description:M(`Replaces existing text with new text in a string.`),args:[V(`text_to_search (string)`,M(`The text within which to search and replace.`)),V(`search_for (string)`,M(`The string to search for within text_to_search.`)),V(`replace_with (string)`,M(`The string that will replace search_for.`)),V(`occurrence_number (number, optional)`,M(`The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced.`))],compute:function(e,t,n,r){let i=F(r,this.locale);if(i<0)return new P(M(`The occurrenceNumber (%s) must be positive or null.`,i));let a=I(e),o=I(t);if(o===``)return{value:a};let s=I(n),c=new RegExp(Tt(o),`g`);if(i===0)return{value:a.replace(c,s)};let l=0;return{value:a.replace(c,e=>++l===i?s:e)}},isExported:!0},h2={description:M(`Combines text from multiple strings and/or arrays.`),args:[V(`delimiter (string)`,M(`A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.`)),V(`ignore_empty (boolean)`,M(`A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.`),[{value:!0,label:M(`Ignore empty cells`)},{value:!1,label:M(`Include empty cells (default)`)}]),V(`texts (string, range<string>, repeating)`,M(`Text item to join.`))],compute:function(e,t={value:!0},...n){let r=I(e),i=L(t),a=0;return{value:ls(n,(e,t)=>i&&I(t)===``?e:(a++?e+r:``)+I(t),``)}},isExported:!0},g2={description:M(`Splits text into rows or columns using specified column and row delimiters.`),args:[V(`text (string)`,M(`The text to split.`)),V(`col_delimiter (string, range<string>)`,M(`Character or string to split columns by.`)),V(`row_delimiter (string, range<string>, optional)`,M(`Character or string to split rows by.`)),V(`ignore_empty (boolean, default=false)`,M(`Whether to ignore empty cells.`),[{value:!1,label:M(`Include empty cells (default)`)},{value:!0,label:M(`Ignore empty cells`)}]),V(`match_mode (number, default=0)`,M(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),q0),V(`pad_with (string, default="${N.NotAvailable}")`,M(`The value to use for padding empty cells.`))],computeArray:function(e,t,n,r={value:!1},i={value:0},a=new Io){let o=I(e);if(o.length<=0)return new P(M(`No text to split.`));if(t===void 0&&n===void 0)return new P(M(`At least one delimiter must be provided.`));let s=R(t).flat().map(e=>Tt(I(e))),c=R(n).flat().map(e=>Tt(I(e)));if(s.some(e=>e===``)||c.some(e=>e===``))return new P(M(`The delimiters cannot be empty values.`));let l=L(r),u=F(i,this.locale);if(![0,1].includes(u))return new P(M(`match_mode should be a value of 0 or 1.`));let d=[],f=u===1?`gi`:`g`,p=c.filter(e=>!s.includes(e)),m=p.length?o.split(new RegExp(p.join(`|`),f)):[o];l&&(m=m.filter(e=>e!==``));let h=new RegExp(s.join(`|`),f);for(let e of m){let t=s.length?e.split(h):[e];l&&(t=t.filter(e=>e!==``)),d.push(t.map(e=>({value:e})))}let g=Math.max(...d.map(e=>e.length));for(let e of d)for(;e.length<g;)e.push(a);return hs(d)},isExported:!0},_2={description:M(`Removes space characters.`),args:[V(`text (string)`,M(`The text or reference to a cell containing text to be trimmed.`))],compute:function(e){return{value:pn(I(e))}},isExported:!0},v2={description:M(`Converts a specified string to uppercase.`),args:[V(`text (string)`,M(`The string to convert to uppercase.`))],compute:function(e){return{value:I(e).toUpperCase()}},isExported:!0},y2={description:M(`Converts a number to text according to a specified format.`),args:[V(`number (number)`,M(`The number, date or time to format.`)),V(`format (string)`,M(`The case-sensitive format of the result, enclosed in quotation marks. Examples: "0.00" rounded to 2 decimal places, "hh:mm:ss" for hour:minutes:seconds.`))],compute:function(e,t){return{value:B(F(e,this.locale),{format:I(t),locale:this.locale})}},isExported:!0},b2={description:M(`Converts a string to a numeric value.`),args:[V(`value (number)`,M(`the string to be converted`))],compute:function(e){return{value:F(e,this.locale)}},isExported:!0},x2={description:M(`Returns text that occurs after a given substring or delimiter.`),args:[V(`text (string)`,M(`The source text.`)),V(`delimiter (string)`,M(`The substring after which text will be returned.`)),V(`instance_num (number, default=1)`,M(`The desired instance of the delimiter after which we extract the text. A negative number searches from the end.`)),V(`match_mode (number, default=0)`,M(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),q0),V(`match_end (number, default=0))`,M(`Whether to treat the end of text as a delimiter.`),J0),V(`if_not_found (string, default="${N.NotAvailable}")`,M(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new Io){let o=I(e),s=F(n,this.locale),c=F(r,this.locale),l=F(i,this.locale);if(s===0)return new P(M(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new P(M(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new P(M(`match_end should have a value of 0 or 1.`));let u=I(t);if(u===``)return Math.sign(s)>0?{value:o}:{value:``};let d=c===1?`gi`:`g`,f=Tt(u),p=new RegExp(f,d),m=[...o.matchAll(p)].map(e=>e.index+u.length);if(s<0&&(m=m.reverse()),l&&Math.abs(s)===m.length+1)return Math.sign(s)>0?{value:``}:{value:o};let h=m[Math.abs(s)-1];return h===void 0?a:{value:o.substring(h)}},isExported:!0},S2={description:M(`Returns text that occurs before a given substring or delimiter.`),args:[V(`text (string)`,M(`The source text.`)),V(`delimiter (string)`,M(`The substring after which text will be returned.`)),V(`instance_num (number, default=1)`,M(`The desired instance of the delimiter before which we extract the text. A negative number searches from the end.`)),V(`match_mode (number, default=0)`,M(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),q0),V(`match_end (number, default=0))`,M(`Whether to match a delimiter against the end of the text.`),J0),V(`if_not_found (string, default="${N.NotAvailable}")`,M(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new Io){let o=I(e),s=F(n,this.locale),c=F(r,this.locale),l=F(i,this.locale);if(s===0)return new P(M(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new P(M(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new P(M(`match_end should have a value of 0 or 1.`));let u=I(t);if(u===``)return Math.sign(s)>0?{value:``}:{value:o};let d=c===1?`gi`:`g`,f=Tt(u),p=new RegExp(f,d),m=[...o.matchAll(p)].map(e=>e.index+u.length);if(s<0&&(m=m.reverse()),l&&Math.abs(s)===m.length+1)return Math.sign(s)>0?{value:o}:{value:``};let h=m[Math.abs(s)-1];return h===void 0?a:{value:o.substring(0,h-u.length)}},isExported:!0};var C2=l({HYPERLINK:()=>w2});let w2={description:M(`Creates a hyperlink in a cell.`),args:[V(`url (string)`,M(`The full URL of the link enclosed in quotation marks.`)),V(`link_label (string, optional)`,M(`The text to display in the cell, enclosed in quotation marks.`))],compute:function(e,t){let n=I(e).trim(),r=I(t)||n;return n===``?{value:r}:{value:Rt(r,n)}},isExported:!0},T2=[{name:M(`Array`),functions:Oq},{name:M(`Database`),functions:GX},{name:M(`Date`),functions:sQ},{name:M(`Filter`),functions:GQ},{name:M(`Financial`),functions:ZQ},{name:M(`Info`),functions:o1},{name:M(`Lookup`),functions:F1},{name:M(`Logical`),functions:y1},{name:M(`Math`),functions:iJ},{name:M(`Operator`),functions:a0},{name:M(`Statistical`),functions:bY},{name:M(`Text`),functions:G0},{name:M(`Engineering`),functions:UQ},{name:M(`Web`),functions:C2},{name:M(`Parser`),functions:U0}];for(let e of T2){let t=e.functions;for(let n in t){let r=t[n];r.category=r.category||e.name,n=n.replace(/_/g,`.`),ml.add(n,{isExported:!1,...r})}}let E2={},D2={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:26,HEADER_WIDTH:48,DESKTOP_BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:96,DEFAULT_CELL_HEIGHT:23,SCROLLBAR_WIDTH:15},O2={autoCompleteProviders:wM,autofillModifiersRegistry:ER,autofillRulesRegistry:DR,cellMenuRegistry:KL,colMenuRegistry:fR,errorTypes:Mo,functionRegistry:ml,featurePluginRegistry:BH,iconsOnCellRegistry:KB,statefulUIPluginRegistry:VH,coreViewsPluginRegistry:HH,corePluginRegistry:zH,rowMenuRegistry:yR,sidePanelRegistry:zI,figureRegistry:HS,chartSidePanelComponentRegistry:XM,chartDataSourceSidePanelComponentRegistry:ak,chartComponentRegistry:A_,chartTypeRegistry:Iw,chartSubtypeRegistry:Dg,chartDataSourceRegistry:Fw,topbarMenuRegistry:dU,topbarComponentRegistry:AU,topBarToolBarRegistry:NW,clickableCellRegistry:Sx,otRegistry:gV,inverseCommandRegistry:UH,urlRegistry:Zd,cellPopoverRegistry:Kx,numberFormatMenuRegistry:sU,repeatLocalCommandTransformRegistry:uH,repeatCommandTransformRegistry:lH,clipboardHandlersRegistries:Vx,pivotRegistry:Zb,pivotTimeAdapterRegistry:ay,pivotSidePanelRegistry:BF,pivotNormalizationValueRegistry:Ly,supportedPivotPositionalFormulaRegistry:Wz,pivotToFunctionValueRegistry:Ry,migrationStepRegistry:vE,chartJsExtensionRegistry:Qr,onIterationEndEvaluationRegistry:IB,specificRangeTransformRegistry:_V,unusedDataSourceRegistry:MN},k2={arg:V,isEvaluationError:Uo,toBoolean:L,toJsDate:rs,toNumber:F,toString:I,toNormalizedPivotValue:Ny,toFunctionPivotValue:Fy,toXC:T,toZone:Xn,toUnboundedZone:Yn,toCartesian:Rn,numberToLetters:kn,lettersToNumber:An,UuidGenerator:K,formatValue:B,createCurrencyFormat:kc,ColorGenerator:fp,computeTextWidth:Ep,createEmptyWorkbookData:RE,createEmptySheet:LE,createEmptyExcelSheet:zE,doesCellContainFunction:wn,rgbaToHex:Rf,colorToRGBA:zf,positionToZone:E,isDefined:C,isMatrix:yt,lazy:Yt,genericRepeat:kU,createAction:we,createActions:be,transformRangeData:Br,deepEquals:w,overlap:ur,union:or,isInside:fr,deepCopy:b,expandZoneOnInsertion:nr,reduceZoneOnDeletion:ar,unquote:Ot,getMaxObjectId:Ty,getFirstPivotFunction:AF,getNumberOfPivotFunctions:MF,parseDimension:Oy,isDateOrDatetimeField:ky,makeFieldProposal:NF,periodYearToComparable:iy,insertTokenAfterArgSeparator:FF,insertTokenAfterLeftParenthesis:IF,mergeContiguousZones:Ir,getPivotHighlights:oF,pivotTimeAdapter:oy,UNDO_REDO_PIVOT_COMMANDS:lV,createPivotFormula:My,areDomainArgsFieldsValid:jy,splitReference:Dl,sanitizeSheetName:At,getUniqueText:xn,isNumber:bo,isDateTime:Va,createCustomFields:Wy,schemeToColorScale:hE,isDateTimeFormat:Sc,jsDateToNumber:to,numberToJsDate:$a,DateTime:Da,parseFormat:Ks,isFormula:Sn,domainToColRowDomain:tv,collapseHierarchicalDisplayName:Xy,getCanonicalSymbolName:kt,fuzzyLookup:CM,PositionMap:J_,replaceSymbolInFormula:od,isSingleCellReference:El,computeCachedTextDimension:Ap,createComputeFunction:ol,isMobileOS:_e,drawHighlight:Hx},A2={isMarkdownLink:It,parseMarkdownLink:zt,markdownLink:Rt,openLink:nf,urlRepresentation:tf},j2={Checkbox:ok,Section:Q,Select:IS,RoundColorPicker:Ck,ChartDataSeries:ck,ChartErrorSection:dk,ChartLabelRange:lk,ChartRangeDataSourceComponent:Ij,ChartTitle:bk,ChartPanel:$M,ChartFigure:BS,ChartJsComponent:ng,ClickableCellSortIcon:X_,ZoomableChartJsComponent:S_,Grid:Uz,GridOverlay:Xx,ScorecardChart:Eg,GaugeChartComponent:O_,LineConfigPanel:FM,BarConfigPanel:pk,PieChartDesignPanel:RM,GenericChartConfigPanel:fk,ChartWithAxisDesignPanel:Ak,GenericZoomableChartDesignPanel:jk,LineChartDesignPanel:IM,GaugeChartConfigPanel:$j,GaugeChartDesignPanel:AM,ScorecardChartConfigPanel:VM,ScorecardChartDesignPanel:HM,GeoChartDesignPanel:NM,RadarChartDesignPanel:zM,WaterfallChartDesignPanel:YM,ComboChartDesignPanel:Xj,FunnelChartDesignPanel:Qj,SunburstChartDesignPanel:UM,TreeMapChartDesignPanel:JM,ChartTypePicker:ZM,FigureComponent:US,MenuPopover:q_,Popover:U_,SelectionInput:WO,StandaloneComposer:kM,ValidationMessages:Ox,AddDimensionButton:bF,PivotDimensionGranularity:SF,PivotDimensionOrder:CF,PivotDimension:_F,PivotLayoutConfigurator:DF,PivotHTMLRenderer:Kz,PivotDeferUpdate:cF,PivotTitleSection:OF,CogWheelMenu:rk,TextInput:JO,SidePanelCollapsible:hk,RadioSelection:Sk,GeoChartRegionSelectSection:jM,ChartMenu:RS,FullScreenFigure:Gz,NumberInput:_k,TopBar:PW,Composer:uM,CalendarButton:lN,Spreadsheet:LW},M2={useDragAndDropListItems:MO,useHighlights:nN,useHighlightsOnHover:tN},N2={Component:O,useExternalListener:Wi,EnvPlugin:Ki,App:Zi},P2={useStoreProvider:ta,DependencyContainer:$i,CellPopoverStore:qx,ComposerFocusStore:Zr,CellComposerStore:fz,FindAndReplaceStore:BN,HighlightStore:Ux,DelayedHoveredCellStore:Dx,HoveredTableStore:Y_,ModelStore:Wr,NotificationStore:TM,RendererStore:Jr,SelectionInputStore:UO,SpreadsheetStore:Yr,useStore:k,useLocalStore:ra,SidePanelStore:VI,PivotSidePanelStore:RF,PivotMeasureDisplayPanelStore:iF,TableAutofillStore:BR,AutofillStore:zR,ClientFocusStore:CR,GridRenderer:OS,ViewportsStore:H,globalStores:PU};function F2(e,t){return ml.add(e,t),{addFunction:(e,t)=>F2(e,t)}}let I2={DEFAULT_LOCALE:z,HIGHLIGHT_COLOR:Ae,PIVOT_STATIC_TABLE_CONFIG:dt,PIVOT_INSERT_TABLE_STYLE_ID:ft,ChartTerms:tb,FIGURE_ID_SPLITTER:`??`,GRID_ICON_EDGE_LENGTH:17,GRID_ICON_MARGIN:2,CHART_TYPES:mE,DARK_MODE_FILTER_STRING:Xf},L2={...Fj,...qz};e.AbstractCellClipboardHandler=TI,e.AbstractChart=rg,e.AbstractFigureClipboardHandler=KK,e.BadExpressionError=No,e.CHART_TYPES=mE,e.CellErrorType=N,e.CellValueType=kd,e.CircularDependencyError=Po,e.ClientDisconnectedError=QV,e.ClipboardMIMEType=Ax,e.CommandResult=Yd,e.CompiledFormula=Sd,e.CorePlugin=KS,e.CoreViewPlugin=CS,e.DEFAULT_LOCALE=z,e.DEFAULT_LOCALES=js,e.DEFAULT_LOCALE_DIGIT_GROUPING=`[3,0]`,e.DIRECTION=xt,e.DispatchResult=qd,e.DivisionByZeroError=zo,e.EvaluationError=P,e.InvalidReferenceError=Fo,e.LocalTransportService=jU,e.Model=UK,e.NEXT_VALUE=Q_,e.NotAvailableError=Io,e.NumberTooLargeError=Bo,e.OrderedLayers=Kr,e.PREVIOUS_VALUE=Z_,e.PivotRuntimeDefinition=Qy,e.Registry=D,e.Revision=ZV,e.SPREADSHEET_DIMENSIONS=D2,e.SplillBlockedError=Ro,e.Spreadsheet=LW,e.SpreadsheetPivotTable=Fb,e.UIPlugin=eH,e.UnknownFunctionError=Lo,e.__info__=E2,e.addFunction=F2,e.addRenderingLayer=qr,e.astToFormula=cz,e.availableConditionalFormatOperators=SN,e.availableDataValidationOperators=LN,e.availableFiltersOperators=lF,e.borderPositions=bt,e.borderStyles=vt,e.canExecuteInReadonly=Kd,e.categories=T2,e.chartHelpers=L2,e.compatibility=N2,e.components=j2,e.composerFocusTypes=St,e.constants=I2,e.convertAstNodes=Su,e.coreTypes=Wd,e.createAutocompleteArgumentsProvider=uq,e.errorTypes=Mo,e.filterDateCriterionOperators=fF,e.filterNumberCriterionOperators=dF,e.filterTextCriterionOperators=uF,e.findCellInNewZone=Cr,e.functionCache=yd,e.getCaretDownSvg=uS,e.getCaretUpSvg=dS,e.helpers=k2,e.hooks=M2,e.invalidSubtotalFormulasCommands=Vd,e.invalidateBordersCommands=Bd,e.invalidateCFEvaluationCommands=zd,e.invalidateChartEvaluationCommands=Ld,e.invalidateDependenciesCommands=Rd,e.invalidateEvaluationCommands=Id,e.isCoreCommand=Gd,e.isHeadersDependant=jd,e.isMatrix=yt,e.isPositionDependent=Pd,e.isRangeDependant=Nd,e.isSheetDependent=Ad,e.isTargetDependent=Md,e.isZoneDependent=Fd,e.iterateAstNodes=Cu,e.links=A2,e.load=CE,e.lockedSheetAllowedCommands=Ud,e.parse=bu,e.parseTokens=xu,e.readonlyAllowedCommands=Hd,e.registries=O2,e.schemeToColorScale=hE,e.setDefaultSheetViewSize=lt,e.setTranslationMethod=ko,e.stores=P2,e.tokenColors=_t,e.tokenize=zl,E2.version=`19.5.0-alpha.9`,E2.date=`2026-08-06T13:08:57.653Z`,E2.hash=`64623a8`})(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|