@odoo/o-spreadsheet 18.2.34 → 18.2.35
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.
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
z-index: ${Fe.FigureTooltip};
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
`,hh.add("chartShowValuesPlugin",{register:e=>e.register(kh),unregister:e=>e.unregister(kh)}),hh.add("waterfallLinesPlugin",{register:e=>e.register(Lh),unregister:e=>e.unregister(Lh)});class Bh extends t.Component{static template="o-spreadsheet-ChartJsComponent";static props={figure:Object};canvas=t.useRef("graphContainer");chart;currentRuntime;currentDevicePixelRatio=window.devicePixelRatio;get background(){return this.chartRuntime.background}get canvasStyle(){return`background-color: ${this.background}`}get chartRuntime(){const e=this.env.model.getters.getChartRuntime(this.props.figure.id);if(!("chartJsConfig"in e))throw new Error("Unsupported chart runtime");return e}setup(){t.onMounted((()=>{dh();const e=this.chartRuntime;this.currentRuntime=e,this.createChart(ze(e.chartJsConfig))})),t.onWillUnmount((()=>this.chart?.destroy())),t.useEffect((()=>{const e=this.chartRuntime;e!==this.currentRuntime?(e.chartJsConfig.type!==this.currentRuntime.chartJsConfig.type?(this.chart?.destroy(),this.createChart(ze(e.chartJsConfig))):this.updateChartJs(ze(e.chartJsConfig)),this.currentRuntime=e):this.currentDevicePixelRatio!==window.devicePixelRatio&&(this.currentDevicePixelRatio=window.devicePixelRatio,this.updateChartJs(ze(this.currentRuntime.chartJsConfig)))}))}createChart(e){const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e)}updateChartJs(e){e.data&&e.data.datasets?(this.chart.data=e.data,e.options?.plugins?.title&&(this.chart.config.options.plugins.title=e.options.plugins.title)):this.chart.data.datasets=[],this.chart.config.options=e.options,this.chart.update()}}class zh{sheetId;title;getters;constructor(e,t,o){this.title=e.title,this.sheetId=t,this.getters=o}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function $h(e,t,o,s,i){if("text"===t||"progress"===t||e?.type!==ii.number||o?.type!==ii.number)return;const n=o.value-e.value;return n>0?s:n<0?i:void 0}function Gh(e,t,o){if("text"===o||e?.type!==ii.number||t?.type!==ii.number)return"neutral";const s=t.value-e.value;return s>0?"up":s<0?"down":"neutral"}function Wh(e){return e.keyValue&&!$r.test(e.keyValue)?"InvalidScorecardKeyValue":"Success"}function qh(e){return e.baseline&&!$r.test(e.baseline)?"InvalidScorecardBaseline":"Success"}const Zh=new window.Path2D("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"),jh=new window.Path2D("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");let Yh=class e extends zh{keyValue;baseline;baselineMode;baselineDescr;progressBar=!1;background;baselineColorUp;baselineColorDown;fontColor;humanize;type="scorecard";constructor(e,t,o){super(e,t,o),this.keyValue=Jr(o,t,e.keyValue),this.baseline=Jr(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp??Ie,this.baselineColorDown=e.baselineColorDown??Re,this.humanize=e.humanize??!1}static validateChartDefinition(e,t){return e.checkValidations(t,Wh,qh)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?.[0]?.dataRange,title:e.title||{text:""},baselineMode:Ee,baselineColorUp:Ie,baselineColorDown:Re,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,s;return e.baseline&&(o=Uc($o(e.baseline),t)),e.keyValue&&(s=Uc($o(e.keyValue),t)),{...e,baseline:o?Zo(o):void 0,keyValue:s?Zo(s):void 0}}duplicateInDuplicatedSheet(t){const o=fh(this.sheetId,t,this.baseline),s=fh(this.sheetId,t,this.keyValue),i=this.getDefinitionWithSpecificRanges(o,s,t);return new e(i,t,this.getters)}copyInSheetId(t){const o=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,t);return new e(o,t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{...this,range:this.keyValue?[{dataRange:this.getters.getRangeString(this.keyValue,this.sheetId)}]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,o){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,o||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,o||this.sheetId):void 0,humanize:this.humanize}}getDefinitionForExcel(){}updateRanges(t){const o=vh(this.baseline,t),s=vh(this.keyValue,t);if(this.baseline===o&&this.keyValue===s)return this;const i=this.getDefinitionWithSpecificRanges(o,s);return new e(i,this.sheetId,this.getters)}};function Xh(e,t){const o=t.getContext("2d"),s=window.devicePixelRatio||1;t.width=s*e.canvas.width,t.height=s*e.canvas.height,o.scale(s,s);const i=e.canvas.width-2*Z;if(o.fillStyle=e.canvas.backgroundColor,o.fillRect(0,0,e.canvas.width,e.canvas.height),e.title){o.font=e.title.style.font,o.fillStyle=e.title.style.color;const t=o.textBaseline;o.textBaseline="middle",o.fillText(xa(o,e.title.text,i-e.title.position.x),e.title.position.x,e.title.position.y),o.textBaseline=t}if(e.baseline&&(o.font=e.baseline.style.font,o.fillStyle=e.baseline.style.color,Ea(o,e.baseline.text,e.baseline.position,e.baseline.style.underline,e.baseline.style.strikethrough)),e.baselineArrow&&e.baselineArrow.style.size>0){o.save(),o.fillStyle=e.baselineArrow.style.color,o.translate(e.baselineArrow.position.x,e.baselineArrow.position.y);const t=e.baselineArrow.style.size/10;switch(o.scale(t,t),e.baselineArrow.direction){case"down":o.fill(Zh);break;case"up":o.fill(jh)}o.restore()}if(e.baselineDescr){const t=e.baselineDescr[0];o.font=t.style.font,o.fillStyle=t.style.color;for(const t of e.baselineDescr)o.fillText(xa(o,t.text,i-t.position.x),t.position.x,t.position.y)}if(e.key&&(o.font=e.key.style.font,o.fillStyle=e.key.style.color,Ea(o,xa(o,e.key.text,i-e.key.position.x),e.key.position,e.key.style.underline,e.key.style.strikethrough)),e.progressBar){if(o.fillStyle=e.progressBar.style.backgroundColor,o.beginPath(),o.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width,e.progressBar.dimension.height,e.progressBar.dimension.height/2),o.fill(),o.fillStyle=e.progressBar.style.color,o.beginPath(),e.progressBar.value>0)o.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{const t=e.progressBar.dimension.width*Math.max(0,Math.min(1,-e.progressBar.value));o.roundRect(e.progressBar.position.x+e.progressBar.dimension.width-t,e.progressBar.position.y,t,e.progressBar.dimension.height,e.progressBar.dimension.height/2)}o.fill()}}function Kh(e,t){let o,s="";const i=t.getLocale();if(e.keyValue){const n={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};o=t.getEvaluatedCell(n),s=function(e,t,o){return e?t?br(e,o):e.formattedValue??String(e.value??""):""}(o,e.humanize??!1,i)}let n;const r=e.baseline;if(r){const e={sheetId:r.sheetId,col:r.zone.left,row:r.zone.top};n=t.getEvaluatedCell(e)}const{background:a,fontColor:l}=t.getStyleOfSingleCellChart(e.background,e.keyValue),c=function(e,t,o,s,i){if(!e)return"";if("text"===o||t?.type!==ii.number||e.type!==ii.number)return s?br(e,i):e.formattedValue;let{value:n,format:r}=e;return"progress"===o?(n=t.value/n,r="0.0%"):(n=Math.abs(t.value-n),"percentage"===o&&0!==n&&(n/=e.value),"percentage"===o&&(r="0.0%"),r||(n=Math.round(100*n)/100)),s?br({value:n,format:r},i):Qn(n,{format:r,locale:i})}(n,o,e.baselineMode,e.humanize??!1,i),h="progress"===e.baselineMode&&ei(c,i)?Li(c,i):0;return{title:{...e.title,text:e.title.text?Bo(e.title.text):""},keyValue:s,baselineDisplay:c,baselineArrow:Gh(n,o,e.baselineMode),baselineColor:$h(n,e.baselineMode,o,e.baselineColorUp,e.baselineColorDown),baselineDescr:"progress"!==e.baselineMode&&e.baselineDescr?Bo(e.baselineDescr):"",fontColor:l,background:a,baselineStyle:"percentage"!==e.baselineMode&&"progress"!==e.baselineMode&&r?t.getCellStyle({sheetId:r.sheetId,col:r.zone.left,row:r.zone.top}):void 0,keyValueStyle:e.keyValue?t.getCellStyle({sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top}):void 0,progressBar:"progress"===e.baselineMode?{value:h,color:h>0?e.baselineColorUp:e.baselineColorDown}:void 0}}const Jh=10,Qh=.05;function ed({width:e,height:t},o){return new td({width:e,height:t},o).computeDesign()}class td{runtime;context;width;height;constructor({width:e,height:t},o){this.runtime=o;const s=document.createElement("canvas");this.width=s.width=e,this.height=s.height=t,this.context=s.getContext("2d")}computeDesign(){const e={canvas:{width:this.width,height:this.height,backgroundColor:this.backgroundColor}},t=this.getTextStyles();let o=0;if(this.title){let s,i;switch(({height:o,width:i}=this.getFullTextDimensions(this.title,t.title.font)),this.runtime.title.align){case"center":s=(this.width-i)/2;break;case"right":s=this.width-i-Jh;break;default:s=Jh}e.title={text:this.title,style:t.title,position:{x:s,y:Jh+o/2}}}const s=t.baselineArrow?.size??0;let{height:i,width:n}=this.getTextDimensions(this.baseline,t.baselineValue.font);this.baseline||(i=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).height);const r=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).width;e.baseline={text:this.baseline,style:t.baselineValue,position:{x:(this.width-n-r+s)/2,y:this.keyValue?this.height*(1-Qh*(this.runtime.progressBar?1:2)):this.height-(this.height-o-i)/2-Jh}};const a=s+20;if(e.baseline.position.x<a&&(e.baseline.position.x=a),t.baselineArrow&&!this.runtime.progressBar&&(e.baselineArrow={direction:this.baselineArrow,style:t.baselineArrow,position:{x:e.baseline.position.x-s,y:e.baseline.position.y-(i+s)/2}}),this.baselineDescr){const o={x:e.baseline.position.x+n,y:e.baseline.position.y};e.baselineDescr=[{text:this.baselineDescr,style:t.baselineDescr,position:o}]}let l=0;this.runtime.progressBar&&(l=.05*this.height,e.progressBar={position:{x:20,y:.9*this.height-i-l},dimension:{height:l,width:this.width-40},value:this.runtime.progressBar.value,style:{color:this.runtime.progressBar.color,backgroundColor:this.secondaryFontColor}});const{width:c,height:h}=this.getFullTextDimensions(this.keyValue,t.keyValue.font);return this.keyValue&&(e.key={text:this.keyValue,style:t.keyValue,position:{x:Math.max(Jh,(this.width-c)/2),y:.4*this.height+5+(o+h/2)/2}}),e}get title(){return this.runtime.title.text??""}get keyValue(){return this.runtime.keyValue}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){return function(e,t){const o=e||"";return t&&o?" "+o:o}(this.runtime.baselineDescr,this.baseline)}get baselineArrow(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get secondaryFontColor(){return Eh(this.backgroundColor)}getTextDimensions(e,t){this.context.font=t;const o=this.context.measureText(e);return{width:o.width,height:o.actualBoundingBoxAscent+o.actualBoundingBoxDescent}}getFullTextDimensions(e,t){this.context.font=t;const o=this.context.measureText(e);return{width:o.width,height:o.fontBoundingBoxAscent+o.fontBoundingBoxDescent}}getTextStyles(){let e=16;const t=Math.floor(.9*e);return this.runtime.progressBar&&(e/=1.5),{title:{font:ha(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:ha(32,this.runtime.keyValueStyle?.bold,this.runtime.keyValueStyle?.italic),strikethrough:this.runtime.keyValueStyle?.strikethrough,underline:this.runtime.keyValueStyle?.underline},baselineValue:{font:ha(e,this.runtime.baselineStyle?.bold,this.runtime.baselineStyle?.italic),strikethrough:this.runtime.baselineStyle?.strikethrough,underline:this.runtime.baselineStyle?.underline,color:this.runtime.baselineStyle?.textColor||this.runtime.baselineColor||this.secondaryFontColor},baselineDescr:{font:ha(t),color:this.secondaryFontColor},baselineArrow:"neutral"===this.baselineArrow||this.runtime.progressBar?void 0:{size:this.keyValue?.8*e:0,color:this.runtime.baselineColor||this.secondaryFontColor}}}}class od extends t.Component{static template="o-spreadsheet-ScorecardChart";static props={figure:Object};canvas=t.useRef("chartContainer");get runtime(){return this.env.model.getters.getChartRuntime(this.props.figure.id)}get title(){const e=this.env.model.getters.getChartDefinition(this.props.figure.id).title.text??"";return Bo(e)}setup(){t.useEffect(this.createChart.bind(this),(()=>{const e=this.canvas.el.getBoundingClientRect();return[e.width,e.height,this.runtime,this.canvas.el,window.devicePixelRatio]}))}createChart(){const e=this.canvas.el;Xh(ed(e.getBoundingClientRect(),this.runtime),e)}}const sd=new n;function id(e,t,o,s){const i=[];e=e.toLowerCase();for(const n of e){const e=t.toLocaleLowerCase().indexOf(n);-1!==e&&(i.push({value:t.slice(0,e),color:""},{value:t[e],color:o,class:s}),t=t.slice(e+1))}return i.push({value:t}),i.filter((e=>e.value))}sd.add("dataValidation",{displayAllOnInitialContent:!0,canBeToggled:!1,getProposals(e,t){return t.startsWith("=")?[]:this.composer.currentEditedCell?function(e,t){const o=e.getValidationRuleForCell(t);if(!o||"isValueInList"!==o.criterion.type&&"isValueInRange"!==o.criterion.type)return[];let s=[];if("isValueInList"===o.criterion.type)s=o.criterion.values.map((e=>({label:e,value:e})));else{const i=new Set,n=e.getRangeFromSheetXC(t.sheetId,o.criterion.values[0]);for(const t of as(n.zone)){const o=e.getEvaluatedCell({...t,sheetId:n.sheetId});o.formattedValue&&!i.has(o.formattedValue)&&(i.add(o.formattedValue),s.push({label:o.formattedValue,value:o.value}))}}return s}(this.getters,this.composer.currentEditedCell).map((e=>({text:e.value?.toString()||"",htmlContent:[{value:e.label}],fuzzySearchKey:e.label}))):[]},selectProposal(e,t){this.composer.setCurrentContent(t),this.composer.stopEdition()}});const nd=/(.*?)\((.*?)\)(.*)/,rd=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function ad(e,t=""){return function(e,t){let o=e.match(nd),s=o[1].trim();if(!s)throw new Error(`Function argument definition is missing a name: '${e}'.`);let i,n=[],r=!1,a=!1;for(let e of o[2].split(",")){const t=e.trim().toUpperCase();let o=rd.find((e=>t===e));o?n.push(o):"RANGE<ANY>"===t?n.push("RANGE"):"OPTIONAL"===t?r=!0:"REPEATING"===t?a=!0:t.startsWith("DEFAULT=")&&(i=e.trim().slice(8))}const l={name:s,description:t,type:n};(n.includes("ANY")||n.includes("RANGE"))&&(l.acceptErrors=!0);r&&(l.optional=!0);a&&(l.repeating=!0);void 0!==i&&(l.default=!0,l.defaultValue=i);n.some((e=>e.startsWith("RANGE")))&&(l.acceptMatrix=!0);n.every((e=>e.startsWith("RANGE")))&&(l.acceptMatrixOnly=!0);return l}(e,t)}function ld(e){let t=0,o=0,s=0;for(let i of e.args)t++,i.optional||i.repeating||i.default||o++,i.repeating&&s++;const i=e;return i.minArgRequired=o,i.maxArgPossible=s?1/0:t,i.nbrArgRepeating=s,i.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const o=e-t;return e=>{if(e<=o)return e;return o+((e-o)%t||t)}}(t,s),i.hidden=e.hidden||!1,i}function cd(e,t){Pi((()=>1===t.length||1===t[0].length),e)}function hd(e,...t){if(t.every(yi)){const o=t[0].length,s=t[0][0].length;for(const i of t)Pi((()=>i.length===o&&i[0].length===s),e)}else if(t.some((e=>Array.isArray(e)&&(1!==e.length||1!==e[0].length))))throw new Ri(e)}function dd(e,t){Pi((()=>t>0),e)}function ud(e,t){Pi((()=>t.length===t[0].length),e)}const gd={description:Bo("Returns a result array constrained to a specific width and height."),args:[ad("input_range (any, range<any>)",Bo("The range to constrain.")),ad("rows (number)",Bo("The number of rows in the constrained array.")),ad("columns (number)",Bo("The number of columns in the constrained array."))],compute:function(e,t,o){const s=Sn(e),i=zi(t?.value,this.locale),n=zi(o?.value,this.locale);dd(Bo("The rows argument (%s) must be strictly positive.",i.toString()),i),dd(Bo("The columns argument (%s) must be strictly positive.",i.toString()),n);const r=Math.min(i,s[0].length);return rn(Math.min(n,s.length),r,((e,t)=>s[e][t]))},isExported:!1},pd={description:Bo("Creates a new array from the selected columns in the existing range."),args:[ad("array (any, range<any>)",Bo("The array that contains the columns to be returned.")),ad("col_num (number, range<number>)",Bo("The first column index of the columns to be returned.")),ad("col_num2 (number, range<number>, repeating)",Bo("The columns indexes of the columns to be returned."))],compute:function(e,...t){const o=Sn(e),s=yn(t,(e=>zi(e?.value,this.locale))),i=s.filter((e=>0===e||o.length<Math.abs(e)));Pi((()=>0===i.length),Bo("The columns arguments must be between -%s and %s (got %s), excluding 0.",o.length.toString(),o.length.toString(),i.join(",")));const n=Array(s.length);for(let e=0;e<s.length;e++)s[e]>0?n[e]=o[s[e]-1]:n[e]=o[o.length+s[e]];return n},isExported:!0},md={description:Bo("Creates a new array from the selected rows in the existing range."),args:[ad("array (any, range<any>)",Bo("The array that contains the rows to be returned.")),ad("row_num (number, range<number>)",Bo("The first row index of the rows to be returned.")),ad("row_num2 (number, range<number>, repeating)",Bo("The rows indexes of the rows to be returned."))],compute:function(e,...t){const o=Sn(e),s=yn(t,(e=>zi(e?.value,this.locale))),i=o.length,n=s.filter((e=>0===e||o[0].length<Math.abs(e)));return Pi((()=>0===n.length),Bo("The rows arguments must be between -%s and %s (got %s), excluding 0.",o[0].length.toString(),o[0].length.toString(),n.join(","))),rn(i,s.length,((e,t)=>s[t]>0?o[e][s[t]-1]:o[e][o[e].length+s[t]]))},isExported:!0},fd={description:Bo("Expands or pads an array to specified row and column dimensions."),args:[ad("array (any, range<any>)",Bo("The array to expand.")),ad("rows (number)",Bo("The number of rows in the expanded array. If missing, rows will not be expanded.")),ad("columns (number, optional)",Bo("The number of columns in the expanded array. If missing, columns will not be expanded.")),ad("pad_with (any, default=0)",Bo("The value with which to pad."))],compute:function(e,t,o,s={value:0}){const i=Sn(e),n=zi(t?.value,this.locale),r=void 0!==o?zi(o.value,this.locale):i.length;return Pi((()=>n>=i[0].length),Bo("The rows arguments (%s) must be greater or equal than the number of rows of the array.",n.toString())),Pi((()=>r>=i.length),Bo("The columns arguments (%s) must be greater or equal than the number of columns of the array.",r.toString())),rn(r,n,((e,t)=>e>=i.length||t>=i[e].length?s:i[e][t]))},isExported:!0},vd={description:Bo("Flattens all the values from one or more ranges into a single column."),args:[ad("range (any, range<any>)",Bo("The first range to flatten.")),ad("range2 (any, range<any>, repeating)",Bo("Additional ranges to flatten."))],compute:function(...e){return[yn(e,(e=>void 0===e?{value:""}:e))]},isExported:!1},bd={description:Bo("Calculates the frequency distribution of a range."),args:[ad("data (range<number>)",Bo("The array of ranges containing the values to be counted.")),ad("classes (number, range<number>)",Bo("The range containing the set of classes."))],compute:function(e,t){const o=yn([e],(e=>e.value)).filter((e=>"number"==typeof e)),s=yn([t],(e=>e.value)).filter((e=>"number"==typeof e)),i=s.map(((e,t)=>({initialIndex:t,value:e,count:0}))).sort(((e,t)=>e.value-t.value));i.push({initialIndex:i.length,value:1/0,count:0});const n=o.sort(((e,t)=>e-t));let r=0;for(const e of n){for(;e>i[r].value&&r<i.length-1;)r++;i[r].count++}return[i.sort(((e,t)=>e.initialIndex-t.initialIndex)).map((e=>e.count))]},isExported:!0},Sd={description:Bo("Appends ranges horizontally and in sequence to return a larger array."),args:[ad("range1 (any, range<any>)",Bo("The first range to be appended.")),ad("range2 (any, range<any>, repeating)",Bo("Additional ranges to add to range1."))],compute:function(...e){const t=Math.max(...e.map((e=>e?.[0]?.length??0))),o=[];for(const s of e){const e=Sn(s);for(let s=0;s<e.length;s++){const i=Array(t).fill({value:null});for(let t=0;t<e[s].length;t++)i[t]=e[s][t];o.push(i)}}return o},isExported:!0},yd={description:Bo("Returns the matrix determinant of a square matrix."),args:[ad("square_matrix (number, range<number>)",Bo("An range with an equal number of rows and columns representing a matrix whose determinant will be calculated."))],compute:function(e){const t=Ui(e,"square_matrix");return ud(Bo("The argument square_matrix must have the same number of columns and rows."),t),Sl(t).determinant},isExported:!0},Cd={description:Bo("Returns the multiplicative inverse of a square matrix."),args:[ad("square_matrix (number, range<number>)",Bo("An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated."))],compute:function(e){const t=Ui(e,"square_matrix");ud(Bo("The argument square_matrix must have the same number of columns and rows."),t);const{inverted:o}=Sl(t);return o||new Ri(Bo("The matrix is not invertible."))},isExported:!0},wd={description:Bo("Calculates the matrix product of two matrices."),args:[ad("matrix1 (number, range<number>)",Bo("The first matrix in the matrix multiplication operation.")),ad("matrix2 (number, range<number>)",Bo("The second matrix in the matrix multiplication operation."))],compute:function(e,t){const o=Ui(e,"matrix1"),s=Ui(t,"matrix2");return Pi((()=>o.length>0&&s.length>0),Bo("The first and second arguments of [[FUNCTION_NAME]] must be non-empty matrices.")),Pi((()=>o.length===s[0].length),Bo("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).",o.length.toString(),s[0].length.toString())),Cl(o,s)},isExported:!0},xd={description:Bo("Calculates the sum of the products of corresponding entries in equal-sized ranges."),args:[ad("range1 (number, range<number>)",Bo("The first range whose entries will be multiplied with corresponding entries in the other ranges.")),ad("range2 (number, range<number>, repeating)",Bo("The other range whose entries will be multiplied with corresponding entries in the other ranges."))],compute:function(...e){hd(Bo("All the ranges must have the same dimensions."),...e);const t=e.map(Sn);let o=0;for(let e=0;e<t[0].length;e++)for(let s=0;s<t[0][e].length;s++){if(!t.every((t=>"number"==typeof t[e][s].value)))continue;let i=1;for(const o of t)i*=Li(o[e][s],this.locale);o+=i}return o},isExported:!0};function Ed(e,t,o){hd("The arguments array_x and array_y must have the same dimensions.",e,t);const s=Sn(e),i=Sn(t);let n=!1,r=0;for(const e in s)for(const t in s[e]){const a=s[e][t].value,l=i[e][t].value;"number"==typeof a&&"number"==typeof l&&(n=!0,r+=o(a,l))}return n?r:new Ri(Bo("The arguments array_x and array_y must contain at least one pair of numbers."))}const Id={description:Bo("Calculates the sum of the difference of the squares of the values in two array."),args:[ad("array_x (number, range<number>)",Bo("The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.")),ad("array_y (number, range<number>)",Bo("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){return Ed(e,t,((e,t)=>e**2-t**2))},isExported:!0},Rd={description:Bo("Calculates the sum of the sum of the squares of the values in two array."),args:[ad("array_x (number, range<number>)",Bo("The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.")),ad("array_y (number, range<number>)",Bo("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){return Ed(e,t,((e,t)=>e**2+t**2))},isExported:!0},Td={description:Bo("Calculates the sum of squares of the differences of values in two array."),args:[ad("array_x (number, range<number>)",Bo("The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.")),ad("array_y (number, range<number>)",Bo("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){return Ed(e,t,((e,t)=>(e-t)**2))},isExported:!0},Ad=!1,_d=[ad("array (any, range<any>)",Bo("The array which will be transformed.")),ad("ignore (number, default=0)",Bo("The control to ignore blanks and errors. 0 (default) is to keep all values, 1 is to ignore blanks, 2 is to ignore errors, and 3 is to ignore blanks and errors.")),ad("scan_by_column (number, default=false)",Bo("Whether the array should be scanned by column. True scans the array by column and false (default) scans the array by row."))];function Dd(e){const t=Math.trunc(e);if(0===t)return()=>!0;if(1===t)return e=>null!==e.value;if(2===t)return e=>!ki(e.value);if(3===t)return e=>null!==e.value&&!ki(e.value);throw new Ri(Bo("Argument ignore must be between 0 and 3"))}const Od={description:Bo("Transforms a range of cells into a single column."),args:_d,compute:function(e,t={value:0},o={value:Ad}){const s=Sn(e),i=Li(t.value,this.locale),n=(Yi(o.value)?s:ln(s)).flat().filter(Dd(i));return 0===n.length?new Di(Bo("No results for the given arguments of TOCOL.")):[n]},isExported:!0},Fd={description:Bo("Transforms a range of cells into a single row."),args:_d,compute:function(e,t={value:0},o={value:Ad}){const s=Sn(e),i=Li(t.value,this.locale),n=(Yi(o.value)?s:ln(s)).flat().filter(Dd(i)).map((e=>[e]));return 0===n.length||0===n[0].length?new Di(Bo("No results for the given arguments of TOROW.")):n},isExported:!0},Md={description:Bo("Transposes the rows and columns of a range."),args:[ad("range (any, range<any>)",Bo("The range to be transposed."))],compute:function(e){const t=Sn(e);return rn(t[0].length,t.length,((e,o)=>t[o][e]))},isExported:!0},Pd={description:Bo("Appends ranges vertically and in sequence to return a larger array."),args:[ad("range1 (any, range<any>)",Bo("The first range to be appended.")),ad("range2 (any, range<any>, repeating)",Bo("Additional ranges to add to range1."))],compute:function(...e){const t=Math.max(...e.map((e=>Sn(e).length))),o=e.reduce(((e,t)=>e+Sn(t)[0].length),0),s=Array(t).fill([]).map((()=>Array(o).fill({value:0})));let i=0;for(const t of e){const e=Sn(t);for(let t=0;t<e.length;t++)for(let o=0;o<e[t].length;o++)s[t][i+o]=e[t][o];i+=e[0].length}return s},isExported:!0},Nd={description:Bo("Wraps the provided row or column of cells by columns after a specified number of elements to form a new array."),args:[ad("range (any, range<any>)",Bo("The range to wrap.")),ad("wrap_count (number)",Bo("The maximum number of cells for each column, rounded down to the nearest whole number.")),ad("pad_with (any, default=0)",Bo("The value with which to fill the extra cells in the range."))],compute:function(e,t,o={value:0}){const s=Sn(e),i=zi(t?.value,this.locale);cd(Bo("Argument range must be a single row or column."),s);const n=s.flat();return rn(Math.ceil(n.length/i),i,((e,t)=>{const s=e*i+t;return s<n.length?n[s]:o}))},isExported:!0},kd={description:Bo("Wraps the provided row or column of cells by rows after a specified number of elements to form a new array."),args:[ad("range (any, range<any>)",Bo("The range to wrap.")),ad("wrap_count (number)",Bo("The maximum number of cells for each row, rounded down to the nearest whole number.")),ad("pad_with (any, default=0)",Bo("The value with which to fill the extra cells in the range."))],compute:function(e,t,o={value:0}){const s=Sn(e),i=zi(t?.value,this.locale);cd(Bo("Argument range must be a single row or column."),s);const n=s.flat(),r=Math.ceil(n.length/i);return rn(i,r,((e,t)=>{const s=t*i+e;return s<n.length?n[s]:o}))},isExported:!0};var Vd=Object.freeze({__proto__:null,ARRAY_CONSTRAIN:gd,CHOOSECOLS:pd,CHOOSEROWS:md,EXPAND:fd,FLATTEN:vd,FREQUENCY:bd,HSTACK:Sd,MDETERM:yd,MINVERSE:Cd,MMULT:wd,SUMPRODUCT:xd,SUMX2MY2:Id,SUMX2PY2:Rd,SUMXMY2:Td,TOCOL:Od,TOROW:Fd,TRANSPOSE:Md,VSTACK:Pd,WRAPCOLS:Nd,WRAPROWS:kd});const Ld={description:Bo("Apply a large number format"),args:[ad("value (number)",Bo("The number.")),ad("unit (string, optional)",Bo("The formatting unit. Use 'k', 'm', or 'b' to force the unit"))],compute:function(e,t){return{value:Li(e,this.locale),format:Sr(e,t,this.locale)}}};var Hd=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:Ld});const Ud=/^-?[a-z0-9]+$/i,Bd={description:Bo("Absolute value of a number."),args:[ad("value (number)",Bo("The number of which to return the absolute value."))],compute:function(e){return Math.abs(Li(e,this.locale))},isExported:!0},zd={description:Bo("Inverse cosine of a value, in radians."),args:[ad("value (number)",Bo("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive."))],compute:function(e){const t=Li(e,this.locale);return Pi((()=>Math.abs(t)<=1),Bo("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},$d={description:Bo("Inverse hyperbolic cosine of a number."),args:[ad("value (number)",Bo("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1."))],compute:function(e){const t=Li(e,this.locale);return Pi((()=>t>=1),Bo("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},Gd={description:Bo("Inverse cotangent of a value."),args:[ad("value (number)",Bo("The value for which to calculate the inverse cotangent."))],compute:function(e){const t=Li(e,this.locale);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},Wd={description:Bo("Inverse hyperbolic cotangent of a value."),args:[ad("value (number)",Bo("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive."))],compute:function(e){const t=Li(e,this.locale);return Pi((()=>Math.abs(t)>1),Bo("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},qd={description:Bo("Inverse sine of a value, in radians."),args:[ad("value (number)",Bo("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive."))],compute:function(e){const t=Li(e,this.locale);return Pi((()=>Math.abs(t)<=1),Bo("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Zd={description:Bo("Inverse hyperbolic sine of a number."),args:[ad("value (number)",Bo("The value for which to calculate the inverse hyperbolic sine."))],compute:function(e){return Math.asinh(Li(e,this.locale))},isExported:!0},jd={description:Bo("Inverse tangent of a value, in radians."),args:[ad("value (number)",Bo("The value for which to calculate the inverse tangent."))],compute:function(e){return Math.atan(Li(e,this.locale))},isExported:!0},Yd={description:Bo("Angle from the X axis to a point (x,y), in radians."),args:[ad("x (number)",Bo("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),ad("y (number)",Bo("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis."))],compute:function(e,t){const o=Li(e,this.locale),s=Li(t,this.locale);return Pi((()=>0!==o||0!==s),Bo("Function [[FUNCTION_NAME]] caused a divide by zero error."),Ei.DivisionByZero),Math.atan2(s,o)},isExported:!0},Xd={description:Bo("Inverse hyperbolic tangent of a number."),args:[ad("value (number)",Bo("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive."))],compute:function(e){const t=Li(e,this.locale);return Pi((()=>Math.abs(t)<1),Bo("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},Kd={description:Bo("Rounds number up to nearest multiple of factor."),args:[ad("value (number)",Bo("The value to round up to the nearest integer multiple of factor.")),ad("factor (number, default=1)",Bo("The number to whose multiples value will be rounded."))],compute:function(e,t={value:1}){const o=Li(e,this.locale),s=Li(t,this.locale);return Pi((()=>s>=0||o<=0),Bo("The factor (%s) must be positive when the value (%s) is positive.",s.toString(),o.toString())),{value:s?Math.ceil(o/s)*s:0,format:e?.format}},isExported:!0};function Jd(e,t,o=0){return 0===t?0:(t=Math.abs(t),e>=0?Math.ceil(e/t)*t:0===o?-Math.floor(Math.abs(e)/t)*t:-Math.ceil(Math.abs(e)/t)*t)}const Qd={description:Bo("Rounds number up to nearest multiple of factor."),args:[ad("number (number)",Bo("The value to round up to the nearest integer multiple of significance.")),ad("significance (number, default=1)",Bo("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),ad("mode (number, default=0)",Bo("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},o={value:0}){const s=Li(t,this.locale);return{value:Jd(Li(e,this.locale),s,Li(o,this.locale)),format:e?.format}},isExported:!0},eu={description:Bo("Rounds number up to nearest multiple of factor."),args:[ad("number (number)",Bo("The value to round up to the nearest integer multiple of significance.")),ad("significance (number, default=1)",Bo("The number to whose multiples number will be rounded."))],compute:function(e,t={value:1}){const o=Li(t,this.locale);return{value:Jd(Li(e,this.locale),o),format:e?.format}},isExported:!0},tu={description:Bo("Cosine of an angle provided in radians."),args:[ad("angle (number)",Bo("The angle to find the cosine of, in radians."))],compute:function(e){return Math.cos(Li(e,this.locale))},isExported:!0},ou={description:Bo("Hyperbolic cosine of any real number."),args:[ad("value (number)",Bo("Any real value to calculate the hyperbolic cosine of."))],compute:function(e){return Math.cosh(Li(e,this.locale))},isExported:!0},su={description:Bo("Cotangent of an angle provided in radians."),args:[ad("angle (number)",Bo("The angle to find the cotangent of, in radians."))],compute:function(e){const t=Li(e,this.locale);return Wi(t),1/Math.tan(t)},isExported:!0},iu={description:Bo("Hyperbolic cotangent of any real number."),args:[ad("value (number)",Bo("Any real value to calculate the hyperbolic cotangent of."))],compute:function(e){const t=Li(e,this.locale);return Wi(t),1/Math.tanh(t)},isExported:!0},nu={description:Bo("Number of empty values."),args:[ad("value1 (any, range)",Bo("The first value or range in which to count the number of blanks.")),ad("value2 (any, range, repeating)",Bo("Additional values or ranges in which to count the number of blanks."))],compute:function(...e){return on(e,((e,t)=>void 0===t||null===t.value||""===t.value?e+1:e),0)},isExported:!0},ru={description:Bo("A conditional count across a range."),args:[ad("range (range)",Bo("The range that is tested against criterion.")),ad("criterion (string)",Bo("The pattern or test to apply to range."))],compute:function(...e){let t=0;return pn(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0},au={description:Bo("Count values depending on multiple criteria."),args:[ad("criteria_range1 (range)",Bo("The range to check against criterion1.")),ad("criterion1 (string)",Bo("The pattern or test to apply to criteria_range1.")),ad("criteria_range2 (any, range, repeating)",Bo("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),ad("criterion2 (string, repeating)",Bo("Additional criteria to check."))],compute:function(...e){let t=0;return pn(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0},lu={description:Bo("Counts number of unique values in a range."),args:[ad("value1 (any, range)",Bo("The first value or range to consider for uniqueness.")),ad("value2 (any, range, repeating)",Bo("Additional values or ranges to consider for uniqueness."))],compute:function(...e){return vl(e)}},cu={description:Bo("Counts number of unique values in a range, filtered by a set of criteria."),args:[ad("range (range)",Bo("The range of cells from which the number of unique values will be counted.")),ad("criteria_range1 (range)",Bo("The range of cells over which to evaluate criterion1.")),ad("criterion1 (string)",Bo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),ad("criteria_range2 (any, range, repeating)",Bo("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),ad("criterion2 (string, repeating)",Bo("The pattern or test to apply to criteria_range2."))],compute:function(e,...t){let o=new Set;return pn(t,((t,s)=>{const i=e[t]?.[s];Cn(i)&&o.add(i.value)}),this.locale),o.size}},hu={description:Bo("Cosecant of an angle provided in radians."),args:[ad("angle (number)",Bo("The angle to find the cosecant of, in radians."))],compute:function(e){const t=Li(e,this.locale);return Wi(t),1/Math.sin(t)},isExported:!0},du={description:Bo("Hyperbolic cosecant of any real number."),args:[ad("value (number)",Bo("Any real value to calculate the hyperbolic cosecant of."))],compute:function(e){const t=Li(e,this.locale);return Wi(t),1/Math.sinh(t)},isExported:!0},uu={description:Bo("Converts from another base to decimal."),args:[ad("value (string)",Bo("The number to convert.")),ad("base (number)",Bo("The base to convert the value from."))],compute:function(e,t){let o=Li(t,this.locale);o=Math.floor(o),Pi((()=>2<=o&&o<=36),Bo("The base (%s) must be between 2 and 36 inclusive.",o.toString()));const s=qi(e);if(""===s)return 0;Pi((()=>Ud.test(s)),Bo("The value (%s) must be a valid base %s representation.",s,o.toString()));const i=parseInt(s,o);return Pi((()=>!isNaN(i)),Bo("The value (%s) must be a valid base %s representation.",s,o.toString())),i},isExported:!0},gu={description:Bo("Converts an angle value in radians to degrees."),args:[ad("angle (number)",Bo("The angle to convert from radians to degrees."))],compute:function(e){return 180*Li(e,this.locale)/Math.PI},isExported:!0},pu={description:Bo("Euler's number, e (~2.718) raised to a power."),args:[ad("value (number)",Bo("The exponent to raise e."))],compute:function(e){return Math.exp(Li(e,this.locale))},isExported:!0},mu={description:Bo("Rounds number down to nearest multiple of factor."),args:[ad("value (number)",Bo("The value to round down to the nearest integer multiple of factor.")),ad("factor (number, default=1)",Bo("The number to whose multiples value will be rounded."))],compute:function(e,t={value:1}){const o=Li(e,this.locale),s=Li(t,this.locale);return Pi((()=>s>=0||o<=0),Bo("The factor (%s) must be positive when the value (%s) is positive.",s.toString(),o.toString())),{value:s?Math.floor(o/s)*s:0,format:e?.format}},isExported:!0};function fu(e,t,o=0){return 0===t?0:(t=Math.abs(t),e>=0?Math.floor(e/t)*t:0===o?-Math.ceil(Math.abs(e)/t)*t:-Math.floor(Math.abs(e)/t)*t)}const vu={description:Bo("Rounds number down to nearest multiple of factor."),args:[ad("number (number)",Bo("The value to round down to the nearest integer multiple of significance.")),ad("significance (number, default=1)",Bo("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),ad("mode (number, default=0)",Bo("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},o={value:0}){const s=Li(t,this.locale);return{value:fu(Li(e,this.locale),s,Li(o,this.locale)),format:e?.format}},isExported:!0},bu={description:Bo("Rounds number down to nearest multiple of factor."),args:[ad("number (number)",Bo("The value to round down to the nearest integer multiple of significance.")),ad("significance (number, default=1)",Bo("The number to whose multiples number will be rounded."))],compute:function(e,t={value:1}){const o=Li(t,this.locale);return{value:fu(Li(e,this.locale),o),format:e?.format}},isExported:!0},Su={description:Bo("Whether the provided value is even."),args:[ad("value (number)",Bo("The value to be verified as even."))],compute:function(e){const t=Bi(e,this.locale);return!(1&Math.floor(Math.abs(t)))},isExported:!0},yu={description:Bo("Rounds number up to nearest multiple of factor."),args:[ad("number (number)",Bo("The value to round up to the nearest integer multiple of significance.")),ad("significance (number, default=1)",Bo("The number to whose multiples number will be rounded."))],compute:function(e,t={value:1}){return{value:Jd(Li(e,this.locale),Li(t,this.locale)),format:e?.format}},isExported:!0},Cu={description:Bo("Whether the provided value is even."),args:[ad("value (number)",Bo("The value to be verified as even."))],compute:function(e){const t=Bi(e,this.locale);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},wu={description:Bo("The logarithm of a number, base e (euler's number)."),args:[ad("value (number)",Bo("The value for which to calculate the logarithm, base e."))],compute:function(e){const t=Li(e,this.locale);return Pi((()=>t>0),Bo("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},xu={description:Bo("The logarithm of a number, for a given base."),args:[ad("value (number)",Bo("The value for which to calculate the logarithm.")),ad("base (number, default=10)",Bo("The base of the logarithm."))],compute:function(e,t={value:10}){const o=Li(e,this.locale),s=Li(t,this.locale);return Pi((()=>o>0),Bo("The value (%s) must be strictly positive.",o.toString())),Pi((()=>s>0),Bo("The base (%s) must be strictly positive.",s.toString())),Pi((()=>1!==s),Bo("The base must be different from 1.")),Math.log10(o)/Math.log10(s)},isExported:!0};function Eu(e,t){Pi((()=>0!==t),Bo("The divisor must be different from 0."),Ei.DivisionByZero);const o=e%t;return o>0&&t<0||o<0&&t>0?o+t:o}const Iu={description:Bo("Modulo (remainder) operator."),args:[ad("dividend (number)",Bo("The number to be divided to find the remainder.")),ad("divisor (number)",Bo("The number to divide by."))],compute:function(e,t){const o=Li(t,this.locale);return{value:Eu(Li(e,this.locale),o),format:e?.format}},isExported:!0},Ru={description:Bo("Returns a n x n unit matrix, where n is the input dimension."),args:[ad("dimension (number)",Bo("An integer specifying the dimension size of the unit matrix. It must be positive."))],compute:function(e){const t=zi(e,this.locale);return dd(Bo("The argument dimension must be positive"),t),bl(t)},isExported:!0},Tu={description:Bo("Rounds a number up to the nearest odd integer."),args:[ad("value (number)",Bo("The value to round to the next greatest odd number."))],compute:function(e){const t=Li(e,this.locale);let o=Math.ceil(Math.abs(t));return o=1&o?o:o+1,{value:t<0?-o:o,format:e?.format}},isExported:!0},Au={description:Bo("The number pi."),args:[],compute:function(){return Math.PI},isExported:!0},_u={description:Bo("A number raised to a power."),args:[ad("base (number)",Bo("The number to raise to the exponent power.")),ad("exponent (number)",Bo("The exponent to raise base to."))],compute:function(e,t){const o=Li(e,this.locale),s=Li(t,this.locale);return Pi((()=>o>=0||Number.isInteger(s)),Bo("The exponent (%s) must be an integer when the base is negative.",s.toString())),{value:Math.pow(o,s),format:e?.format}},isExported:!0},Du={description:Bo("Result of multiplying a series of numbers together."),args:[ad("factor1 (number, range<number>)",Bo("The first number or range to calculate for the product.")),ad("factor2 (number, range<number>, repeating)",Bo("More numbers or ranges to calculate for the product."))],compute:function(...e){let t=0,o=1;for(let s of e)if(yi(s))for(let e of s)for(let s of e){const e=s.value;if("number"==typeof e&&(o*=e,t+=1),ki(e))return s}else void 0!==s&&null!==s.value&&(o*=Bi(s,this.locale),t+=1);return{value:0===t?0:o,format:Ni(e[0])}},isExported:!0},Ou={description:Bo("A random number between 0 inclusive and 1 exclusive."),args:[],compute:function(){return Math.random()},isExported:!0},Fu={description:Bo("Returns a grid of random numbers between 0 inclusive and 1 exclusive."),args:[ad("rows (number, default=1)",Bo("The number of rows to be returned.")),ad("columns (number, default=1)",Bo("The number of columns to be returned.")),ad("min (number, default=0)",Bo("The minimum number you would like returned.")),ad("max (number, default=1)",Bo("The maximum number you would like returned.")),ad("whole_number (number, default=FALSE)",Bo("Return a whole number or a decimal value."))],compute:function(e={value:1},t={value:1},o={value:0},s={value:1},i={value:!1}){const n=zi(t,this.locale),r=zi(e,this.locale),a=Li(o,this.locale),l=Li(s,this.locale),c=Yi(i);dd(Bo("The number of columns (%s) must be positive.",n.toString()),n),dd(Bo("The number of rows (%s) must be positive.",r.toString()),r),Pi((()=>a<=l),Bo("The maximum (%s) must be greater than or equal to the minimum (%s).",l.toString(),a.toString())),c&&Pi((()=>Number.isInteger(a)&&Number.isInteger(l)),Bo("The maximum (%s) and minimum (%s) must be integers when whole_number is TRUE.",l.toString(),a.toString()));const h=Array(n);for(let e=0;e<n;e++){h[e]=Array(r);for(let t=0;t<r;t++)h[e][t]=c?Math.floor(Math.random()*(l-a+1)+a):a+Math.random()*(l-a)}return h},isExported:!0},Mu={description:Bo("Random integer between two values, inclusive."),args:[ad("low (number)",Bo("The low end of the random range.")),ad("high (number)",Bo("The high end of the random range."))],compute:function(e,t){let o=Li(e,this.locale);Number.isInteger(o)||(o=Math.ceil(o));let s=Li(t,this.locale);return Number.isInteger(s)||(s=Math.floor(s)),Pi((()=>o<=s),Bo("The high (%s) must be greater than or equal to the low (%s).",s.toString(),o.toString())),{value:o+Math.ceil((s-o+1)*Math.random())-1,format:e?.format}},isExported:!0},Pu={description:Bo("Rounds a number according to standard rules."),args:[ad("value (number)",Bo("The value to round to places number of places.")),ad("places (number, default=0)",Bo("The number of decimal places to which to round."))],compute:function(e,t={value:0}){const o=Li(e,this.locale);let s=Li(t,this.locale);const i=Math.abs(o);let n;return 0===s?n=Math.round(i):(Number.isInteger(s)||(s=Math.trunc(s)),n=Math.round(i*Math.pow(10,s))/Math.pow(10,s)),{value:o>=0?n:-n,format:e?.format}},isExported:!0},Nu={description:Bo("Rounds down a number."),args:[ad("value (number)",Bo("The value to round to places number of places, always rounding down.")),ad("places (number, default=0)",Bo("The number of decimal places to which to round."))],compute:function(e,t={value:0}){const o=Li(e,this.locale);let s=Li(t,this.locale);const i=Math.abs(o);let n;return 0===s?n=Math.floor(i):(Number.isInteger(s)||(s=Math.trunc(s)),n=Math.floor(i*Math.pow(10,s))/Math.pow(10,s)),{value:o>=0?n:-n,format:e?.format}},isExported:!0},ku={description:Bo("Rounds up a number."),args:[ad("value (number)",Bo("The value to round to places number of places, always rounding up.")),ad("places (number, default=0)",Bo("The number of decimal places to which to round."))],compute:function(e,t={value:0}){const o=Li(e,this.locale);let s=Li(t,this.locale);const i=Math.abs(o);let n;return 0===s?n=Math.ceil(i):(Number.isInteger(s)||(s=Math.trunc(s)),n=Math.ceil(i*Math.pow(10,s))/Math.pow(10,s)),{value:o>=0?n:-n,format:e?.format}},isExported:!0},Vu={description:Bo("Secant of an angle provided in radians."),args:[ad("angle (number)",Bo("The angle to find the secant of, in radians."))],compute:function(e){return 1/Math.cos(Li(e,this.locale))},isExported:!0},Lu={description:Bo("Hyperbolic secant of any real number."),args:[ad("value (number)",Bo("Any real value to calculate the hyperbolic secant of."))],compute:function(e){return 1/Math.cosh(Li(e,this.locale))},isExported:!0},Hu={description:Bo("Returns a sequence of numbers."),args:[ad("rows (number)",Bo("The number of rows to return")),ad("columns (number, optional, default=1)",Bo("The number of columns to return")),ad("start (number, optional, default=1)",Bo("The first number in the sequence")),ad("step (number, optional, default=1)",Bo("The amount to increment each value in the sequence"))],compute:function(e,t={value:1},o={value:1},s={value:1}){const i=Li(o,this.locale),n=Li(s,this.locale),r=zi(e,this.locale),a=zi(t,this.locale);return dd(Bo("The number of columns (%s) must be positive.",a),a),dd(Bo("The number of rows (%s) must be positive.",r),r),rn(a,r,((e,t)=>({value:i+t*a*n+e*n})))},isExported:!0},Uu={description:Bo("Sine of an angle provided in radians."),args:[ad("angle (number)",Bo("The angle to find the sine of, in radians."))],compute:function(e){return Math.sin(Li(e,this.locale))},isExported:!0},Bu={description:Bo("Hyperbolic sine of any real number."),args:[ad("value (number)",Bo("Any real value to calculate the hyperbolic sine of."))],compute:function(e){return Math.sinh(Li(e,this.locale))},isExported:!0},zu={description:Bo("Positive square root of a positive number."),args:[ad("value (number)",Bo("The number for which to calculate the positive square root."))],compute:function(e){const t=Li(e,this.locale);return Pi((()=>t>=0),Bo("The value (%s) must be positive or null.",t.toString())),{value:Math.sqrt(t),format:e?.format}},isExported:!0},$u={description:Bo("Sum of a series of numbers and/or cells."),args:[ad("value1 (number, range<number>)",Bo("The first number or range to add together.")),ad("value2 (number, range<number>, repeating)",Bo("Additional numbers or ranges to add to value1."))],compute:function(...e){const t=e[0];return{value:fl(e,this.locale),format:Ni(t)}},isExported:!0},Gu={description:Bo("A conditional sum across a range."),args:[ad("criteria_range (range)",Bo("The range which is tested against criterion.")),ad("criterion (string)",Bo("The pattern or test to apply to range.")),ad("sum_range (range, default=criteria_range)",Bo("The range to be summed, if different from range."))],compute:function(e,t,o){void 0===o&&(o=e);let s=0;return pn([e,t],((e,t)=>{const i=o[e]?.[t]?.value;"number"==typeof i&&(s+=i)}),this.locale),s},isExported:!0},Wu={description:Bo("Sums a range depending on multiple criteria."),args:[ad("sum_range (range)",Bo("The range to sum.")),ad("criteria_range1 (range)",Bo("The range to check against criterion1.")),ad("criterion1 (string)",Bo("The pattern or test to apply to criteria_range1.")),ad("criteria_range2 (any, range, repeating)",Bo("Additional ranges to check.")),ad("criterion2 (string, repeating)",Bo("Additional criteria to check."))],compute:function(e,...t){let o=0;return pn(t,((t,s)=>{const i=e[t]?.[s]?.value;"number"==typeof i&&(o+=i)}),this.locale),o},isExported:!0},qu={description:Bo("Tangent of an angle provided in radians."),args:[ad("angle (number)",Bo("The angle to find the tangent of, in radians."))],compute:function(e){return Math.tan(Li(e,this.locale))},isExported:!0},Zu={description:Bo("Hyperbolic tangent of any real number."),args:[ad("value (number)",Bo("Any real value to calculate the hyperbolic tangent of."))],compute:function(e){return Math.tanh(Li(e,this.locale))},isExported:!0};function ju(e,t){return 0===t?Math.trunc(e):(Number.isInteger(t)||(t=Math.trunc(t)),Math.trunc(e*Math.pow(10,t))/Math.pow(10,t))}const Yu={description:Bo("Truncates a number."),args:[ad("value (number)",Bo("The value to be truncated.")),ad("places (number, default=0)",Bo("The number of significant digits to the right of the decimal point to retain."))],compute:function(e,t={value:0}){return{value:ju(Li(e,this.locale),Li(t,this.locale)),format:e?.format}},isExported:!0},Xu={description:Bo("Rounds a number down to the nearest integer that is less than or equal to it."),args:[ad("value (number)",Bo("The number to round down to the nearest integer."))],compute:function(e){return Math.floor(Li(e,this.locale))},isExported:!0};var Ku=Object.freeze({__proto__:null,ABS:Bd,ACOS:zd,ACOSH:$d,ACOT:Gd,ACOTH:Wd,ASIN:qd,ASINH:Zd,ATAN:jd,ATAN2:Yd,ATANH:Xd,CEILING:Kd,CEILING_MATH:Qd,CEILING_PRECISE:eu,COS:tu,COSH:ou,COT:su,COTH:iu,COUNTBLANK:nu,COUNTIF:ru,COUNTIFS:au,COUNTUNIQUE:lu,COUNTUNIQUEIFS:cu,CSC:hu,CSCH:du,DECIMAL:uu,DEGREES:gu,EXP:pu,FLOOR:mu,FLOOR_MATH:vu,FLOOR_PRECISE:bu,INT:Xu,ISEVEN:Su,ISODD:Cu,ISO_CEILING:yu,LN:wu,LOG:xu,MOD:Iu,MUNIT:Ru,ODD:Tu,PI:Au,POWER:_u,PRODUCT:Du,RAND:Ou,RANDARRAY:Fu,RANDBETWEEN:Mu,ROUND:Pu,ROUNDDOWN:Nu,ROUNDUP:ku,SEC:Vu,SECH:Lu,SEQUENCE:Hu,SIN:Uu,SINH:Bu,SQRT:zu,SUM:$u,SUMIF:Gu,SUMIFS:Wu,TAN:qu,TANH:Zu,TRUNC:Yu});function Ju(e,t){const o=[],s=[];let i=0,n=0;Qi([e],(e=>{o.push(e),i+=1})),Qi([t],(e=>{s.push(e),n+=1})),Pi((()=>i===n),Bo("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",i,n));const r=[],a=[];for(let e=0;e<i;e++){const t=o[e]?.value,i=s[e]?.value;"number"==typeof t&&"number"==typeof i&&(a.push(t),r.push(i))}return{flatDataX:r,flatDataY:a}}function Qu(e,t,o){const{flatDataX:s,flatDataY:i}=Ju(e,t),n=i.length;Pi((()=>0!==n&&(!o||1!==n)),Bo("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."),Ei.DivisionByZero);let r=0,a=0;for(let e=0;e<n;e++)r+=i[e],a+=s[e];const l=r/n,c=a/n;let h=0;for(let e=0;e<n;e++)h+=(i[e]-l)*(s[e]-c);return h/(n-(o?1:0))}function eg(e,t,o,s){let i=0;const n=o?nn:sn,r=n(e,((e,t)=>(i+=1,e+t)),0,s);Pi((()=>0!==i&&(!t||1!==i)),Bo("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."),Ei.DivisionByZero);const a=r/i;return n(e,((e,t)=>e+Math.pow(t-a,2)),0,s)/(i-(t?1:0))}function tg(e,t,o,s){const i=Li(t,s);Pi((()=>o?0<=i&&i<=1:0<i&&i<1),Bo("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let n,r=[],a=0;return Qi(e,(e=>{const t=e?.value;"number"==typeof t&&(n=mn(r,e,"nextSmaller","asc",r.length,((e,t)=>e[t])),r.splice(n+1,0,t),a++)})),Pi((()=>0!==a),Bo("[[FUNCTION_NAME]] has no valid input data.")),o||Pi((()=>1/(a+1)<=i&&i<=a/(a+1)),Bo("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),si(r,i,o)}const og={description:Bo("Average magnitude of deviations from mean."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the sample.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the sample."))],compute:function(...e){let t=0;const o=sn(e,((e,o)=>(t+=1,e+o)),0,this.locale);Wi(t);const s=o/t;return sn(e,((e,t)=>e+Math.abs(s-t)),0,this.locale)/t},isExported:!0},sg={description:Bo("Numerical average value in a dataset, ignoring text."),args:[ad("value1 (number, range<number>)",Bo("The first value or range to consider when calculating the average value.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to consider when calculating the average value."))],compute:function(...e){return{value:Rl(e,this.locale),format:Ni(e[0])}},isExported:!0},ig=Bo("[[FUNCTION_NAME]] has mismatched range sizes."),ng=Bo("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),rg={description:Bo("Weighted average."),args:[ad("values (number, range<number>)",Bo("Values to average.")),ad("weights (number, range<number>)",Bo("Weights for each corresponding value.")),ad("additional_values (number, range<number>, repeating)",Bo("Additional values to average.")),ad("additional_weights (number, range<number>, repeating)",Bo("Additional weights."))],compute:function(...e){let t=0,o=0;for(let s=0;s<e.length-1;s+=2){const i=e[s],n=e[s+1];if(hd(ig,i,n),yi(i))for(let e=0;e<i.length;e++)for(let s=0;s<i[0].length;s++){const r=i[e][s].value,a=yi(n)?n?.[e][s].value:Li(n,this.locale),l="number"==typeof r,c="number"==typeof a;l&&c?(Pi((()=>a>=0),ng),t+=r*a,o+=a):Pi((()=>l===c),Bo("[[FUNCTION_NAME]] expects number values."))}else{const e=Li(i,this.locale),s=yi(n)?n?.[0][0].value:Li(n,this.locale);"number"==typeof s&&(Pi((()=>s>=0),ng),t+=e*s,o+=s)}}return Wi(o),{value:t/o,format:Ni(e[0])}}},ag={description:Bo("Numerical average value in a dataset."),args:[ad("value1 (number, range<number>)",Bo("The first value or range to consider when calculating the average value.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to consider when calculating the average value."))],compute:function(...e){let t=0;const o=nn(e,((e,o)=>(t+=1,e+o)),0,this.locale);return Wi(t),{value:o/t,format:Ni(e[0])}},isExported:!0},lg={description:Bo("Average of values depending on criteria."),args:[ad("criteria_range (number, range<number>)",Bo("The range to check against criterion.")),ad("criterion (string)",Bo("The pattern or test to apply to criteria_range.")),ad("average_range (number, range<number>, default=criteria_range)",Bo("The range to average. If not included, criteria_range is used for the average instead."))],compute:function(e,t,o){const s=Sn(void 0===o?e:o);let i=0,n=0;return pn([e,t],((e,t)=>{const o=s[e]?.[t]?.value;"number"==typeof o&&(i+=1,n+=o)}),this.locale),Wi(i),n/i},isExported:!0},cg={description:Bo("Average of values depending on multiple criteria."),args:[ad("average_range (range)",Bo("The range to average.")),ad("criteria_range1 (range)",Bo("The range to check against criterion1.")),ad("criterion1 (string)",Bo("The pattern or test to apply to criteria_range1.")),ad("criteria_range2 (any, range, repeating)",Bo("Additional criteria_range and criterion to check.")),ad("criterion2 (string, repeating)",Bo("The pattern or test to apply to criteria_range2."))],compute:function(e,...t){const o=Sn(e);let s=0,i=0;return pn(t,((e,t)=>{const n=o[e]?.[t]?.value;"number"==typeof n&&(s+=1,i+=n)}),this.locale),Wi(s),i/s},isExported:!0},hg={description:Bo("The number of numeric values in dataset."),args:[ad("value1 (number, any, range<number>)",Bo("The first value or range to consider when counting.")),ad("value2 (number, any, range<number>, repeating)",Bo("Additional values or ranges to consider when counting."))],compute:function(...e){return Tl(e,this.locale)},isExported:!0},dg={description:Bo("The number of values in a dataset."),args:[ad("value1 (any, range)",Bo("The first value or range to consider when counting.")),ad("value2 (any, range, repeating)",Bo("Additional values or ranges to consider when counting."))],compute:function(...e){return Al(e)},isExported:!0},ug={description:Bo("The covariance of a dataset."),args:[ad("data_y (any, range)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (any, range)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Qu(e,t,!1)},isExported:!0},gg={description:Bo("The covariance of a dataset."),args:[ad("data_y (any, range)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (any, range)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Qu(e,t,!1)},isExported:!0},pg={description:Bo("The sample covariance of a dataset."),args:[ad("data_y (any, range)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (any, range)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Qu(e,t,!0)},isExported:!0},mg={description:Bo("Calculates the expected y-value for a specified x based on a linear regression of a dataset."),args:[ad("x (number, range<number>)",Bo("The value(s) on the x-axis to forecast.")),ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t,o){const{flatDataX:s,flatDataY:i}=Ju(t,o);return Ul(s,i),Ll([i],[s],an(Sn(e),(e=>Li(e,this.locale))),!0)},isExported:!0},fg={description:Bo("Fits points to exponential growth trend."),args:[ad("known_data_y (range<number>)",Bo("The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.")),ad("known_data_x (range<number>, default={1;2;3;...})",Bo("The values of the independent variable(s) corresponding with known_data_y.")),ad("new_data_x (any, range, default=known_data_x)",Bo("The data points to return the y values for on the ideal curve fit.")),ad("b (boolean, default=TRUE)",Bo("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."))],compute:function(e,t=[[]],o=[[]],s={value:!0}){return Hl(e,"known_data_y"),kl(Ll(Vl(Ui(e,"known_data_y")),Ui(t,"known_data_x"),Ui(o,"new_data_y"),Yi(s)))}},vg={description:Bo("Compute the intercept of the linear regression."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Ju(e,t);Ul(o,s);const[[],[i]]=Fl([o],[s]);return i},isExported:!0},bg={description:Bo("Nth largest element from a data set."),args:[ad("data (any, range)",Bo("Array or range containing the dataset to consider.")),ad("n (number)",Bo("The rank from largest to smallest of the element to return."))],compute:function(e,t){const o=Math.trunc(Li(t?.value,this.locale));let s,i=[],n=0;Qi([e],(e=>{"number"==typeof e?.value&&(s=mn(i,e,"nextSmaller","asc",i.length,((e,t)=>e[t].value)),i.splice(s+1,0,e),n++,n>o&&(i.shift(),n--))}));const r=i.shift();return Pi((()=>void 0!==r),Bo("[[FUNCTION_NAME]] has no valid input data.")),Pi((()=>n>=o),Bo("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o)),r},isExported:!0},Sg={description:Bo("Given partial data about a linear trend, calculates various parameters about the ideal linear trend using the least-squares method."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>, default={1;2;3;...})",Bo("The range representing the array or matrix of independent data.")),ad("calculate_b (boolean, default=TRUE)",Bo("A flag specifying wheter to compute the slope or not")),ad("verbose (boolean, default=FALSE)",Bo("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept"))],compute:function(e,t=[[]],o={value:!0},s={value:!1}){return Hl(e,"data_y"),Fl(Ui(t,"data_x"),Ui(e,"data_y"),Yi(o),Yi(s))},isExported:!0},yg={description:Bo("Given partial data about an exponential growth curve, calculates various parameters about the best fit ideal exponential growth curve."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>, optional, default={1;2;3;...})",Bo("The range representing the array or matrix of independent data.")),ad("calculate_b (boolean, default=TRUE)",Bo("A flag specifying wheter to compute the slope or not")),ad("verbose (boolean, default=FALSE)",Bo("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept"))],compute:function(e,t=[[]],o={value:!0},s={value:!1}){Hl(e,"data_y");const i=Fl(Ui(t,"data_x"),Vl(Ui(e,"data_y")),Yi(o),Yi(s));for(let e=0;e<i.length;e++)i[e][0]=Math.exp(i[e][0]);return i},isExported:!0},Cg={description:Bo("Compute the Matthews correlation coefficient of a dataset."),args:[ad("data_x (range)",Bo("The range representing the array or matrix of observed data.")),ad("data_y (range)",Bo("The range representing the array or matrix of predicted data."))],compute:function(e,t){const o=e.flat(),s=t.flat();Il(o,s),Ul(o,s);const i=o.length;let n=0,r=0,a=0,l=0;for(let e=0;e<i;++e){const t=Yi(o[e]);t===Yi(s[e])?t?r++:n++:t?l++:a++}return(r*n-a*l)/Math.sqrt((r+a)*(r+l)*(n+a)*(n+l))},isExported:!1},wg={description:Bo("Maximum value in a numeric dataset."),args:[ad("value1 (number, range<number>)",Bo("The first value or range to consider when calculating the maximum value.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to consider when calculating the maximum value."))],compute:function(...e){return _l(e,this.locale)},isExported:!0},xg={description:Bo("Maximum numeric value in a dataset."),args:[ad("value1 (any, range)",Bo("The first value or range to consider when calculating the maximum value.")),ad("value2 (any, range, repeating)",Bo("Additional values or ranges to consider when calculating the maximum value."))],compute:function(...e){const t=nn(e,((e,t)=>Math.max(t,e)),-1/0,this.locale);return{value:t===-1/0?0:t,format:Ni(e[0])}},isExported:!0},Eg={description:Bo("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:[ad("range (range)",Bo("The range of cells from which the maximum will be determined.")),ad("criteria_range1 (range)",Bo("The range of cells over which to evaluate criterion1.")),ad("criterion1 (string)",Bo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),ad("criteria_range2 (any, range, repeating)",Bo("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),ad("criterion2 (string, repeating)",Bo("The pattern or test to apply to criteria_range2."))],compute:function(e,...t){let o=-1/0;return pn(t,((t,s)=>{const i=e[t]?.[s]?.value;"number"==typeof i&&(o=o<i?i:o)}),this.locale),o===-1/0?0:o},isExported:!0},Ig={description:Bo("Median value in a numeric dataset."),args:[ad("value1 (any, range)",Bo("The first value or range to consider when calculating the median value.")),ad("value2 (any, range, repeating)",Bo("Additional values or ranges to consider when calculating the median value."))],compute:function(...e){let t=[];return en(e,(e=>{t.push(e)}),this.locale),{value:tg(t,{value:.5},!0,this.locale),format:Ni(t[0])}},isExported:!0},Rg={description:Bo("Minimum value in a numeric dataset."),args:[ad("value1 (number, range<number>)",Bo("The first value or range to consider when calculating the minimum value.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to consider when calculating the minimum value."))],compute:function(...e){return Dl(e,this.locale)},isExported:!0},Tg={description:Bo("Minimum numeric value in a dataset."),args:[ad("value1 (number, range<number>)",Bo("The first value or range to consider when calculating the minimum value.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to consider when calculating the minimum value."))],compute:function(...e){const t=nn(e,((e,t)=>Math.min(t,e)),1/0,this.locale);return{value:t===1/0?0:t,format:Ni(e[0])}},isExported:!0},Ag={description:Bo("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:[ad("range (range)",Bo("The range of cells from which the minimum will be determined.")),ad("criteria_range1 (range)",Bo("The range of cells over which to evaluate criterion1.")),ad("criterion1 (string)",Bo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),ad("criteria_range2 (any, range, repeating)",Bo("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),ad("criterion2 (string, repeating)",Bo("The pattern or test to apply to criteria_range2."))],compute:function(e,...t){let o=1/0;return pn(t,((t,s)=>{const i=e[t]?.[s]?.value;"number"==typeof i&&(o=o>i?i:o)}),this.locale),o===1/0?0:o},isExported:!0};function _g(e,t){const{flatDataX:o,flatDataY:s}=Ju(e,t);Ul(o,s);const i=o.length;let n=0,r=0,a=0,l=0,c=0;for(let e=0;e<i;e++){const t=o[e],i=s[e];n+=t,r+=i,a+=t*i,l+=t*t,c+=i*i}return(i*a-n*r)/Math.sqrt((i*l-n*n)*(i*c-r*r))}const Dg={description:Bo("Compute the Pearson product-moment correlation coefficient of a dataset."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){return _g(e,t)},isExported:!0},Og=Dg,Fg={description:Bo("Value at a given percentile of a dataset."),args:[ad("data (any, range)",Bo("The array or range containing the dataset to consider.")),ad("percentile (number)",Bo("The percentile whose value within data will be calculated and returned."))],compute:function(e,t){return Pg.compute.bind(this)(e,t)},isExported:!0},Mg={description:Bo("Value at a given percentile of a dataset exclusive of 0 and 1."),args:[ad("data (any, range)",Bo("The array or range containing the dataset to consider.")),ad("percentile (number)",Bo("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned."))],compute:function(e,t){return{value:tg([e],t,!1,this.locale),format:Ni(e)}},isExported:!0},Pg={description:Bo("Value at a given percentile of a dataset."),args:[ad("data (any, range)",Bo("The array or range containing the dataset to consider.")),ad("percentile (number)",Bo("The percentile whose value within data will be calculated and returned."))],compute:function(e,t){return{value:tg([e],t,!0,this.locale),format:Ni(e)}},isExported:!0},Ng={description:Bo("Compute the coefficients of polynomial regression of the dataset."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data.")),ad("order (number)",Bo("The order of the polynomial to fit the data, between 1 and 6.")),ad("intercept (boolean, default=TRUE)",Bo("A flag specifying whether to compute the intercept or not."))],compute:function(e,t,o,s={value:!0}){const{flatDataX:i,flatDataY:n}=Ju(e,t);return Ul(i,n),Ml(n,i,Li(o,this.locale),Yi(s))},isExported:!1},kg={description:Bo("Predict value by computing a polynomial regression of the dataset."),args:[ad("x (number, range<number>)",Bo("The value(s) on the x-axis to forecast.")),ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data.")),ad("order (number)",Bo("The order of the polynomial to fit the data, between 1 and 6.")),ad("intercept (boolean, default=TRUE)",Bo("A flag specifying whether to compute the intercept or not."))],compute:function(e,t,o,s,i={value:!0}){const n=Li(s,this.locale),{flatDataX:r,flatDataY:a}=Ju(t,o);Ul(r,a);const l=Ml(a,r,n,Yi(i)).flat();return an(Sn(e),(e=>Nl(l,Li(e,this.locale),n)))},isExported:!1},Vg={description:Bo("Value nearest to a specific quartile of a dataset."),args:[ad("data (any, range)",Bo("The array or range containing the dataset to consider.")),ad("quartile_number (number)",Bo("Which quartile value to return."))],compute:function(e,t){return Hg.compute.bind(this)(e,t)},isExported:!0},Lg={description:Bo("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:[ad("data (any, range)",Bo("The array or range containing the dataset to consider.")),ad("quartile_number (number)",Bo("Which quartile value, exclusive of 0 and 4, to return."))],compute:function(e,t){return{value:tg([e],{value:.25*Math.trunc(Li(t,this.locale))},!1,this.locale),format:Ni(e)}},isExported:!0},Hg={description:Bo("Value nearest to a specific quartile of a dataset."),args:[ad("data (any, range)",Bo("The array or range containing the dataset to consider.")),ad("quartile_number (number)",Bo("Which quartile value to return."))],compute:function(e,t){return{value:tg([e],{value:.25*Math.trunc(Li(t,this.locale))},!0,this.locale),format:Ni(e)}},isExported:!0},Ug={description:Bo("Returns the rank of a specified value in a dataset."),args:[ad("value (number)",Bo("The value whose rank will be determined.")),ad("data (range)",Bo("The range containing the dataset to consider.")),ad("is_ascending (boolean, default=FALSE)",Bo("Whether to consider the values in data in descending or ascending order."))],compute:function(e,t,o={value:!1}){const s=Yi(o),i=Li(e,this.locale);let n=1,r=!1;for(const e of t)for(const t of e){if("number"!=typeof t.value)continue;const e=Li(t,this.locale);e===i?r=!0:e>i!==s&&n++}return r?n:new Di(Bo("Value not found in the given data."))},isExported:!0},Bg={description:Bo("Compute the square of r, the Pearson product-moment correlation coefficient of a dataset."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Math.pow(_g(t,e),2)},isExported:!0},zg={description:Bo("Compute the slope of the linear regression."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Ju(e,t);Ul(o,s);const[[i]]=Fl([o],[s]);return i},isExported:!0},$g={description:Bo("Nth smallest element in a data set."),args:[ad("data (any, range)",Bo("The array or range containing the dataset to consider.")),ad("n (number)",Bo("The rank from smallest to largest of the element to return."))],compute:function(e,t){const o=Math.trunc(Li(t?.value,this.locale));let s,i=[],n=0;Qi([e],(e=>{"number"==typeof e?.value&&(s=mn(i,e,"nextSmaller","asc",i.length,((e,t)=>e[t].value)),i.splice(s+1,0,e),n++,n>o&&(i.pop(),n--))}));const r=i.pop();return Pi((()=>void 0!==r),Bo("[[FUNCTION_NAME]] has no valid input data.")),Pi((()=>n>=o),Bo("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o)),r},isExported:!0},Gg={description:Bo("Compute the Spearman rank correlation coefficient of a dataset."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Ju(t,e);Ul(o,s);const i=o.length,n=o.map(((e,t)=>[e,s[t]]));n.sort(((e,t)=>e[0]-t[0]));for(let e=0;e<i;++e)n[e][0]=e;n.sort(((e,t)=>e[1]-t[1]));let r=0;for(let e=0;e<i;++e)r+=(n[e][0]-e)**2;return 1-6*r/(i**3-i)},isExported:!1},Wg={description:Bo("Standard deviation."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the sample.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the sample."))],compute:function(...e){return Math.sqrt(Qg.compute.bind(this)(...e))},isExported:!0},qg={description:Bo("Standard deviation of entire population."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the population.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the population."))],compute:function(...e){return Math.sqrt(ep.compute.bind(this)(...e))},isExported:!0},Zg={description:Bo("Standard deviation."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the sample.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the sample."))],compute:function(...e){return Math.sqrt(tp.compute.bind(this)(...e))},isExported:!0},jg={description:Bo("Standard deviation of sample (text as 0)."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the sample.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the sample."))],compute:function(...e){return Math.sqrt(op.compute.bind(this)(...e))},isExported:!0},Yg={description:Bo("Standard deviation of entire population."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the population.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the population."))],compute:function(...e){return Math.sqrt(sp.compute.bind(this)(...e))},isExported:!0},Xg={description:Bo("Standard deviation of entire population (text as 0)."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the population.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the population."))],compute:function(...e){return Math.sqrt(ip.compute.bind(this)(...e))},isExported:!0},Kg={description:Bo("Calculates the standard error of the predicted y-value for each x in the regression of a dataset."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Ju(e,t);Ul(o,s);return Fl([o],[s],!0,!0)[1][2]},isExported:!0},Jg={description:Bo("Fits points to linear trend derived via least-squares."),args:[ad("known_data_y (number, range<number>)",Bo("The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.")),ad("known_data_x (number, range<number>, optional, default={1;2;3;...})",Bo("The values of the independent variable(s) corresponding with known_data_y.")),ad("new_data_x (number, range<number>, optional, default=known_data_x)",Bo("The data points to return the y values for on the ideal curve fit.")),ad("b (boolean, optional, default=TRUE)",Bo("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."))],compute:function(e,t=[[]],o=[[]],s={value:!0}){return Hl(e,"known_data_y"),Ll(Ui(e,"known_data_y"),Ui(t,"known_data_x"),Ui(o,"new_data_y"),Yi(s))}},Qg={description:Bo("Variance."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the sample.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the sample."))],compute:function(...e){return eg(e,!0,!1,this.locale)},isExported:!0},ep={description:Bo("Variance of entire population."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the population.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the population."))],compute:function(...e){return eg(e,!1,!1,this.locale)},isExported:!0},tp={description:Bo("Variance."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the sample.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the sample."))],compute:function(...e){return eg(e,!0,!1,this.locale)},isExported:!0},op={description:Bo("Variance of sample (text as 0)."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the sample.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the sample."))],compute:function(...e){return eg(e,!0,!0,this.locale)},isExported:!0},sp={description:Bo("Variance of entire population."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the population.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the population."))],compute:function(...e){return eg(e,!1,!1,this.locale)},isExported:!0},ip={description:Bo("Variance of entire population (text as 0)."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the population.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the population."))],compute:function(...e){return eg(e,!1,!0,this.locale)},isExported:!0};var np=Object.freeze({__proto__:null,AVEDEV:og,AVERAGE:sg,AVERAGEA:ag,AVERAGEIF:lg,AVERAGEIFS:cg,AVERAGE_WEIGHTED:rg,CORREL:Og,COUNT:hg,COUNTA:dg,COVAR:ug,COVARIANCE_P:gg,COVARIANCE_S:pg,FORECAST:mg,GROWTH:fg,INTERCEPT:vg,LARGE:bg,LINEST:Sg,LOGEST:yg,MATTHEWS:Cg,MAX:wg,MAXA:xg,MAXIFS:Eg,MEDIAN:Ig,MIN:Rg,MINA:Tg,MINIFS:Ag,PEARSON:Dg,PERCENTILE:Fg,PERCENTILE_EXC:Mg,PERCENTILE_INC:Pg,POLYFIT_COEFFS:Ng,POLYFIT_FORECAST:kg,QUARTILE:Vg,QUARTILE_EXC:Lg,QUARTILE_INC:Hg,RANK:Ug,RSQ:Bg,SLOPE:zg,SMALL:$g,SPEARMAN:Gg,STDEV:Wg,STDEVA:jg,STDEVP:Yg,STDEVPA:Xg,STDEV_P:qg,STDEV_S:Zg,STEYX:Kg,TREND:Jg,VAR:Qg,VARA:op,VARP:sp,VARPA:ip,VAR_P:ep,VAR_S:tp});function rp(e,t,o,s){const i=new Map,n=e.length;for(let t=n-1;t>=0;t--)i.set(qi(e[t][0]).toUpperCase(),t);const r=t?.value;if("number"!=typeof r&&"string"!=typeof r)throw new Ri(Bo("The field must be a number or a string"));let a;if("number"==typeof r){if(a=Math.trunc(r)-1,a<0||n-1<a)throw new Ri(Bo("The field (%(fieldValue)s) must be one of %(dimRowDB)s or must be a number between 1 and %s inclusive.",{fieldValue:r.toString(),dimRowDB:n.toString()}))}else{const e=qi(t).toUpperCase();if(a=i.get(e)??-1,-1===a)throw new Ri(Bo("The field (%s) must be one of %s.",qi(t),[...i.keys()].toString()))}const l=o[0].length;if(l<2)throw new Ri(Bo("The criteria range contains %s row, it must be at least 2 rows.",l.toString()));let c=new Set;const h=e[0].length;for(let t=1;t<l;t++){let n=[],r=!0;for(let s=0;s<o.length;s++){const a=qi(o[s][0]).toUpperCase(),l=i.get(a),c=o[s][t];if(null!==c.value){if(void 0===l){r=!1;break}n.push([e[l].slice(1,h)]),n.push(c)}}if(r){if(!(n.length>0)){c=new Set(Array(h-1).keys());break}pn(n,((e,t)=>{c.add(t)}),s,!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const ap=[ad("database (range)",Bo("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.")),ad("field (number, string)",Bo("Indicates which column in database contains the values to be extracted and operated on.")),ad("criteria (range)",Bo("An array or range containing zero or more criteria to filter the database values by before operating."))],lp={description:Bo("Average of a set of values from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return sg.compute.bind(this)([s])},isExported:!0},cp={description:Bo("Counts values from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return hg.compute.bind(this)([s])},isExported:!0},hp={description:Bo("Counts values and text from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return dg.compute.bind(this)([s])},isExported:!0},dp={description:Bo("Single value from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return Pi((()=>1===s.length),Bo("More than one match found in DGET evaluation.")),s[0]},isExported:!0},up={description:Bo("Maximum of values from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return wg.compute.bind(this)([s])},isExported:!0},gp={description:Bo("Minimum of values from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return Rg.compute.bind(this)([s])},isExported:!0},pp={description:Bo("Product of values from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return Du.compute.bind(this)([s])},isExported:!0},mp={description:Bo("Standard deviation of population sample from table."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return Wg.compute.bind(this)([s])},isExported:!0},fp={description:Bo("Standard deviation of entire population from table."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return Yg.compute.bind(this)([s])},isExported:!0},vp={description:Bo("Sum of values from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return $u.compute.bind(this)([s])},isExported:!0},bp={description:Bo("Variance of population sample from table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return Qg.compute.bind(this)([s])},isExported:!0},Sp={description:Bo("Variance of a population from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return sp.compute.bind(this)([s])},isExported:!0};var yp=Object.freeze({__proto__:null,DAVERAGE:lp,DCOUNT:cp,DCOUNTA:hp,DGET:dp,DMAX:up,DMIN:gp,DPRODUCT:pp,DSTDEV:mp,DSTDEVP:fp,DSUM:vp,DVAR:bp,DVARP:Sp});var Cp;!function(e){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"}(Cp||(Cp={}));const wp={description:Bo("Converts year/month/day into a date."),args:[ad("year (number)",Bo("The year component of the date.")),ad("month (number)",Bo("The month component of the date.")),ad("day (number)",Bo("The day component of the date."))],compute:function(e,t,o){let s=Math.trunc(Li(e,this.locale));const i=Math.trunc(Li(t,this.locale)),n=Math.trunc(Li(o,this.locale));Pi((()=>0<=s&&s<=9999),Bo("The year (%s) must be between 0 and 9999 inclusive.",s.toString())),s<1900&&(s+=1900);const r=Bs(new xs(s,i-1,n));return Pi((()=>r>=0),Bo("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),{value:r,format:this.locale.dateFormat}},isExported:!0},xp={description:Bo("Calculates the number of days, months, or years between two dates."),args:[ad("start_date (date)",Bo("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.")),ad("end_date (date)",Bo("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.")),ad("unit (string)",Bo('A text abbreviation for unit of time. Accepted values are "Y" (the number of whole years between start_date and end_date), "M" (the number of whole months between start_date and end_date), "D" (the number of days between start_date and end_date), "MD" (the number of days between start_date and end_date after subtracting whole months), "YM" (the number of whole months between start_date and end_date after subtracting whole years), "YD" (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,o){const s=qi(o).toUpperCase();Pi((()=>Object.values(Cp).includes(s)),((e,t)=>{const o=e.map((e=>`'${e}'`)).join(", ");return Bo("The function [[FUNCTION_NAME]] has an argument with value '%s'. It should be one of: %s.",t,o)})(Object.values(Cp),qi(o)));const i=Math.trunc(Li(e,this.locale)),n=Math.trunc(Li(t,this.locale)),r=Us(i),a=Us(n);switch(Pi((()=>n>=i),Bo("start_date (%s) should be on or before end_date (%s).",r.toLocaleDateString(),a.toLocaleDateString())),s){case Cp.WHOLE_YEARS:return Xs(r,a);case Cp.WHOLE_MONTHS:return js(r,a);case Cp.WHOLE_DAYS:return Ys(r,a);case Cp.MONTH_WITHOUT_WHOLE_YEARS:return js(r,a)-12*Xs(r,a);case Cp.DAYS_WITHOUT_WHOLE_MONTHS:let e=a.getDate()-r.getDate();if(e<0){e=$s(new xs(a.getFullYear(),a.getMonth()-1,1))-Math.abs(e)}return e;case Cp.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR:{if(function(e,t){return Zs(e,t,1)<1}(i,n))return Ys(r,a);const e=new xs(r.getFullYear(),a.getMonth(),a.getDate());let t=Ys(r,e);return t<0&&(e.setFullYear(r.getFullYear()+1),t=Ys(r,e)),t}}},isExported:!0},Ep={description:Bo("Converts a date string to a date value."),args:[ad("date_string (string)",Bo("The string representing the date."))],compute:function(e){const t=qi(e),o=Hs(t,this.locale);return Pi((()=>null!==o),Bo("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(o.value)},isExported:!0},Ip={description:Bo("Day of the month that a specific date falls on."),args:[ad("date (string)",Bo("The date from which to extract the day."))],compute:function(e){return Xi(e,this.locale).getDate()},isExported:!0},Rp={description:Bo("Number of days between two dates."),args:[ad("end_date (date)",Bo("The end of the date range.")),ad("start_date (date)",Bo("The start of the date range."))],compute:function(e,t){const o=Xi(e,this.locale),s=Xi(t,this.locale),i=o.getTime()-s.getTime();return Math.round(i/Is)},isExported:!0},Tp={description:Bo("Number of days between two dates on a 360-day year (months of 30 days)."),args:[ad("start_date (date)",Bo("The start date to consider in the calculation.")),ad("end_date (date)",Bo("The end date to consider in the calculation.")),ad("method (number, default=0)",Bo("An indicator of what day count method to use. (0) US NASD method (1) European method"))],compute:function(e,t,o={value:0}){const s=Math.trunc(Li(e,this.locale)),i=Math.trunc(Li(t,this.locale)),n=Zs(s,i,Yi(o)?4:0);return Math.sign(i-s)*Math.round(360*n)},isExported:!0},Ap={description:Bo("Date a number of months before/after another date."),args:[ad("start_date (date)",Bo("The date from which to calculate the result.")),ad("months (number)",Bo("The number of months before (negative) or after (positive) 'start_date' to calculate."))],compute:function(e,t){return{value:Bs(Ws(Xi(e,this.locale),Math.trunc(Li(t,this.locale)),!1)),format:this.locale.dateFormat}},isExported:!0},_p={description:Bo("Last day of a month before or after a date."),args:[ad("start_date (date)",Bo("The date from which to calculate the result.")),ad("months (number)",Bo("The number of months before (negative) or after (positive) 'start_date' to consider."))],compute:function(e,t){const o=Xi(e,this.locale),s=Math.trunc(Li(t,this.locale)),i=o.getFullYear(),n=o.getMonth();return{value:Bs(new xs(i,n+s+1,0)),format:this.locale.dateFormat}},isExported:!0},Dp={description:Bo("Hour component of a specific time."),args:[ad("time (date)",Bo("The time from which to calculate the hour component."))],compute:function(e){return Xi(e,this.locale).getHours()},isExported:!0},Op={description:Bo("ISO week number of the year."),args:[ad("date (date)",Bo("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){const t=Xi(e,this.locale),o=t.getFullYear();let s=1;for(;4!==new xs(o,0,s).getDay();)s+=1;const i=new xs(o,0,s-3);let n=31;for(;4!==new xs(o,11,n).getDay();)n-=1;const r=new xs(o,11,n+3);let a,l;switch(a=i.getTime()<=t.getTime()?t.getTime()<=r.getTime()?0:1:-1,a){case 0:l=i;break;case 1:l=new xs(o,11,n+3+1);break;case-1:let e=1;for(;4!==new xs(o-1,0,e).getDay();)e+=1;l=new xs(o-1,0,e-3)}const c=(t.getTime()-l.getTime())/Is;return Math.floor(c/7)+1},isExported:!0},Fp={description:Bo("Minute component of a specific time."),args:[ad("time (date)",Bo("The time from which to calculate the minute component."))],compute:function(e){return Xi(e,this.locale).getMinutes()},isExported:!0},Mp={description:Bo("Month of the year a specific date falls in"),args:[ad("date (date)",Bo("The date from which to extract the month."))],compute:function(e){return Xi(e,this.locale).getMonth()+1},isExported:!0},Pp={description:Bo("Net working days between two provided days."),args:[ad("start_date (date)",Bo("The start date of the period from which to calculate the number of net working days.")),ad("end_date (date)",Bo("The end date of the period from which to calculate the number of net working days.")),ad("holidays (date, range<date>, optional)",Bo("A range or array constant containing the date serial numbers to consider holidays."))],compute:function(e,t,o){return kp.compute.bind(this)(e,t,{value:1},o)},isExported:!0};function Np(e){const t=e?.value;if("string"==typeof t){Pi((()=>{if(7!==t.length)return!1;for(let e of t)if("0"!==e&&"1"!==e)return!1;return!0}),Bo('When weekend is a string (%s) it must be composed of "0" or "1".',t));let e=[];for(let o=0;o<7;o++)"1"===t[o]&&e.push((o+1)%7);return e}if("number"==typeof t)return Pi((()=>1<=t&&t<=7||11<=t&&t<=17),Bo("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 Ri(Bo("The weekend must be a number or a string."))}const kp={description:Bo("Net working days between two dates (specifying weekends)."),args:[ad("start_date (date)",Bo("The start date of the period from which to calculate the number of net working days.")),ad("end_date (date)",Bo("The end date of the period from which to calculate the number of net working days.")),ad("weekend (any, default=1)",Bo("A number or string representing which days of the week are considered weekends.")),ad("holidays (date, range<date>, optional)",Bo("A range or array constant containing the dates to consider as holidays."))],compute:function(e,t,o={value:1},s){const i=Xi(e,this.locale),n=Xi(t,this.locale),r=Np(o);let a=new Set;void 0!==s&&Qi([s],(e=>{const t=Xi(e,this.locale);a.add(t.getTime())}));const l=i.getTime()>n.getTime(),c=xs.fromTimestamp((l?i:n).getTime());let h=xs.fromTimestamp((l?n:i).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)r.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},Vp={description:Bo("Current date and time as a date value."),args:[],compute:function(){const e=xs.now(),t=e.getTime()-Es.getTime(),o=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return{value:Math.floor(t/Is)+o,format:gl(this.locale)}},isExported:!0},Lp={description:Bo("Minute component of a specific time."),args:[ad("time (date)",Bo("The time from which to calculate the second component."))],compute:function(e){return Xi(e,this.locale).getSeconds()},isExported:!0},Hp={description:Bo("Converts hour/minute/second into a time."),args:[ad("hour (number)",Bo("The hour component of the time.")),ad("minute (number)",Bo("The minute component of the time.")),ad("second (number)",Bo("The second component of the time."))],compute:function(e,t,o){let s=Math.trunc(Li(e,this.locale)),i=Math.trunc(Li(t,this.locale)),n=Math.trunc(Li(o,this.locale));return i+=Math.floor(n/60),n=n%60+(n<0?60:0),s+=Math.floor(i/60),i=i%60+(i<0?60:0),s%=24,Pi((()=>s>=0),Bo("The function [[FUNCTION_NAME]] result cannot be negative")),{value:s/24+i/1440+n/86400,format:this.locale.timeFormat}},isExported:!0},Up={description:Bo("Converts a time string into its serial number representation."),args:[ad("time_string (string)",Bo("The string that holds the time representation."))],compute:function(e){const t=qi(e),o=Hs(t,this.locale);Pi((()=>null!==o),Bo("The time_string (%s) cannot be parsed to date/time.",t));const s=o.value-Math.trunc(o.value);return s<0?1+s:s},isExported:!0},Bp={description:Bo("Current date as a date value."),args:[],compute:function(){const e=xs.now();return{value:Bs(new xs(e.getFullYear(),e.getMonth(),e.getDate())),format:this.locale.dateFormat}},isExported:!0},zp={description:Bo("Day of the week of the date provided (as number)."),args:[ad("date (date)",Bo("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.")),ad("type (number, default=1)",Bo("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1."))],compute:function(e,t={value:1}){const o=Xi(e,this.locale),s=Math.round(Li(t,this.locale)),i=o.getDay();return Pi((()=>[1,2,3].includes(s)),Bo("The type (%s) must be 1, 2 or 3.",s.toString())),1===s?i+1:2===s?0===i?7:i:0===i?6:i-1},isExported:!0},$p={description:Bo("Week number of the year."),args:[ad("date (date)",Bo("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.")),ad("type (number, default=1)",Bo("A number representing the day that a week starts on. Sunday = 1."))],compute:function(e,t={value:1}){const o=Xi(e,this.locale),s=Math.round(Li(t,this.locale));if(Pi((()=>1===s||2===s||11<=s&&s<=17||21===s),Bo("The type (%s) is out of range.",s.toString())),21===s)return Op.compute.bind(this)(e);let i;i=1===s||2===s?s-1:s-10==7?0:s-10;const n=o.getFullYear();let r=1,a=new xs(n,0,r);for(;a.getDay()!==i;)r+=1,a=new xs(n,0,r);const l=(o.getTime()-a.getTime())/Is;return l<0?1:Math.floor(l/7)+(1===r?1:2)},isExported:!0},Gp={description:Bo("Date after a number of workdays."),args:[ad("start_date (date)",Bo("The date from which to begin counting.")),ad("num_days (number)",Bo("The number of working days to advance from start_date. If negative, counts backwards.")),ad("holidays (date, range<date>, optional)",Bo("A range or array constant containing the dates to consider holidays."))],compute:function(e,t,o={value:null}){return Wp.compute.bind(this)(e,t,{value:1},o)},isExported:!0},Wp={description:Bo("Date after a number of workdays (specifying weekends)."),args:[ad("start_date (date)",Bo("The date from which to begin counting.")),ad("num_days (number)",Bo("The number of working days to advance from start_date. If negative, counts backwards.")),ad("weekend (any, default=1)",Bo("A number or string representing which days of the week are considered weekends.")),ad("holidays (date, range<date>, optional)",Bo("A range or array constant containing the dates to consider holidays."))],compute:function(e,t,o={value:1},s){let i=Xi(e,this.locale),n=Math.trunc(Li(t,this.locale));"string"==typeof o.value&&Pi((()=>"1111111"!==o.value),Bo("The weekend must be different from '1111111'."));const r=Np(o);let a=new Set;void 0!==s&&Qi([s],(e=>{const t=Xi(e,this.locale);a.add(t.getTime())}));let l=xs.fromTimestamp(i.getTime()),c=l.getTime();const h=Math.sign(n);let d=Math.abs(n);for(;d>0;)l.setDate(l.getDate()+h),c=l.getTime(),r.includes(l.getDay())||a.has(c)||(d-=1);const u=c-Es.getTime();return{value:Math.round(u/Is),format:this.locale.dateFormat}},isExported:!0},qp={description:Bo("Year specified by a given date."),args:[ad("date (date)",Bo("The date from which to extract the year."))],compute:function(e){return Xi(e,this.locale).getFullYear()},isExported:!0},Zp={description:Bo("Exact number of years between two dates."),args:[ad("start_date (date)",Bo("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.")),ad("end_date (date)",Bo("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.")),ad("day_count_convention (number, default=0)",Bo("An indicator of what day count method to use."))],compute:function(e,t,o={value:0}){let s=Math.trunc(Li(e,this.locale)),i=Math.trunc(Li(t,this.locale));const n=Math.trunc(Li(o,this.locale));return Pi((()=>s>=0),Bo("The start_date (%s) must be positive or null.",s.toString())),Pi((()=>i>=0),Bo("The end_date (%s) must be positive or null.",i.toString())),Pi((()=>0<=n&&n<=4),Bo("The day_count_convention (%s) must be between 0 and 4 inclusive.",n.toString())),Zs(s,i,n)}},jp={description:Bo("First day of the month preceding a date."),args:[ad("date (date)",Bo("The date from which to calculate the result."))],compute:function(e){const t=Xi(e,this.locale),o=t.getFullYear(),s=t.getMonth();return{value:Bs(new xs(o,s,1)),format:this.locale.dateFormat}}},Yp={description:Bo("Last day of the month following a date."),args:[ad("date (date)",Bo("The date from which to calculate the result."))],compute:function(e){return _p.compute.bind(this)(e,{value:0})}},Xp={description:Bo("Quarter of the year a specific date falls in"),args:[ad("date (date)",Bo("The date from which to extract the quarter."))],compute:function(e){return Math.ceil((Xi(e,this.locale).getMonth()+1)/3)}},Kp={description:Bo("First day of the quarter of the year a specific date falls in."),args:[ad("date (date)",Bo("The date from which to calculate the start of quarter."))],compute:function(e){const t=Xp.compute.bind(this)(e),o=qp.compute.bind(this)(e);return{value:Bs(new xs(o,3*(t-1),1)),format:this.locale.dateFormat}}},Jp={description:Bo("Last day of the quarter of the year a specific date falls in."),args:[ad("date (date)",Bo("The date from which to calculate the end of quarter."))],compute:function(e){const t=Xp.compute.bind(this)(e),o=qp.compute.bind(this)(e);return{value:Bs(new xs(o,3*t,0)),format:this.locale.dateFormat}}},Qp={description:Bo("First day of the year a specific date falls in."),args:[ad("date (date)",Bo("The date from which to calculate the start of the year."))],compute:function(e){const t=qp.compute.bind(this)(e);return{value:Bs(new xs(t,0,1)),format:this.locale.dateFormat}}},em={description:Bo("Last day of the year a specific date falls in."),args:[ad("date (date)",Bo("The date from which to calculate the end of the year."))],compute:function(e){const t=qp.compute.bind(this)(e);return{value:Bs(new xs(t+1,0,0)),format:this.locale.dateFormat}}};var tm=Object.freeze({__proto__:null,DATE:wp,DATEDIF:xp,DATEVALUE:Ep,DAY:Ip,DAYS:Rp,DAYS360:Tp,EDATE:Ap,EOMONTH:_p,HOUR:Dp,ISOWEEKNUM:Op,MINUTE:Fp,MONTH:Mp,MONTH_END:Yp,MONTH_START:jp,NETWORKDAYS:Pp,NETWORKDAYS_INTL:kp,NOW:Vp,QUARTER:Xp,QUARTER_END:Jp,QUARTER_START:Kp,SECOND:Lp,TIME:Hp,TIMEVALUE:Up,TODAY:Bp,WEEKDAY:zp,WEEKNUM:$p,WORKDAY:Gp,WORKDAY_INTL:Wp,YEAR:qp,YEARFRAC:Zp,YEAR_END:em,YEAR_START:Qp});const om={description:Bo("Compare two numeric values, returning 1 if they're equal."),args:[ad("number1 (number)",Bo("The first number to compare.")),ad("number2 (number, default=0)",Bo("The second number to compare."))],compute:function(e,t={value:0}){return Li(e,this.locale)===Li(t,this.locale)?1:0},isExported:!0};var sm=Object.freeze({__proto__:null,DELTA:om});const im=[ii.number,ii.error,ii.text,ii.boolean];function nm(e){const t="asc"===e?1:-1;return(e,o)=>{if(e.type===ii.empty)return o.type===ii.empty?0:1;if(o.type===ii.empty)return-1;let s=im.indexOf(e.type)-im.indexOf(o.type);return 0===s&&(s=e.type===ii.text||e.type===ii.error?e.value.localeCompare(o.value):e.value-o.value),t*s}}function rm(e,t,o,s,i){let n=s.right>s.left;if(e.model.getters.doesIntersectMerge(t,s)){let o;n=!1;for(let i=s.top;i<=s.bottom;i++){o=[];for(let n=s.left;n<=s.right;n++){let s=e.model.getters.getMerge({sheetId:t,col:n,row:i});s&&!o.includes(s.id.toString())&&o.push(s.id.toString())}if(o.length>=2){n=!0;break}}}if(n)return void am(e,t,o,s,i);const r=e.model.getters.getContiguousZone(t,s);es(r,s)?am(e,t,o,s,i):e.askConfirmation(Bo("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>am(e,t,o,r,i)),(()=>am(e,t,o,s,i)))}function am(e,t,o,s,i,n){const r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:o.col,row:o.row,zone:s,sortDirection:i,sortOptions:n});if(r.isCancelledBecause("InvalidSortZone")){const{col:t,row:i}=o;e.model.selection.selectZone({cell:{col:t,row:i},zone:s}),e.raiseError(Bo("Cannot sort. To sort, select only cells or only merges that have the same size."))}if(r.isCancelledBecause("SortZoneWithArrayFormulas")){const{col:t,row:i}=o;e.model.selection.selectZone({cell:{col:t,row:i},zone:s}),e.raiseError(Bo("Cannot sort a zone with array formulas."))}}function lm(e,t,...o){for(let e=0;e<o.length;e++){Pi((()=>void 0!==o[e]),Bo("Value for parameter %s is missing in [[FUNCTION_NAME]].",e%2==0?"sort_column":"is_ascending"))}const s=[],i=[],n=e.length;for(let r=0;r<o.length;r+=2){s.push(Yi(wl(o[r+1])?.value)?"asc":"desc");const a=o[r];if(yi(a)&&(a.length>1||a[0].length>1))Pi((()=>1===a.length&&a[0].length===n),Bo("Wrong size for %s. Expected a range of size 1x%s. Got %sx%s.",`sort_column${r+1}`,n,a.length,a[0].length)),i.push(a.flat().map((e=>e.value)));else{const o=Li(wl(a)?.value,t);if(o<1||o>e[0].length)return e;i.push(e.map((e=>e[o-1].value)))}}if(0===i.length)for(let t=0;t<e[0].length;t++)i.push(e.map((e=>e[t].value))),s.push("asc");const r={desc:nm("desc"),asc:nm("asc")},a=je(0,e.length);return a.sort(((e,t)=>{for(const[o,n]of i.entries()){const i=n[e],a=n[t],l={value:i,type:null===i?ii.empty:"string"==typeof i?ii.text:typeof i},c={value:a,type:null===a?ii.empty:"string"==typeof a?ii.text:typeof a},h=r[s[o]](l,c);if(0!==h)return h}return 0})),a.map((t=>e[t]))}const cm={description:Bo("Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions."),args:[ad("range (any, range<any>)",Bo("The data to be filtered.")),ad("condition1 (boolean, range<boolean>)",Bo("A column or row containing true or false values corresponding to the first column or row of range.")),ad("condition2 (boolean, range<boolean>, repeating)",Bo("Additional column or row containing true or false values."))],compute:function(e,...t){let o=Sn(e);const s=t.map((e=>an(Sn(e),(e=>e.value))));s.map((e=>cd(Bo("The arguments condition must be a single column or row."),e))),hd(Bo("The arguments conditions must have the same dimensions."),...t);const i=s.map((e=>e.flat())),n=1===s[0].length?"row":"col";o="row"===n?ln(o):o,Pi((()=>i.every((e=>e.length===o.length))),Bo("FILTER has mismatched sizes on the range and conditions."));const r=[];for(let e=0;e<o.length;e++){const t=o[e];i.every((t=>("boolean"==typeof t[e]||"number"==typeof t[e])&&t[e]))&&r.push(t)}return r.length?"row"===n?ln(r):r:new Di(Bo("No match found in FILTER evaluation"))},isExported:!1},hm={description:Bo("Sorts the rows of a given array or range by the values in one or more columns."),args:[ad("range (range)",Bo("The data to be sorted.")),ad("sort_column (any, range<number>, repeating)",Bo("The index of the column in range or a range outside of range containing the values by which to sort.")),ad("is_ascending (boolean, repeating)",Bo("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order."))],compute:function(e,...t){const o=ln(e);return ln(lm(o,this.locale,...t))},isExported:!0},dm={description:Bo("Returns the first n items in a data set after performing a sort."),args:[ad("range (range)",Bo("The data to be sorted.")),ad("n (number, default=1)",Bo("The number of items to return.")),ad("display_ties_mode (number, default=0)",Bo("A number representing the way to display ties.")),ad("sort_column (number, range<number>, repeating)",Bo("The index of the column in range or a range outside of range containing the values by which to sort.")),ad("is_ascending (boolean, repeating)",Bo("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order."))],compute:function(e,t,o,...s){const i=Li(t?.value??1,this.locale);Pi((()=>i>=0),Bo("Wrong value of 'n'. Expected a positive number. Got %s.",i));const n=Li(o?.value??0,this.locale);Pi((()=>n>=0&&n<=3),Bo("Wrong value of 'display_ties_mode'. Expected a positive number between 0 and 3. Got %s.",n));const r=lm(ln(e),this.locale,...s),a=(e,t)=>JSON.stringify(r[e].map((e=>e.value)))===JSON.stringify(r[t].map((e=>e.value)));switch(n){case 0:return ln(r.slice(0,i));case 1:for(let e=i;e<r.length;e++)if(!a(e,i-1))return ln(r.slice(0,e));return ln(r);case 2:{const e=[r[0]];for(let t=1;t<r.length;t++)for(let o=0;o<t&&!a(t,o);o++)o===t-1&&e.push(r[t]);return ln(e.slice(0,i))}case 3:{const e=[r[0]];let t=1;for(let o=1;o<r.length&&(a(o,o-1)||t++,!(t>i));o++)e.push(r[o]);return ln(e)}}},isExported:!1},um={description:Bo("Unique rows in the provided source range."),args:[ad("range (any, range<any>)",Bo("The data to filter by unique entries.")),ad("by_column (boolean, default=FALSE)",Bo("Whether to filter the data by columns or by rows.")),ad("exactly_once (boolean, default=FALSE)",Bo("Whether to return only entries with no duplicates."))],compute:function(e={value:""},t,o){if(!yi(e))return[[e]];const s=Yi(t?.value)||!1,i=Yi(o?.value)||!1;s||(e=ln(e));const n=new Map;for(const t of e){const e=JSON.stringify(t.map((e=>e.value))),o=n.get(e);o?o.count++:n.set(e,{data:t,count:1})}const r=[];for(const e of n.values())i&&e.count>1||r.push(e.data);return r.length?s?r:ln(r):new Ri(Bo("No unique values found"))},isExported:!0};var gm=Object.freeze({__proto__:null,FILTER:cm,SORT:hm,SORTN:dm,UNIQUE:um});function pm(e,t){Pi((()=>e<t),Bo("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function mm(e,t){Pi((()=>t<e),Bo("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function fm(e){Pi((()=>[1,2,4].includes(e)),Bo("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function vm(e){Pi((()=>0<=e&&e<=4),Bo("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function bm(e){Pi((()=>e>0),Bo("The redemption (%s) must be strictly positive.",e.toString()))}function Sm(e){Pi((()=>e>0),Bo("The price (%s) must be strictly positive.",e.toString()))}function ym(e){Pi((()=>e>0),Bo("The number_of_periods (%s) must be greater than 0.",e.toString()))}function Cm(e){Pi((()=>e>0),Bo("The rate (%s) must be strictly positive.",e.toString()))}function wm(e){Pi((()=>e>0),Bo("The life (%s) must be strictly positive.",e.toString()))}function xm(e){Pi((()=>e>=0),Bo("The cost (%s) must be positive or null.",e.toString()))}function Em(e){Pi((()=>e>0),Bo("The period (%s) must be strictly positive.",e.toString()))}function Im(e){Pi((()=>e>=0),Bo("The salvage (%s) must be positive or null.",e.toString()))}function Rm(e){Pi((()=>e>0),Bo("The present value (%s) must be strictly positive.",e.toString()))}function Tm(e,t){Pi((()=>e<=t),Bo("The period (%s) must be less than or equal life (%s).",e.toString(),t.toString()))}function Am(e){Pi((()=>e>0),Bo("The investment (%s) must be strictly positive.",e.toString()))}function _m(e){Pi((()=>e>0),Bo("The discount (%s) must be strictly positive.",e.toString()))}function Dm(e){Pi((()=>e<1),Bo("The discount (%s) must be smaller than 1.",e.toString()))}function Om(e){Pi((()=>e>0),Bo("The depreciation factor (%s) must be strictly positive.",e.toString()))}function Fm(e,t,o){const s=Xi(e,o),i=Xi(t,o),n=Xi(e,o);n.setFullYear(s.getFullYear()+1),Pi((()=>i.getTime()<=n.getTime()),Bo("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function Mm(e,t,o){ym(o),Pi((()=>e>0),Bo("The first_period (%s) must be strictly positive.",e.toString())),Pi((()=>t>0),Bo("The last_period (%s) must be strictly positive.",t.toString())),Pi((()=>e<=t),Bo("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),Pi((()=>t<=o),Bo("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),o.toString()))}function Pm(e){Pi((()=>e>-1),Bo("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function Nm(e,t){Pi((()=>e.length===t.length&&e[0].length===t[0].length),Bo("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function km(e){Pi((()=>e.every((t=>t>=e[0]))),Bo("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const Vm=[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("frequency (number)",Bo("The number of interest or coupon payments per year (1, 2, or 4).")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))];function Lm(e,t,o,s,i=1e-10,n){let r,a,l,c,h=o,d=!1,u=0;do{l=e(h),isNaN(l)?(Pi((()=>u<s&&void 0!==n),Bo("Function [[FUNCTION_NAME]] didn't find any result.")),u++,h=n(c),c=h):(r=h-l/t(h),a=Math.abs(r-h),h=r,d=a<i||Math.abs(l)<i,Pi((()=>u<s),Bo("Function [[FUNCTION_NAME]] didn't find any result.")),u++)}while(!d);return h}const Hm={description:Bo("Accrued interest of security paying at maturity."),args:[ad("issue (date)",Bo("The date the security was initially issued.")),ad("maturity (date)",Bo("The maturity date of the security.")),ad("rate (number)",Bo("The annualized rate of interest.")),ad("redemption (number)",Bo("The redemption amount per 100 face value, or par.")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){const n=Math.trunc(Li(e,this.locale)),r=Math.trunc(Li(t,this.locale)),a=Li(s,this.locale),l=Li(o,this.locale),c=Math.trunc(Li(i,this.locale));!function(e){Pi((()=>e>=0),Bo("The issue (%s) must be positive or null.",e.toString()))}(n),mm(r,n),vm(c),bm(a),Cm(l);return a*l*Zs(n,r,c)},isExported:!0},Um={description:Bo("Depreciation for an accounting period."),args:[ad("cost (number)",Bo("The initial cost of the asset.")),ad("purchase_date (date)",Bo("The date the asset was purchased.")),ad("first_period_end (date)",Bo("The date the first period ended.")),ad("salvage (number)",Bo("The value of the asset at the end of depreciation.")),ad("period (number)",Bo("The single period within life for which to calculate depreciation.")),ad("rate (number)",Bo("The deprecation rate.")),ad("day_count_convention (number, optional)",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=Li(e,this.locale),l=Math.trunc(Li(t,this.locale)),c=Math.trunc(Li(o,this.locale)),h=Li(s,this.locale),d=Li(i,this.locale),u=Li(n,this.locale),g=Math.trunc(Li(r,this.locale));!function(e){Pi((()=>e>0),Bo("The cost (%s) must be strictly positive.",e.toString()))}(a),function(e){Pi((()=>e>=0),Bo("The purchase_date (%s) must be positive or null.",e.toString()))}(l),Im(h),function(e,t){Pi((()=>e<=t),Bo("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(h,a),function(e){Pi((()=>e>=0),Bo("The period (%s) must be positive or null.",e.toString()))}(d),Cm(u),vm(g),Pi((()=>l<=c),Bo("The purchase_date (%s) must be before the first_period_end (%s).",l.toString(),c.toString()));const p=d<1&&d>0?1:Math.trunc(d),m=a*u,f=Zs(l,c,g),v=l===c?m:m*f,b=a-v-m*p;return b>=h?0===p?v:m:h-b<m?m-(h-b):0},isExported:!0},Bm={description:Bo("Days in coupon period containing settlement date."),args:Vm,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Li(e,this.locale)),n=Math.trunc(Li(t,this.locale)),r=Math.trunc(Li(o,this.locale)),a=Math.trunc(Li(s,this.locale));if(pm(i,n),fm(r),vm(a),1===a){const i=qm.compute.bind(this)(e,t,o,s).value;return Gm.compute.bind(this)(e,t,o,s).value-i}return(3===a?365:360)/r},isExported:!0},zm={description:Bo("Days from settlement until next coupon."),args:Vm,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Li(e,this.locale)),n=Math.trunc(Li(t,this.locale)),r=Math.trunc(Li(o,this.locale)),a=Math.trunc(Li(s,this.locale));pm(i,n),fm(r),vm(a);const l=qm.compute.bind(this)(e,t,o,s).value;if([1,2,3].includes(a))return i-l;if(4===a){const e=Zs(l,i,a);return Math.round(360*e)}const c=Xi(i,this.locale),h=Xi(l,this.locale),d=h.getFullYear(),u=c.getFullYear(),g=h.getMonth()+1,p=c.getMonth()+1;let m=h.getDate(),f=c.getDate();return 2===g&&2===p&&Gs(h)&&Gs(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&Gs(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},$m={description:Bo("Days from settlement until next coupon."),args:Vm,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Li(e,this.locale)),n=Math.trunc(Li(t,this.locale)),r=Math.trunc(Li(o,this.locale)),a=Math.trunc(Li(s,this.locale));pm(i,n),fm(r),vm(a);const l=Gm.compute.bind(this)(e,t,o,s).value;if([1,2,3].includes(a))return l-i;if(4===a){const e=Zs(i,l,a);return Math.round(360*e)}const c=zm.compute.bind(this)(e,t,o,s);return Bm.compute.bind(this)(e,t,o,s)-c},isExported:!0},Gm={description:Bo("Next coupon date after the settlement date."),args:Vm,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Li(e,this.locale)),n=Math.trunc(Li(t,this.locale)),r=Math.trunc(Li(o,this.locale)),a=Math.trunc(Li(s,this.locale));pm(i,n),fm(r),vm(a);const l=12/r,c=Wm.compute.bind(this)(e,t,o,s);return{value:Bs(Ws(Xi(n,this.locale),-(c-1)*l,!0)),format:this.locale.dateFormat}},isExported:!0},Wm={description:Bo("Number of coupons between settlement and maturity."),args:Vm,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Li(e,this.locale)),n=Math.trunc(Li(t,this.locale)),r=Math.trunc(Li(o,this.locale)),a=Math.trunc(Li(s,this.locale));pm(i,n),fm(r),vm(a);let l=1,c=n;const h=12/r;for(;c>i;)c=Bs(Ws(Xi(c,this.locale),-h,!1)),l++;return l-1},isExported:!0},qm={description:Bo("Last coupon date prior to or on the settlement date."),args:Vm,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Li(e,this.locale)),n=Math.trunc(Li(t,this.locale)),r=Math.trunc(Li(o,this.locale)),a=Math.trunc(Li(s,this.locale));pm(i,n),fm(r),vm(a);const l=12/r,c=Wm.compute.bind(this)(e,t,o,s);return{value:Bs(Ws(Xi(n,this.locale),-c*l,!0)),format:this.locale.dateFormat}},isExported:!0},Zm={description:Bo("Cumulative interest paid over a set of periods."),args:[ad("rate (number)",Bo("The interest rate.")),ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("present_value (number)",Bo("The current value of the annuity.")),ad("first_period (number)",Bo("The number of the payment period to begin the cumulative calculation.")),ad("last_period (number)",Bo("The number of the payment period to end the cumulative calculation.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s,i,n={value:0}){const r=Li(s,this.locale),a=Li(i,this.locale),l=Li(e,this.locale),c=Li(o,this.locale),h=Li(t,this.locale),d=Yi(n)?1:0;Mm(r,a,h),Cm(l),Rm(c);let u=0;for(let e=r;e<=a;e++)u+=lf(l,e,h,c,0,d);return u},isExported:!0},jm={description:Bo("Cumulative principal paid over a set of periods."),args:[ad("rate (number)",Bo("The interest rate.")),ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("present_value (number)",Bo("The current value of the annuity.")),ad("first_period (number)",Bo("The number of the payment period to begin the cumulative calculation.")),ad("last_period (number)",Bo("The number of the payment period to end the cumulative calculation.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s,i,n={value:0}){const r=Li(s,this.locale),a=Li(i,this.locale),l=Li(e,this.locale),c=Li(o,this.locale),h=Li(t,this.locale),d=Yi(n)?1:0;Mm(r,a,h),Cm(l),Rm(c);let u=0;for(let e=r;e<=a;e++)u+=Cf(l,e,h,c,0,d);return u},isExported:!0},Ym={description:Bo("Depreciation via declining balance method."),args:[ad("cost (number)",Bo("The initial cost of the asset.")),ad("salvage (number)",Bo("The value of the asset at the end of depreciation.")),ad("life (number)",Bo("The number of periods over which the asset is depreciated.")),ad("period (number)",Bo("The single period within life for which to calculate depreciation.")),ad("month (number, optional)",Bo("The number of months in the first year of depreciation."))],compute:function(e,t,o,s,...i){const n=Li(e,this.locale),r=Li(t,this.locale),a=Li(o,this.locale),l=Math.trunc(Li(s,this.locale)),c=i.length?Math.trunc(Li(i[0],this.locale)):12,h=a+(12===c?0:1);xm(n),Im(r),Em(l),wm(a),Pi((()=>1<=c&&c<=12),Bo("The month (%s) must be between 1 and 12 inclusive.",c.toString())),Pi((()=>l<=h),Bo("The period (%s) must be less than or equal to %s.",l.toString(),h.toString()));const d=c/12;let u=1-Math.pow(r/n,1/a);u=Math.round(1e3*u)/1e3;let g=n,p=n*(1-u*d);for(let e=1;e<l;e++)g=p,p=g*(1-u),e===a&&(p=g*(1-u*(1-d)));return{value:g-p,format:"#,##0.00"}},isExported:!0};function Xm(e,t,o,s,i){if(xm(e),Im(t),Em(s),wm(o),Tm(s,o),Om(i),0===e||t>=e)return 0;const n=i/o;if(n>1)return 1===s?e-t:0;if(s<=1)return e*n;const r=e*Math.pow(1-n,s-1),a=e*Math.pow(1-n,s),l=a<t?r-t:r-a;return Math.max(l,0)}const Km={description:Bo("Depreciation via double-declining balance method."),args:[ad("cost (number)",Bo("The initial cost of the asset.")),ad("salvage (number)",Bo("The value of the asset at the end of depreciation.")),ad("life (number)",Bo("The number of periods over which the asset is depreciated.")),ad("period (number)",Bo("The single period within life for which to calculate depreciation.")),ad("factor (number, default=2)",Bo("The factor by which depreciation decreases."))],compute:function(e,t,o,s,i={value:2}){return{value:Xm(Li(e,this.locale),Li(t,this.locale),Li(o,this.locale),Li(s,this.locale),Li(i,this.locale)),format:"#,##0.00"}},isExported:!0},Jm={description:Bo("Discount rate of a security based on price."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("price (number)",Bo("The price at which the security is bought per 100 face value.")),ad("redemption (number)",Bo("The redemption amount per 100 face value, or par.")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(Li(e,this.locale)),r=Math.trunc(Li(t,this.locale)),a=Li(o,this.locale),l=Li(s,this.locale),c=Math.trunc(Li(i,this.locale));pm(n,r),vm(c),Sm(a),bm(l);return(l-a)/l/Zs(n,r,c)},isExported:!0},Qm={description:Bo("Convert a decimal fraction to decimal value."),args:[ad("fractional_price (number)",Bo("The price quotation given using fractional decimal conventions.")),ad("unit (number)",Bo("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],compute:function(e,t){const o=Li(e,this.locale),s=Math.trunc(Li(t,this.locale));Pi((()=>s>0),Bo("The unit (%s) must be strictly positive.",s.toString()));const i=Math.trunc(o);return i+(o-i)*(10**Math.ceil(Math.log10(s))/s)},isExported:!0},ef={description:Bo("Convert a decimal value to decimal fraction."),args:[ad("decimal_price (number)",Bo("The price quotation given as a decimal value.")),ad("unit (number)",Bo("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],compute:function(e,t){const o=Li(e,this.locale),s=Math.trunc(Li(t,this.locale));Pi((()=>s>0),Bo("The unit (%s) must be strictly positive.",s.toString()));const i=Math.trunc(o);return i+(o-i)*(s/10**Math.ceil(Math.log10(s)))},isExported:!0},tf={description:Bo("Number of periods for an investment to reach a value."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("rate (number)",Bo("The annualized rate of interest.")),ad("yield (number)",Bo("The expected annual yield of the security.")),ad("frequency (number)",Bo("The number of interest or coupon payments per year (1, 2, or 4).")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n={value:0}){const r=Math.trunc(Li(e,this.locale)),a=Math.trunc(Li(t,this.locale)),l=Li(o,this.locale),c=Li(s,this.locale),h=Math.trunc(Li(i,this.locale)),d=Math.trunc(Li(n,this.locale));pm(r,a),fm(h),vm(d),Pi((()=>l>=0),Bo("The rate (%s) must be positive or null.",l.toString())),Pi((()=>c>=0),Bo("The yield (%s) must be positive or null.",c.toString()));const u=Zs(r,a,d),g=u-Math.trunc(u)||1/h,p=Math.ceil(u*h),m=l/h,f=c/h;let v=0,b=0;for(let e=1;e<=p;e++){const t=(m+(e===p?1:0))/(1+f)**e;b+=(g+(e-1)/h)*t,v+=t}return 0===v?0:b/v},isExported:!0},of={description:Bo("Annual effective interest rate."),args:[ad("nominal_rate (number)",Bo("The nominal interest rate per year.")),ad("periods_per_year (number)",Bo("The number of compounding periods per year."))],compute:function(e,t){const o=Li(e,this.locale),s=Math.trunc(Li(t,this.locale));return Pi((()=>o>0),Bo("The nominal rate (%s) must be strictly greater than 0.",o.toString())),Pi((()=>s>0),Bo("The number of periods by year (%s) must strictly greater than 0.",s.toString())),Math.pow(1+o/s,s)-1},isExported:!0};function sf(e,t,o,s,i){return 0===e?-(s+o*t):-s*(1+e)**t-o*(1+e*i)*((1+e)**t-1)/e}const nf={description:Bo("Future value of an annuity investment."),args:[ad("rate (number)",Bo("The interest rate.")),ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("payment_amount (number)",Bo("The amount per period to be paid.")),ad("present_value (number, default=0)",Bo("The current value of the annuity.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;return{value:sf(Li(e,this.locale),Li(t,this.locale),Li(o,this.locale),Li(s,this.locale),Yi(i)?1:0),format:"#,##0.00"}},isExported:!0},rf={description:Bo("Future value of principal from series of rates."),args:[ad("principal (number)",Bo("The amount of initial capital or value to compound against.")),ad("rate_schedule (number, range<number>)",Bo("A series of interest rates to compound against the principal."))],compute:function(e,t){return on([t],((e,t)=>e*(1+Li(t,this.locale))),Li(e,this.locale))},isExported:!0},af={description:Bo("Calculates effective interest rate."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("investment (number)",Bo("The amount invested in the security.")),ad("redemption (number)",Bo("The amount to be received at maturity.")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){const n=Math.trunc(Li(e,this.locale)),r=Math.trunc(Li(t,this.locale)),a=Li(s,this.locale),l=Li(o,this.locale),c=Math.trunc(Li(i,this.locale));pm(n,r),Am(l),bm(a),vm(c);return(a-l)/l/Zs(n,r,c)},isExported:!0};function lf(e,t,o,s,i,n){return Sf(e,o,s,i,n)-Cf(e,t,o,s,i,n)}const cf={description:Bo("Payment on the principal of an investment."),args:[ad("rate (number)",Bo("The annualized rate of interest.")),ad("period (number)",Bo("The amortization period, in terms of number of periods.")),ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("present_value (number)",Bo("The current value of the annuity.")),ad("future_value (number, default=0)",Bo("The future value remaining after the final payment has been made.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s,i={value:0},n={value:0}){return{value:lf(Li(e,this.locale),Li(t,this.locale),Li(o,this.locale),Li(s,this.locale),Li(i,this.locale),Yi(n)?1:0),format:"#,##0.00"}},isExported:!0},hf={description:Bo("Internal rate of return given periodic cashflows."),args:[ad("cashflow_amounts (number, range<number>)",Bo("An array or range containing the income or payments associated with the investment.")),ad("rate_guess (number, default=0.1)",Bo("An estimate for what the internal rate of return will be."))],compute:function(e,t={value:.1}){const o=Li(t,this.locale);Pm(o);let s=!1,i=!1,n=[];en([e],(({value:e})=>{e>0&&(s=!0),e<0&&(i=!0),n.push(e)}),this.locale),Pi((()=>s&&i),Bo("The cashflow_amounts must include negative and positive values."));const r=n.shift();return{value:Lm((function(e){return function(e,t,o){const s=o.length;let i=0;return o.reduce(((t,o)=>(i++,t+o*e**(s-i))),t*e**s)}(e,r,n)}),(function(e){return function(e,t,o){const s=o.length;let i=0;return o.reduce(((t,o)=>(i++,t+o*(s-i)*e**(s-i-1))),t*s*e**(s-1))}(e,r,n)}),o+1,20,1e-5)-1,format:"0%"}},isExported:!0},df={description:Bo("Returns the interest paid at a particular period of an investment."),args:[ad("rate (number)",Bo("The interest rate.")),ad("period (number)",Bo("The period for which you want to view the interest payment.")),ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("present_value (number)",Bo("The current value of the annuity."))],compute:function(e,t,o,s){const i=Li(e,this.locale),n=Li(t,this.locale),r=Li(o,this.locale),a=Li(s,this.locale);Pi((()=>0!==r),Bo("The number of periods must be different than 0.",r.toString()));return-1*(a-a*(n/r))*i},isExported:!0},uf={description:Bo("Modified Macaulay duration."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("rate (number)",Bo("The annualized rate of interest.")),ad("yield (number)",Bo("The expected annual yield of the security.")),ad("frequency (number)",Bo("The number of interest or coupon payments per year (1, 2, or 4).")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n={value:0}){return tf.compute.bind(this)(e,t,o,s,i,n)/(1+Li(s,this.locale)/Math.trunc(Li(i,this.locale)))},isExported:!0},gf={description:Bo("Modified internal rate of return."),args:[ad("cashflow_amounts (range<number>)",Bo("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")),ad("financing_rate (number)",Bo("The interest rate paid on funds invested.")),ad("reinvestment_return_rate (number)",Bo("The return (as a percentage) earned on reinvestment of income received from the investment."))],compute:function(e,t,o){const s=Li(t,this.locale),i=Li(o,this.locale),n=ln(e).flat().filter((e=>null!==e.value)).map((e=>Li(e,this.locale))),r=n.length;let a=0,l=0;for(const e of je(0,r)){const t=n[e];t>=0?a+=t*(i+1)**(r-e-1):l+=t/(s+1)**e}Pi((()=>0!==l&&0!==a),Bo("There must be both positive and negative values in cashflow_amounts."));return(-a/l)**(1/(r-1))-1},isExported:!0},pf={description:Bo("Annual nominal interest rate."),args:[ad("effective_rate (number)",Bo("The effective interest rate per year.")),ad("periods_per_year (number)",Bo("The number of compounding periods per year."))],compute:function(e,t){const o=Li(e,this.locale),s=Math.trunc(Li(t,this.locale));return Pi((()=>o>0),Bo("The effective rate (%s) must must strictly greater than 0.",o.toString())),Pi((()=>s>0),Bo("The number of periods by year (%s) must strictly greater than 0.",s.toString())),(Math.pow(o+1,1/s)-1)*s},isExported:!0},mf={description:Bo("Number of payment periods for an investment."),args:[ad("rate (number)",Bo("The interest rate.")),ad("payment_amount (number)",Bo("The amount of each payment made.")),ad("present_value (number)",Bo("The current value of the annuity.")),ad("future_value (number, default=0)",Bo("The future value remaining after the final payment has been made.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;const n=Li(e,this.locale),r=Li(t,this.locale),a=Li(o,this.locale),l=Li(s,this.locale),c=Yi(i)?1:0;if(0===n)return-(l+a)/r;const h=r*(1+n*c)/n;return Math.log((h-l)/(a+h))/Math.log(1+n)},isExported:!0};function ff(e,t,o,s){let i=0;return sn(o,((t,o)=>(i++,t+o/(1+e)**i)),t,s)}const vf={description:Bo("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:[ad("discount (number)",Bo("The discount rate of the investment over one period.")),ad("cashflow1 (number, range<number>)",Bo("The first future cash flow.")),ad("cashflow2 (number, range<number>, repeating)",Bo("Additional future cash flows."))],compute:function(e,...t){const o=Li(e,this.locale);return Pi((()=>-1!==o),Bo("The discount (%s) must be different from -1.",o.toString())),{value:ff(o,0,t,this.locale),format:"#,##0.00"}},isExported:!0},bf={description:Bo("Computes the number of periods needed for an investment to reach a value."),args:[ad("rate (number)",Bo("The rate at which the investment grows each period.")),ad("present_value (number)",Bo("The investment's current value.")),ad("future_value (number)",Bo("The investment's desired future value."))],compute:function(e,t,o){const s=Li(e,this.locale),i=Li(t,this.locale),n=Li(o,this.locale);return Cm(s),Pi((()=>i>0),Bo("The present_value (%s) must be strictly positive.",i.toString())),Pi((()=>n>0),Bo("The future_value (%s) must be strictly positive.",n.toString())),(Math.log(n)-Math.log(i))/Math.log(1+s)},isExported:!0};function Sf(e,t,o,s,i){if(ym(t),0===e)return-(s+o)/t;let n=-(o*(1+e)**t+s);return n=n*e/((1+e*i)*((1+e)**t-1)),n}const yf={description:Bo("Periodic payment for an annuity investment."),args:[ad("rate (number)",Bo("The annualized rate of interest.")),ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("present_value (number)",Bo("The current value of the annuity.")),ad("future_value (number, default=0)",Bo("The future value remaining after the final payment has been made.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s={value:0},i={value:0}){const n=Li(t,this.locale),r=Li(e,this.locale),a=Yi(i)?1:0,l=Li(s,this.locale);return{value:Sf(r,n,Li(o,this.locale),l,a),format:"#,##0.00"}},isExported:!0};function Cf(e,t,o,s,i,n){ym(o),Pi((()=>t>0&&t<=o),Bo("The period must be between 1 and number_of_periods (%s)",o));const r=Sf(e,o,s,i,n);if(1===n&&1===t)return r;return r+-sf(e,0===n?t-1:t-2,r,s+r*n,0)*e}const wf={description:Bo("Payment on the principal of an investment."),args:[ad("rate (number)",Bo("The annualized rate of interest.")),ad("period (number)",Bo("The amortization period, in terms of number of periods.")),ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("present_value (number)",Bo("The current value of the annuity.")),ad("future_value (number, default=0)",Bo("The future value remaining after the final payment has been made.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s,i={value:0},n={value:0}){const r=Li(o,this.locale),a=Li(e,this.locale),l=Li(t,this.locale),c=Yi(n)?1:0,h=Li(i,this.locale);return{value:Cf(a,l,r,Li(s,this.locale),h,c),format:"#,##0.00"}},isExported:!0},xf={description:Bo("Present value of an annuity investment."),args:[ad("rate (number)",Bo("The interest rate.")),ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("payment_amount (number)",Bo("The amount per period to be paid.")),ad("future_value (number, default=0)",Bo("The future value remaining after the final payment has been made.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;const n=Li(e,this.locale),r=Li(t,this.locale),a=Li(o,this.locale),l=Li(s,this.locale),c=Yi(i)?1:0;return{value:n?-(a*(1+n*c)*((1+n)**r-1)/n+l)/(1+n)**r:-(l+a*r),format:"#,##0.00"}},isExported:!0},Ef={description:Bo("Price of a security paying periodic interest."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("rate (number)",Bo("The annualized rate of interest.")),ad("yield (number)",Bo("The expected annual yield of the security.")),ad("redemption (number)",Bo("The redemption amount per 100 face value, or par.")),ad("frequency (number)",Bo("The number of interest or coupon payments per year (1, 2, or 4).")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=Math.trunc(Li(e,this.locale)),l=Math.trunc(Li(t,this.locale)),c=Li(o,this.locale),h=Li(s,this.locale),d=Li(i,this.locale),u=Math.trunc(Li(n,this.locale)),g=Math.trunc(Li(r,this.locale));pm(a,l),fm(u),vm(g),Pi((()=>c>=0),Bo("The rate (%s) must be positive or null.",c.toString())),Pi((()=>h>=0),Bo("The yield (%s) must be positive or null.",h.toString())),bm(d);const p=Zs(a,l,g)*u,m=Math.ceil(p),f=p-Math.floor(p)||1,v=1+h/u,b=100*c/u;if(1===m)return(b+d)/(f*h/u+1)-b*(1-f);let S=0;for(let e=1;e<=m;e++)S+=b/v**(e-1+f);return d/v**(m-1+f)+S-b*(1-f)},isExported:!0},If={description:Bo("Price of a discount security."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("discount (number)",Bo("The discount rate of the security at time of purchase.")),ad("redemption (number)",Bo("The redemption amount per 100 face value, or par.")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(Li(e,this.locale)),r=Math.trunc(Li(t,this.locale)),a=Li(o,this.locale),l=Li(s,this.locale),c=Math.trunc(Li(i,this.locale));pm(n,r),vm(c),_m(a),bm(l);return l-a*l*Zs(n,r,c)},isExported:!0},Rf={description:Bo("Calculates the price of a security paying interest at maturity, based on expected yield."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("issue (date)",Bo("The date the security was initially issued.")),ad("rate (number)",Bo("The annualized rate of interest.")),ad("yield (number)",Bo("The expected annual yield of the security.")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n={value:0}){n=n||0;const r=Math.trunc(Li(e,this.locale)),a=Math.trunc(Li(t,this.locale)),l=Math.trunc(Li(o,this.locale)),c=Li(s,this.locale),h=Li(i,this.locale),d=Math.trunc(Li(n,this.locale));mm(r,l),pm(r,a),vm(d),Pi((()=>c>=0),Bo("The rate (%s) must be positive or null.",c.toString())),Pi((()=>h>=0),Bo("The yield (%s) must be positive or null.",h.toString()));const u=Zs(r,a,d),g=Zs(r,l,d);return(100+Zs(l,a,d)*c*100)/(1+u*h)-g*c*100},isExported:!0},Tf=.1,Af={description:Bo("Interest rate of an annuity investment."),args:[ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("payment_per_period (number)",Bo("The amount per period to be paid.")),ad("present_value (number)",Bo("The current value of the annuity.")),ad("future_value (number, default=0)",Bo("The future value remaining after the final payment has been made.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period.")),ad("rate_guess (number, default=0.1)",Bo("An estimate for what the interest rate will be."))],compute:function(e,t,o,s={value:0},i={value:0},n={value:Tf}){const r=Li(e,this.locale),a=Li(t,this.locale),l=Yi(i)?1:0,c=Li(n,this.locale)||Tf;let h=Li(s,this.locale),d=Li(o,this.locale);ym(r),Pi((()=>[a,d,h].some((e=>e>0))&&[a,d,h].some((e=>e<0))),Bo("There must be both positive and negative values in [payment_amount, present_value, future_value].",r.toString())),Pm(c),h-=a*l,d+=a*l;return{value:Lm((e=>{const t=Math.pow(1+e,r);return h+d*t+a*((t-1)/e)}),(e=>{const t=Math.pow(1+e,r-1),o=Math.pow(1+e,r);return d*r*t+a*(r*t/e-(o-1)/e/e)}),c,40,1e-5),format:"0%"}},isExported:!0},_f={description:Bo("Amount received at maturity for a security."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("investment (number)",Bo("The amount invested (irrespective of face value of each security).")),ad("discount (number)",Bo("The discount rate of the security invested in.")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(Li(e,this.locale)),r=Math.trunc(Li(t,this.locale)),a=Li(o,this.locale),l=Li(s,this.locale),c=Math.trunc(Li(i,this.locale));pm(n,r),vm(c),Am(a),_m(l);return a/(1-l*Zs(n,r,c))},isExported:!0},Df={description:Bo("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:[ad("number_of_periods (number)",Bo("The number of periods.")),ad("present_value (number)",Bo("The present value of the investment.")),ad("future_value (number)",Bo("The future value of the investment."))],compute:function(e,t,o){const s=Li(e,this.locale),i=Li(t,this.locale),n=Li(o,this.locale);return ym(s),(n/i)**(1/s)-1},isExported:!0},Of={description:Bo("Depreciation of an asset using the straight-line method."),args:[ad("cost (number)",Bo("The initial cost of the asset.")),ad("salvage (number)",Bo("The value of the asset at the end of depreciation.")),ad("life (number)",Bo("The number of periods over which the asset is depreciated."))],compute:function(e,t,o){return{value:(Li(e,this.locale)-Li(t,this.locale))/Li(o,this.locale),format:"#,##0.00"}},isExported:!0},Ff={description:Bo("Depreciation via sum of years digit method."),args:[ad("cost (number)",Bo("The initial cost of the asset.")),ad("salvage (number)",Bo("The value of the asset at the end of depreciation.")),ad("life (number)",Bo("The number of periods over which the asset is depreciated.")),ad("period (number)",Bo("The single period within life for which to calculate depreciation."))],compute:function(e,t,o,s){const i=Li(e,this.locale),n=Li(t,this.locale),r=Li(o,this.locale),a=Li(s,this.locale);Em(a),wm(r),Tm(a,r);return{value:(r-a+1)/(r*(r+1)/2)*(i-n),format:"#,##0.00"}},isExported:!0};function Mf(e,t,o){return 100*(1-o*Zs(e,t,2))}const Pf={description:Bo("Price of a US Treasury bill."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("discount (number)",Bo("The discount rate of the bill at time of purchase."))],compute:function(e,t,o){const s=Math.trunc(Li(e,this.locale)),i=Math.trunc(Li(t,this.locale)),n=Li(o,this.locale);return pm(s,i),Fm(s,i,this.locale),_m(n),Dm(n),Mf(s,i,n)},isExported:!0},Nf={description:Bo("Equivalent rate of return for a US Treasury bill."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("discount (number)",Bo("The discount rate of the bill at time of purchase."))],compute:function(e,t,o){const s=Math.trunc(Li(e,this.locale)),i=Math.trunc(Li(t,this.locale)),n=Li(o,this.locale);pm(s,i),Fm(s,i,this.locale),_m(n),Dm(n);const r=Rp.compute.bind(this)({value:i},{value:s});if(r<=182)return 365*n/(360-n*r);const a=Mf(s,i,n)/100,l=r/(366===r?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},kf={description:Bo("The yield of a US Treasury bill based on price."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("price (number)",Bo("The price at which the security is bought per 100 face value."))],compute:function(e,t,o){const s=Math.trunc(Li(e,this.locale)),i=Math.trunc(Li(t,this.locale)),n=Li(o,this.locale);pm(s,i),Fm(s,i,this.locale),Sm(n);return(100-n)/n*(1/Zs(s,i,2))},isExported:!0},Vf={description:Bo("Variable declining balance. WARNING : does not handle decimal periods."),args:[ad("cost (number)",Bo("The initial cost of the asset.")),ad("salvage (number)",Bo("The value of the asset at the end of depreciation.")),ad("life (number)",Bo("The number of periods over which the asset is depreciated.")),ad("start (number)",Bo("Starting period to calculate depreciation.")),ad("end (number)",Bo("Ending period to calculate depreciation.")),ad("factor (number, default=2)",Bo("The number of months in the first year of depreciation.")),ad("no_switch (number, default=false)",Bo("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation."))],compute:function(e,t,o,s,i,n={value:2},r={value:false}){n=n||0;const a=Li(e,this.locale),l=Li(t,this.locale),c=Li(o,this.locale),h=Math.trunc(Li(s,this.locale)),d=Math.trunc(Li(i,this.locale)),u=Li(n,this.locale),g=Yi(r);if(xm(a),Im(l),function(e,t,o){wm(o),Pi((()=>e>=0),Bo("The start_period (%s) must be greater or equal than 0.",e.toString())),Pi((()=>t>=0),Bo("The end_period (%s) must be greater or equal than 0.",t.toString())),Pi((()=>e<=t),Bo("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),Pi((()=>t<=o),Bo("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),o.toString()))}(h,d,c),Om(u),0===a)return 0;if(l>=a)return h<1?a-l:0;const p=u/c;if(p>=1)return h<1?a-l:0;let m=a,f=0,v=0,b=!1;for(let e=0;e<d;e++){if(!b||g){const t=m*p,o=(m-l)/(c-e);!g&&o>t?(b=!0,f=o):f=t}const t=Math.max(m-f,l);e>=h&&(v+=m-t),m=t}return v},isExported:!0},Lf={description:Bo("Internal rate of return given non-periodic cash flows."),args:[ad("cashflow_amounts (range<number>)",Bo("An range containing the income or payments associated with the investment.")),ad("cashflow_dates (range<number>)",Bo("An range with dates corresponding to the cash flows in cashflow_amounts.")),ad("rate_guess (number, default=0.1)",Bo("An estimate for what the internal rate of return will be."))],compute:function(e,t,o={value:Tf}){const s=Li(o,this.locale),i=e.flat().map((e=>Li(e,this.locale))),n=t.flat().map((e=>Li(e,this.locale)));var r;Nm(e,t),r=i,Pi((()=>r.some((e=>e>0))&&r.some((e=>e<0))),Bo("There must be both positive and negative values in cashflow_amounts.")),km(n),Pm(s);const a=new Map;for(const e of je(0,n.length)){const t=n[e];a.has(t)?a.set(t,a.get(t)+i[e]):a.set(t,i[e])}const l=Array.from(a.keys()),c=l.map((e=>a.get(e)));return Lm((e=>{let t=c[0];for(const o of je(1,c.length)){const s=(l[0]-l[o])/365;t+=c[o]*(1+e)**s}return t}),(e=>{let t=0;for(const o of je(1,c.length)){const s=(l[0]-l[o])/365;t+=s*c[o]*(1+e)**(s-1)}return t}),s,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},Hf={description:Bo("Net present value given to non-periodic cash flows.."),args:[ad("discount (number)",Bo("The discount rate of the investment over one period.")),ad("cashflow_amounts (number, range<number>)",Bo("An range containing the income or payments associated with the investment.")),ad("cashflow_dates (number, range<number>)",Bo("An range with dates corresponding to the cash flows in cashflow_amounts."))],compute:function(e,t,o){const s=Li(e,this.locale),i=yi(t)?t.flat().map((e=>Bi(e,this.locale))):[Bi(t,this.locale)],n=yi(o)?o.flat().map((e=>Bi(e,this.locale))):[Bi(o,this.locale)];if(yi(o)&&yi(t)?Nm(t,o):Pi((()=>i.length===n.length),Bo("There must be the same number of values in cashflow_amounts and cashflow_dates.")),km(n),Cm(s),1===i.length)return i[0];const r=new Map;for(const e of je(0,n.length)){const t=n[e];r.has(t)?r.set(t,r.get(t)+i[e]):r.set(t,i[e])}const a=Array.from(r.keys()),l=a.map((e=>r.get(e)));let c=l[0];for(const e of je(1,l.length)){const t=(a[0]-a[e])/365;c+=l[e]*(1+s)**t}return c},isExported:!0},Uf={description:Bo("Annual yield of a security paying periodic interest."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("rate (number)",Bo("The annualized rate of interest.")),ad("price (number)",Bo("The price at which the security is bought per 100 face value.")),ad("redemption (number)",Bo("The redemption amount per 100 face value, or par.")),ad("frequency (number)",Bo("The number of interest or coupon payments per year (1, 2, or 4).")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=Math.trunc(Li(e,this.locale)),l=Math.trunc(Li(t,this.locale)),c=Li(o,this.locale),h=Li(s,this.locale),d=Li(i,this.locale),u=Math.trunc(Li(n,this.locale)),g=Math.trunc(Li(r,this.locale));pm(a,l),fm(u),vm(g),Pi((()=>c>=0),Bo("The rate (%s) must be positive or null.",c.toString())),Sm(h),bm(d);const p=Zs(a,l,g)*u,m=Math.ceil(p),f=p-Math.floor(p)||1,v=100*c/u;if(1===m){const e=h+v*(1-f);return(d+v-e)*u*(1/f)/e}const b=Lm((function(e){return function(e,t,o,s,i,n){let r=n-(e+i*(1-t))*s**(o-1+t);for(let e=1;e<=o;e++)r+=i*s**(e-1);return r}(h,f,m,e,v,d)}),(function(e){return function(e,t,o,s,i){let n=-(e+i*(1-t))*(o-1+t)*s**(o-2+t);for(let e=1;e<=o;e++)n+=i*(e-1)*s**(e-2);return n}(h,f,m,e,v)}),1+(c+1)/u,100,1e-5);return(b-1)*u},isExported:!0},Bf={description:Bo("Annual yield of a discount security."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("price (number)",Bo("The price at which the security is bought per 100 face value.")),ad("redemption (number)",Bo("The redemption amount per 100 face value, or par.")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(Li(e,this.locale)),r=Math.trunc(Li(t,this.locale)),a=Li(o,this.locale),l=Li(s,this.locale),c=Math.trunc(Li(i,this.locale));pm(n,r),vm(c),Sm(a),bm(l);return(l/a-1)/Zs(n,r,c)},isExported:!0},zf={description:Bo("Annual yield of a security paying interest at maturity."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("issue (date)",Bo("The date the security was initially issued.")),ad("rate (number)",Bo("The annualized rate of interest.")),ad("price (number)",Bo("The price at which the security is bought.")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n={value:0}){n=n||0;const r=Math.trunc(Li(e,this.locale)),a=Math.trunc(Li(t,this.locale)),l=Math.trunc(Li(o,this.locale)),c=Li(s,this.locale),h=Li(i,this.locale),d=Math.trunc(Li(n,this.locale));pm(r,a),vm(d),Pi((()=>r>=l),Bo("The settlement (%s) must be greater than or equal to the issue (%s).",r.toString(),l.toString())),Pi((()=>c>=0),Bo("The rate (%s) must be positive or null.",c.toString())),Sm(h);const u=Zs(l,a,d),g=Zs(l,r,d),p=Zs(r,a,d);return(100*(1+c*u)/(h+100*c*g)-1)/p},isExported:!0};var $f,Gf=Object.freeze({__proto__:null,ACCRINTM:Hm,AMORLINC:Um,COUPDAYBS:zm,COUPDAYS:Bm,COUPDAYSNC:$m,COUPNCD:Gm,COUPNUM:Wm,COUPPCD:qm,CUMIPMT:Zm,CUMPRINC:jm,DB:Ym,DDB:Km,DISC:Jm,DOLLARDE:Qm,DOLLARFR:ef,DURATION:tf,EFFECT:of,FV:nf,FVSCHEDULE:rf,INTRATE:af,IPMT:cf,IRR:hf,ISPMT:df,MDURATION:uf,MIRR:gf,NOMINAL:pf,NPER:mf,NPV:vf,PDURATION:bf,PMT:yf,PPMT:wf,PRICE:Ef,PRICEDISC:If,PRICEMAT:Rf,PV:xf,RATE:Af,RECEIVED:_f,RRI:Df,SLN:Of,SYD:Ff,TBILLEQ:Nf,TBILLPRICE:Pf,TBILLYIELD:kf,VDB:Vf,XIRR:Lf,XNPV:Hf,YIELD:Uf,YIELDDISC:Bf,YIELDMAT:zf});!function(e){e[e.LeftRef=0]="LeftRef",e[e.RightRef=1]="RightRef",e[e.Separator=2]="Separator",e[e.FullColumnSeparator=3]="FullColumnSeparator",e[e.FullRowSeparator=4]="FullRowSeparator",e[e.RightColumnRef=5]="RightColumnRef",e[e.RightRowRef=6]="RightRowRef",e[e.Found=7]="Found"}($f||($f={}));const Wf=(e,t=(()=>!0))=>[{goTo:e,guard:t}],qf=(e,t=(()=>!0))=>({goTo:e,guard:t}),Zf={[$f.LeftRef]:{REFERENCE:Wf($f.Separator),NUMBER:Wf($f.FullRowSeparator),SYMBOL:[qf($f.FullColumnSeparator,(e=>{return t=e.value,Br.test(t);var t})),qf($f.FullRowSeparator,(e=>Gr(e.value)))]},[$f.FullColumnSeparator]:{SPACE:Wf($f.FullColumnSeparator),OPERATOR:Wf($f.RightColumnRef,(e=>":"===e.value))},[$f.FullRowSeparator]:{SPACE:Wf($f.FullRowSeparator),OPERATOR:Wf($f.RightRowRef,(e=>":"===e.value))},[$f.Separator]:{SPACE:Wf($f.Separator),OPERATOR:Wf($f.RightRef,(e=>":"===e.value))},[$f.RightRef]:{SPACE:Wf($f.RightRef),NUMBER:Wf($f.Found),REFERENCE:Wf($f.Found,(e=>Zr(e.value))),SYMBOL:Wf($f.Found,(e=>Wr(e.value)||qr(e.value)))},[$f.RightColumnRef]:{SPACE:Wf($f.RightColumnRef),SYMBOL:Wf($f.Found,(e=>Wr(e.value))),REFERENCE:Wf($f.Found,(e=>Zr(e.value)))},[$f.RightRowRef]:{SPACE:Wf($f.RightRowRef),NUMBER:Wf($f.Found),REFERENCE:Wf($f.Found,(e=>Zr(e.value))),SYMBOL:Wf($f.Found,(e=>qr(e.value)))},[$f.Found]:{}};function jf(e){let t=0,o=Zf[$f.LeftRef],s="";for(;void 0!==o;){const i=e[t++];if(!i)return null;const n=o[i.type]?.find((e=>e.guard(i))),r=n?n.goTo:void 0;switch(r){case void 0:return null;case $f.Found:return s+=i.value,e.splice(0,t),{type:"REFERENCE",value:s};default:o=Zf[r],s+=i.value}}return null}function Yf(e,t=bi){const o=Va(e,t),s=[];for(;o.length;)s.push(jf(o)||o.shift());return s}const Xf=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,Kf=["-","+"],Jf=["%"],Qf=["*","+","&"],ev={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10};function tv(e){const t=e.shift();if(!t)throw new Ti;switch(t.type){case"DEBUGGER":const o=iv(e,1e3);return o.debug=!0,o;case"NUMBER":return{type:"NUMBER",value:oi(t.value,bi)};case"STRING":return{type:"STRING",value:Ue(t.value)};case"INVALID_REFERENCE":return{type:"REFERENCE",value:Ei.InvalidReference};case"REFERENCE":if(":"===e[0]?.value&&"REFERENCE"===e[1]?.type){e.shift();const o=e.shift();return{type:"REFERENCE",value:`${t.value}:${o?.value}`}}return{type:"REFERENCE",value:t.value};case"SYMBOL":const s=t.value,i=e[0];if("LEFT_PAREN"===i?.type&&Xf.test(t.value)&&s===Ge(s,"'")){const t=function(e){sv(e,"LEFT_PAREN",Bo("Missing opening parenthesis"));const t=e[0];if("RIGHT_PAREN"===t?.type)return sv(e,"RIGHT_PAREN"),[];const o=[];o.push(ov(e));for(;"RIGHT_PAREN"!==e[0]?.type;)sv(e,"ARG_SEPARATOR",Bo("Wrong function call")),o.push(ov(e));return sv(e,"RIGHT_PAREN"),o}(e);return{type:"FUNCALL",value:s,args:t}}const n=s.toUpperCase();return"TRUE"===n||"FALSE"===n?{type:"BOOLEAN",value:"TRUE"===n}:{type:"SYMBOL",value:Ge(t.value,"'")};case"LEFT_PAREN":const r=iv(e);return sv(e,"RIGHT_PAREN",Bo("Missing closing parenthesis")),r;case"OPERATOR":const a=t.value;if(Kf.includes(a))return{type:"UNARY_OPERATION",value:a,operand:iv(e,ev[a])};throw new Ti(Bo("Unexpected token: %s",t.value));default:throw new Ti(Bo("Unexpected token: %s",t.value))}}function ov(e){const t=e[0];return"ARG_SEPARATOR"===t?.type||"RIGHT_PAREN"===t?.type?{type:"EMPTY",value:""}:iv(e)}function sv(e,t,o){const s=e.shift();if(!s||s.type!==t)throw new Ti(o)}function iv(e,t=0){if(0===e.length)throw new Ti;let o=tv(e);for(;"OPERATOR"===e[0]?.type&&ev[e[0].value]>t;){const t=e.shift().value;if(Jf.includes(t))o={type:"UNARY_OPERATION",value:t,operand:o,postfix:!0};else{o={type:"BIN_OPERATION",value:t,left:o,right:iv(e,ev[t])}}}return o}function nv(e){return rv(Yf(e))}function rv(e){e=e.filter((e=>"SPACE"!==e.type)),"="===e[0]?.value&&e.splice(0,1);const t=iv(e);if(e.length)throw new Ti;return t}function av(e,t,o){return hv(e,(e=>e.type===t?o(e):e))}function lv(e){return Array.from(cv(e))}function*cv(e){switch(yield e,e.type){case"FUNCALL":for(const t of e.args)yield*cv(t);break;case"UNARY_OPERATION":yield*cv(e.operand);break;case"BIN_OPERATION":yield*cv(e.left),yield*cv(e.right)}}function hv(e,t){switch((e=t(e)).type){case"FUNCALL":return{...e,args:e.args.map((e=>hv(e,t)))};case"UNARY_OPERATION":return{...e,operand:hv(e.operand,t)};case"BIN_OPERATION":return{...e,right:hv(e.right,t),left:hv(e.left,t)};default:return e}}function dv(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>dv(e)));return`${e.value}(${t.join(",")})`;case"NUMBER":return e.value.toString();case"REFERENCE":default:return e.value;case"STRING":return`"${e.value}"`;case"BOOLEAN":return e.value?"TRUE":"FALSE";case"UNARY_OPERATION":return e.postfix?uv(e)+e.value:e.value+gv(e);case"BIN_OPERATION":return uv(e)+e.value+gv(e)}}function uv(e){const t=e.value,o="left"in e?e.left:e.operand,s=o.value;return"BIN_OPERATION"===o.type&&ev[s]<ev[t]?`(${dv(o)})`:dv(o)}function gv(e){const t=e.value,o="right"in e?e.right:e.operand,s=ev[o.value],i=ev[t];let n=!1;return"BIN_OPERATION"!==o.type?n=!1:s<i?n=!0:s!==i||Qf.includes(t)||(n=!0),n?`(${dv(o)})`:dv(o)}function pv(e,t){return function(e){for(const t of e)if(t.functionContext){const{argsTokens:e,args:o}=t.functionContext;if(delete t.functionContext.argsTokens,o.length||!e)continue;"LEFT_PAREN"===e[0]?.[0]?.type&&(e[0]=e[0].slice(1));for(const t of e){let e=t;"ARG_SEPARATOR"===e.at(-1)?.type&&(e=e.slice(0,-1));try{o.push(rv(e))}catch(e){o.push(void 0)}}}return e}(function(e){let t=[],o="";function s(e){if(0===t.length)return;const o=t.at(-1);if(o&&o.argsTokens){const{argsTokens:t,argPosition:s}=o;t[s]||(t[s]=[]),t[s].push({value:e.value,type:e.type})}}return e.map(((e,i)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(o=""),e.type){case"SYMBOL":s(e),o=e.value;break;case"LEFT_PAREN":t.push({parent:o,argPosition:0,argsTokens:[],args:[]}),s(e),o="";break;case"RIGHT_PAREN":const i=t.pop();i?.argsTokens?.flat().forEach(s),s(e);break;case"ARG_SEPARATOR":s(e),t.length&&t[t.length-1].argPosition++;break;default:s(e)}if(t.length){const o=t[t.length-1];o.parent&&(e.functionContext=Object.assign({},o))}return e}))}(function(e){let t=[],o=0;return e.map(((s,i)=>{if("LEFT_PAREN"===s.type){t.push(o+1),o=0;for(let o=i-1;o>=0;o--){if("SPACE"!==e[o].type){"SYMBOL"===e[o].type&&(e[o].parenthesesCode=t.join(":"));break}e[o].parenthesesCode=t.join(":")}}return s.parenthesesCode=t.join(":"),"RIGHT_PAREN"===s.type&&t.length&&(o=t.pop()),s}))}(function(e){let t=0;return e.map((e=>{const o=e.value.toString().length,s=Object.assign({},e,{start:t,end:t+o,length:o});return t=s.end,s}))}(Yf(e,t)))))}function mv(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:o}=jr(e.value),[s,i]=t.split(":"),n=fv(s),r=i?`:${fv(i)}`:"";return{...e,value:Yr(o,n+r)}}function fv(e){switch(function(e){if(function(e){return e.startsWith("$")&&e.length>1&&e.slice(1).includes("$")}(e))return"colrow";if(function(e){return e.startsWith("$")}(e))return"col";if(function(e){return e.includes("$",1)}(e))return"row";return"none"}(e)){case"none":e=vv(e,"colrow");break;case"colrow":e=vv(e,"row");break;case"row":e=vv(e,"col");break;case"col":e=vv(e,"none")}return e}function vv(e,t){let o;({sheetName:o,xc:e}=jr(e)),o=o?o+"!":"";const s=(e=e.replace(/\$/g,"")).indexOf(":");return s>=0?`${o}${bv(e.slice(0,s),t)}:${bv(e.slice(s+1),t)}`:o+bv(e,t)}function bv(e,t){const o=e.search(/[0-9]/),s=0!==o,i=o>=0;switch(t){case"col":return s?"$"+e:e;case"row":return i?e.slice(0,o)+"$"+e.slice(o):e;case"colrow":return i&&s?"$"+e.slice(0,o)+"$"+e.slice(o):"$"+e;case"none":return e}}function Sv(e,t,o){const s=(t.startsWith("=")?pv(t,o):[]).filter((t=>t.start<=e.start&&t.end>=e.start||t.start>=e.start&&t.start<e.end)),i=s.filter((e=>"REFERENCE"===e.type));if(0===i.length)return;const n=s.map(mv).map((e=>e.value)).join(""),r=s[0].start,a=s[s.length-1].end,l=t.slice(0,r)+n+t.slice(a),c=l.length-t.length,h={start:i[0].start,end:i[i.length-1].end+c};return 1===i.length&&e.start===e.end&&(h.start=h.end),{content:l,selection:h}}const yv=["address","col","contents","format","row","type"],Cv={description:Bo("Gets information about a cell."),args:[ad("info_type (string)",Bo("The type of information requested. Can be one of %s",yv.join(", "))),ad("reference (meta)",Bo("The reference to the cell."))],compute:function(e,t){const o=qi(e).toLowerCase();Pi((()=>yv.includes(o)),Bo("The info_type should be one of %s.",yv.join(", ")));const s=this.__originSheetId,i=qi(t),n=i.includes(":")?i.split(":")[0]:i;let{sheetName:r,xc:a}=jr(n);r=r===this.getters.getSheetName(s)?void 0:r;const l=Yr(r,vv(a,"colrow")),c=this.getters.getRangeFromSheetXC(s,l);switch(o){case"address":return this.getters.getRangeString(c,s);case"col":return c.zone.left+1;case"contents":{const e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top};return this.getters.getEvaluatedCell(e).value}case"format":{const e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top};return this.getters.getEvaluatedCell(e).format||""}case"row":return c.zone.top+1;case"type":{const e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top},t=this.getters.getEvaluatedCell(e).type;return t===ii.empty?"b":t===ii.text?"l":"v"}}return""},isExported:!0},wv={description:Bo("Whether a value is an error other than #N/A."),args:[ad("value (any)",Bo("The value to be verified as an error type."))],compute:function(e){const t=e?.value;return ki(t)&&t!==Ei.NotAvailable},isExported:!0},xv={description:Bo("Whether a value is an error."),args:[ad("value (any)",Bo("The value to be verified as an error type."))],compute:function(e){const t=e?.value;return ki(t)},isExported:!0},Ev={description:Bo("Whether a value is `true` or `false`."),args:[ad("value (any)",Bo("The value to be verified as a logical TRUE or FALSE."))],compute:function(e){return"boolean"==typeof e?.value},isExported:!0},Iv={description:Bo("Whether a value is the error #N/A."),args:[ad("value (any)",Bo("The value to be verified as an error type."))],compute:function(e){return e?.value===Ei.NotAvailable},isExported:!0},Rv={description:Bo("Whether a value is non-textual."),args:[ad("value (any)",Bo("The value to be checked."))],compute:function(e){return!Av.compute.bind(this)(e)},isExported:!0},Tv={description:Bo("Whether a value is a number."),args:[ad("value (any)",Bo("The value to be verified as a number."))],compute:function(e){return"number"==typeof e?.value},isExported:!0},Av={description:Bo("Whether a value is text."),args:[ad("value (any)",Bo("The value to be verified as text."))],compute:function(e){return"string"==typeof e?.value&&!1===ki(e?.value)},isExported:!0},_v={description:Bo("Whether the referenced cell is empty"),args:[ad("value (any)",Bo("Reference to the cell that will be checked for emptiness."))],compute:function(e){return null===e?.value},isExported:!0},Dv={description:Bo("Returns the error value #N/A."),args:[],compute:function(){return{value:Ei.NotAvailable}},isExported:!0};var Ov=Object.freeze({__proto__:null,CELL:Cv,ISBLANK:_v,ISERR:wv,ISERROR:xv,ISLOGICAL:Ev,ISNA:Iv,ISNONTEXT:Rv,ISNUMBER:Tv,ISTEXT:Av,NA:Dv});const Fv={description:Bo("Logical `and` operator."),args:[ad("logical_expression1 (boolean, range<boolean>)",Bo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),ad("logical_expression2 (boolean, range<boolean>, repeating)",Bo("More expressions that represent logical values."))],compute:function(...e){const{result:t,foundBoolean:o}=pl(e);return Pi((()=>o),Bo("[[FUNCTION_NAME]] has no valid input data.")),t},isExported:!0},Mv={description:Bo("Logical value `false`."),args:[],compute:function(){return!1},isExported:!0},Pv={description:Bo("Returns value depending on logical expression."),args:[ad("logical_expression (boolean, range<boolean>)",Bo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")),ad("value_if_true (any, range)",Bo("The value the function returns if logical_expression is TRUE.")),ad("value_if_false (any, range, default=FALSE)",Bo("The value the function returns if logical_expression is FALSE."))],compute:function(e,t,o){if(El(e))return cn(Pv.compute,[e,t,o]);let s=Yi(wl(e))?t:o;return El(s)||(s=wl(s)),void 0===s?{value:""}:yi(s)||null!==s.value?s:{...s,value:""}},isExported:!0},Nv={description:Bo("Value if it is not an error, otherwise 2nd argument."),args:[ad("value (any, range)",Bo("The value to return if value itself is not an error.")),ad('value_if_error (any, range, default="empty")',Bo("The value the function returns if value is an error."))],compute:function(e,t){if(El(e))return cn(Nv.compute,[e,t]);let o=ki(wl(e)?.value)?t:e;return El(o)||(o=wl(o)),void 0===o?{value:""}:yi(o)||null!==o.value?o:{...o,value:""}},isExported:!0},kv={description:Bo("Value if it is not an #N/A error, otherwise 2nd argument."),args:[ad("value (any, range)",Bo("The value to return if value itself is not #N/A an error.")),ad('value_if_error (any, range, default="empty")',Bo("The value the function returns if value is an #N/A error."))],compute:function(e,t){if(El(e))return cn(kv.compute,[e,t]);let o=wl(e)?.value===Ei.NotAvailable?t:e;return El(o)||(o=wl(o)),void 0===o?{value:""}:yi(o)||null!==o.value?o:{...o,value:""}},isExported:!0},Vv={description:Bo("Returns a value depending on multiple logical expressions."),args:[ad("condition1 (boolean, range<boolean>)",Bo("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")),ad("value1 (any, range)",Bo("The returned value if condition1 is TRUE.")),ad("condition2 (boolean, any, range, repeating)",Bo("Additional conditions to be evaluated if the previous ones are FALSE.")),ad("value2 (any, range, repeating)",Bo("Additional values to be returned if their corresponding conditions are TRUE."))],compute:function(...e){for(Pi((()=>e.length%2==0),Bo("Wrong number of arguments. Expected an even number of arguments."));e.length>0;){if(El(e[0]))return cn(Vv.compute,e);const t=Yi(wl(e.shift()));let o=e.shift();if(t)return El(o)||(o=wl(o)),void 0===o?{value:""}:yi(o)||null!==o.value?o:{...o,value:""}}return new Ri(Bo("No match."))},isExported:!0},Lv={description:Bo("Returns opposite of provided logical value."),args:[ad("logical_expression (boolean)",Bo("An expression or reference to a cell holding an expression that represents some logical value."))],compute:function(e){return!Yi(e)},isExported:!0},Hv={description:Bo("Logical `or` operator."),args:[ad("logical_expression1 (boolean, range<boolean>)",Bo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),ad("logical_expression2 (boolean, range<boolean>, repeating)",Bo("More expressions that evaluate to logical values."))],compute:function(...e){const{result:t,foundBoolean:o}=ml(e);return Pi((()=>o),Bo("[[FUNCTION_NAME]] has no valid input data.")),t},isExported:!0},Uv={description:Bo("Logical value `true`."),args:[],compute:function(){return!0},isExported:!0},Bv={description:Bo("Logical `xor` operator."),args:[ad("logical_expression1 (boolean, range<boolean>)",Bo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),ad("logical_expression2 (boolean, range<boolean>, repeating)",Bo("More expressions that evaluate to logical values."))],compute:function(...e){let t=!1,o=!1;return hn(e,(e=>(t=!0,o=o?!e:e,!0))),Pi((()=>t),Bo("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0};var zv=Object.freeze({__proto__:null,AND:Fv,FALSE:Mv,IF:Pv,IFERROR:Nv,IFNA:kv,IFS:Vv,NOT:Lv,OR:Hv,TRUE:Uv,XOR:Bv});function $v(e,t){const o=t.getPivotId(e);if(!o)throw new Ri(Bo('There is no pivot with id "%s"',e));return o}function Gv(e){if(e.length%2!=0)throw new Ri(Bo("Function PIVOT takes an even number of arguments."))}function Wv(e,t,o){const s=[];if("SPREADSHEET"===t.type&&t.dataSet){const{sheetId:o,zone:i}=t.dataSet,n=Zo(i),r=e.getters.getRangeFromSheetXC(o,n);if(void 0===r||r.invalidXc||r.invalidSheetName)throw new _i;if(e.__originCellPosition&&r.sheetId===e.__originSheetId&&ss(ds(e.__originCellPosition),i))throw new Ai;s.push(r)}for(const t of o)if(t.computedBy){const o=e.getters.getMeasureCompiledFormula(t);s.push(...o.dependencies.filter((e=>!e.invalidXc)))}const i=e.__originCellPosition;i&&s.length&&(e.updateDependencies?.(i),e.addDependencies?.(i,s))}const qv=!0;function Zv(e){return{value:Ei.NotAvailable,message:Bo("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",qi(e))}}const jv={description:Bo("Returns a cell reference as a string. "),args:[ad("row (number)",Bo("The row number of the cell reference. ")),ad("column (number)",Bo("The column number (not name) of the cell reference. A is column number 1. ")),ad("absolute_relative_mode (number, default=1)",Bo("An indicator of whether the reference is row/column absolute. 1 is row and column absolute (e.g. $A$1), 2 is row absolute and column relative (e.g. A$1), 3 is row relative and column absolute (e.g. $A1), and 4 is row and column relative (e.g. A1).")),ad("use_a1_notation (boolean, default=TRUE)",Bo("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).")),ad("sheet (string, optional)",Bo("A string indicating the name of the sheet into which the address points."))],compute:function(e,t,o={value:1},s={value:!0},i){const n=$i(e,this.locale),r=$i(t,this.locale);Gi(n),Gi(r);const a=$i(o,this.locale);var l,c;Pi((()=>[1,2,3,4].includes(a)),(l=4,c=a,Bo("The function [[FUNCTION_NAME]] expects a number value between %s and %s inclusive, but receives %s.",1..toString(),l.toString(),c.toString())));let h;if(Yi(s)){h=_o(r-1,n-1,{rowFixed:[1,2].includes(a),colFixed:[1,3].includes(a)})}else{h=([1,2].includes(a)?`R${n}`:`R[${n}]`)+([1,3].includes(a)?`C${r}`:`C[${r}]`)}return void 0!==i?Yr(qi(i),h):h},isExported:!0},Yv={description:Bo("Column number of a specified cell."),args:[ad("cell_reference (meta, default='this cell')",Bo("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."))],compute:function(e){if(ki(e?.value))return e;if(void 0===e)return Pi((()=>void 0!==this.__originCellPosition?.col),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter."),this.__originCellPosition.col+1;const t=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),e.value).zone;return t.left===t.right?t.left+1:rn(t.right-t.left+1,1,((e,o)=>({value:t.left+e+1})))},isExported:!0},Xv={description:Bo("Number of columns in a specified array or range."),args:[ad("range (meta)",Bo("The range whose column count will be returned."))],compute:function(e){if(ki(e?.value))return e;const t=Go(e.value);return t.right-t.left+1},isExported:!0},Kv={description:Bo("Horizontal lookup"),args:[ad("search_key (string, number, boolean)",Bo("The value to search for. For example, 42, 'Cats', or I24.")),ad("range (any, range)",Bo("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")),ad("index (number)",Bo("The row index of the value to be returned, where the first row in range is numbered 1.")),ad("is_sorted (boolean, default=true)",Bo("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."))],compute:function(e,t,o,s={value:qv}){const i=Math.trunc(Li(o?.value,this.locale)),n=Sn(t);Pi((()=>1<=i&&i<=n[0].length),Bo("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const r=(e,t)=>e[t][0].value,a=Yi(s.value)?mn(n,e,"nextSmaller","asc",n.length,r):fn(n,e,"wildcard",n.length,r,this.lookupCaches),l=n[a];return void 0===l?Zv(e):l[i-1]},isExported:!0},Jv={description:Bo("Returns the content of a cell, specified by row and column offset."),args:[ad("reference (any, range)",Bo("The range of cells from which the values are returned.")),ad("row (number, default=0)",Bo("The index of the row to be returned from within the reference range of cells.")),ad("column (number, default=0)",Bo("The index of the column to be returned from within the reference range of cells."))],compute:function(e,t={value:0},o={value:0}){const s=Sn(e),i=Li(t.value,this.locale),n=Li(o.value,this.locale);return Pi((()=>n>=0&&n-1<s.length&&i>=0&&i-1<s[0].length),Bo("Index out of range.")),0===i&&0===n?s:0===i?[s[n-1]]:0===n?s.map((e=>[e[i-1]])):s[n-1][i-1]},isExported:!0},Qv={description:Bo("Returns the content of a cell, specified by a string."),args:[ad("reference (string)",Bo("The range of cells from which the values are returned.")),ad("use_a1_notation (boolean, default=TRUE)",Bo("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE)."))],compute:function(e,t={value:!0}){let o=e?.value?.toString();if(!o)return new _i(Bo("Reference should be defined."));if(!Yi(t))return new Ri(Bo("R1C1 notation is not supported."));const s=this.__originSheetId,i=this.__originCellPosition;i&&this.updateDependencies?.(i);const n=this.getters.getRangeFromSheetXC(s,o);if(void 0===n||n.invalidXc||n.invalidSheetName)return new _i;i&&this.addDependencies?.(i,[n]);const r=[];for(let e=n.zone.left;e<=n.zone.right;e++){const t=[];for(let o=n.zone.top;o<=n.zone.bottom;o++){const s={sheetId:n.sheetId,col:e,row:o};t.push(this.getters.getEvaluatedCell(s))}r.push(t)}return 1===r.length&&1===r[0].length?r[0][0]:r},isExported:!0},eb={description:Bo("Look up a value."),args:[ad("search_key (string, number, boolean)",Bo("The value to search for. For example, 42, 'Cats', or I24.")),ad("search_array (any, range)",Bo("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.")),ad("result_range (any, range, optional)",Bo("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,o){const s=Sn(t),i=Sn(o);let n=s.length,r=s[0].length;const a=r>=n,l=a?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,c=mn(s,e,"nextSmaller","asc",a?r:n,l);return-1===c||a&&void 0===s[0][c]||!a&&void 0===s[c][r-1]?Zv(e):0===i[0].length?a?s[n-1][c]:s[c][r-1]:(n=i.length,r=i[0].length,Pi((()=>1===n||1===r),Bo("The result_range must be a single row or a single column.")),n>1?(Pi((()=>c<=n-1),Bo("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(c+1).toString())),i[c][0]):(Pi((()=>c<=r-1),Bo("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(c+1).toString())),i[0][c]))},isExported:!0},tb={description:Bo("Position of item in range that matches value."),args:[ad("search_key (string, number, boolean)",Bo("The value to search for. For example, 42, 'Cats', or I24.")),ad("range (any, range)",Bo("The one-dimensional array to be searched.")),ad("search_type (number, default=1)",Bo("The search method. 1 (default) 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."))],compute:function(e,t,o={value:1}){let s=Li(o,this.locale);const i=Sn(t),n=i.length,r=i[0].length;Pi((()=>1===n||1===r),Bo("The range must be a single row or a single column."));let a=-1;const l=1===n?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,c=1===n?i[0].length:i.length;switch(s=Math.sign(s),s){case 1:a=mn(i,e,"nextSmaller","asc",c,l);break;case 0:a=fn(i,e,"wildcard",c,l,this.lookupCaches);break;case-1:a=mn(i,e,"nextGreater","desc",c,l)}return 1===n&&void 0===i[0][a]||1!==n&&void 0===i[a]?Zv(e):a+1},isExported:!0},ob={description:Bo("Row number of a specified cell."),args:[ad("cell_reference (meta, default='this cell')",Bo("The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered."))],compute:function(e){if(ki(e?.value))return e;if(void 0===e)return Pi((()=>void 0!==this.__originCellPosition?.row),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter."),this.__originCellPosition.row+1;const t=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),e.value).zone;return t.top===t.bottom?t.top+1:rn(1,t.bottom-t.top+1,((e,o)=>({value:t.top+o+1})))},isExported:!0},sb={description:Bo("Number of rows in a specified array or range."),args:[ad("range (meta)",Bo("The range whose row count will be returned."))],compute:function(e){if(ki(e?.value))return e;const t=Go(e.value);return t.bottom-t.top+1},isExported:!0},ib={description:Bo("Vertical lookup."),args:[ad("search_key (string, number, boolean)",Bo("The value to search for. For example, 42, 'Cats', or I24.")),ad("range (any, range)",Bo("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")),ad("index (number)",Bo("The column index of the value to be returned, where the first column in range is numbered 1.")),ad("is_sorted (boolean, default=true)",Bo("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."))],compute:function(e,t,o,s={value:qv}){const i=Math.trunc(Li(o?.value,this.locale)),n=Sn(t);Pi((()=>1<=i&&i<=n.length),Bo("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const r=(e,t)=>e[0][t].value,a=Yi(s.value)?mn(n,e,"nextSmaller","asc",n[0].length,r):fn(n,e,"wildcard",n[0].length,r,this.lookupCaches),l=n[i-1][a];return void 0===l?Zv(e):l},isExported:!0},nb={0:"strict",1:"nextGreater","-1":"nextSmaller",2:"wildcard"},rb={description:Bo("Search a range for a match and return the corresponding item from a second range."),args:[ad("search_key (string,number,boolean)",Bo("The value to search for.")),ad("lookup_range (any, range)",Bo("The range to consider for the search. Should be a single column or a single row.")),ad("return_range (any, range)",Bo("The range containing the return value. Should have the same dimensions as lookup_range.")),ad("if_not_found (any, optional)",Bo("If a valid match is not found, return this value.")),ad("match_mode (any, default=0)",Bo("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match. (2) Wildcard match.")),ad("search_mode (any, default=1)",Bo("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. "))],compute:function(e,t,o,s,i={value:0},n={value:1}){const r=Math.trunc(Li(i.value,this.locale)),a=Math.trunc(Li(n.value,this.locale)),l=Sn(t),c=Sn(o);Pi((()=>1===l.length||1===l[0].length),Bo("lookup_range should be either a single row or single column.")),Pi((()=>[-1,1,-2,2].includes(a)),Bo("search_mode should be a value in [-1, 1, -2, 2].")),Pi((()=>[-1,0,1,2].includes(r)),Bo("match_mode should be a value in [-1, 0, 1, 2]."));const h=1===l.length?"col":"row";Pi((()=>!(2===r&&[-2,2].includes(a))),Bo("the search and match mode combination is not supported for XLOOKUP evaluation.")),Pi((()=>"col"===h?c[0].length===l[0].length:c.length===l.length),Bo("return_range should have the same dimensions as lookup_range."));const d="col"===h?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,u="col"===h?l[0].length:l.length,g=nb[r],p=-1===a,m=2===a||-2===a?mn(l,e,g,2===a?"asc":"desc",u,d):fn(l,e,g,u,d,this.lookupCaches,p);return-1!==m?"col"===h?c.map((e=>[e[m]])):[c[m]]:void 0===s?Zv(e):[[s]]},isExported:!0},ab={description:Bo("Get the value from a pivot."),args:[ad("pivot_id (number,string)",Bo("ID of the pivot.")),ad("measure_name (string)",Bo("Name of the measure.")),ad("domain_field_name (string,optional,repeating)",Bo("Field name.")),ad("domain_value (number,string,boolean,optional,repeating)",Bo("Value."))],compute:function(e,t,...o){const s=qi(e),i=qi(t),n=$v(s,this.getters);!function(e,t,o){const{measures:s}=o.getPivotCoreDefinition(e);if(!s.find((e=>e.id===t))){const e=`(${s.map((e=>e.id)).join(", ")})`;throw new Ri(Bo("The argument %s is not a valid measure. Here are the measures: %s",t,e))}}(n,i,this.getters),Gv(o);const r=this.getters.getPivot(n),a=this.getters.getPivotCoreDefinition(n);Wv(this,a,a.measures.filter((e=>e.id===i))),r.init({reload:r.needsReevaluation});const l=r.assertIsValid({throwOnError:!1});if(l)return l;if(!r.areDomainArgsFieldsValid(o)){const e=Bo("Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.",`=PIVOT(${s})`);return{value:Ei.GenericError,message:Bo("Dimensions don't match the pivot definition")+". "+e}}const c=r.parseArgsToPivotDomain(o);return this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(n)?.trackValue(i,c),r.getPivotCellValueAndFormat(i,c)}},lb={description:Bo("Get the header of a pivot."),args:[ad("pivot_id (number,string)",Bo("ID of the pivot.")),ad("domain_field_name (string,optional,repeating)",Bo("Field name.")),ad("domain_value (number,string,value,optional,repeating)",Bo("Value."))],compute:function(e,...t){const o=qi(e),s=$v(o,this.getters);Gv(t);const i=this.getters.getPivot(s);Wv(this,this.getters.getPivotCoreDefinition(s),[]),i.init({reload:i.needsReevaluation});const n=i.assertIsValid({throwOnError:!1});if(n)return n;if(!i.areDomainArgsFieldsValid(t)){const e=Bo("Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.",`=PIVOT(${o})`);return{value:Ei.GenericError,message:Bo("Dimensions don't match the pivot definition")+". "+e}}const r=i.parseArgsToPivotDomain(t);this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(s)?.trackHeader(r);const a=r.at(-1);if("measure"===a?.field)return i.getPivotMeasureValue(qi(a.value),r);const{value:l,format:c}=i.getPivotHeaderValueAndFormat(r);return{value:l,format:a&&"measure"!==a.field&&"false"!==a.value?c:void 0}}},cb={description:Bo("Get a pivot table."),args:[ad("pivot_id (string)",Bo("ID of the pivot.")),ad("row_count (number, optional)",Bo("number of rows")),ad("include_total (boolean, default=TRUE)",Bo("Whether to include total/sub-totals or not.")),ad("include_column_titles (boolean, default=TRUE)",Bo("Whether to include the column titles or not.")),ad("column_count (number, optional)",Bo("number of columns"))],compute:function(e,t={value:1e4},o={value:!0},s={value:!0},i={value:Number.MAX_VALUE}){const n=qi(e),r=Li(t,this.locale);if(r<0)return new Ri(Bo("The number of rows must be positive."));const a=Li(i,this.locale);if(a<0)return new Ri(Bo("The number of columns must be positive."));const l=Yi(s),c=Yi(o),h=$v(n,this.getters),d=this.getters.getPivot(h),u=this.getters.getPivotCoreDefinition(h);Wv(this,u,u.measures),d.init({reload:d.needsReevaluation});const g=d.assertIsValid({throwOnError:!1});if(g)return g;const p=d.getTableStructure(),m=p.getPivotCells(c,l),f=l?p.columns.length:0,v=this.getters.getPivotDisplayName(h),b=Math.min(f+r,m[0].length);if(0===b)return[[{value:v}]];const S=Math.min(1+a,m.length),y=[];for(const e of je(0,S)){y[e]=[];for(const t of je(0,b)){const o=m[e][t];switch(o.type){case"EMPTY":y[e].push({value:""});break;case"HEADER":const t=d.getPivotHeaderValueAndFormat(o.domain);y[e].push(Nc(d,o.domain,t));break;case"MEASURE_HEADER":y[e].push(d.getPivotMeasureValue(o.measure,o.domain));break;case"VALUE":y[e].push(d.getPivotCellValueAndFormat(o.measure,o.domain))}}}return l&&(y[0][0]={value:v}),y}},hb={description:Bo("Returns a range reference shifted by a specified number of rows and columns from a starting cell reference."),args:[ad("cell_reference (meta)",Bo("The starting point from which to count the offset rows and columns.")),ad("offset_rows (number)",Bo("The number of rows to offset by.")),ad("offset_columns (number)",Bo("The number of columns to offset by.")),ad("height (number, default='height of cell_reference')",Bo("The number of rows of the range to return starting at the offset target.")),ad("width (number, default='width of cell_reference')",Bo("The number of columns of the range to return starting at the offset target."))],compute:function(e,t,o,s,i){if(ki(e?.value))return e;const n=e?.value;if(!n)return new Ri("In this context, the function OFFSET needs to have a cell or range in parameter.");const r=Go(n);let a=r.bottom-r.top+1,l=r.right-r.left+1;if(s){const e=Li(s,this.locale);dd(Bo("Height value is %(_height)s. It should be greater than or equal to 1.",{_height:e}),e),a=e}if(i){const e=Li(i,this.locale);dd(Bo("Width value is %(_width)s. It should be greater than or equal to 1.",{_width:e}),e),l=e}const{sheetName:c}=jr(n),h=c&&this.getters.getSheetIdByName(c)||this.getters.getActiveSheetId(),d=Li(t,this.locale),u=Li(o,this.locale),g=this.__originCellPosition;g&&this.updateDependencies?.(g);const p=r.left+u,m=r.top+d;if(p<0||m<0)return new _i(Bo("OFFSET evaluates to an out of bounds range."));const f={left:p,top:m,right:p+l-1,bottom:m+a-1},v=this.getters.getRangeFromZone(h,f);return v.invalidXc||v.invalidSheetName?new _i:(g&&this.addDependencies?.(g,[v]),rn(l,a,((e,t)=>this.getters.getEvaluatedCell({sheetId:h,col:p+e,row:m+t}))))}};var db=Object.freeze({__proto__:null,ADDRESS:jv,COLUMN:Yv,COLUMNS:Xv,HLOOKUP:Kv,INDEX:Jv,INDIRECT:Qv,LOOKUP:eb,MATCH:tb,OFFSET:hb,PIVOT:cb,PIVOT_HEADER:lb,PIVOT_VALUE:ab,ROW:ob,ROWS:sb,VLOOKUP:ib,XLOOKUP:rb});const ub={description:Bo("Sum of two numbers."),args:[ad("value1 (number)",Bo("The first addend.")),ad("value2 (number)",Bo("The second addend."))],compute:function(e,t){return{value:Li(e,this.locale)+Li(t,this.locale),format:e?.format||t?.format}}},gb={description:Bo("Concatenation of two values."),args:[ad("value1 (string)",Bo("The value to which value2 will be appended.")),ad("value2 (string)",Bo("The value to append to value1."))],compute:function(e,t){return qi(e)+qi(t)},isExported:!0},pb={description:Bo("One number divided by another."),args:[ad("dividend (number)",Bo("The number to be divided.")),ad("divisor (number)",Bo("The number to divide by."))],compute:function(e,t){const o=Li(t,this.locale);return Pi((()=>0!==o),Bo("The divisor must be different from zero."),Ei.DivisionByZero),{value:Li(e,this.locale)/o,format:e?.format||t?.format}}};function mb(e){return void 0===e||null===e.value}const fb={number:0,string:"",boolean:!1};function vb(e,t,o=2e-16){return Math.abs(e-t)<o}const bb={description:Bo("Equal."),args:[ad("value1 (string, number, boolean)",Bo("The first value.")),ad("value2 (string, number, boolean)",Bo("The value to test against value1 for equality."))],compute:function(e,t){if(ki(e?.value))return e;if(ki(t?.value))return t;let o=mb(e)?fb[typeof t?.value]:e?.value,s=mb(t)?fb[typeof e?.value]:t?.value;return"string"==typeof o&&(o=o.toUpperCase()),"string"==typeof s&&(s=s.toUpperCase()),"number"==typeof o&&"number"==typeof s?{value:vb(o,s)}:{value:o===s}}};function Sb(e,t,o){if(ki(e?.value))return e;if(ki(t?.value))return t;let s=mb(e)?fb[typeof t?.value]:e?.value,i=mb(t)?fb[typeof e?.value]:t?.value;"number"!=typeof s&&(s=qi(s).toUpperCase()),"number"!=typeof i&&(i=qi(i).toUpperCase());const n=typeof s,r=typeof i;return"string"===n&&"number"===r?{value:!0}:"string"===r&&"number"===n?{value:!1}:{value:o(s,i)}}const yb={description:Bo("Strictly greater than."),args:[ad("value1 (number, string, boolean)",Bo("The value to test as being greater than value2.")),ad("value2 (number, string, boolean)",Bo("The second value."))],compute:function(e,t){return Sb(e,t,((e,t)=>"number"==typeof e&&"number"==typeof t?!vb(e,t)&&e>t:e>t))}},Cb={description:Bo("Greater than or equal to."),args:[ad("value1 (number, string, boolean)",Bo("The value to test as being greater than or equal to value2.")),ad("value2 (number, string, boolean)",Bo("The second value."))],compute:function(e,t){return Sb(e,t,((e,t)=>"number"==typeof e&&"number"==typeof t?vb(e,t)||e>t:e>=t))}},wb={description:Bo("Less than."),args:[ad("value1 (number, string, boolean)",Bo("The value to test as being less than value2.")),ad("value2 (number, string, boolean)",Bo("The second value."))],compute:function(e,t){const o=Cb.compute.bind(this)(e,t);return ki(o.value)?o:{value:!o.value}}},xb={description:Bo("Less than or equal to."),args:[ad("value1 (number, string, boolean)",Bo("The value to test as being less than or equal to value2.")),ad("value2 (number, string, boolean)",Bo("The second value."))],compute:function(e,t){const o=yb.compute.bind(this)(e,t);return ki(o.value)?o:{value:!o.value}}},Eb={description:Bo("Difference of two numbers."),args:[ad("value1 (number)",Bo("The minuend, or number to be subtracted from.")),ad("value2 (number)",Bo("The subtrahend, or number to subtract from value1."))],compute:function(e,t){return{value:Li(e,this.locale)-Li(t,this.locale),format:e?.format||t?.format}}},Ib={description:Bo("Product of two numbers"),args:[ad("factor1 (number)",Bo("The first multiplicand.")),ad("factor2 (number)",Bo("The second multiplicand."))],compute:function(e,t){return{value:Li(e,this.locale)*Li(t,this.locale),format:e?.format||t?.format}}},Rb={description:Bo("Not equal."),args:[ad("value1 (string, number, boolean)",Bo("The first value.")),ad("value2 (string, number, boolean)",Bo("The value to test against value1 for inequality."))],compute:function(e,t){const o=bb.compute.bind(this)(e,t);return ki(o.value)?o:{value:!o.value}}},Tb={description:Bo("A number raised to a power."),args:[ad("base (number)",Bo("The number to raise to the exponent power.")),ad("exponent (number)",Bo("The exponent to raise base to."))],compute:function(e,t){return _u.compute.bind(this)(e,t)}},Ab={description:Bo("A number with the sign reversed."),args:[ad("value (number)",Bo("The number to have its sign reversed. Equivalently, the number to multiply by -1."))],compute:function(e){return{value:-Li(e,this.locale),format:e?.format}}},_b={description:Bo("Value interpreted as a percentage."),args:[ad("percentage (number)",Bo("The value to interpret as a percentage."))],compute:function(e){return Li(e,this.locale)/100}},Db={description:Bo("A specified number, unchanged."),args:[ad("value (any)",Bo("The number to return."))],compute:function(e={value:null}){return e}};var Ob=Object.freeze({__proto__:null,ADD:ub,CONCAT:gb,DIVIDE:pb,EQ:bb,GT:yb,GTE:Cb,LT:wb,LTE:xb,MINUS:Eb,MULTIPLY:Ib,NE:Rb,POW:Tb,UMINUS:Ab,UNARY_PERCENT:_b,UPLUS:Db});const Fb=e=>({transform:t=>t*e,inverseTransform:t=>t/e}),Mb={transform:e=>e,inverseTransform:e=>e},Pb=1e-10,Nb=.0254,kb=Nb/72,Vb=.3048,Lb=.9144,Hb=1609.34,Ub=1852,Bb=946073047258e4,zb={g:{...Mb,category:"weight"},u:{...Fb(166053e-29),category:"weight"},grain:{...Fb(.0647989),category:"weight"},ozm:{...Fb(28.3495),category:"weight"},lbm:{...Fb(453.592),category:"weight"},stone:{...Fb(6350.29),category:"weight"},sg:{...Fb(14593.90294),category:"weight"},cwt:{...Fb(45359.237),category:"weight"},uk_cwt:{...Fb(50802.3),category:"weight"},ton:{...Fb(907184.74),category:"weight"},uk_ton:{...Fb(1016046.9),category:"weight"},m:{...Mb,category:"distance"},km:{...Fb(1e3),category:"distance"},ang:{...Fb(Pb),category:"distance"},Picapt:{...Fb(kb),category:"distance"},pica:{...Fb(Nb/6),category:"distance"},in:{...Fb(Nb),category:"distance"},ft:{...Fb(Vb),category:"distance"},yd:{...Fb(Lb),category:"distance"},ell:{...Fb(1.143),category:"distance"},mi:{...Fb(Hb),category:"distance"},survey_mi:{...Fb(1609.34),category:"distance"},Nmi:{...Fb(Ub),category:"distance"},ly:{...Fb(Bb),category:"distance"},parsec:{...Fb(0x6da012f95c9fd0),category:"distance"},sec:{...Mb,category:"time"},min:{...Fb(60),category:"time"},hr:{...Fb(3600),category:"time"},day:{...Fb(86400),category:"time"},yr:{...Fb(31556952),category:"time"},Pa:{...Mb,category:"pressure"},bar:{...Fb(1e5),category:"pressure"},mmHg:{...Fb(133.322),category:"pressure"},Torr:{...Fb(133.322),category:"pressure"},psi:{...Fb(6894.76),category:"pressure"},atm:{...Fb(101325),category:"pressure"},N:{...Mb,category:"force"},dyn:{...Fb(1e-5),category:"force"},pond:{...Fb(.00980665),category:"force"},lbf:{...Fb(4.44822),category:"force"},J:{...Mb,category:"energy"},eV:{...Fb(160218e-24),category:"energy"},e:{...Fb(1e-7),category:"energy"},flb:{...Fb(1.3558179483),category:"energy"},c:{...Fb(4.184),category:"energy"},cal:{...Fb(4.1868),category:"energy"},BTU:{...Fb(1055.06),category:"energy"},Wh:{...Fb(3600),category:"energy"},HPh:{...Fb(2684520),category:"energy"},W:{...Mb,category:"power"},PS:{...Fb(735.499),category:"power"},HP:{...Fb(745.7),category:"power"},T:{...Mb,category:"magnetism"},ga:{...Fb(1e-4),category:"magnetism"},K:{...Mb,category:"temperature"},C:{transform:e=>e+273.15,inverseTransform:e=>e-273.15,category:"temperature"},F:{transform:e=>5*(e-32)/9+273.15,inverseTransform:e=>9*(e-273.15)/5+32,category:"temperature"},Rank:{...Fb(5/9),category:"temperature"},Reau:{transform:e=>1.25*e+273.15,inverseTransform:e=>(e-273.15)/1.25,category:"temperature"},"m^3":{...Mb,category:"volume",order:3},"ang^3":{...Fb(Math.pow(Pb,3)),category:"volume",order:3},"Picapt^3":{...Fb(Math.pow(kb,3)),category:"volume",order:3},tsp:{...Fb(492892e-11),category:"volume"},tspm:{...Fb(5e-6),category:"volume"},tbs:{...Fb(14786764825785619e-21),category:"volume"},"in^3":{...Fb(Math.pow(Nb,3)),category:"volume",order:3},oz:{...Fb(295735295625e-16),category:"volume"},cup:{...Fb(237e-6),category:"volume"},pt:{...Fb(.0004731765),category:"volume"},uk_pt:{...Fb(568261e-9),category:"volume"},qt:{...Fb(.0009463529),category:"volume"},l:{...Fb(.001),category:"volume"},uk_qt:{...Fb(.0011365225),category:"volume"},gal:{...Fb(.0037854118),category:"volume"},uk_gal:{...Fb(.00454609),category:"volume"},"ft^3":{...Fb(Math.pow(Vb,3)),category:"volume",order:3},bushel:{...Fb(.0352390704),category:"volume"},barrel:{...Fb(.158987295),category:"volume"},"yd^3":{...Fb(Math.pow(Lb,3)),category:"volume",order:3},MTON:{...Fb(1.13267386368),category:"volume"},GRT:{...Fb(2.83168),category:"volume"},"mi^3":{...Fb(Math.pow(Hb,3)),category:"volume",order:3},"Nmi^3":{...Fb(Math.pow(Ub,3)),category:"volume",order:3},"ly^3":{...Fb(Math.pow(Bb,3)),category:"volume",order:3},"m^2":{...Mb,category:"area",order:2},"ang^2":{...Fb(Math.pow(Pb,2)),category:"area",order:2},"Picapt^2":{...Fb(Math.pow(kb,2)),category:"area",order:2},"in^2":{...Fb(Math.pow(Nb,2)),category:"area",order:2},"ft^2":{...Fb(Math.pow(Vb,2)),category:"area",order:2},"yd^2":{...Fb(Math.pow(Lb,2)),category:"area",order:2},ar:{...Fb(100),category:"area"},Morgen:{...Fb(2500),category:"area"},uk_acre:{...Fb(4046.8564224),category:"area"},us_acre:{...Fb(4046.8726098743),category:"area"},ha:{...Fb(1e4),category:"area"},"mi^2":{...Fb(Math.pow(Hb,2)),category:"area",order:2},"Nmi^2":{...Fb(Math.pow(Ub,2)),category:"area",order:2},"ly^2":{...Fb(Math.pow(Bb,2)),category:"area",order:2},bit:{...Mb,category:"information"},byte:{...Fb(8),category:"information"},"m/s":{...Mb,category:"speed"},"m/hr":{...Fb(1/3600),category:"speed"},"km/hr":{...Fb(1/3.6),category:"speed"},mph:{...Fb(.44704),category:"speed"},kn:{...Fb(.5144444444),category:"speed"},admkn:{...Fb(.5147733333),category:"speed"}},$b={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"},Gb={"":1,Y:1e24,Z:1e21,E:1e18,P:1e15,T:1e12,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:Math.pow(2,80),Zi:Math.pow(2,70),Ei:Math.pow(2,60),Pi:Math.pow(2,50),Ti:Math.pow(2,40),Gi:Math.pow(2,30),Mi:Math.pow(2,20),ki:Math.pow(2,10)},Wb={weight:Bo("Weight"),distance:Bo("Distance"),time:Bo("Time"),pressure:Bo("Pressure"),force:Bo("Force"),energy:Bo("Energy"),power:Bo("Power"),magnetism:Bo("Magnetism"),temperature:Bo("Temperature"),volume:Bo("Volume"),area:Bo("Area"),information:Bo("Information"),speed:Bo("Speed")};function qb(e){return Wb[e]??""}function Zb(e){for(const[t,o]of Object.entries(Gb)){if(t&&!e.startsWith(t))continue;const s=e.slice(t.length);let i=zb[s];if(!i&&$b[s]&&(i=zb[$b[s]]),i)return{...i,factor:i.order?Math.pow(o,i.order):o}}}const jb={description:Bo("Converts a numeric value to a different unit of measure."),args:[ad("value (number)",Bo("the numeric value in start_unit to convert to end_unit")),ad("start_unit (string)",Bo("The starting unit, the unit currently assigned to value")),ad("end_unit (string)",Bo("The unit of measure into which to convert value"))],compute:function(e,t,o){const s=Li(e,this.locale),i=qi(t),n=qi(o),r=Zb(i),a=Zb(n);return r?a?r.category!==a.category?{value:Ei.GenericError,message:Bo("Incompatible units of measure ('%s' vs '%s')",qb(r.category),qb(a.category))}:{value:a.inverseTransform(r.factor*r.transform(s))/a.factor,format:e?.format}:{value:Ei.GenericError,message:Bo("Invalid units of measure ('%s')",n)}:{value:Ei.GenericError,message:Bo("Invalid units of measure ('%s')",i)}},isExported:!0};var Yb=Object.freeze({__proto__:null,CONVERT:jb});const Xb=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,Kb={description:Bo("Gets character associated with number."),args:[ad("table_number (number)",Bo("The number of the character to look up from the current Unicode table in decimal format."))],compute:function(e){const t=Math.trunc(Li(e,this.locale));return Pi((()=>t>=1),Bo("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},Jb={description:Bo("Remove non-printable characters from a piece of text."),args:[ad("text (string)",Bo("The text whose non-printable characters are to be removed."))],compute:function(e){const t=qi(e);let o="";for(const e of t)e&&e.charCodeAt(0)>31&&(o+=e);return o},isExported:!0},Qb={description:Bo("Appends strings to one another."),args:[ad("string1 (string, range<string>)",Bo("The initial string.")),ad("string2 (string, range<string>, repeating)",Bo("More strings to append in sequence."))],compute:function(...e){return on(e,((e,t)=>e+qi(t)),"")},isExported:!0},eS={description:Bo("Tests whether two strings are identical."),args:[ad("string1 (string)",Bo("The first string to compare.")),ad("string2 (string)",Bo("The second string to compare."))],compute:function(e,t){return qi(e)===qi(t)},isExported:!0},tS={description:Bo("First position of string found in text, case-sensitive."),args:[ad("search_for (string)",Bo("The string to look for within text_to_search.")),ad("text_to_search (string)",Bo("The text to search for the first occurrence of search_for.")),ad("starting_at (number, default=1)",Bo("The character within text_to_search at which to start the search."))],compute:function(e,t,o={value:1}){const s=qi(e),i=qi(t),n=Li(o,this.locale);Pi((()=>""!==i),Bo("The text_to_search must be non-empty.")),Pi((()=>n>=1),Bo("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const r=i.indexOf(s,n-1);return Pi((()=>r>=0),Bo("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",s.toString(),i)),r+1},isExported:!0},oS={description:Bo("Concatenates elements of arrays with delimiter."),args:[ad("delimiter (string)",Bo("The character or string to place between each concatenated value.")),ad("value_or_array1 (string, range<string>)",Bo("The value or values to be appended using delimiter.")),ad("value_or_array2 (string, range<string>, repeating)",Bo("More values to be appended using delimiter."))],compute:function(e,...t){const o=qi(e);return on(t,((e,t)=>(e?e+o:"")+qi(t)),"")}},sS={description:Bo("Substring from beginning of specified string."),args:[ad("text (string)",Bo("The string from which the left portion will be returned.")),ad("number_of_characters (number, optional)",Bo("The number of characters to return from the left side of string."))],compute:function(e,...t){const o=t.length?Li(t[0],this.locale):1;return Pi((()=>o>=0),Bo("The number_of_characters (%s) must be positive or null.",o.toString())),qi(e).substring(0,o)},isExported:!0},iS={description:Bo("Length of a string."),args:[ad("text (string)",Bo("The string whose length will be returned."))],compute:function(e){return qi(e).length},isExported:!0},nS={description:Bo("Converts a specified string to lowercase."),args:[ad("text (string)",Bo("The string to convert to lowercase."))],compute:function(e){return qi(e).toLowerCase()},isExported:!0},rS={description:Bo("A segment of a string."),args:[ad("text (string)",Bo("The string to extract a segment from.")),ad("starting_at (number)",Bo("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),ad("extract_length (number)",Bo("The length of the segment to extract."))],compute:function(e,t,o){const s=qi(e),i=Li(t,this.locale),n=Li(o,this.locale);return Pi((()=>i>=1),Bo("The starting_at argument (%s) must be positive greater than one.",i.toString())),Pi((()=>n>=0),Bo("The extract_length argument (%s) must be positive or null.",n.toString())),s.slice(i-1,i+n-1)},isExported:!0},aS={description:Bo("Capitalizes each word in a specified string."),args:[ad("text_to_capitalize (string)",Bo("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 qi(e).replace(Xb,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},lS={description:Bo("Replaces part of a text string with different text."),args:[ad("text (string)",Bo("The text, a part of which will be replaced.")),ad("position (number)",Bo("The position where the replacement will begin (starting from 1).")),ad("length (number)",Bo("The number of characters in the text to be replaced.")),ad("new_text (string)",Bo("The text which will be inserted into the original text."))],compute:function(e,t,o,s){const i=Li(t,this.locale);Pi((()=>i>=1),Bo("The position (%s) must be greater than or equal to 1.",i.toString()));const n=qi(e),r=Li(o,this.locale),a=qi(s);return n.substring(0,i-1)+a+n.substring(i-1+r)},isExported:!0},cS={description:Bo("A substring from the end of a specified string."),args:[ad("text (string)",Bo("The string from which the right portion will be returned.")),ad("number_of_characters (number, optional)",Bo("The number of characters to return from the right side of string."))],compute:function(e,...t){const o=t.length?Li(t[0],this.locale):1;Pi((()=>o>=0),Bo("The number_of_characters (%s) must be positive or null.",o.toString()));const s=qi(e),i=s.length;return s.substring(i-o,i)},isExported:!0},hS={description:Bo("First position of string found in text, ignoring case."),args:[ad("search_for (string)",Bo("The string to look for within text_to_search.")),ad("text_to_search (string)",Bo("The text to search for the first occurrence of search_for.")),ad("starting_at (number, default=1)",Bo("The character within text_to_search at which to start the search."))],compute:function(e,t,o={value:1}){const s=qi(e).toLowerCase(),i=qi(t).toLowerCase(),n=Li(o,this.locale);if(""===i)return{value:Ei.GenericError,message:Bo("The text_to_search must be non-empty.")};if(n<1)return{value:Ei.GenericError,message:Bo("The starting_at (%s) must be greater than or equal to 1.",n)};const r=i.indexOf(s,n-1);return-1===r?{value:Ei.GenericError,message:Bo("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",s,i)}:{value:r+1}},isExported:!0},dS={description:Bo("Split text by specific character delimiter(s)."),args:[ad("text (string)",Bo("The text to divide.")),ad("delimiter (string)",Bo("The character or characters to use to split text.")),ad("split_by_each (boolean, default=true})",Bo("Whether or not to divide text around each character contained in delimiter.")),ad("remove_empty_text (boolean, default=true)",Bo("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."))],compute:function(e,t,o={value:true},s={value:true}){const i=qi(e),n=Be(qi(t)),r=Yi(o),a=Yi(s);Pi((()=>n.length>0),Bo("The _delimiter (%s) must be not be empty.",n));const l=r?new RegExp(`[${n}]`,"g"):new RegExp(n,"g");let c=i.split(l);return a&&(c=c.filter((e=>""!==e))),ln([c])},isExported:!1},uS={description:Bo("Replaces existing text with new text in a string."),args:[ad("text_to_search (string)",Bo("The text within which to search and replace.")),ad("search_for (string)",Bo("The string to search for within text_to_search.")),ad("replace_with (string)",Bo("The string that will replace search_for.")),ad("occurrence_number (number, optional)",Bo("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,o,s){const i=Li(s,this.locale);Pi((()=>i>=0),Bo("The occurrenceNumber (%s) must be positive or null.",i.toString()));const n=qi(e),r=qi(t);if(""===r)return n;const a=qi(o),l=new RegExp(Be(r),"g");if(0===i)return n.replace(l,a);let c=0;return n.replace(l,(e=>++c===i?a:e))},isExported:!0},gS={description:Bo("Combines text from multiple strings and/or arrays."),args:[ad("delimiter (string)",Bo(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")),ad("ignore_empty (boolean)",Bo("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")),ad("text1 (string, range<string>)",Bo("Any text item. This could be a string, or an array of strings in a range.")),ad("text2 (string, range<string>, repeating)",Bo("Additional text item(s)."))],compute:function(e,t,...o){const s=qi(e),i=Yi(t);let n=0;return on(o,((e,t)=>i&&""===qi(t)?e:(n++?e+s:"")+qi(t)),"")},isExported:!0},pS={description:Bo("Removes space characters."),args:[ad("text (string)",Bo("The text or reference to a cell containing text to be trimmed."))],compute:function(e){return _t(qi(e))},isExported:!0},mS={description:Bo("Converts a specified string to uppercase."),args:[ad("text (string)",Bo("The string to convert to uppercase."))],compute:function(e){return qi(e).toUpperCase()},isExported:!0},fS={description:Bo("Converts a number to text according to a specified format."),args:[ad("number (number)",Bo("The number, date or time to format.")),ad("format (string)",Bo("The pattern by which to format the number, enclosed in quotation marks."))],compute:function(e,t){return Qn(Li(e,this.locale),{format:qi(t),locale:this.locale})},isExported:!0},vS={description:Bo("Converts a string to a numeric value."),args:[ad("value (number)",Bo("the string to be converted"))],compute:function(e){return Li(e,this.locale)},isExported:!0};var bS=Object.freeze({__proto__:null,CHAR:Kb,CLEAN:Jb,CONCATENATE:Qb,EXACT:eS,FIND:tS,JOIN:oS,LEFT:sS,LEN:iS,LOWER:nS,MID:rS,PROPER:aS,REPLACE:lS,RIGHT:cS,SEARCH:hS,SPLIT:dS,SUBSTITUTE:uS,TEXT:fS,TEXTJOIN:gS,TRIM:pS,UPPER:mS,VALUE:vS});const SS={description:Bo("Creates a hyperlink in a cell."),args:[ad("url (string)",Bo("The full URL of the link enclosed in quotation marks.")),ad("link_label (string, optional)",Bo("The text to display in the cell, enclosed in quotation marks."))],compute:function(e,t){const o=qi(e).trim(),s=qi(t)||o;return""===o?s:ot(s,o)},isExported:!0};var yS=Object.freeze({__proto__:null,HYPERLINK:SS});const CS=[{name:Bo("Array"),functions:Vd},{name:Bo("Database"),functions:yp},{name:Bo("Date"),functions:tm},{name:Bo("Filter"),functions:gm},{name:Bo("Financial"),functions:Gf},{name:Bo("Info"),functions:Ov},{name:Bo("Lookup"),functions:db},{name:Bo("Logical"),functions:zv},{name:Bo("Math"),functions:Ku},{name:Bo("Misc"),functions:Hd},{name:Bo("Operator"),functions:Ob},{name:Bo("Statistical"),functions:np},{name:Bo("Text"),functions:bS},{name:Bo("Engineering"),functions:sm},{name:Bo("Web"),functions:yS},{name:Bo("Parser"),functions:Yb}],wS=/^[A-Z0-9\_\.]+$/;const xS=new class extends n{mapping={};add(e,t){if(e=e.toUpperCase(),!wS.test(e))throw new Error(Bo("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const o=ld(t);return function(e){let t=!1,o=!1,s=!1;for(let i of e){if(i.type.includes("META")&&i.type.length>1)throw new Error(Bo("Function ${name} has an argument that has been declared with more than one type whose type 'META'. The 'META' type can only be declared alone."));if(t&&!i.repeating)throw new Error(Bo("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=o||t||s,n=!(i.optional||i.repeating||i.default);if(e&&n)throw new Error(Bo("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=i.repeating,o=i.optional,s=i.default}}(o.args),this.mapping[e]=function(e,t){function o(...o){const i=[];for(let s=0;s<o.length;s++){const n=e.args[e.getArgToFocus(s+1)-1];if(!yi(o[s])&&n.acceptMatrixOnly)throw new Ti(Bo("Function %s expects the parameter '%s' to be reference to a cell or range.",t,(s+1).toString()));i.push(!n.acceptMatrix)}return cn(s.bind(this),o,i)}function s(...o){for(let t=0;t<o.length;t++){const s=o[t];if(!e.args[e.getArgToFocus(t+1)-1].acceptErrors&&!yi(s)&&ki(s?.value))return s}try{return i.apply(this,o)}catch(e){return ES(e,t)}}function i(...o){this.debug;const s=e.compute.apply(this,o);return yi(s)?"object"==typeof s[0][0]&&null!==s[0][0]&&"value"in s[0][0]?(function(e,t){const o=e.length,s=e[0]?.length??0;for(let i=0;i<o;i++)for(let o=0;o<s;o++)t(e[i][o])}(s,(e=>IS(e,t))),s):an(s,(e=>({value:e}))):"object"==typeof s&&null!==s&&"value"in s?(IS(s,t),s):{value:s}}return o}(o,e),super.add(e,o),this}};for(let e of CS){const t=e.functions;for(let o in t){const s=t[o];s.category=s.category||e.name,o=o.replace(/_/g,"."),xS.add(o,{isExported:!1,...s})}}function ES(e,t){return o=e,void 0!==o?.value&&"string"==typeof o.value&&ki(e.value)?(TS(e)&&IS(e,t),e):(console.error(e),new Ri(RS+(TS(e)?" "+e.message:"")));var o}function IS(e,t){e.message?.includes("[[FUNCTION_NAME]]")&&(e.message=e.message.replace("[[FUNCTION_NAME]]",t))}const RS=Bo("An unexpected error occurred. Submit a support ticket at odoo.com/help.");function TS(e){return void 0!==e?.message&&"string"==typeof e.message}function AS(e,t,o){const{x:s,y:i,width:n,height:r}=o;if(n<0||r<0)return;const l=t.color||a,{ctx:c}=e;c.save(),t.noBorder||(t.dashed&&c.setLineDash([5,3]),c.strokeStyle=l,t.thinLine?(c.lineWidth=1,c.strokeRect(s,i,n,r)):(c.lineWidth=2,c.strokeRect(s+.5,i+.5,n,r))),t.noFill||(c.fillStyle=eo($t(l),t.fillAlpha??.12),c.fillRect(s,i,n,r)),c.restore()}sd.add("functions",{sequence:100,autoSelectFirstProposal:!0,maxDisplayedProposals:10,getProposals(e){if("SYMBOL"!==e.type)return[];const t=e.value;if(!this.composer.currentContent.startsWith("="))return[];const o=Object.entries(xS.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:o}])=>({text:e,description:o,htmlContent:id(t,e,I,"o-semi-bold")}))).sort(((e,t)=>e.text.length-t.text.length||e.text.localeCompare(t.text)));return o},selectProposal(e,t){let o=e.end,s=e.end;["SYMBOL","FUNCTION"].includes(e.type)&&(o=e.start);const i=this.composer.currentTokens;t+="(";const n=i.map((e=>e.start)).indexOf(e.start);if(n+1<i.length){const e=i[n+1];"LEFT_PAREN"===e?.type&&s++}this.composer.changeComposerCursorSelection(o,s),this.composer.replaceComposerCursorSelection(t)}});class _S extends th{mutators=["register","unRegister"];providers=[];constructor(e){super(e),this.onDispose((()=>{this.providers=[]}))}get renderingLayers(){return["Highlights"]}get highlights(){const e=this.getters.getActiveSheetId();return this.providers.flatMap((e=>e.highlights)).filter((t=>t.sheetId===e)).map((e=>{const{numberOfRows:t,numberOfCols:o}=is(e.zone),s=t*o==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:s}}))}register(e){this.providers.push(e)}unRegister(e){this.providers=this.providers.filter((t=>t!==e))}drawLayer(e,t){if("Highlights"===t)for(const t of this.highlights){AS(e,t,this.getters.getVisibleRect(t.zone))}}}class DS{mutators=["notifyUser","raiseError","askConfirmation","updateNotificationCallbacks"];notifyUser=e=>window.alert(e.text);askConfirmation=(e,t,o)=>{window.confirm(e)?t():o?.()};raiseError=(e,t)=>{window.alert(e),t?.()};updateNotificationCallbacks(e){this.notifyUser=e.notifyUser||this.notifyUser,this.raiseError=e.raiseError||this.raiseError,this.askConfirmation=e.askConfirmation||this.askConfirmation}}const OS="#000000",FS="#3da4ab",MS={OPERATOR:FS,NUMBER:"#02c39a",STRING:"#00a82d",FUNCTION:OS,DEBUGGER:FS,LEFT_PAREN:OS,RIGHT_PAREN:OS,ARG_SEPARATOR:OS,ORPHAN_RIGHT_PAREN:"#ff0000"};class PS extends th{mutators=["startEdition","setCurrentContent","stopEdition","stopComposerRangeSelection","cancelEdition","cycleReferences","toggleEditionMode","changeComposerCursorSelection","replaceComposerCursorSelection"];col=0;row=0;editionMode="inactive";sheetId="";_currentContent="";currentTokens=[];selectionStart=0;selectionEnd=0;initialContent="";colorIndexByRange={};notificationStore=this.get(DS);highlightStore=this.get(_S);constructor(e){super(e),this.highlightStore.register(this),this.onDispose((()=>{this.highlightStore.unRegister(this),this._cancelEdition()}))}handleEvent(e){const t=this.getters.getActiveSheetId();let o;if(o=e.options.unbounded?this.getters.getUnboundedZone(t,e.anchor.zone):e.anchor.zone,"newAnchor"===e.mode)"selecting"===this.editionMode&&this.insertSelectedRange(o);else"selecting"===this.editionMode?this.replaceSelectedRange(o):this.updateComposerRange(e.previousAnchor.zone,o)}changeComposerCursorSelection(e,t){this.isSelectionValid(this._currentContent.length,e,t)&&(this.selectionStart=e,this.selectionEnd=t,this.computeFormulaCursorContext(),this.computeParenthesisRelatedToCursor())}stopComposerRangeSelection(){this.isSelectingRange&&(this.editionMode="editing")}startEdition(e,t){if(t){const o=e||this.getComposerContent(this.getters.getActivePosition());if(!this.isSelectionValid(o.length,t.start,t.end))return}const{col:o,row:s}=this.getters.getActivePosition();this.model.dispatch("SELECT_FIGURE",{id:null}),this.model.dispatch("SCROLL_TO_CELL",{col:o,row:s}),"inactive"!==this.editionMode&&e?this.setContent(e,t):this._startEdition(e,t),this.updateTokenColor(),this.computeFormulaCursorContext(),this.computeParenthesisRelatedToCursor()}cancelEdition(){this.resetContent(),this.cancelEditionAndActivateSheet()}setCurrentContent(e,t){t&&!this.isSelectionValid(e.length,t.start,t.end)||(this.setContent(e,t,!0),this.updateTokenColor(),this.computeFormulaCursorContext(),this.computeParenthesisRelatedToCursor())}replaceComposerCursorSelection(e){this.replaceSelection(e)}handle(e){switch(e.type){case"SELECT_FIGURE":e.id&&(this.resetContent(),this.cancelEditionAndActivateSheet());break;case"START_CHANGE_HIGHLIGHT":const{left:t,top:o}=e.zone;this.isSelectingRange&&(this.editionMode="editing"),this.model.selection.resetAnchor(this,{cell:{col:t,row:o},zone:e.zone})}}get currentContent(){return"inactive"===this.editionMode?this.getComposerContent(this.getters.getActivePosition()):this._currentContent}get composerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}get isSelectingRange(){return"selecting"===this.editionMode}get showSelectionIndicator(){return this.isSelectingRange&&this.canStartComposerRangeSelection()}get tokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((o=>o.start<=e&&o.end>=t))}cycleReferences(){const e=this.getters.getLocale(),t=Sv(this.composerSelection,this._currentContent,e);void 0!==t&&this.setCurrentContent(t.content,t.selection)}toggleEditionMode(){if("inactive"===this.editionMode)return;const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd),o=[...this.currentTokens].reverse().find((o=>o.end>=e&&t>=o.start&&"REFERENCE"===o.type));if("editing"===this.editionMode&&o){const e=this.getters.getActiveSheetId(),{sheetName:t,xc:s}=jr(o.value),i=this.getters.getSheetIdByName(t);i&&i!==e&&this.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e,sheetIdTo:i}),this.selectionStart=this.selectionEnd=o.end;const n=this.getters.getRangeFromSheetXC(this.sheetId,s).zone;this.captureSelection(n),this.editionMode="selecting"}else this.editionMode="editing"}captureSelection(e,t,o){this.model.selection.capture(this,{cell:{col:t??e.left,row:o??e.right},zone:e},{handleEvent:this.handleEvent.bind(this),release:()=>{this._stopEdition()}})}isSelectionValid(e,t,o){return t>=0&&t<=e&&o>=0&&o<=e}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=ds({col:this.col,row:this.row});this.model.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.editionMode="selecting"}_startEdition(e,t){const o=this.getters.getActiveCell(),s=this.getters.getLocale();e&&o.format?.includes("%")&&ei(e,s)&&(t=t||{start:e.length,end:e.length},e=`${e}%`);const{col:i,row:n,sheetId:r}=this.getters.getActivePosition();this.col=i,this.sheetId=r,this.row=n,this.initialContent=this.getComposerContent({sheetId:r,col:i,row:n}),this.editionMode="editing",this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const a=ds({col:this.col,row:this.row});this.captureSelection(a,i,n)}_stopEdition(){if("inactive"!==this.editionMode){this.cancelEditionAndActivateSheet();let e=this.getCurrentCanonicalContent();if(!(this.initialContent!==e))return;if(e&&e.startsWith("=")){const t=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length-this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length;t>0&&(e+=ut(new Array(t).fill(")")))}this.confirmEdition(e)}}getCurrentCanonicalContent(){return el(this._currentContent,this.getters.getLocale())}cancelEditionAndActivateSheet(){if("inactive"===this.editionMode)return;this._cancelEdition();this.getters.getActiveSheetId()!==this.sheetId&&this.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}_cancelEdition(){"inactive"!==this.editionMode&&(this.editionMode="inactive",this.model.selection.release(this),this.colorIndexByRange={})}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,o){const s=this._currentContent!==e;if(this._currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,s||"inactive"!==this.editionMode){const t=this.getters.getLocale();this.currentTokens=e.startsWith("=")?pv(e,t):[],this.currentTokens.length>100&&o&&this.notificationStore.raiseError(Bo("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells"))}this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}getAutoCompleteProviders(){return sd.getAll()}insertSelectedRange(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=this.getZoneReference(e);this.canStartComposerRangeSelection()?this.insertText(o,t):this.insertText(","+o,t)}replaceSelectedRange(e){const t=this.getZoneReference(e),o=this.tokenAtCursor,s="REFERENCE"===o?.type?o.start:this.selectionStart;this.replaceText(t,s,this.selectionEnd)}updateComposerRange(e,t){const o=this.getters.getActiveSheetId(),s=this.tokenAtCursor,i=(s?[s,...this.currentTokens]:this.currentTokens).filter((e=>"REFERENCE"===e.type)).find((t=>{const{xc:s,sheetName:i}=jr(t.value),n=i||this.getters.getSheetName(this.sheetId);if(!aa(this.getters.getSheetName(o),n))return!1;const r=this.getters.getRangeFromSheetXC(o,s);return es(this.getters.expandZone(o,r.zone),e)}));if(!i)return;const n=this.getters.getRangeFromSheetXC(o,i.value);this.selectionStart=i.start,this.selectionEnd=this.selectionStart+i.value.length;const r=this.getters.getRangeFromZone(o,t),a=this.getRangeReference(r,n.parts);this.replaceSelection(a)}getZoneReference(e){const t=this.sheetId,o=this.getters.getActiveSheetId(),s=this.getters.getRangeFromZone(o,e);return this.getters.getSelectionRangeString(s,t)}getRangeReference(e,t){let o=[...t];const s=e.clone({parts:o});return this.getters.getSelectionRangeString(s,this.sheetId)}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,o)}replaceText(e,t,o){this._currentContent=this._currentContent.slice(0,t)+this._currentContent.slice(o,this._currentContent.length),this.insertText(e,t)}insertText(e,t){const o=this._currentContent.slice(0,t)+e+this._currentContent.slice(t),s=t+e.length;this.setCurrentContent(o,{start:s,end:s})}updateTokenColor(){this.updateRangeColor();for(let e=0;e<this.currentTokens.length;e++)this.currentTokens[e].color=this.getTokenColor(this.currentTokens[e])}getTokenColor(e){if("REFERENCE"===e.type){const{xc:t,sheetName:o}=jr(e.value);return this.rangeColor(t,o)||OS}if("SYMBOL"===e.type){const t=e.value.toUpperCase();if("TRUE"===t||"FALSE"===t)return MS.NUMBER;if(t in xS.content)return MS.FUNCTION}return["LEFT_PAREN","RIGHT_PAREN"].includes(e.type)&&""===e.parenthesesCode?MS.ORPHAN_RIGHT_PAREN:MS[e.type]||OS}rangeColor(e,t){const o=t?this.model.getters.getSheetIdByName(t):this.sheetId,s=this.highlights.find((t=>{if(t.sheetId!==o)return!1;let s=this.model.getters.getRangeFromSheetXC(o,e).zone;return s=1===ps(s)?this.model.getters.expandZone(o,s):s,es(s,t.zone)}));return s&&s.color?s.color:void 0}computeFormulaCursorContext(){for(let e=0;e<this.currentTokens.length;e++)this.currentTokens[e].isBlurred=!1;if(this.selectionStart!==this.selectionEnd)return;const e=this.getParenthesesCodeAfterCursor(),t=[...this.currentTokens].reverse().find((t=>e.startsWith(t.parenthesesCode)&&"SYMBOL"===t.type));if(t)for(let e=0;e<this.currentTokens.length;e++)(this.currentTokens[e].parenthesesCode||"").startsWith(t.parenthesesCode||"")||(this.currentTokens[e].isBlurred=!0)}getParenthesesCodeAfterCursor(){const e=this.tokenAtCursor?.parenthesesCode||"";return"RIGHT_PAREN"===this.tokenAtCursor?.type?e.slice(0,-1)||"":e}computeParenthesisRelatedToCursor(){for(let e=0;e<this.currentTokens.length;e++)this.currentTokens[e].isParenthesisLinkedToCursor=!1;const e=this.tokenAtCursor;if(e&&""!==e.parenthesesCode&&["LEFT_PAREN","RIGHT_PAREN"].includes(e.type))for(let t=0;t<this.currentTokens.length;t++){const o=this.currentTokens[t];["LEFT_PAREN","RIGHT_PAREN"].includes(o.type)&&o.parenthesesCode===e.parenthesesCode&&o!==e&&(this.currentTokens[t].isParenthesisLinkedToCursor=!0,this.tokenAtCursor.isParenthesisLinkedToCursor=!0)}}updateRangeColor(){if(!this._currentContent.startsWith("=")||"inactive"===this.editionMode)return;const e=this.sheetId,t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),o={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(o[e]=this.colorIndexByRange[e]);const s=new Set(Object.values(o));let i=0;const n=()=>{for(;s.has(i);)i++;return s.add(i),i};for(const e of t){const t=e in o?o[e]:n();o[e]=t}this.colorIndexByRange=o}get highlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.editionMode)return[];const e=this.sheetId,t=e=>{const t=this.colorIndexByRange[e];return Ut[t%Ut.length]};return this.getReferencedRanges().map((o=>{const s=this.getters.getRangeString(o,e),{numberOfRows:i,numberOfCols:n}=is(o.zone);return{zone:i*n==1?this.getters.expandZone(o.sheetId,o.zone):o.zone,color:t(s),sheetId:o.sheetId,interactive:!0}}))}getReferencedRanges(){const e=this.sheetId;return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value))).filter((e=>!e.invalidSheetName&&!e.invalidXc))}get autocompleteProvider(){const e=this.currentContent,t=e.startsWith("=")?this.tokenAtCursor:{type:"STRING",value:e};if("inactive"===this.editionMode||!t||["TRUE","FALSE"].includes(t.value.toUpperCase())||!this.canStartComposerRangeSelection()&&!["SYMBOL","STRING","UNKNOWN"].includes(t.type))return;const o={composer:this,getters:this.getters},s=this.getAutoCompleteProviders().sort(((e,t)=>(e.sequence??1/0)-(t.sequence??1/0))).map((s=>({...s,getProposals:s.getProposals.bind(o,t,e),selectProposal:s.selectProposal.bind(o,t)})));for(const e of s){let o=e.getProposals();const s=o?.find((e=>e.text===t.value)),i=t.value.replace(/[ ,\(\)]/g,"");if(this._currentContent===this.initialContent&&e.displayAllOnInitialContent&&o?.length)return{proposals:o,selectProposal:e.selectProposal,autoSelectFirstProposal:e.autoSelectFirstProposal??!1,canBeToggled:e.canBeToggled};if(s&&this._currentContent!==this.initialContent)return;if(i&&o&&!["ARG_SEPARATOR","LEFT_PAREN","OPERATOR"].includes(t.type)){const e=ta(i,o,(e=>e.fuzzySearchKey||e.text));s&&!e.length||(o=e)}if(e.maxDisplayedProposals&&(o=o?.slice(0,e.maxDisplayedProposals)),o?.length)return{proposals:o,selectProposal:e.selectProposal,autoSelectFirstProposal:e.autoSelectFirstProposal??!1,canBeToggled:e.canBeToggled}}}canStartComposerRangeSelection(){if(this._currentContent.startsWith("=")){const e=this.tokenAtCursor;if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let o=t,s=e;for(;!["ARG_SEPARATOR","LEFT_PAREN","OPERATOR"].includes(s.type)||Na.includes(s.value);){if("SPACE"!==s.type||o<1)return!1;o--,s=this.currentTokens[o]}for(o=t+1,s=this.currentTokens[o];s&&!["ARG_SEPARATOR","RIGHT_PAREN","OPERATOR"].includes(s.type);){if("SPACE"!==s.type)return!1;o++,s=this.currentTokens[o]}return!0}return!1}}class NS{scope;code="";constructor(e=new VS){this.scope=e}append(...e){this.code+=e.map((e=>e.toString())).join("\n")+"\n"}return(e){return new kS(this.scope,this.code,e)}toString(){return LS(this.code)}}class kS{scope;returnExpression;code;constructor(e,t,o){this.scope=e,this.returnExpression=o,this.code=LS(t)}toString(){return this.code}assignResultToVariable(){if(this.scope.isAlreadyDeclared(this.returnExpression))return this;const e=this.scope.nextVariableName(),t=new NS(this.scope);return t.append(this.code),t.append(`const ${e} = ${this.returnExpression};`),t.return(e)}}class VS{nextId=1;declaredVariables=new Set;nextVariableName(){const e="_"+this.nextId++;return this.declaredVariables.add(e),e}isAlreadyDeclared(e){return this.declaredVariables.has(e)}}function LS(e){let t="",o=0;const s=e.split("\n").map((e=>e.trim())).filter((e=>""!==e));for(const e of s)e.startsWith("}")&&o--,t+="\t".repeat(o)+e+"\n",e.endsWith("{")&&o++;return t.trim()}const HS=xS.content,US={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},BS={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"},zS={};function $S(e){return GS(Yf(e))}function GS(e){try{return function(e){const{dependencies:t,literalValues:o,symbols:s}=function(e){const t={numbers:[],strings:[]},o=[],s=[];for(const i of e)switch(i.type){case"INVALID_REFERENCE":case"REFERENCE":o.push(i.value);break;case"STRING":const e=Ue(i.value);t.strings.push({value:e});break;case"NUMBER":{const e=oi(i.value,bi);t.numbers.push({value:e});break}case"SYMBOL":s.push(Ge(i.value,"'"))}return{dependencies:o,literalValues:t,symbols:s}}(e),i=function(e){let t="";for(const o of e)switch(o.type){case"STRING":t+="|S|";break;case"NUMBER":t+="|N|";break;case"REFERENCE":case"INVALID_REFERENCE":o.value.includes(":")?t+="|R|":t+="|C|";break;case"SPACE":break;default:t+=o.value}return t}(e);if(!zS[i]){const r=rv([...e]),a=new VS;let l=0,c=0,h=0;if("BIN_OPERATION"===r.type&&":"===r.value)throw new Ti(Bo("Invalid formula"));if("EMPTY"===r.type)throw new Ti(Bo("Invalid formula"));const d=m(r),u=new NS;u.append(`// ${i}`),u.append(d),u.append(`return ${d.returnExpression};`);let g=new Function("deps","ref","range","getSymbolValue","ctx",u.toString());function p(e){const{args:t}=e,o=e.value.toUpperCase(),s=HS[o];if(!s)throw new Oi(Bo('Unknown function: "%s"',e.value));!function(e){const t=e.args.length,o=e.value.toUpperCase(),s=HS[o];if(t<s.minArgRequired)throw new Ti(Bo("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",o,s.minArgRequired.toString(),t.toString()));if(t>s.maxArgPossible)throw new Ti(Bo("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",o,s.maxArgPossible.toString(),t.toString()));const i=s.nbrArgRepeating;if(i>1){const e=s.args.length-i;if((t-e)%i!=0)throw new Ti(Bo("Invalid number of arguments for the %s function. Expected all arguments after position %s to be supplied by groups of %s arguments",o,e.toString(),i.toString()))}}(e);const i=[];for(let e=0;e<t.length;e++){const o=s.getArgToFocus(e+1)-1,n=s.args[o],r=t[e],a=n.type||[],l=a.includes("META"),c=a.some((e=>WS(e)));i.push(m(r,l,c))}return i}function m(e,t=!1,o=!1){const i=new NS(a);if("REFERENCE"!==e.type&&("BIN_OPERATION"!==e.type||":"!==e.value)&&t)throw new Ti(Bo("Argument must be a reference to a cell or range."));switch(e.debug&&(i.append("debugger;"),i.append('ctx["debug"] = true;')),e.type){case"BOOLEAN":return i.return(`{ value: ${e.value} }`);case"NUMBER":return i.return(`this.literalValues.numbers[${c++}]`);case"STRING":return i.return(`this.literalValues.strings[${l++}]`);case"REFERENCE":return!t&&e.value.includes(":")||o?i.return(`range(deps[${h++}])`):i.return(`ref(deps[${h++}], ${t?"true":"false"})`);case"FUNCALL":const n=p(e).map((e=>e.assignResultToVariable()));i.append(...n);const r=e.value.toUpperCase();return i.return(`ctx['${r}'](${n.map((e=>e.returnExpression))})`);case"UNARY_OPERATION":{const t=BS[e.value],o=m(e.operand,!1,!1).assignResultToVariable();return i.append(o),i.return(`ctx['${t}'](${o.returnExpression})`)}case"BIN_OPERATION":{const t=US[e.value],o=m(e.left,!1,!1).assignResultToVariable(),s=m(e.right,!1,!1).assignResultToVariable();return i.append(o),i.append(s),i.return(`ctx['${t}'](${o.returnExpression}, ${s.returnExpression})`)}case"SYMBOL":const a=s.indexOf(e.value);return i.return(`getSymbolValue(this.symbols[${a}])`);case"EMPTY":return i.return("undefined")}}zS[i]=g}const n={execute:zS[i],dependencies:t,literalValues:o,symbols:s,tokens:e,isBadExpression:!1,normalizedFormula:i};return n}(e)}catch(t){return{tokens:e,dependencies:[],execute:function(){return t},isBadExpression:!0,normalizedFormula:e.map((e=>e.value)).join("")}}}function WS(e){return e.startsWith("RANGE")}const qS=xS.content;function ZS(e){try{return 0===lv(rv(e)).filter((e=>"FUNCALL"===e.type&&!qS[e.value.toUpperCase()]?.isExported)).length}catch(e){return!1}}function jS(e,t){if(!e.some((e=>"SYMBOL"===e.type&&t.includes(e.value.toUpperCase()))))return[];let o;try{o=rv(e)}catch{return[]}return function(e,t){return lv(e).filter((e=>"FUNCALL"===e.type&&t.includes(e.value.toUpperCase()))).map((e=>({functionName:e.value.toUpperCase(),args:e.args})))}(o,t)}const YS=["PIVOT.VALUE","PIVOT.HEADER","PIVOT"];function XS(e,t){const o=`"${t?`${e.name}:${t}`:e.name}"`,s=e.string!==e.name?e.string+o:o;return{text:o,description:e.string+(e.help?` (${e.help})`:""),htmlContent:[{value:o,color:MS.STRING}],fuzzySearchKey:s}}function KS(e,t){let o=e.end;const s=e.end;"ARG_SEPARATOR"!==e.type&&(o=e.start),this.composer.stopComposerRangeSelection(),this.composer.changeComposerCursorSelection(o,s),this.composer.replaceComposerCursorSelection(t)}function JS(e,t){let o=e.end;const s=e.end;"LEFT_PAREN"!==e.type&&(o=e.start),this.composer.stopComposerRangeSelection(),this.composer.changeComposerCursorSelection(o,s),this.composer.replaceComposerCursorSelection(t)}function QS(e){const t=e.functionContext?.args[0];if(t&&["STRING","NUMBER"].includes(t.type))return t.value}function ey(e){return jS(e,YS)[0]}function ty(e){return jS(e,YS).length}const oy=new n;oy.add("SPREADSHEET",!1),sd.add("pivot_ids",{sequence:50,autoSelectFirstProposal:!0,getProposals(e){const t=e.functionContext;if(!t||!["PIVOT.VALUE","PIVOT.HEADER","PIVOT"].includes(t.parent.toUpperCase())||0!==t.argPosition)return;const o=this.getters.getPivotIds();return o.includes(e.value)?void 0:o.map((e=>{const t=this.getters.getPivotCoreDefinition(e),o=`${this.getters.getPivotFormulaId(e)}`;return{text:o,description:t.name,htmlContent:[{value:o,color:MS.NUMBER}],fuzzySearchKey:o+t.name,alwaysExpanded:!0}})).filter(lt)},selectProposal:JS}),sd.add("pivot_measures",{sequence:50,autoSelectFirstProposal:!0,getProposals(e){const t=e.functionContext;if("PIVOT.VALUE"!==t?.parent.toUpperCase()||1!==t.argPosition)return[];const o=QS(e),s=this.getters.getPivotId(o);if(!s||!this.getters.isExistingPivot(s))return[];const i=this.getters.getPivot(s);return i.init(),i.isValid()?i.definition.measures.map((e=>{if("__count"===e.fieldName){const e='"__count"';return{text:e,description:Bo("Count"),htmlContent:[{value:e,color:MS.STRING}],fuzzySearchKey:Bo("Count")+e}}return function(e){const t=`"${e.id}"`,o=e.displayName+e.fieldName+t;return{text:t,description:e.displayName,htmlContent:[{value:t,color:MS.STRING}],fuzzySearchKey:o}}(e)})).filter(lt):[]},selectProposal:KS}),sd.add("pivot_group_fields",{sequence:50,autoSelectFirstProposal:!0,getProposals(e){const t=e.functionContext;if(!t||!function(e){const t=e.functionContext;return"PIVOT.VALUE"===t?.parent.toUpperCase()&&t.argPosition>=2&&t.argPosition%2==0}(e)&&!function(e){const t=e.functionContext;return"PIVOT.HEADER"===t?.parent.toUpperCase()&&t.argPosition>=1&&t.argPosition%2==1}(e))return;const o=QS(e),s=this.getters.getPivotId(o);if(!s||!this.getters.isExistingPivot(s))return;const i=this.getters.getPivot(s);i.init();const n=i.getFields(),{columns:r,rows:a}=i.definition;let l=t.args;"PIVOT.VALUE"===t?.parent.toUpperCase()?(l=l.filter(((e,t)=>t%2==0)),l=l.slice(1,t.argPosition)):l=l.filter(((e,t)=>t%2==1));const c=l.map((e=>e?.value)).filter(lt),h=r.map((e=>e.nameWithGranularity)),d=a.map((e=>e.nameWithGranularity)),u=[];let g=["ARG_SEPARATOR","SPACE"].includes(e.type)?c.at(-1):c.at(-2);const p=oy.get(i.type);if(p&&g?.startsWith("#")&&(g=g.slice(1)),void 0===g&&(u.push(h[0]),u.push(d[0])),d.includes(g)){const e=d[d.indexOf(g)+1];u.push(e),u.push(h[0])}if(h.includes(g)){const e=h[h.indexOf(g)+1];u.push(e)}const m=u.filter(lt);return m.map((e=>{const[t,o]=e.split(":"),s=n[t];return s?XS(s,o):void 0})).concat(m.map((e=>{if(!p)return;const t=e.split(":")[0],o=n[t];if(!o)return;const s=`"#${e}"`;return{text:s,description:Bo("%s (positional)",o.string)+(o.help?` (${o.help})`:""),htmlContent:[{value:s,color:MS.STRING}],fuzzySearchKey:o.string+s}}))).filter(lt)},selectProposal:KS}),sd.add("pivot_group_values",{sequence:50,autoSelectFirstProposal:!0,getProposals(e){const t=e.functionContext;if(!t||!e||!function(e){const t=e.functionContext;return"PIVOT.VALUE"===t?.parent.toUpperCase()&&t.argPosition>=2&&t.argPosition%2==1}(e)&&!function(e){const t=e.functionContext;return"PIVOT.HEADER"===t?.parent.toUpperCase()&&t.argPosition>=1&&t.argPosition%2==0}(e))return;const o=QS(e),s=this.getters.getPivotId(o);if(!s||!this.getters.isExistingPivot(s))return;const i=this.getters.getPivot(s);if(!i.isValid())return;const n=t.argPosition,r=e.functionContext?.args[n-1]?.value;if(!r)return;let a;try{a=i.definition.getDimension(r)}catch(e){return}return"month_number"===a.granularity?Object.values(Kn).map(((e,t)=>({text:`${t+1}`,fuzzySearchKey:e.toString(),description:e.toString(),htmlContent:[{value:`${t+1}`,color:MS.NUMBER}]}))):"quarter_number"===a.granularity?[1,2,3,4].map((e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:Bo("Quarter %s",e),htmlContent:[{value:`${e}`,color:MS.NUMBER}]}))):"day_of_month"===a.granularity?je(1,32).map((e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:"",htmlContent:[{value:`${e}`,color:MS.NUMBER}]}))):"iso_week_number"===a.granularity?je(0,54).map((e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:"",htmlContent:[{value:`${e}`,color:MS.NUMBER}]}))):"day_of_week"===a.granularity?je(1,8).map((e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:"",htmlContent:[{value:`${e}`,color:MS.NUMBER}]}))):"hour_number"===a.granularity?je(0,24).map((e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:"",htmlContent:[{value:`${e}`,color:MS.NUMBER}]}))):"minute_number"===a.granularity?je(0,60).map((e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:"",htmlContent:[{value:`${e}`,color:MS.NUMBER}]}))):"second_number"===a.granularity?je(0,60).map((e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:"",htmlContent:[{value:`${e}`,color:MS.NUMBER}]}))):i.getPossibleFieldValues(a).map((({value:e,label:t})=>{const o="string"==typeof e,s=o?`"${e}"`:e.toString(),i=t===e?"":t;return{text:s,description:i,htmlContent:[{value:s,color:o?MS.STRING:MS.NUMBER}],fuzzySearchKey:s+i}}))},selectProposal:KS}),sd.add("sheet_names",{sequence:150,autoSelectFirstProposal:!0,getProposals(e){return"SYMBOL"===e.type||"UNKNOWN"===e.type&&e.value.startsWith("'")?this.getters.getSheetIds().map((e=>{const t=We(this.getters.getSheetName(e));return{text:t,fuzzySearchKey:t.startsWith("'")?t:"'"+t}})):[]},selectProposal(e,t){const o=e.start,s=e.end;this.composer.changeComposerCursorSelection(o,s),this.composer.replaceComposerCursorSelection(t+"!")}});const sy=new n;sy.add("ALPHANUMERIC_INCREMENT_MODIFIER",{apply:(e,t)=>{e.current+=e.increment;const o=`${e.prefix}${e.current.toString().padStart(e.numberPostfixLength||0,"0")}`;return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:o},tooltip:{props:{content:o}}}}}).add("INCREMENT_MODIFIER",{apply:(e,t,o)=>{e.current+=e.increment;const s=e.current.toString(),i=o.getLocale(),n=Qn(e.current,{format:t.cell?.format,locale:i});return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:s},tooltip:s?{props:{content:n}}:void 0}}}).add("DATE_INCREMENT_MODIFIER",{apply:(e,t,o)=>{const s=Xi(e.current,o.getLocale());s.setFullYear(s.getFullYear()+e.increment.years||0),s.setMonth(s.getMonth()+e.increment.months||0),s.setDate(s.getDate()+e.increment.days||0);const i=zs(s);e.current=i;const n=o.getLocale(),r=Qn(i,{format:t.cell?.format,locale:n});return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:i.toString()},tooltip:i?{props:{content:r}}:void 0}}}).add("COPY_MODIFIER",{apply:(e,t,o)=>{const s=t.cell?.content||"",i={locale:o.getLocale(),format:t.cell?.format};return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:s},tooltip:s?{props:{content:t.cell?Rr(t.cell,i).formattedValue:""}}:void 0}}}).add("FORMULA_MODIFIER",{apply:(e,t,o,s)=>{e.current+=e.increment;let i=0,n=0;switch(s){case"up":i=0,n=-e.current;break;case"down":i=0,n=e.current;break;case"left":i=-e.current,n=0;break;case"right":i=e.current,n=0}const r=t.cell;if(!r||!r.isFormula)return{cellData:{}};const a=t.sheetId,l=o.getTranslatedCellFormula(a,i,n,r.compiledFormula.tokens);return{cellData:{border:t.border,style:r.style,format:r.format,content:l},tooltip:l?{props:{content:l}}:void 0}}});const iy=new n,ny=/(\d+)$/,ry=/^(.*\D+)/,ay=/^(.*\D+)(\d+)$/;function ly(e,t,o){let s=[],i=!1;for(let n of t){n===e&&(i=!0);const t=void 0===n||n.isFormula?void 0:Rr(n,{locale:bi,format:n.format});if(t&&o(t))s.push(t);else{if(i)return s;s=[]}}return s}function cy(e){let t=1;return e.length>=2&&(t=function(e){const t=[];let o=e[0];for(let s=1;s<e.length;s++){const i=e[s];t.push(i-o),o=i}return t.reduce(((e,t)=>e+t),0)/t.length}(e)*e.length),t}function hy(e){if(e.length<2)return 1;const t=e.map((e=>Xi(e,bi))),o=function(e){if(e.length<2)return[{years:0,months:0,days:0}];const t=e.map(((t,o)=>{if(0===o)return{years:0,months:0,days:0};const s=xs.fromTimestamp(e[o-1].getTime()),i=Xs(s,t),n=js(s,t)%12;s.setFullYear(s.getFullYear()+i),s.setMonth(s.getMonth()+n);return{years:i,months:n,days:Ys(s,t)}}));return t.slice(1)}(t),s=(i=o).length<2?i[0]||{years:0,months:0,days:0}:i.every((e=>e.years===i[0].years&&e.months===i[0].months&&e.days===i[0].days))?i[0]:void 0;var i;if(void 0===s)return;const n=1===Object.values(s).filter((e=>0!==e)).length,r=Object.values(s).every((e=>0===e));if(!n||r){const o=t.map(((e,o)=>{if(0===o)return 0;const s=t[o-1];return Math.floor(e.getTime())-Math.floor(s.getTime())})).slice(1);if(o.every((e=>e===o[0])))return e.length*(e[1]-e[0])}return{years:s.years*e.length,months:s.months*e.length,days:s.days*e.length}}iy.add("simple_value_copy",{condition:(e,t)=>!(1!==t.length||e.isFormula||e.format&&ar(e.format)),generateRule:()=>({type:"COPY_MODIFIER"}),sequence:10}).add("increment_alphanumeric_value",{condition:e=>!e.isFormula&&Rr(e,{locale:bi}).type===ii.text&&ay.test(e.content),generateRule:(e,t,o)=>{const s=parseInt(e.content.match(ny)[0]),i=e.content.match(ry)[0],n=e.content.length-i.length,r=ly(e,t,(e=>e.type===ii.text&&ay.test(e.value))).filter((e=>i===(e.value??"").toString().match(ry)[0])).map((e=>parseInt((e.value??"").toString().match(ny)[0])));let a=cy(r);return["up","left"].includes(o)&&1===r.length&&(a=-a),{type:"ALPHANUMERIC_INCREMENT_MODIFIER",prefix:i,current:s,increment:a,numberPostfixLength:n}},sequence:15}).add("copy_text",{condition:e=>!e.isFormula&&Rr(e,{locale:bi}).type===ii.text,generateRule:()=>({type:"COPY_MODIFIER"}),sequence:20}).add("update_formula",{condition:e=>e.isFormula,generateRule:(e,t)=>({type:"FORMULA_MODIFIER",increment:t.length,current:0}),sequence:30}).add("increment_dates",{condition:(e,t)=>!e.isFormula&&Rr(e,{locale:bi}).type===ii.number&&!!e.format&&ar(e.format),generateRule:(e,t)=>{const o=hy(ly(e,t,(e=>e.type===ii.number&&!!e.format&&ar(e.format))).map((e=>Number(e.value))));if(void 0===o)return{type:"COPY_MODIFIER"};const s=Rr(e,{locale:bi});return"object"==typeof o?{type:"DATE_INCREMENT_MODIFIER",increment:o,current:s.type===ii.number?s.value:0}:{type:"INCREMENT_MODIFIER",increment:o,current:s.type===ii.number?s.value:0}},sequence:25}).add("increment_number",{condition:e=>!e.isFormula&&Rr(e,{locale:bi}).type===ii.number,generateRule:(e,t,o)=>{const s=ly(e,t,(e=>e.type===ii.number&&!ar(e.format||""))).map((e=>Number(e.value)));let i=cy(s);["up","left"].includes(o)&&1===s.length&&(i=-i);const n=Rr(e,{locale:bi});return{type:"INCREMENT_MODIFIER",increment:i,current:n.type===ii.number?n.value:0}},sequence:40});const dy=new n,uy=30,gy=10,py=20,my=12,fy=80,vy="#F3F2F1",by=6,Sy=25;function yy(e,t){const o=e.getBoundingClientRect(),s=window.devicePixelRatio||1;e.width=s*o.width,e.height=s*o.height;const i=e.getContext("2d");i.scale(s,s);const n=function(e,t,o){const s=t.maxValue,i=t.minValue,n=t.gaugeValue,r=function(e,t){const o=t?Sy:0,s=e.height-py-o-gy,i=e.width-2*uy;let n,r;i>2*s?(n=2*s,r=s):(n=i,r=i/2);const a=o+gy+(s-r)/2;return{x:uy+(i-n)/2,y:a,width:n,height:r}}(e,t.title.text),a=r.width/6,l=n?(n.value-i.value)/(s.value-i.value):0,c={x:e.width/2,y:r.y+r.height-r.height/12};let h=fy;r.height<300&&(h*=r.height/300);const d=r.width/2,u=n?.label||"-";ua(o,u,{fontSize:h},"px")>d&&(h=function(e,t,o,s=.25){let i=1;if(o(i)>e)return i;if(o(t)<e)return t;let n=(i+t)/2,r=o(n),a=0;for(;Math.abs(r-e)>s&&a<20;)r>=e?t=(i+t)/2:i=(i+t)/2,n=(i+t)/2,r=o(n),a++;return n}(d,h,(e=>ua(o,u,{fontSize:e},"px"))));const g={x:r.x+a/2,y:r.y+r.height+my},p={x:r.x+r.width-a/2,y:r.y+r.height+my},m=Eh(t.background),f=function(e,t,o,s){const i=e.maxValue,n=e.minValue,r={x:t.x+t.width/2,y:t.y+t.height},a={fontSize:my},l=[],c=[];for(const h of e.inflectionValues){const e=(h.value-n.value)/(i.value-n.value),d=ua(s,h.label,a,"px"),u=Math.PI-Math.PI*e,g=Iy(u,t.height+by,r.x,r.y,d+2,my);let p=c.some((e=>Ey(e,g)))?my:0;c.push(g),l.push({rotation:u,label:h.label,fontSize:my,color:o,offset:p})}return l}(t,r,m,o);let v=0,b=0,S=0;t.title.text&&({width:b,height:S}=ma(o,t.title.text,{fontSize:X,...t.title},"px"));switch(t.title.align){case"right":v=e.width-b-Z;break;case"center":v=(e.width-b)/2;break;default:v=Z}return{width:e.width,height:e.height,title:{label:t.title.text??"",fontSize:t.title.fontSize??X,textPosition:{x:v,y:Y+S/2},color:t.title.color??m,bold:t.title.bold,italic:t.title.italic},backgroundColor:t.background,gauge:{rect:r,arcWidth:a,percentage:Ze(l,0,1),color:Cy(t)},inflectionValues:f,gaugeValue:{label:u,textPosition:c,fontSize:h,color:m},minLabel:{label:t.minValue.label,textPosition:g,fontSize:my,color:m},maxLabel:{label:t.maxValue.label,textPosition:p,fontSize:my,color:m}}}(o,t,i);!function(e,t){e.save(),e.fillStyle=t.backgroundColor,e.fillRect(0,0,t.width,t.height),e.restore()}(i,n),function(e,t){e.save();const o=t.gauge,s=o.rect.x+o.rect.width/2,i=o.rect.y+o.rect.height,n=o.rect.height-o.arcWidth/2;if(n<0)return;const r=1===o.percentage?0:Math.PI*(1+o.percentage);e.strokeStyle=vy,e.beginPath(),e.lineWidth=o.arcWidth,e.arc(s,i,n,r,0),e.stroke(),e.strokeStyle=o.color,e.beginPath(),e.arc(s,i,n,Math.PI,r),e.stroke(),e.restore()}(i,n),function(e,t){const{x:o,y:s,width:i,height:n}=t.gauge.rect;for(const r of t.inflectionValues){e.save(),e.translate(o+i/2-.5,s+n-.5),e.rotate(Math.PI/2-r.rotation),e.lineWidth=2,e.strokeStyle=Eh(t.backgroundColor)+"aa",e.beginPath(),e.moveTo(0,-(n-t.gauge.arcWidth)),e.lineTo(0,-n-3),e.stroke(),e.textAlign="center",e.font=`${r.fontSize}px ${ve}`,e.fillStyle=r.color;const a=-n-by-r.offset;e.fillText(r.label,0,a),e.restore()}}(i,n),function(e,t){for(const o of[t.minLabel,t.maxLabel,t.gaugeValue])e.save(),e.textAlign="center",e.fillStyle=o.color,e.font=`${o.fontSize}px ${ve}`,e.fillText(o.label,o.textPosition.x,o.textPosition.y),e.restore()}(i,n),function(e,t){e.save();const o=t.title;e.font=ha(o.fontSize,o.bold,o.italic),e.textBaseline="middle",e.fillStyle=o.color,e.fillText(o.label,o.textPosition.x,o.textPosition.y),e.restore()}(i,n)}function Cy(e){const t=e.gaugeValue?.value;if(void 0===t)return vy;for(let o=0;o<e.inflectionValues.length;o++){const s=e.inflectionValues[o];if("<"===s.operator&&t<s.value)return e.colors[o];if("<="===s.operator&&t<=s.value)return e.colors[o]}return e.colors.at(-1)}function wy(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 xy(e,t){const o=e.start,s=e.end,i=t.start,n=t.end;function r(e,t,o){return(o.y-e.y)*(t.x-e.x)>(t.y-e.y)*(o.x-e.x)}return r(o,i,n)!==r(s,i,n)&&r(o,s,i)!==r(o,s,n)}function Ey(e,t){const o=wy(e),s=wy(t);for(const e of o)for(const t of s)if(xy(e,t))return!0;return!1}function Iy(e,t,o,s,i,n){const r=Math.cos(e),a=Math.sin(e),l=r*t,c=a*t,h=a*(i/2),d=r*(i/2),u=r*(t+n),g=a*(t+n);return{bottomLeft:{x:l-h+o,y:s-(c+d)},bottomRight:{x:l+h+o,y:s-(c-d)},topRight:{x:u+h+o,y:s-(g-d)},topLeft:{x:u-h+o,y:s-(g+d)}}}class Ry extends t.Component{static template="o-spreadsheet-GaugeChartComponent";canvas=t.useRef("chartContainer");get runtime(){return this.env.model.getters.getChartRuntime(this.props.figure.id)}setup(){t.useEffect((()=>yy(this.canvas.el,this.runtime)),(()=>{const e=this.canvas.el.getBoundingClientRect();return[e.width,e.height,this.runtime,this.canvas.el,window.devicePixelRatio]}))}}function Ty(e){return 8===(e=$t(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}Ry.props={figure:Object};const Ay={responsive:!0,maintainAspectRatio:!1,elements:{line:{fill:!1},point:{hitRadius:15}},animation:!1,events:["mousemove","mouseout","click","touchstart","touchmove","mouseup"]};function _y(e,t,o){const s=document.createElement("div");s.style.width=`${t.width}px`,s.style.height=`${t.height}px`;const i=document.createElement("canvas");if(s.append(i),i.setAttribute("width",t.width.toString()),i.setAttribute("height",t.height.toString()),document.body.append(s),"chartJsConfig"in e){const t=ze(e.chartJsConfig);t.plugins=[Dy];const o=new window.Chart(i,t),n=o.toBase64Image();return o.destroy(),s.remove(),n}if("scorecard"===o){Xh(ed(t,e),i);const o=i.toDataURL();return s.remove(),o}if("gauge"===o){yy(i,e);const t=i.toDataURL();return s.remove(),t}}const Dy={id:"customCanvasBackgroundColor",beforeDraw:e=>{const{ctx:t}=e;t.save(),t.globalCompositeOperation="destination-over",t.fillStyle="#ffffff",t.fillRect(0,0,e.width,e.height),t.restore()}};class Oy{xmlString;constructor(e){this.xmlString=e}toString(){return this.xmlString}}const Fy=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart","comboChart","radarChart"],My="000000",Py={arrows:"3Arrows",smiley:"3Symbols",dots:"3TrafficLights1"},Ny={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"},ky="http://schemas.openxmlformats.org/drawingml/2006/main",Vy="http://schemas.openxmlformats.org/drawingml/2006/chart",Ly={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"},Hy={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"},Uy="bdbb8cdc-fa1e-496e-a857-3c3f30c029c3",By="http://schemas.openxmlformats.org/officeDocument/2006/relationships",zy=.75,$y=.143,Gy=8.43,Wy=12.75,qy=30,Zy=100,jy=164,Yy={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}]},Xy=["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"],Ky="[Content_Types].xml",Jy=new n;rh`
|
|
9
|
+
`,hh.add("chartShowValuesPlugin",{register:e=>e.register(kh),unregister:e=>e.unregister(kh)}),hh.add("waterfallLinesPlugin",{register:e=>e.register(Lh),unregister:e=>e.unregister(Lh)});class Bh extends t.Component{static template="o-spreadsheet-ChartJsComponent";static props={figure:Object};canvas=t.useRef("graphContainer");chart;currentRuntime;currentDevicePixelRatio=window.devicePixelRatio;get background(){return this.chartRuntime.background}get canvasStyle(){return`background-color: ${this.background}`}get chartRuntime(){const e=this.env.model.getters.getChartRuntime(this.props.figure.id);if(!("chartJsConfig"in e))throw new Error("Unsupported chart runtime");return e}setup(){t.onMounted((()=>{dh();const e=this.chartRuntime;this.currentRuntime=e,this.createChart(ze(e.chartJsConfig))})),t.onWillUnmount((()=>this.chart?.destroy())),t.useEffect((()=>{const e=this.chartRuntime;e!==this.currentRuntime?(e.chartJsConfig.type!==this.currentRuntime.chartJsConfig.type?(this.chart?.destroy(),this.createChart(ze(e.chartJsConfig))):this.updateChartJs(ze(e.chartJsConfig)),this.currentRuntime=e):this.currentDevicePixelRatio!==window.devicePixelRatio&&(this.currentDevicePixelRatio=window.devicePixelRatio,this.updateChartJs(ze(this.currentRuntime.chartJsConfig)))}))}createChart(e){const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e)}updateChartJs(e){e.data&&e.data.datasets?(this.chart.data=e.data,e.options?.plugins?.title&&(this.chart.config.options.plugins.title=e.options.plugins.title)):this.chart.data.datasets=[],this.chart.config.options=e.options,this.chart.update()}}class zh{sheetId;title;getters;constructor(e,t,o){this.title=e.title,this.sheetId=t,this.getters=o}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function $h(e,t,o,s,i){if("text"===t||"progress"===t||e?.type!==ii.number||o?.type!==ii.number)return;const n=o.value-e.value;return n>0?s:n<0?i:void 0}function Gh(e,t,o){if("text"===o||e?.type!==ii.number||t?.type!==ii.number)return"neutral";const s=t.value-e.value;return s>0?"up":s<0?"down":"neutral"}function Wh(e){return e.keyValue&&!$r.test(e.keyValue)?"InvalidScorecardKeyValue":"Success"}function qh(e){return e.baseline&&!$r.test(e.baseline)?"InvalidScorecardBaseline":"Success"}const Zh=new window.Path2D("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"),jh=new window.Path2D("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");let Yh=class e extends zh{keyValue;baseline;baselineMode;baselineDescr;progressBar=!1;background;baselineColorUp;baselineColorDown;fontColor;humanize;type="scorecard";constructor(e,t,o){super(e,t,o),this.keyValue=Jr(o,t,e.keyValue),this.baseline=Jr(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp??Ie,this.baselineColorDown=e.baselineColorDown??Re,this.humanize=e.humanize??!1}static validateChartDefinition(e,t){return e.checkValidations(t,Wh,qh)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?.[0]?.dataRange,title:e.title||{text:""},baselineMode:Ee,baselineColorUp:Ie,baselineColorDown:Re,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,s;return e.baseline&&(o=Uc($o(e.baseline),t)),e.keyValue&&(s=Uc($o(e.keyValue),t)),{...e,baseline:o?Zo(o):void 0,keyValue:s?Zo(s):void 0}}duplicateInDuplicatedSheet(t){const o=fh(this.sheetId,t,this.baseline),s=fh(this.sheetId,t,this.keyValue),i=this.getDefinitionWithSpecificRanges(o,s,t);return new e(i,t,this.getters)}copyInSheetId(t){const o=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,t);return new e(o,t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{...this,range:this.keyValue?[{dataRange:this.getters.getRangeString(this.keyValue,this.sheetId)}]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,o){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,o||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,o||this.sheetId):void 0,humanize:this.humanize}}getDefinitionForExcel(){}updateRanges(t){const o=vh(this.baseline,t),s=vh(this.keyValue,t);if(this.baseline===o&&this.keyValue===s)return this;const i=this.getDefinitionWithSpecificRanges(o,s);return new e(i,this.sheetId,this.getters)}};function Xh(e,t){const o=t.getContext("2d"),s=window.devicePixelRatio||1;t.width=s*e.canvas.width,t.height=s*e.canvas.height,o.scale(s,s);const i=e.canvas.width-2*Z;if(o.fillStyle=e.canvas.backgroundColor,o.fillRect(0,0,e.canvas.width,e.canvas.height),e.title){o.font=e.title.style.font,o.fillStyle=e.title.style.color;const t=o.textBaseline;o.textBaseline="middle",o.fillText(xa(o,e.title.text,i-e.title.position.x),e.title.position.x,e.title.position.y),o.textBaseline=t}if(e.baseline&&(o.font=e.baseline.style.font,o.fillStyle=e.baseline.style.color,Ea(o,e.baseline.text,e.baseline.position,e.baseline.style.underline,e.baseline.style.strikethrough)),e.baselineArrow&&e.baselineArrow.style.size>0){o.save(),o.fillStyle=e.baselineArrow.style.color,o.translate(e.baselineArrow.position.x,e.baselineArrow.position.y);const t=e.baselineArrow.style.size/10;switch(o.scale(t,t),e.baselineArrow.direction){case"down":o.fill(Zh);break;case"up":o.fill(jh)}o.restore()}if(e.baselineDescr){const t=e.baselineDescr[0];o.font=t.style.font,o.fillStyle=t.style.color;for(const t of e.baselineDescr)o.fillText(xa(o,t.text,i-t.position.x),t.position.x,t.position.y)}if(e.key&&(o.font=e.key.style.font,o.fillStyle=e.key.style.color,Ea(o,xa(o,e.key.text,i-e.key.position.x),e.key.position,e.key.style.underline,e.key.style.strikethrough)),e.progressBar){if(o.fillStyle=e.progressBar.style.backgroundColor,o.beginPath(),o.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width,e.progressBar.dimension.height,e.progressBar.dimension.height/2),o.fill(),o.fillStyle=e.progressBar.style.color,o.beginPath(),e.progressBar.value>0)o.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{const t=e.progressBar.dimension.width*Math.max(0,Math.min(1,-e.progressBar.value));o.roundRect(e.progressBar.position.x+e.progressBar.dimension.width-t,e.progressBar.position.y,t,e.progressBar.dimension.height,e.progressBar.dimension.height/2)}o.fill()}}function Kh(e,t){let o,s="";const i=t.getLocale();if(e.keyValue){const n={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};o=t.getEvaluatedCell(n),s=function(e,t,o){return e?t?br(e,o):e.formattedValue??String(e.value??""):""}(o,e.humanize??!1,i)}let n;const r=e.baseline;if(r){const e={sheetId:r.sheetId,col:r.zone.left,row:r.zone.top};n=t.getEvaluatedCell(e)}const{background:a,fontColor:l}=t.getStyleOfSingleCellChart(e.background,e.keyValue),c=function(e,t,o,s,i){if(!e)return"";if("text"===o||t?.type!==ii.number||e.type!==ii.number)return s?br(e,i):e.formattedValue;let{value:n,format:r}=e;return"progress"===o?(n=t.value/n,r="0.0%"):(n=Math.abs(t.value-n),"percentage"===o&&0!==n&&(n/=e.value),"percentage"===o&&(r="0.0%"),r||(n=Math.round(100*n)/100)),s?br({value:n,format:r},i):Qn(n,{format:r,locale:i})}(n,o,e.baselineMode,e.humanize??!1,i),h="progress"===e.baselineMode&&ei(c,i)?Li(c,i):0;return{title:{...e.title,text:e.title.text?Bo(e.title.text):""},keyValue:s,baselineDisplay:c,baselineArrow:Gh(n,o,e.baselineMode),baselineColor:$h(n,e.baselineMode,o,e.baselineColorUp,e.baselineColorDown),baselineDescr:"progress"!==e.baselineMode&&e.baselineDescr?Bo(e.baselineDescr):"",fontColor:l,background:a,baselineStyle:"percentage"!==e.baselineMode&&"progress"!==e.baselineMode&&r?t.getCellStyle({sheetId:r.sheetId,col:r.zone.left,row:r.zone.top}):void 0,keyValueStyle:e.keyValue?t.getCellStyle({sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top}):void 0,progressBar:"progress"===e.baselineMode?{value:h,color:h>0?e.baselineColorUp:e.baselineColorDown}:void 0}}const Jh=10,Qh=.05;function ed({width:e,height:t},o){return new td({width:e,height:t},o).computeDesign()}class td{runtime;context;width;height;constructor({width:e,height:t},o){this.runtime=o;const s=document.createElement("canvas");this.width=s.width=e,this.height=s.height=t,this.context=s.getContext("2d")}computeDesign(){const e={canvas:{width:this.width,height:this.height,backgroundColor:this.backgroundColor}},t=this.getTextStyles();let o=0;if(this.title){let s,i;switch(({height:o,width:i}=this.getFullTextDimensions(this.title,t.title.font)),this.runtime.title.align){case"center":s=(this.width-i)/2;break;case"right":s=this.width-i-Jh;break;default:s=Jh}e.title={text:this.title,style:t.title,position:{x:s,y:Jh+o/2}}}const s=t.baselineArrow?.size??0;let{height:i,width:n}=this.getTextDimensions(this.baseline,t.baselineValue.font);this.baseline||(i=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).height);const r=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).width;e.baseline={text:this.baseline,style:t.baselineValue,position:{x:(this.width-n-r+s)/2,y:this.keyValue?this.height*(1-Qh*(this.runtime.progressBar?1:2)):this.height-(this.height-o-i)/2-Jh}};const a=s+20;if(e.baseline.position.x<a&&(e.baseline.position.x=a),t.baselineArrow&&!this.runtime.progressBar&&(e.baselineArrow={direction:this.baselineArrow,style:t.baselineArrow,position:{x:e.baseline.position.x-s,y:e.baseline.position.y-(i+s)/2}}),this.baselineDescr){const o={x:e.baseline.position.x+n,y:e.baseline.position.y};e.baselineDescr=[{text:this.baselineDescr,style:t.baselineDescr,position:o}]}let l=0;this.runtime.progressBar&&(l=.05*this.height,e.progressBar={position:{x:20,y:.9*this.height-i-l},dimension:{height:l,width:this.width-40},value:this.runtime.progressBar.value,style:{color:this.runtime.progressBar.color,backgroundColor:this.secondaryFontColor}});const{width:c,height:h}=this.getFullTextDimensions(this.keyValue,t.keyValue.font);return this.keyValue&&(e.key={text:this.keyValue,style:t.keyValue,position:{x:Math.max(Jh,(this.width-c)/2),y:.4*this.height+5+(o+h/2)/2}}),e}get title(){return this.runtime.title.text??""}get keyValue(){return this.runtime.keyValue}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){return function(e,t){const o=e||"";return t&&o?" "+o:o}(this.runtime.baselineDescr,this.baseline)}get baselineArrow(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get secondaryFontColor(){return Eh(this.backgroundColor)}getTextDimensions(e,t){this.context.font=t;const o=this.context.measureText(e);return{width:o.width,height:o.actualBoundingBoxAscent+o.actualBoundingBoxDescent}}getFullTextDimensions(e,t){this.context.font=t;const o=this.context.measureText(e);return{width:o.width,height:o.fontBoundingBoxAscent+o.fontBoundingBoxDescent}}getTextStyles(){let e=16;const t=Math.floor(.9*e);return this.runtime.progressBar&&(e/=1.5),{title:{font:ha(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:ha(32,this.runtime.keyValueStyle?.bold,this.runtime.keyValueStyle?.italic),strikethrough:this.runtime.keyValueStyle?.strikethrough,underline:this.runtime.keyValueStyle?.underline},baselineValue:{font:ha(e,this.runtime.baselineStyle?.bold,this.runtime.baselineStyle?.italic),strikethrough:this.runtime.baselineStyle?.strikethrough,underline:this.runtime.baselineStyle?.underline,color:this.runtime.baselineStyle?.textColor||this.runtime.baselineColor||this.secondaryFontColor},baselineDescr:{font:ha(t),color:this.secondaryFontColor},baselineArrow:"neutral"===this.baselineArrow||this.runtime.progressBar?void 0:{size:this.keyValue?.8*e:0,color:this.runtime.baselineColor||this.secondaryFontColor}}}}class od extends t.Component{static template="o-spreadsheet-ScorecardChart";static props={figure:Object};canvas=t.useRef("chartContainer");get runtime(){return this.env.model.getters.getChartRuntime(this.props.figure.id)}get title(){const e=this.env.model.getters.getChartDefinition(this.props.figure.id).title.text??"";return Bo(e)}setup(){t.useEffect(this.createChart.bind(this),(()=>{const e=this.canvas.el.getBoundingClientRect();return[e.width,e.height,this.runtime,this.canvas.el,window.devicePixelRatio]}))}createChart(){const e=this.canvas.el;Xh(ed(e.getBoundingClientRect(),this.runtime),e)}}const sd=new n;function id(e,t,o,s){const i=[];e=e.toLowerCase();for(const n of e){const e=t.toLocaleLowerCase().indexOf(n);-1!==e&&(i.push({value:t.slice(0,e),color:""},{value:t[e],color:o,class:s}),t=t.slice(e+1))}return i.push({value:t}),i.filter((e=>e.value))}sd.add("dataValidation",{displayAllOnInitialContent:!0,canBeToggled:!1,getProposals(e,t){return t.startsWith("=")?[]:this.composer.currentEditedCell?function(e,t){const o=e.getValidationRuleForCell(t);if(!o||"isValueInList"!==o.criterion.type&&"isValueInRange"!==o.criterion.type)return[];let s=[];if("isValueInList"===o.criterion.type)s=o.criterion.values.map((e=>({label:e,value:e})));else{const i=new Set,n=e.getRangeFromSheetXC(t.sheetId,o.criterion.values[0]);for(const t of as(n.zone)){const o=e.getEvaluatedCell({...t,sheetId:n.sheetId});o.formattedValue&&!i.has(o.formattedValue)&&(i.add(o.formattedValue),s.push({label:o.formattedValue,value:o.value}))}}return s}(this.getters,this.composer.currentEditedCell).map((e=>({text:e.value?.toString()||"",htmlContent:[{value:e.label}],fuzzySearchKey:e.label}))):[]},selectProposal(e,t){this.composer.setCurrentContent(t),this.composer.stopEdition()}});const nd=/(.*?)\((.*?)\)(.*)/,rd=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function ad(e,t=""){return function(e,t){let o=e.match(nd),s=o[1].trim();if(!s)throw new Error(`Function argument definition is missing a name: '${e}'.`);let i,n=[],r=!1,a=!1;for(let e of o[2].split(",")){const t=e.trim().toUpperCase();let o=rd.find((e=>t===e));o?n.push(o):"RANGE<ANY>"===t?n.push("RANGE"):"OPTIONAL"===t?r=!0:"REPEATING"===t?a=!0:t.startsWith("DEFAULT=")&&(i=e.trim().slice(8))}const l={name:s,description:t,type:n};(n.includes("ANY")||n.includes("RANGE"))&&(l.acceptErrors=!0);r&&(l.optional=!0);a&&(l.repeating=!0);void 0!==i&&(l.default=!0,l.defaultValue=i);n.some((e=>e.startsWith("RANGE")))&&(l.acceptMatrix=!0);n.every((e=>e.startsWith("RANGE")))&&(l.acceptMatrixOnly=!0);return l}(e,t)}function ld(e){let t=0,o=0,s=0;for(let i of e.args)t++,i.optional||i.repeating||i.default||o++,i.repeating&&s++;const i=e;return i.minArgRequired=o,i.maxArgPossible=s?1/0:t,i.nbrArgRepeating=s,i.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const o=e-t;return e=>{if(e<=o)return e;return o+((e-o)%t||t)}}(t,s),i.hidden=e.hidden||!1,i}function cd(e,t){Pi((()=>1===t.length||1===t[0].length),e)}function hd(e,...t){if(t.every(yi)){const o=t[0].length,s=t[0][0].length;for(const i of t)Pi((()=>i.length===o&&i[0].length===s),e)}else if(t.some((e=>Array.isArray(e)&&(1!==e.length||1!==e[0].length))))throw new Ri(e)}function dd(e,t){Pi((()=>t>0),e)}function ud(e,t){Pi((()=>t.length===t[0].length),e)}const gd={description:Bo("Returns a result array constrained to a specific width and height."),args:[ad("input_range (any, range<any>)",Bo("The range to constrain.")),ad("rows (number)",Bo("The number of rows in the constrained array.")),ad("columns (number)",Bo("The number of columns in the constrained array."))],compute:function(e,t,o){const s=Sn(e),i=zi(t?.value,this.locale),n=zi(o?.value,this.locale);dd(Bo("The rows argument (%s) must be strictly positive.",i.toString()),i),dd(Bo("The columns argument (%s) must be strictly positive.",i.toString()),n);const r=Math.min(i,s[0].length);return rn(Math.min(n,s.length),r,((e,t)=>s[e][t]))},isExported:!1},pd={description:Bo("Creates a new array from the selected columns in the existing range."),args:[ad("array (any, range<any>)",Bo("The array that contains the columns to be returned.")),ad("col_num (number, range<number>)",Bo("The first column index of the columns to be returned.")),ad("col_num2 (number, range<number>, repeating)",Bo("The columns indexes of the columns to be returned."))],compute:function(e,...t){const o=Sn(e),s=yn(t,(e=>zi(e?.value,this.locale))),i=s.filter((e=>0===e||o.length<Math.abs(e)));Pi((()=>0===i.length),Bo("The columns arguments must be between -%s and %s (got %s), excluding 0.",o.length.toString(),o.length.toString(),i.join(",")));const n=Array(s.length);for(let e=0;e<s.length;e++)s[e]>0?n[e]=o[s[e]-1]:n[e]=o[o.length+s[e]];return n},isExported:!0},md={description:Bo("Creates a new array from the selected rows in the existing range."),args:[ad("array (any, range<any>)",Bo("The array that contains the rows to be returned.")),ad("row_num (number, range<number>)",Bo("The first row index of the rows to be returned.")),ad("row_num2 (number, range<number>, repeating)",Bo("The rows indexes of the rows to be returned."))],compute:function(e,...t){const o=Sn(e),s=yn(t,(e=>zi(e?.value,this.locale))),i=o.length,n=s.filter((e=>0===e||o[0].length<Math.abs(e)));return Pi((()=>0===n.length),Bo("The rows arguments must be between -%s and %s (got %s), excluding 0.",o[0].length.toString(),o[0].length.toString(),n.join(","))),rn(i,s.length,((e,t)=>s[t]>0?o[e][s[t]-1]:o[e][o[e].length+s[t]]))},isExported:!0},fd={description:Bo("Expands or pads an array to specified row and column dimensions."),args:[ad("array (any, range<any>)",Bo("The array to expand.")),ad("rows (number)",Bo("The number of rows in the expanded array. If missing, rows will not be expanded.")),ad("columns (number, optional)",Bo("The number of columns in the expanded array. If missing, columns will not be expanded.")),ad("pad_with (any, default=0)",Bo("The value with which to pad."))],compute:function(e,t,o,s={value:0}){const i=Sn(e),n=zi(t?.value,this.locale),r=void 0!==o?zi(o.value,this.locale):i.length;return Pi((()=>n>=i[0].length),Bo("The rows arguments (%s) must be greater or equal than the number of rows of the array.",n.toString())),Pi((()=>r>=i.length),Bo("The columns arguments (%s) must be greater or equal than the number of columns of the array.",r.toString())),rn(r,n,((e,t)=>e>=i.length||t>=i[e].length?s:i[e][t]))},isExported:!0},vd={description:Bo("Flattens all the values from one or more ranges into a single column."),args:[ad("range (any, range<any>)",Bo("The first range to flatten.")),ad("range2 (any, range<any>, repeating)",Bo("Additional ranges to flatten."))],compute:function(...e){return[yn(e,(e=>void 0===e?{value:""}:e))]},isExported:!1},bd={description:Bo("Calculates the frequency distribution of a range."),args:[ad("data (range<number>)",Bo("The array of ranges containing the values to be counted.")),ad("classes (number, range<number>)",Bo("The range containing the set of classes."))],compute:function(e,t){const o=yn([e],(e=>e.value)).filter((e=>"number"==typeof e)),s=yn([t],(e=>e.value)).filter((e=>"number"==typeof e)),i=s.map(((e,t)=>({initialIndex:t,value:e,count:0}))).sort(((e,t)=>e.value-t.value));i.push({initialIndex:i.length,value:1/0,count:0});const n=o.sort(((e,t)=>e-t));let r=0;for(const e of n){for(;e>i[r].value&&r<i.length-1;)r++;i[r].count++}return[i.sort(((e,t)=>e.initialIndex-t.initialIndex)).map((e=>e.count))]},isExported:!0},Sd={description:Bo("Appends ranges horizontally and in sequence to return a larger array."),args:[ad("range1 (any, range<any>)",Bo("The first range to be appended.")),ad("range2 (any, range<any>, repeating)",Bo("Additional ranges to add to range1."))],compute:function(...e){const t=Math.max(...e.map((e=>e?.[0]?.length??0))),o=[];for(const s of e){const e=Sn(s);for(let s=0;s<e.length;s++){const i=Array(t).fill({value:null});for(let t=0;t<e[s].length;t++)i[t]=e[s][t];o.push(i)}}return o},isExported:!0},yd={description:Bo("Returns the matrix determinant of a square matrix."),args:[ad("square_matrix (number, range<number>)",Bo("An range with an equal number of rows and columns representing a matrix whose determinant will be calculated."))],compute:function(e){const t=Ui(e,"square_matrix");return ud(Bo("The argument square_matrix must have the same number of columns and rows."),t),Sl(t).determinant},isExported:!0},Cd={description:Bo("Returns the multiplicative inverse of a square matrix."),args:[ad("square_matrix (number, range<number>)",Bo("An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated."))],compute:function(e){const t=Ui(e,"square_matrix");ud(Bo("The argument square_matrix must have the same number of columns and rows."),t);const{inverted:o}=Sl(t);return o||new Ri(Bo("The matrix is not invertible."))},isExported:!0},wd={description:Bo("Calculates the matrix product of two matrices."),args:[ad("matrix1 (number, range<number>)",Bo("The first matrix in the matrix multiplication operation.")),ad("matrix2 (number, range<number>)",Bo("The second matrix in the matrix multiplication operation."))],compute:function(e,t){const o=Ui(e,"matrix1"),s=Ui(t,"matrix2");return Pi((()=>o.length>0&&s.length>0),Bo("The first and second arguments of [[FUNCTION_NAME]] must be non-empty matrices.")),Pi((()=>o.length===s[0].length),Bo("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).",o.length.toString(),s[0].length.toString())),Cl(o,s)},isExported:!0},xd={description:Bo("Calculates the sum of the products of corresponding entries in equal-sized ranges."),args:[ad("range1 (number, range<number>)",Bo("The first range whose entries will be multiplied with corresponding entries in the other ranges.")),ad("range2 (number, range<number>, repeating)",Bo("The other range whose entries will be multiplied with corresponding entries in the other ranges."))],compute:function(...e){hd(Bo("All the ranges must have the same dimensions."),...e);const t=e.map(Sn);let o=0;for(let e=0;e<t[0].length;e++)for(let s=0;s<t[0][e].length;s++){if(!t.every((t=>"number"==typeof t[e][s].value)))continue;let i=1;for(const o of t)i*=Li(o[e][s],this.locale);o+=i}return o},isExported:!0};function Ed(e,t,o){hd("The arguments array_x and array_y must have the same dimensions.",e,t);const s=Sn(e),i=Sn(t);let n=!1,r=0;for(const e in s)for(const t in s[e]){const a=s[e][t].value,l=i[e][t].value;"number"==typeof a&&"number"==typeof l&&(n=!0,r+=o(a,l))}return n?r:new Ri(Bo("The arguments array_x and array_y must contain at least one pair of numbers."))}const Id={description:Bo("Calculates the sum of the difference of the squares of the values in two array."),args:[ad("array_x (number, range<number>)",Bo("The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.")),ad("array_y (number, range<number>)",Bo("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){return Ed(e,t,((e,t)=>e**2-t**2))},isExported:!0},Rd={description:Bo("Calculates the sum of the sum of the squares of the values in two array."),args:[ad("array_x (number, range<number>)",Bo("The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.")),ad("array_y (number, range<number>)",Bo("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){return Ed(e,t,((e,t)=>e**2+t**2))},isExported:!0},Td={description:Bo("Calculates the sum of squares of the differences of values in two array."),args:[ad("array_x (number, range<number>)",Bo("The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.")),ad("array_y (number, range<number>)",Bo("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){return Ed(e,t,((e,t)=>(e-t)**2))},isExported:!0},Ad=!1,_d=[ad("array (any, range<any>)",Bo("The array which will be transformed.")),ad("ignore (number, default=0)",Bo("The control to ignore blanks and errors. 0 (default) is to keep all values, 1 is to ignore blanks, 2 is to ignore errors, and 3 is to ignore blanks and errors.")),ad("scan_by_column (number, default=false)",Bo("Whether the array should be scanned by column. True scans the array by column and false (default) scans the array by row."))];function Dd(e){const t=Math.trunc(e);if(0===t)return()=>!0;if(1===t)return e=>null!==e.value;if(2===t)return e=>!ki(e.value);if(3===t)return e=>null!==e.value&&!ki(e.value);throw new Ri(Bo("Argument ignore must be between 0 and 3"))}const Od={description:Bo("Transforms a range of cells into a single column."),args:_d,compute:function(e,t={value:0},o={value:Ad}){const s=Sn(e),i=Li(t.value,this.locale),n=(Yi(o.value)?s:ln(s)).flat().filter(Dd(i));return 0===n.length?new Di(Bo("No results for the given arguments of TOCOL.")):[n]},isExported:!0},Fd={description:Bo("Transforms a range of cells into a single row."),args:_d,compute:function(e,t={value:0},o={value:Ad}){const s=Sn(e),i=Li(t.value,this.locale),n=(Yi(o.value)?s:ln(s)).flat().filter(Dd(i)).map((e=>[e]));return 0===n.length||0===n[0].length?new Di(Bo("No results for the given arguments of TOROW.")):n},isExported:!0},Md={description:Bo("Transposes the rows and columns of a range."),args:[ad("range (any, range<any>)",Bo("The range to be transposed."))],compute:function(e){const t=Sn(e);return rn(t[0].length,t.length,((e,o)=>t[o][e]))},isExported:!0},Pd={description:Bo("Appends ranges vertically and in sequence to return a larger array."),args:[ad("range1 (any, range<any>)",Bo("The first range to be appended.")),ad("range2 (any, range<any>, repeating)",Bo("Additional ranges to add to range1."))],compute:function(...e){const t=Math.max(...e.map((e=>Sn(e).length))),o=e.reduce(((e,t)=>e+Sn(t)[0].length),0),s=Array(t).fill([]).map((()=>Array(o).fill({value:0})));let i=0;for(const t of e){const e=Sn(t);for(let t=0;t<e.length;t++)for(let o=0;o<e[t].length;o++)s[t][i+o]=e[t][o];i+=e[0].length}return s},isExported:!0},Nd={description:Bo("Wraps the provided row or column of cells by columns after a specified number of elements to form a new array."),args:[ad("range (any, range<any>)",Bo("The range to wrap.")),ad("wrap_count (number)",Bo("The maximum number of cells for each column, rounded down to the nearest whole number.")),ad("pad_with (any, default=0)",Bo("The value with which to fill the extra cells in the range."))],compute:function(e,t,o={value:0}){const s=Sn(e),i=zi(t?.value,this.locale);cd(Bo("Argument range must be a single row or column."),s);const n=s.flat();return rn(Math.ceil(n.length/i),i,((e,t)=>{const s=e*i+t;return s<n.length?n[s]:o}))},isExported:!0},kd={description:Bo("Wraps the provided row or column of cells by rows after a specified number of elements to form a new array."),args:[ad("range (any, range<any>)",Bo("The range to wrap.")),ad("wrap_count (number)",Bo("The maximum number of cells for each row, rounded down to the nearest whole number.")),ad("pad_with (any, default=0)",Bo("The value with which to fill the extra cells in the range."))],compute:function(e,t,o={value:0}){const s=Sn(e),i=zi(t?.value,this.locale);cd(Bo("Argument range must be a single row or column."),s);const n=s.flat(),r=Math.ceil(n.length/i);return rn(i,r,((e,t)=>{const s=t*i+e;return s<n.length?n[s]:o}))},isExported:!0};var Vd=Object.freeze({__proto__:null,ARRAY_CONSTRAIN:gd,CHOOSECOLS:pd,CHOOSEROWS:md,EXPAND:fd,FLATTEN:vd,FREQUENCY:bd,HSTACK:Sd,MDETERM:yd,MINVERSE:Cd,MMULT:wd,SUMPRODUCT:xd,SUMX2MY2:Id,SUMX2PY2:Rd,SUMXMY2:Td,TOCOL:Od,TOROW:Fd,TRANSPOSE:Md,VSTACK:Pd,WRAPCOLS:Nd,WRAPROWS:kd});const Ld={description:Bo("Apply a large number format"),args:[ad("value (number)",Bo("The number.")),ad("unit (string, optional)",Bo("The formatting unit. Use 'k', 'm', or 'b' to force the unit"))],compute:function(e,t){return{value:Li(e,this.locale),format:Sr(e,t,this.locale)}}};var Hd=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:Ld});const Ud=/^-?[a-z0-9]+$/i,Bd={description:Bo("Absolute value of a number."),args:[ad("value (number)",Bo("The number of which to return the absolute value."))],compute:function(e){return Math.abs(Li(e,this.locale))},isExported:!0},zd={description:Bo("Inverse cosine of a value, in radians."),args:[ad("value (number)",Bo("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive."))],compute:function(e){const t=Li(e,this.locale);return Pi((()=>Math.abs(t)<=1),Bo("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},$d={description:Bo("Inverse hyperbolic cosine of a number."),args:[ad("value (number)",Bo("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1."))],compute:function(e){const t=Li(e,this.locale);return Pi((()=>t>=1),Bo("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},Gd={description:Bo("Inverse cotangent of a value."),args:[ad("value (number)",Bo("The value for which to calculate the inverse cotangent."))],compute:function(e){const t=Li(e,this.locale);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},Wd={description:Bo("Inverse hyperbolic cotangent of a value."),args:[ad("value (number)",Bo("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive."))],compute:function(e){const t=Li(e,this.locale);return Pi((()=>Math.abs(t)>1),Bo("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},qd={description:Bo("Inverse sine of a value, in radians."),args:[ad("value (number)",Bo("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive."))],compute:function(e){const t=Li(e,this.locale);return Pi((()=>Math.abs(t)<=1),Bo("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Zd={description:Bo("Inverse hyperbolic sine of a number."),args:[ad("value (number)",Bo("The value for which to calculate the inverse hyperbolic sine."))],compute:function(e){return Math.asinh(Li(e,this.locale))},isExported:!0},jd={description:Bo("Inverse tangent of a value, in radians."),args:[ad("value (number)",Bo("The value for which to calculate the inverse tangent."))],compute:function(e){return Math.atan(Li(e,this.locale))},isExported:!0},Yd={description:Bo("Angle from the X axis to a point (x,y), in radians."),args:[ad("x (number)",Bo("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),ad("y (number)",Bo("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis."))],compute:function(e,t){const o=Li(e,this.locale),s=Li(t,this.locale);return Pi((()=>0!==o||0!==s),Bo("Function [[FUNCTION_NAME]] caused a divide by zero error."),Ei.DivisionByZero),Math.atan2(s,o)},isExported:!0},Xd={description:Bo("Inverse hyperbolic tangent of a number."),args:[ad("value (number)",Bo("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive."))],compute:function(e){const t=Li(e,this.locale);return Pi((()=>Math.abs(t)<1),Bo("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},Kd={description:Bo("Rounds number up to nearest multiple of factor."),args:[ad("value (number)",Bo("The value to round up to the nearest integer multiple of factor.")),ad("factor (number, default=1)",Bo("The number to whose multiples value will be rounded."))],compute:function(e,t={value:1}){const o=Li(e,this.locale),s=Li(t,this.locale);return Pi((()=>s>=0||o<=0),Bo("The factor (%s) must be positive when the value (%s) is positive.",s.toString(),o.toString())),{value:s?Math.ceil(o/s)*s:0,format:e?.format}},isExported:!0};function Jd(e,t,o=0){return 0===t?0:(t=Math.abs(t),e>=0?Math.ceil(e/t)*t:0===o?-Math.floor(Math.abs(e)/t)*t:-Math.ceil(Math.abs(e)/t)*t)}const Qd={description:Bo("Rounds number up to nearest multiple of factor."),args:[ad("number (number)",Bo("The value to round up to the nearest integer multiple of significance.")),ad("significance (number, default=1)",Bo("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),ad("mode (number, default=0)",Bo("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},o={value:0}){const s=Li(t,this.locale);return{value:Jd(Li(e,this.locale),s,Li(o,this.locale)),format:e?.format}},isExported:!0},eu={description:Bo("Rounds number up to nearest multiple of factor."),args:[ad("number (number)",Bo("The value to round up to the nearest integer multiple of significance.")),ad("significance (number, default=1)",Bo("The number to whose multiples number will be rounded."))],compute:function(e,t={value:1}){const o=Li(t,this.locale);return{value:Jd(Li(e,this.locale),o),format:e?.format}},isExported:!0},tu={description:Bo("Cosine of an angle provided in radians."),args:[ad("angle (number)",Bo("The angle to find the cosine of, in radians."))],compute:function(e){return Math.cos(Li(e,this.locale))},isExported:!0},ou={description:Bo("Hyperbolic cosine of any real number."),args:[ad("value (number)",Bo("Any real value to calculate the hyperbolic cosine of."))],compute:function(e){return Math.cosh(Li(e,this.locale))},isExported:!0},su={description:Bo("Cotangent of an angle provided in radians."),args:[ad("angle (number)",Bo("The angle to find the cotangent of, in radians."))],compute:function(e){const t=Li(e,this.locale);return Wi(t),1/Math.tan(t)},isExported:!0},iu={description:Bo("Hyperbolic cotangent of any real number."),args:[ad("value (number)",Bo("Any real value to calculate the hyperbolic cotangent of."))],compute:function(e){const t=Li(e,this.locale);return Wi(t),1/Math.tanh(t)},isExported:!0},nu={description:Bo("Number of empty values."),args:[ad("value1 (any, range)",Bo("The first value or range in which to count the number of blanks.")),ad("value2 (any, range, repeating)",Bo("Additional values or ranges in which to count the number of blanks."))],compute:function(...e){return on(e,((e,t)=>void 0===t||null===t.value||""===t.value?e+1:e),0)},isExported:!0},ru={description:Bo("A conditional count across a range."),args:[ad("range (range)",Bo("The range that is tested against criterion.")),ad("criterion (string)",Bo("The pattern or test to apply to range."))],compute:function(...e){let t=0;return pn(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0},au={description:Bo("Count values depending on multiple criteria."),args:[ad("criteria_range1 (range)",Bo("The range to check against criterion1.")),ad("criterion1 (string)",Bo("The pattern or test to apply to criteria_range1.")),ad("criteria_range2 (any, range, repeating)",Bo("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),ad("criterion2 (string, repeating)",Bo("Additional criteria to check."))],compute:function(...e){let t=0;return pn(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0},lu={description:Bo("Counts number of unique values in a range."),args:[ad("value1 (any, range)",Bo("The first value or range to consider for uniqueness.")),ad("value2 (any, range, repeating)",Bo("Additional values or ranges to consider for uniqueness."))],compute:function(...e){return vl(e)}},cu={description:Bo("Counts number of unique values in a range, filtered by a set of criteria."),args:[ad("range (range)",Bo("The range of cells from which the number of unique values will be counted.")),ad("criteria_range1 (range)",Bo("The range of cells over which to evaluate criterion1.")),ad("criterion1 (string)",Bo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),ad("criteria_range2 (any, range, repeating)",Bo("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),ad("criterion2 (string, repeating)",Bo("The pattern or test to apply to criteria_range2."))],compute:function(e,...t){let o=new Set;return pn(t,((t,s)=>{const i=e[t]?.[s];Cn(i)&&o.add(i.value)}),this.locale),o.size}},hu={description:Bo("Cosecant of an angle provided in radians."),args:[ad("angle (number)",Bo("The angle to find the cosecant of, in radians."))],compute:function(e){const t=Li(e,this.locale);return Wi(t),1/Math.sin(t)},isExported:!0},du={description:Bo("Hyperbolic cosecant of any real number."),args:[ad("value (number)",Bo("Any real value to calculate the hyperbolic cosecant of."))],compute:function(e){const t=Li(e,this.locale);return Wi(t),1/Math.sinh(t)},isExported:!0},uu={description:Bo("Converts from another base to decimal."),args:[ad("value (string)",Bo("The number to convert.")),ad("base (number)",Bo("The base to convert the value from."))],compute:function(e,t){let o=Li(t,this.locale);o=Math.floor(o),Pi((()=>2<=o&&o<=36),Bo("The base (%s) must be between 2 and 36 inclusive.",o.toString()));const s=qi(e);if(""===s)return 0;Pi((()=>Ud.test(s)),Bo("The value (%s) must be a valid base %s representation.",s,o.toString()));const i=parseInt(s,o);return Pi((()=>!isNaN(i)),Bo("The value (%s) must be a valid base %s representation.",s,o.toString())),i},isExported:!0},gu={description:Bo("Converts an angle value in radians to degrees."),args:[ad("angle (number)",Bo("The angle to convert from radians to degrees."))],compute:function(e){return 180*Li(e,this.locale)/Math.PI},isExported:!0},pu={description:Bo("Euler's number, e (~2.718) raised to a power."),args:[ad("value (number)",Bo("The exponent to raise e."))],compute:function(e){return Math.exp(Li(e,this.locale))},isExported:!0},mu={description:Bo("Rounds number down to nearest multiple of factor."),args:[ad("value (number)",Bo("The value to round down to the nearest integer multiple of factor.")),ad("factor (number, default=1)",Bo("The number to whose multiples value will be rounded."))],compute:function(e,t={value:1}){const o=Li(e,this.locale),s=Li(t,this.locale);return Pi((()=>s>=0||o<=0),Bo("The factor (%s) must be positive when the value (%s) is positive.",s.toString(),o.toString())),{value:s?Math.floor(o/s)*s:0,format:e?.format}},isExported:!0};function fu(e,t,o=0){return 0===t?0:(t=Math.abs(t),e>=0?Math.floor(e/t)*t:0===o?-Math.ceil(Math.abs(e)/t)*t:-Math.floor(Math.abs(e)/t)*t)}const vu={description:Bo("Rounds number down to nearest multiple of factor."),args:[ad("number (number)",Bo("The value to round down to the nearest integer multiple of significance.")),ad("significance (number, default=1)",Bo("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),ad("mode (number, default=0)",Bo("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},o={value:0}){const s=Li(t,this.locale);return{value:fu(Li(e,this.locale),s,Li(o,this.locale)),format:e?.format}},isExported:!0},bu={description:Bo("Rounds number down to nearest multiple of factor."),args:[ad("number (number)",Bo("The value to round down to the nearest integer multiple of significance.")),ad("significance (number, default=1)",Bo("The number to whose multiples number will be rounded."))],compute:function(e,t={value:1}){const o=Li(t,this.locale);return{value:fu(Li(e,this.locale),o),format:e?.format}},isExported:!0},Su={description:Bo("Whether the provided value is even."),args:[ad("value (number)",Bo("The value to be verified as even."))],compute:function(e){const t=Bi(e,this.locale);return!(1&Math.floor(Math.abs(t)))},isExported:!0},yu={description:Bo("Rounds number up to nearest multiple of factor."),args:[ad("number (number)",Bo("The value to round up to the nearest integer multiple of significance.")),ad("significance (number, default=1)",Bo("The number to whose multiples number will be rounded."))],compute:function(e,t={value:1}){return{value:Jd(Li(e,this.locale),Li(t,this.locale)),format:e?.format}},isExported:!0},Cu={description:Bo("Whether the provided value is even."),args:[ad("value (number)",Bo("The value to be verified as even."))],compute:function(e){const t=Bi(e,this.locale);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},wu={description:Bo("The logarithm of a number, base e (euler's number)."),args:[ad("value (number)",Bo("The value for which to calculate the logarithm, base e."))],compute:function(e){const t=Li(e,this.locale);return Pi((()=>t>0),Bo("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},xu={description:Bo("The logarithm of a number, for a given base."),args:[ad("value (number)",Bo("The value for which to calculate the logarithm.")),ad("base (number, default=10)",Bo("The base of the logarithm."))],compute:function(e,t={value:10}){const o=Li(e,this.locale),s=Li(t,this.locale);return Pi((()=>o>0),Bo("The value (%s) must be strictly positive.",o.toString())),Pi((()=>s>0),Bo("The base (%s) must be strictly positive.",s.toString())),Pi((()=>1!==s),Bo("The base must be different from 1.")),Math.log10(o)/Math.log10(s)},isExported:!0};function Eu(e,t){Pi((()=>0!==t),Bo("The divisor must be different from 0."),Ei.DivisionByZero);const o=e%t;return o>0&&t<0||o<0&&t>0?o+t:o}const Iu={description:Bo("Modulo (remainder) operator."),args:[ad("dividend (number)",Bo("The number to be divided to find the remainder.")),ad("divisor (number)",Bo("The number to divide by."))],compute:function(e,t){const o=Li(t,this.locale);return{value:Eu(Li(e,this.locale),o),format:e?.format}},isExported:!0},Ru={description:Bo("Returns a n x n unit matrix, where n is the input dimension."),args:[ad("dimension (number)",Bo("An integer specifying the dimension size of the unit matrix. It must be positive."))],compute:function(e){const t=zi(e,this.locale);return dd(Bo("The argument dimension must be positive"),t),bl(t)},isExported:!0},Tu={description:Bo("Rounds a number up to the nearest odd integer."),args:[ad("value (number)",Bo("The value to round to the next greatest odd number."))],compute:function(e){const t=Li(e,this.locale);let o=Math.ceil(Math.abs(t));return o=1&o?o:o+1,{value:t<0?-o:o,format:e?.format}},isExported:!0},Au={description:Bo("The number pi."),args:[],compute:function(){return Math.PI},isExported:!0},_u={description:Bo("A number raised to a power."),args:[ad("base (number)",Bo("The number to raise to the exponent power.")),ad("exponent (number)",Bo("The exponent to raise base to."))],compute:function(e,t){const o=Li(e,this.locale),s=Li(t,this.locale);return Pi((()=>o>=0||Number.isInteger(s)),Bo("The exponent (%s) must be an integer when the base is negative.",s.toString())),{value:Math.pow(o,s),format:e?.format}},isExported:!0},Du={description:Bo("Result of multiplying a series of numbers together."),args:[ad("factor1 (number, range<number>)",Bo("The first number or range to calculate for the product.")),ad("factor2 (number, range<number>, repeating)",Bo("More numbers or ranges to calculate for the product."))],compute:function(...e){let t=0,o=1;for(let s of e)if(yi(s))for(let e of s)for(let s of e){const e=s.value;if("number"==typeof e&&(o*=e,t+=1),ki(e))return s}else void 0!==s&&null!==s.value&&(o*=Bi(s,this.locale),t+=1);return{value:0===t?0:o,format:Ni(e[0])}},isExported:!0},Ou={description:Bo("A random number between 0 inclusive and 1 exclusive."),args:[],compute:function(){return Math.random()},isExported:!0},Fu={description:Bo("Returns a grid of random numbers between 0 inclusive and 1 exclusive."),args:[ad("rows (number, default=1)",Bo("The number of rows to be returned.")),ad("columns (number, default=1)",Bo("The number of columns to be returned.")),ad("min (number, default=0)",Bo("The minimum number you would like returned.")),ad("max (number, default=1)",Bo("The maximum number you would like returned.")),ad("whole_number (number, default=FALSE)",Bo("Return a whole number or a decimal value."))],compute:function(e={value:1},t={value:1},o={value:0},s={value:1},i={value:!1}){const n=zi(t,this.locale),r=zi(e,this.locale),a=Li(o,this.locale),l=Li(s,this.locale),c=Yi(i);dd(Bo("The number of columns (%s) must be positive.",n.toString()),n),dd(Bo("The number of rows (%s) must be positive.",r.toString()),r),Pi((()=>a<=l),Bo("The maximum (%s) must be greater than or equal to the minimum (%s).",l.toString(),a.toString())),c&&Pi((()=>Number.isInteger(a)&&Number.isInteger(l)),Bo("The maximum (%s) and minimum (%s) must be integers when whole_number is TRUE.",l.toString(),a.toString()));const h=Array(n);for(let e=0;e<n;e++){h[e]=Array(r);for(let t=0;t<r;t++)h[e][t]=c?Math.floor(Math.random()*(l-a+1)+a):a+Math.random()*(l-a)}return h},isExported:!0},Mu={description:Bo("Random integer between two values, inclusive."),args:[ad("low (number)",Bo("The low end of the random range.")),ad("high (number)",Bo("The high end of the random range."))],compute:function(e,t){let o=Li(e,this.locale);Number.isInteger(o)||(o=Math.ceil(o));let s=Li(t,this.locale);return Number.isInteger(s)||(s=Math.floor(s)),Pi((()=>o<=s),Bo("The high (%s) must be greater than or equal to the low (%s).",s.toString(),o.toString())),{value:o+Math.ceil((s-o+1)*Math.random())-1,format:e?.format}},isExported:!0},Pu={description:Bo("Rounds a number according to standard rules."),args:[ad("value (number)",Bo("The value to round to places number of places.")),ad("places (number, default=0)",Bo("The number of decimal places to which to round."))],compute:function(e,t={value:0}){const o=Li(e,this.locale);let s=Li(t,this.locale);const i=Math.abs(o);let n;return 0===s?n=Math.round(i):(Number.isInteger(s)||(s=Math.trunc(s)),n=Math.round(i*Math.pow(10,s))/Math.pow(10,s)),{value:o>=0?n:-n,format:e?.format}},isExported:!0},Nu={description:Bo("Rounds down a number."),args:[ad("value (number)",Bo("The value to round to places number of places, always rounding down.")),ad("places (number, default=0)",Bo("The number of decimal places to which to round."))],compute:function(e,t={value:0}){const o=Li(e,this.locale);let s=Li(t,this.locale);const i=Math.abs(o);let n;return 0===s?n=Math.floor(i):(Number.isInteger(s)||(s=Math.trunc(s)),n=Math.floor(i*Math.pow(10,s))/Math.pow(10,s)),{value:o>=0?n:-n,format:e?.format}},isExported:!0},ku={description:Bo("Rounds up a number."),args:[ad("value (number)",Bo("The value to round to places number of places, always rounding up.")),ad("places (number, default=0)",Bo("The number of decimal places to which to round."))],compute:function(e,t={value:0}){const o=Li(e,this.locale);let s=Li(t,this.locale);const i=Math.abs(o);let n;return 0===s?n=Math.ceil(i):(Number.isInteger(s)||(s=Math.trunc(s)),n=Math.ceil(i*Math.pow(10,s))/Math.pow(10,s)),{value:o>=0?n:-n,format:e?.format}},isExported:!0},Vu={description:Bo("Secant of an angle provided in radians."),args:[ad("angle (number)",Bo("The angle to find the secant of, in radians."))],compute:function(e){return 1/Math.cos(Li(e,this.locale))},isExported:!0},Lu={description:Bo("Hyperbolic secant of any real number."),args:[ad("value (number)",Bo("Any real value to calculate the hyperbolic secant of."))],compute:function(e){return 1/Math.cosh(Li(e,this.locale))},isExported:!0},Hu={description:Bo("Returns a sequence of numbers."),args:[ad("rows (number)",Bo("The number of rows to return")),ad("columns (number, optional, default=1)",Bo("The number of columns to return")),ad("start (number, optional, default=1)",Bo("The first number in the sequence")),ad("step (number, optional, default=1)",Bo("The amount to increment each value in the sequence"))],compute:function(e,t={value:1},o={value:1},s={value:1}){const i=Li(o,this.locale),n=Li(s,this.locale),r=zi(e,this.locale),a=zi(t,this.locale);return dd(Bo("The number of columns (%s) must be positive.",a),a),dd(Bo("The number of rows (%s) must be positive.",r),r),rn(a,r,((e,t)=>({value:i+t*a*n+e*n})))},isExported:!0},Uu={description:Bo("Sine of an angle provided in radians."),args:[ad("angle (number)",Bo("The angle to find the sine of, in radians."))],compute:function(e){return Math.sin(Li(e,this.locale))},isExported:!0},Bu={description:Bo("Hyperbolic sine of any real number."),args:[ad("value (number)",Bo("Any real value to calculate the hyperbolic sine of."))],compute:function(e){return Math.sinh(Li(e,this.locale))},isExported:!0},zu={description:Bo("Positive square root of a positive number."),args:[ad("value (number)",Bo("The number for which to calculate the positive square root."))],compute:function(e){const t=Li(e,this.locale);return Pi((()=>t>=0),Bo("The value (%s) must be positive or null.",t.toString())),{value:Math.sqrt(t),format:e?.format}},isExported:!0},$u={description:Bo("Sum of a series of numbers and/or cells."),args:[ad("value1 (number, range<number>)",Bo("The first number or range to add together.")),ad("value2 (number, range<number>, repeating)",Bo("Additional numbers or ranges to add to value1."))],compute:function(...e){const t=e[0];return{value:fl(e,this.locale),format:Ni(t)}},isExported:!0},Gu={description:Bo("A conditional sum across a range."),args:[ad("criteria_range (range)",Bo("The range which is tested against criterion.")),ad("criterion (string)",Bo("The pattern or test to apply to range.")),ad("sum_range (range, default=criteria_range)",Bo("The range to be summed, if different from range."))],compute:function(e,t,o){void 0===o&&(o=e);let s=0;return pn([e,t],((e,t)=>{const i=o[e]?.[t]?.value;"number"==typeof i&&(s+=i)}),this.locale),s},isExported:!0},Wu={description:Bo("Sums a range depending on multiple criteria."),args:[ad("sum_range (range)",Bo("The range to sum.")),ad("criteria_range1 (range)",Bo("The range to check against criterion1.")),ad("criterion1 (string)",Bo("The pattern or test to apply to criteria_range1.")),ad("criteria_range2 (any, range, repeating)",Bo("Additional ranges to check.")),ad("criterion2 (string, repeating)",Bo("Additional criteria to check."))],compute:function(e,...t){let o=0;return pn(t,((t,s)=>{const i=e[t]?.[s]?.value;"number"==typeof i&&(o+=i)}),this.locale),o},isExported:!0},qu={description:Bo("Tangent of an angle provided in radians."),args:[ad("angle (number)",Bo("The angle to find the tangent of, in radians."))],compute:function(e){return Math.tan(Li(e,this.locale))},isExported:!0},Zu={description:Bo("Hyperbolic tangent of any real number."),args:[ad("value (number)",Bo("Any real value to calculate the hyperbolic tangent of."))],compute:function(e){return Math.tanh(Li(e,this.locale))},isExported:!0};function ju(e,t){return 0===t?Math.trunc(e):(Number.isInteger(t)||(t=Math.trunc(t)),Math.trunc(e*Math.pow(10,t))/Math.pow(10,t))}const Yu={description:Bo("Truncates a number."),args:[ad("value (number)",Bo("The value to be truncated.")),ad("places (number, default=0)",Bo("The number of significant digits to the right of the decimal point to retain."))],compute:function(e,t={value:0}){return{value:ju(Li(e,this.locale),Li(t,this.locale)),format:e?.format}},isExported:!0},Xu={description:Bo("Rounds a number down to the nearest integer that is less than or equal to it."),args:[ad("value (number)",Bo("The number to round down to the nearest integer."))],compute:function(e){return Math.floor(Li(e,this.locale))},isExported:!0};var Ku=Object.freeze({__proto__:null,ABS:Bd,ACOS:zd,ACOSH:$d,ACOT:Gd,ACOTH:Wd,ASIN:qd,ASINH:Zd,ATAN:jd,ATAN2:Yd,ATANH:Xd,CEILING:Kd,CEILING_MATH:Qd,CEILING_PRECISE:eu,COS:tu,COSH:ou,COT:su,COTH:iu,COUNTBLANK:nu,COUNTIF:ru,COUNTIFS:au,COUNTUNIQUE:lu,COUNTUNIQUEIFS:cu,CSC:hu,CSCH:du,DECIMAL:uu,DEGREES:gu,EXP:pu,FLOOR:mu,FLOOR_MATH:vu,FLOOR_PRECISE:bu,INT:Xu,ISEVEN:Su,ISODD:Cu,ISO_CEILING:yu,LN:wu,LOG:xu,MOD:Iu,MUNIT:Ru,ODD:Tu,PI:Au,POWER:_u,PRODUCT:Du,RAND:Ou,RANDARRAY:Fu,RANDBETWEEN:Mu,ROUND:Pu,ROUNDDOWN:Nu,ROUNDUP:ku,SEC:Vu,SECH:Lu,SEQUENCE:Hu,SIN:Uu,SINH:Bu,SQRT:zu,SUM:$u,SUMIF:Gu,SUMIFS:Wu,TAN:qu,TANH:Zu,TRUNC:Yu});function Ju(e,t){const o=[],s=[];let i=0,n=0;Qi([e],(e=>{o.push(e),i+=1})),Qi([t],(e=>{s.push(e),n+=1})),Pi((()=>i===n),Bo("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",i,n));const r=[],a=[];for(let e=0;e<i;e++){const t=o[e]?.value,i=s[e]?.value;"number"==typeof t&&"number"==typeof i&&(a.push(t),r.push(i))}return{flatDataX:r,flatDataY:a}}function Qu(e,t,o){const{flatDataX:s,flatDataY:i}=Ju(e,t),n=i.length;Pi((()=>0!==n&&(!o||1!==n)),Bo("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."),Ei.DivisionByZero);let r=0,a=0;for(let e=0;e<n;e++)r+=i[e],a+=s[e];const l=r/n,c=a/n;let h=0;for(let e=0;e<n;e++)h+=(i[e]-l)*(s[e]-c);return h/(n-(o?1:0))}function eg(e,t,o,s){let i=0;const n=o?nn:sn,r=n(e,((e,t)=>(i+=1,e+t)),0,s);Pi((()=>0!==i&&(!t||1!==i)),Bo("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."),Ei.DivisionByZero);const a=r/i;return n(e,((e,t)=>e+Math.pow(t-a,2)),0,s)/(i-(t?1:0))}function tg(e,t,o,s){const i=Li(t,s);Pi((()=>o?0<=i&&i<=1:0<i&&i<1),Bo("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let n,r=[],a=0;return Qi(e,(e=>{const t=e?.value;"number"==typeof t&&(n=mn(r,e,"nextSmaller","asc",r.length,((e,t)=>e[t])),r.splice(n+1,0,t),a++)})),Pi((()=>0!==a),Bo("[[FUNCTION_NAME]] has no valid input data.")),o||Pi((()=>1/(a+1)<=i&&i<=a/(a+1)),Bo("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),si(r,i,o)}const og={description:Bo("Average magnitude of deviations from mean."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the sample.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the sample."))],compute:function(...e){let t=0;const o=sn(e,((e,o)=>(t+=1,e+o)),0,this.locale);Wi(t);const s=o/t;return sn(e,((e,t)=>e+Math.abs(s-t)),0,this.locale)/t},isExported:!0},sg={description:Bo("Numerical average value in a dataset, ignoring text."),args:[ad("value1 (number, range<number>)",Bo("The first value or range to consider when calculating the average value.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to consider when calculating the average value."))],compute:function(...e){return{value:Rl(e,this.locale),format:Ni(e[0])}},isExported:!0},ig=Bo("[[FUNCTION_NAME]] has mismatched range sizes."),ng=Bo("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),rg={description:Bo("Weighted average."),args:[ad("values (number, range<number>)",Bo("Values to average.")),ad("weights (number, range<number>)",Bo("Weights for each corresponding value.")),ad("additional_values (number, range<number>, repeating)",Bo("Additional values to average.")),ad("additional_weights (number, range<number>, repeating)",Bo("Additional weights."))],compute:function(...e){let t=0,o=0;for(let s=0;s<e.length-1;s+=2){const i=e[s],n=e[s+1];if(hd(ig,i,n),yi(i))for(let e=0;e<i.length;e++)for(let s=0;s<i[0].length;s++){const r=i[e][s].value,a=yi(n)?n?.[e][s].value:Li(n,this.locale),l="number"==typeof r,c="number"==typeof a;l&&c?(Pi((()=>a>=0),ng),t+=r*a,o+=a):Pi((()=>l===c),Bo("[[FUNCTION_NAME]] expects number values."))}else{const e=Li(i,this.locale),s=yi(n)?n?.[0][0].value:Li(n,this.locale);"number"==typeof s&&(Pi((()=>s>=0),ng),t+=e*s,o+=s)}}return Wi(o),{value:t/o,format:Ni(e[0])}}},ag={description:Bo("Numerical average value in a dataset."),args:[ad("value1 (number, range<number>)",Bo("The first value or range to consider when calculating the average value.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to consider when calculating the average value."))],compute:function(...e){let t=0;const o=nn(e,((e,o)=>(t+=1,e+o)),0,this.locale);return Wi(t),{value:o/t,format:Ni(e[0])}},isExported:!0},lg={description:Bo("Average of values depending on criteria."),args:[ad("criteria_range (number, range<number>)",Bo("The range to check against criterion.")),ad("criterion (string)",Bo("The pattern or test to apply to criteria_range.")),ad("average_range (number, range<number>, default=criteria_range)",Bo("The range to average. If not included, criteria_range is used for the average instead."))],compute:function(e,t,o){const s=Sn(void 0===o?e:o);let i=0,n=0;return pn([e,t],((e,t)=>{const o=s[e]?.[t]?.value;"number"==typeof o&&(i+=1,n+=o)}),this.locale),Wi(i),n/i},isExported:!0},cg={description:Bo("Average of values depending on multiple criteria."),args:[ad("average_range (range)",Bo("The range to average.")),ad("criteria_range1 (range)",Bo("The range to check against criterion1.")),ad("criterion1 (string)",Bo("The pattern or test to apply to criteria_range1.")),ad("criteria_range2 (any, range, repeating)",Bo("Additional criteria_range and criterion to check.")),ad("criterion2 (string, repeating)",Bo("The pattern or test to apply to criteria_range2."))],compute:function(e,...t){const o=Sn(e);let s=0,i=0;return pn(t,((e,t)=>{const n=o[e]?.[t]?.value;"number"==typeof n&&(s+=1,i+=n)}),this.locale),Wi(s),i/s},isExported:!0},hg={description:Bo("The number of numeric values in dataset."),args:[ad("value1 (number, any, range<number>)",Bo("The first value or range to consider when counting.")),ad("value2 (number, any, range<number>, repeating)",Bo("Additional values or ranges to consider when counting."))],compute:function(...e){return Tl(e,this.locale)},isExported:!0},dg={description:Bo("The number of values in a dataset."),args:[ad("value1 (any, range)",Bo("The first value or range to consider when counting.")),ad("value2 (any, range, repeating)",Bo("Additional values or ranges to consider when counting."))],compute:function(...e){return Al(e)},isExported:!0},ug={description:Bo("The covariance of a dataset."),args:[ad("data_y (any, range)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (any, range)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Qu(e,t,!1)},isExported:!0},gg={description:Bo("The covariance of a dataset."),args:[ad("data_y (any, range)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (any, range)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Qu(e,t,!1)},isExported:!0},pg={description:Bo("The sample covariance of a dataset."),args:[ad("data_y (any, range)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (any, range)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Qu(e,t,!0)},isExported:!0},mg={description:Bo("Calculates the expected y-value for a specified x based on a linear regression of a dataset."),args:[ad("x (number, range<number>)",Bo("The value(s) on the x-axis to forecast.")),ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t,o){const{flatDataX:s,flatDataY:i}=Ju(t,o);return Ul(s,i),Ll([i],[s],an(Sn(e),(e=>Li(e,this.locale))),!0)},isExported:!0},fg={description:Bo("Fits points to exponential growth trend."),args:[ad("known_data_y (range<number>)",Bo("The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.")),ad("known_data_x (range<number>, default={1;2;3;...})",Bo("The values of the independent variable(s) corresponding with known_data_y.")),ad("new_data_x (any, range, default=known_data_x)",Bo("The data points to return the y values for on the ideal curve fit.")),ad("b (boolean, default=TRUE)",Bo("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."))],compute:function(e,t=[[]],o=[[]],s={value:!0}){return Hl(e,"known_data_y"),kl(Ll(Vl(Ui(e,"known_data_y")),Ui(t,"known_data_x"),Ui(o,"new_data_y"),Yi(s)))}},vg={description:Bo("Compute the intercept of the linear regression."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Ju(e,t);Ul(o,s);const[[],[i]]=Fl([o],[s]);return i},isExported:!0},bg={description:Bo("Nth largest element from a data set."),args:[ad("data (any, range)",Bo("Array or range containing the dataset to consider.")),ad("n (number)",Bo("The rank from largest to smallest of the element to return."))],compute:function(e,t){const o=Math.trunc(Li(t?.value,this.locale));let s,i=[],n=0;Qi([e],(e=>{"number"==typeof e?.value&&(s=mn(i,e,"nextSmaller","asc",i.length,((e,t)=>e[t].value)),i.splice(s+1,0,e),n++,n>o&&(i.shift(),n--))}));const r=i.shift();return Pi((()=>void 0!==r),Bo("[[FUNCTION_NAME]] has no valid input data.")),Pi((()=>n>=o),Bo("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o)),r},isExported:!0},Sg={description:Bo("Given partial data about a linear trend, calculates various parameters about the ideal linear trend using the least-squares method."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>, default={1;2;3;...})",Bo("The range representing the array or matrix of independent data.")),ad("calculate_b (boolean, default=TRUE)",Bo("A flag specifying wheter to compute the slope or not")),ad("verbose (boolean, default=FALSE)",Bo("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept"))],compute:function(e,t=[[]],o={value:!0},s={value:!1}){return Hl(e,"data_y"),Fl(Ui(t,"data_x"),Ui(e,"data_y"),Yi(o),Yi(s))},isExported:!0},yg={description:Bo("Given partial data about an exponential growth curve, calculates various parameters about the best fit ideal exponential growth curve."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>, optional, default={1;2;3;...})",Bo("The range representing the array or matrix of independent data.")),ad("calculate_b (boolean, default=TRUE)",Bo("A flag specifying wheter to compute the slope or not")),ad("verbose (boolean, default=FALSE)",Bo("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept"))],compute:function(e,t=[[]],o={value:!0},s={value:!1}){Hl(e,"data_y");const i=Fl(Ui(t,"data_x"),Vl(Ui(e,"data_y")),Yi(o),Yi(s));for(let e=0;e<i.length;e++)i[e][0]=Math.exp(i[e][0]);return i},isExported:!0},Cg={description:Bo("Compute the Matthews correlation coefficient of a dataset."),args:[ad("data_x (range)",Bo("The range representing the array or matrix of observed data.")),ad("data_y (range)",Bo("The range representing the array or matrix of predicted data."))],compute:function(e,t){const o=e.flat(),s=t.flat();Il(o,s),Ul(o,s);const i=o.length;let n=0,r=0,a=0,l=0;for(let e=0;e<i;++e){const t=Yi(o[e]);t===Yi(s[e])?t?r++:n++:t?l++:a++}return(r*n-a*l)/Math.sqrt((r+a)*(r+l)*(n+a)*(n+l))},isExported:!1},wg={description:Bo("Maximum value in a numeric dataset."),args:[ad("value1 (number, range<number>)",Bo("The first value or range to consider when calculating the maximum value.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to consider when calculating the maximum value."))],compute:function(...e){return _l(e,this.locale)},isExported:!0},xg={description:Bo("Maximum numeric value in a dataset."),args:[ad("value1 (any, range)",Bo("The first value or range to consider when calculating the maximum value.")),ad("value2 (any, range, repeating)",Bo("Additional values or ranges to consider when calculating the maximum value."))],compute:function(...e){const t=nn(e,((e,t)=>Math.max(t,e)),-1/0,this.locale);return{value:t===-1/0?0:t,format:Ni(e[0])}},isExported:!0},Eg={description:Bo("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:[ad("range (range)",Bo("The range of cells from which the maximum will be determined.")),ad("criteria_range1 (range)",Bo("The range of cells over which to evaluate criterion1.")),ad("criterion1 (string)",Bo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),ad("criteria_range2 (any, range, repeating)",Bo("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),ad("criterion2 (string, repeating)",Bo("The pattern or test to apply to criteria_range2."))],compute:function(e,...t){let o=-1/0;return pn(t,((t,s)=>{const i=e[t]?.[s]?.value;"number"==typeof i&&(o=o<i?i:o)}),this.locale),o===-1/0?0:o},isExported:!0},Ig={description:Bo("Median value in a numeric dataset."),args:[ad("value1 (any, range)",Bo("The first value or range to consider when calculating the median value.")),ad("value2 (any, range, repeating)",Bo("Additional values or ranges to consider when calculating the median value."))],compute:function(...e){let t=[];return en(e,(e=>{t.push(e)}),this.locale),{value:tg(t,{value:.5},!0,this.locale),format:Ni(t[0])}},isExported:!0},Rg={description:Bo("Minimum value in a numeric dataset."),args:[ad("value1 (number, range<number>)",Bo("The first value or range to consider when calculating the minimum value.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to consider when calculating the minimum value."))],compute:function(...e){return Dl(e,this.locale)},isExported:!0},Tg={description:Bo("Minimum numeric value in a dataset."),args:[ad("value1 (number, range<number>)",Bo("The first value or range to consider when calculating the minimum value.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to consider when calculating the minimum value."))],compute:function(...e){const t=nn(e,((e,t)=>Math.min(t,e)),1/0,this.locale);return{value:t===1/0?0:t,format:Ni(e[0])}},isExported:!0},Ag={description:Bo("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:[ad("range (range)",Bo("The range of cells from which the minimum will be determined.")),ad("criteria_range1 (range)",Bo("The range of cells over which to evaluate criterion1.")),ad("criterion1 (string)",Bo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),ad("criteria_range2 (any, range, repeating)",Bo("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),ad("criterion2 (string, repeating)",Bo("The pattern or test to apply to criteria_range2."))],compute:function(e,...t){let o=1/0;return pn(t,((t,s)=>{const i=e[t]?.[s]?.value;"number"==typeof i&&(o=o>i?i:o)}),this.locale),o===1/0?0:o},isExported:!0};function _g(e,t){const{flatDataX:o,flatDataY:s}=Ju(e,t);Ul(o,s);const i=o.length;let n=0,r=0,a=0,l=0,c=0;for(let e=0;e<i;e++){const t=o[e],i=s[e];n+=t,r+=i,a+=t*i,l+=t*t,c+=i*i}return(i*a-n*r)/Math.sqrt((i*l-n*n)*(i*c-r*r))}const Dg={description:Bo("Compute the Pearson product-moment correlation coefficient of a dataset."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){return _g(e,t)},isExported:!0},Og=Dg,Fg={description:Bo("Value at a given percentile of a dataset."),args:[ad("data (any, range)",Bo("The array or range containing the dataset to consider.")),ad("percentile (number)",Bo("The percentile whose value within data will be calculated and returned."))],compute:function(e,t){return Pg.compute.bind(this)(e,t)},isExported:!0},Mg={description:Bo("Value at a given percentile of a dataset exclusive of 0 and 1."),args:[ad("data (any, range)",Bo("The array or range containing the dataset to consider.")),ad("percentile (number)",Bo("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned."))],compute:function(e,t){return{value:tg([e],t,!1,this.locale),format:Ni(e)}},isExported:!0},Pg={description:Bo("Value at a given percentile of a dataset."),args:[ad("data (any, range)",Bo("The array or range containing the dataset to consider.")),ad("percentile (number)",Bo("The percentile whose value within data will be calculated and returned."))],compute:function(e,t){return{value:tg([e],t,!0,this.locale),format:Ni(e)}},isExported:!0},Ng={description:Bo("Compute the coefficients of polynomial regression of the dataset."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data.")),ad("order (number)",Bo("The order of the polynomial to fit the data, between 1 and 6.")),ad("intercept (boolean, default=TRUE)",Bo("A flag specifying whether to compute the intercept or not."))],compute:function(e,t,o,s={value:!0}){const{flatDataX:i,flatDataY:n}=Ju(e,t);return Ul(i,n),Ml(n,i,Li(o,this.locale),Yi(s))},isExported:!1},kg={description:Bo("Predict value by computing a polynomial regression of the dataset."),args:[ad("x (number, range<number>)",Bo("The value(s) on the x-axis to forecast.")),ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data.")),ad("order (number)",Bo("The order of the polynomial to fit the data, between 1 and 6.")),ad("intercept (boolean, default=TRUE)",Bo("A flag specifying whether to compute the intercept or not."))],compute:function(e,t,o,s,i={value:!0}){const n=Li(s,this.locale),{flatDataX:r,flatDataY:a}=Ju(t,o);Ul(r,a);const l=Ml(a,r,n,Yi(i)).flat();return an(Sn(e),(e=>Nl(l,Li(e,this.locale),n)))},isExported:!1},Vg={description:Bo("Value nearest to a specific quartile of a dataset."),args:[ad("data (any, range)",Bo("The array or range containing the dataset to consider.")),ad("quartile_number (number)",Bo("Which quartile value to return."))],compute:function(e,t){return Hg.compute.bind(this)(e,t)},isExported:!0},Lg={description:Bo("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:[ad("data (any, range)",Bo("The array or range containing the dataset to consider.")),ad("quartile_number (number)",Bo("Which quartile value, exclusive of 0 and 4, to return."))],compute:function(e,t){return{value:tg([e],{value:.25*Math.trunc(Li(t,this.locale))},!1,this.locale),format:Ni(e)}},isExported:!0},Hg={description:Bo("Value nearest to a specific quartile of a dataset."),args:[ad("data (any, range)",Bo("The array or range containing the dataset to consider.")),ad("quartile_number (number)",Bo("Which quartile value to return."))],compute:function(e,t){return{value:tg([e],{value:.25*Math.trunc(Li(t,this.locale))},!0,this.locale),format:Ni(e)}},isExported:!0},Ug={description:Bo("Returns the rank of a specified value in a dataset."),args:[ad("value (number)",Bo("The value whose rank will be determined.")),ad("data (range)",Bo("The range containing the dataset to consider.")),ad("is_ascending (boolean, default=FALSE)",Bo("Whether to consider the values in data in descending or ascending order."))],compute:function(e,t,o={value:!1}){const s=Yi(o),i=Li(e,this.locale);let n=1,r=!1;for(const e of t)for(const t of e){if("number"!=typeof t.value)continue;const e=Li(t,this.locale);e===i?r=!0:e>i!==s&&n++}return r?n:new Di(Bo("Value not found in the given data."))},isExported:!0},Bg={description:Bo("Compute the square of r, the Pearson product-moment correlation coefficient of a dataset."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Math.pow(_g(t,e),2)},isExported:!0},zg={description:Bo("Compute the slope of the linear regression."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Ju(e,t);Ul(o,s);const[[i]]=Fl([o],[s]);return i},isExported:!0},$g={description:Bo("Nth smallest element in a data set."),args:[ad("data (any, range)",Bo("The array or range containing the dataset to consider.")),ad("n (number)",Bo("The rank from smallest to largest of the element to return."))],compute:function(e,t){const o=Math.trunc(Li(t?.value,this.locale));let s,i=[],n=0;Qi([e],(e=>{"number"==typeof e?.value&&(s=mn(i,e,"nextSmaller","asc",i.length,((e,t)=>e[t].value)),i.splice(s+1,0,e),n++,n>o&&(i.pop(),n--))}));const r=i.pop();return Pi((()=>void 0!==r),Bo("[[FUNCTION_NAME]] has no valid input data.")),Pi((()=>n>=o),Bo("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o)),r},isExported:!0},Gg={description:Bo("Compute the Spearman rank correlation coefficient of a dataset."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Ju(t,e);Ul(o,s);const i=o.length,n=o.map(((e,t)=>[e,s[t]]));n.sort(((e,t)=>e[0]-t[0]));for(let e=0;e<i;++e)n[e][0]=e;n.sort(((e,t)=>e[1]-t[1]));let r=0;for(let e=0;e<i;++e)r+=(n[e][0]-e)**2;return 1-6*r/(i**3-i)},isExported:!1},Wg={description:Bo("Standard deviation."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the sample.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the sample."))],compute:function(...e){return Math.sqrt(Qg.compute.bind(this)(...e))},isExported:!0},qg={description:Bo("Standard deviation of entire population."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the population.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the population."))],compute:function(...e){return Math.sqrt(ep.compute.bind(this)(...e))},isExported:!0},Zg={description:Bo("Standard deviation."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the sample.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the sample."))],compute:function(...e){return Math.sqrt(tp.compute.bind(this)(...e))},isExported:!0},jg={description:Bo("Standard deviation of sample (text as 0)."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the sample.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the sample."))],compute:function(...e){return Math.sqrt(op.compute.bind(this)(...e))},isExported:!0},Yg={description:Bo("Standard deviation of entire population."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the population.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the population."))],compute:function(...e){return Math.sqrt(sp.compute.bind(this)(...e))},isExported:!0},Xg={description:Bo("Standard deviation of entire population (text as 0)."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the population.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the population."))],compute:function(...e){return Math.sqrt(ip.compute.bind(this)(...e))},isExported:!0},Kg={description:Bo("Calculates the standard error of the predicted y-value for each x in the regression of a dataset."),args:[ad("data_y (range<number>)",Bo("The range representing the array or matrix of dependent data.")),ad("data_x (range<number>)",Bo("The range representing the array or matrix of independent data."))],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Ju(e,t);Ul(o,s);return Fl([o],[s],!0,!0)[1][2]},isExported:!0},Jg={description:Bo("Fits points to linear trend derived via least-squares."),args:[ad("known_data_y (number, range<number>)",Bo("The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.")),ad("known_data_x (number, range<number>, optional, default={1;2;3;...})",Bo("The values of the independent variable(s) corresponding with known_data_y.")),ad("new_data_x (number, range<number>, optional, default=known_data_x)",Bo("The data points to return the y values for on the ideal curve fit.")),ad("b (boolean, optional, default=TRUE)",Bo("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."))],compute:function(e,t=[[]],o=[[]],s={value:!0}){return Hl(e,"known_data_y"),Ll(Ui(e,"known_data_y"),Ui(t,"known_data_x"),Ui(o,"new_data_y"),Yi(s))}},Qg={description:Bo("Variance."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the sample.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the sample."))],compute:function(...e){return eg(e,!0,!1,this.locale)},isExported:!0},ep={description:Bo("Variance of entire population."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the population.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the population."))],compute:function(...e){return eg(e,!1,!1,this.locale)},isExported:!0},tp={description:Bo("Variance."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the sample.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the sample."))],compute:function(...e){return eg(e,!0,!1,this.locale)},isExported:!0},op={description:Bo("Variance of sample (text as 0)."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the sample.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the sample."))],compute:function(...e){return eg(e,!0,!0,this.locale)},isExported:!0},sp={description:Bo("Variance of entire population."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the population.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the population."))],compute:function(...e){return eg(e,!1,!1,this.locale)},isExported:!0},ip={description:Bo("Variance of entire population (text as 0)."),args:[ad("value1 (number, range<number>)",Bo("The first value or range of the population.")),ad("value2 (number, range<number>, repeating)",Bo("Additional values or ranges to include in the population."))],compute:function(...e){return eg(e,!1,!0,this.locale)},isExported:!0};var np=Object.freeze({__proto__:null,AVEDEV:og,AVERAGE:sg,AVERAGEA:ag,AVERAGEIF:lg,AVERAGEIFS:cg,AVERAGE_WEIGHTED:rg,CORREL:Og,COUNT:hg,COUNTA:dg,COVAR:ug,COVARIANCE_P:gg,COVARIANCE_S:pg,FORECAST:mg,GROWTH:fg,INTERCEPT:vg,LARGE:bg,LINEST:Sg,LOGEST:yg,MATTHEWS:Cg,MAX:wg,MAXA:xg,MAXIFS:Eg,MEDIAN:Ig,MIN:Rg,MINA:Tg,MINIFS:Ag,PEARSON:Dg,PERCENTILE:Fg,PERCENTILE_EXC:Mg,PERCENTILE_INC:Pg,POLYFIT_COEFFS:Ng,POLYFIT_FORECAST:kg,QUARTILE:Vg,QUARTILE_EXC:Lg,QUARTILE_INC:Hg,RANK:Ug,RSQ:Bg,SLOPE:zg,SMALL:$g,SPEARMAN:Gg,STDEV:Wg,STDEVA:jg,STDEVP:Yg,STDEVPA:Xg,STDEV_P:qg,STDEV_S:Zg,STEYX:Kg,TREND:Jg,VAR:Qg,VARA:op,VARP:sp,VARPA:ip,VAR_P:ep,VAR_S:tp});function rp(e,t,o,s){const i=new Map,n=e.length;for(let t=n-1;t>=0;t--)i.set(qi(e[t][0]).toUpperCase(),t);const r=t?.value;if("number"!=typeof r&&"string"!=typeof r)throw new Ri(Bo("The field must be a number or a string"));let a;if("number"==typeof r){if(a=Math.trunc(r)-1,a<0||n-1<a)throw new Ri(Bo("The field (%(fieldValue)s) must be one of %(dimRowDB)s or must be a number between 1 and %s inclusive.",{fieldValue:r.toString(),dimRowDB:n.toString()}))}else{const e=qi(t).toUpperCase();if(a=i.get(e)??-1,-1===a)throw new Ri(Bo("The field (%s) must be one of %s.",qi(t),[...i.keys()].toString()))}const l=o[0].length;if(l<2)throw new Ri(Bo("The criteria range contains %s row, it must be at least 2 rows.",l.toString()));let c=new Set;const h=e[0].length;for(let t=1;t<l;t++){let n=[],r=!0;for(let s=0;s<o.length;s++){const a=qi(o[s][0]).toUpperCase(),l=i.get(a),c=o[s][t];if(null!==c.value){if(void 0===l){r=!1;break}n.push([e[l].slice(1,h)]),n.push(c)}}if(r){if(!(n.length>0)){c=new Set(Array(h-1).keys());break}pn(n,((e,t)=>{c.add(t)}),s,!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const ap=[ad("database (range)",Bo("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.")),ad("field (number, string)",Bo("Indicates which column in database contains the values to be extracted and operated on.")),ad("criteria (range)",Bo("An array or range containing zero or more criteria to filter the database values by before operating."))],lp={description:Bo("Average of a set of values from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return sg.compute.bind(this)([s])},isExported:!0},cp={description:Bo("Counts values from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return hg.compute.bind(this)([s])},isExported:!0},hp={description:Bo("Counts values and text from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return dg.compute.bind(this)([s])},isExported:!0},dp={description:Bo("Single value from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return Pi((()=>1===s.length),Bo("More than one match found in DGET evaluation.")),s[0]},isExported:!0},up={description:Bo("Maximum of values from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return wg.compute.bind(this)([s])},isExported:!0},gp={description:Bo("Minimum of values from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return Rg.compute.bind(this)([s])},isExported:!0},pp={description:Bo("Product of values from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return Du.compute.bind(this)([s])},isExported:!0},mp={description:Bo("Standard deviation of population sample from table."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return Wg.compute.bind(this)([s])},isExported:!0},fp={description:Bo("Standard deviation of entire population from table."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return Yg.compute.bind(this)([s])},isExported:!0},vp={description:Bo("Sum of values from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return $u.compute.bind(this)([s])},isExported:!0},bp={description:Bo("Variance of population sample from table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return Qg.compute.bind(this)([s])},isExported:!0},Sp={description:Bo("Variance of a population from a table-like range."),args:ap,compute:function(e,t,o){const s=rp(e,t,o,this.locale);return sp.compute.bind(this)([s])},isExported:!0};var yp=Object.freeze({__proto__:null,DAVERAGE:lp,DCOUNT:cp,DCOUNTA:hp,DGET:dp,DMAX:up,DMIN:gp,DPRODUCT:pp,DSTDEV:mp,DSTDEVP:fp,DSUM:vp,DVAR:bp,DVARP:Sp});var Cp;!function(e){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"}(Cp||(Cp={}));const wp={description:Bo("Converts year/month/day into a date."),args:[ad("year (number)",Bo("The year component of the date.")),ad("month (number)",Bo("The month component of the date.")),ad("day (number)",Bo("The day component of the date."))],compute:function(e,t,o){let s=Math.trunc(Li(e,this.locale));const i=Math.trunc(Li(t,this.locale)),n=Math.trunc(Li(o,this.locale));Pi((()=>0<=s&&s<=9999),Bo("The year (%s) must be between 0 and 9999 inclusive.",s.toString())),s<1900&&(s+=1900);const r=Bs(new xs(s,i-1,n));return Pi((()=>r>=0),Bo("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),{value:r,format:this.locale.dateFormat}},isExported:!0},xp={description:Bo("Calculates the number of days, months, or years between two dates."),args:[ad("start_date (date)",Bo("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.")),ad("end_date (date)",Bo("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.")),ad("unit (string)",Bo('A text abbreviation for unit of time. Accepted values are "Y" (the number of whole years between start_date and end_date), "M" (the number of whole months between start_date and end_date), "D" (the number of days between start_date and end_date), "MD" (the number of days between start_date and end_date after subtracting whole months), "YM" (the number of whole months between start_date and end_date after subtracting whole years), "YD" (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,o){const s=qi(o).toUpperCase();Pi((()=>Object.values(Cp).includes(s)),((e,t)=>{const o=e.map((e=>`'${e}'`)).join(", ");return Bo("The function [[FUNCTION_NAME]] has an argument with value '%s'. It should be one of: %s.",t,o)})(Object.values(Cp),qi(o)));const i=Math.trunc(Li(e,this.locale)),n=Math.trunc(Li(t,this.locale)),r=Us(i),a=Us(n);switch(Pi((()=>n>=i),Bo("start_date (%s) should be on or before end_date (%s).",r.toLocaleDateString(),a.toLocaleDateString())),s){case Cp.WHOLE_YEARS:return Xs(r,a);case Cp.WHOLE_MONTHS:return js(r,a);case Cp.WHOLE_DAYS:return Ys(r,a);case Cp.MONTH_WITHOUT_WHOLE_YEARS:return js(r,a)-12*Xs(r,a);case Cp.DAYS_WITHOUT_WHOLE_MONTHS:let e=a.getDate()-r.getDate();if(e<0){e=$s(new xs(a.getFullYear(),a.getMonth()-1,1))-Math.abs(e)}return e;case Cp.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR:{if(function(e,t){return Zs(e,t,1)<1}(i,n))return Ys(r,a);const e=new xs(r.getFullYear(),a.getMonth(),a.getDate());let t=Ys(r,e);return t<0&&(e.setFullYear(r.getFullYear()+1),t=Ys(r,e)),t}}},isExported:!0},Ep={description:Bo("Converts a date string to a date value."),args:[ad("date_string (string)",Bo("The string representing the date."))],compute:function(e){const t=qi(e),o=Hs(t,this.locale);return Pi((()=>null!==o),Bo("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(o.value)},isExported:!0},Ip={description:Bo("Day of the month that a specific date falls on."),args:[ad("date (string)",Bo("The date from which to extract the day."))],compute:function(e){return Xi(e,this.locale).getDate()},isExported:!0},Rp={description:Bo("Number of days between two dates."),args:[ad("end_date (date)",Bo("The end of the date range.")),ad("start_date (date)",Bo("The start of the date range."))],compute:function(e,t){const o=Xi(e,this.locale),s=Xi(t,this.locale),i=o.getTime()-s.getTime();return Math.round(i/Is)},isExported:!0},Tp={description:Bo("Number of days between two dates on a 360-day year (months of 30 days)."),args:[ad("start_date (date)",Bo("The start date to consider in the calculation.")),ad("end_date (date)",Bo("The end date to consider in the calculation.")),ad("method (number, default=0)",Bo("An indicator of what day count method to use. (0) US NASD method (1) European method"))],compute:function(e,t,o={value:0}){const s=Math.trunc(Li(e,this.locale)),i=Math.trunc(Li(t,this.locale)),n=Zs(s,i,Yi(o)?4:0);return Math.sign(i-s)*Math.round(360*n)},isExported:!0},Ap={description:Bo("Date a number of months before/after another date."),args:[ad("start_date (date)",Bo("The date from which to calculate the result.")),ad("months (number)",Bo("The number of months before (negative) or after (positive) 'start_date' to calculate."))],compute:function(e,t){return{value:Bs(Ws(Xi(e,this.locale),Math.trunc(Li(t,this.locale)),!1)),format:this.locale.dateFormat}},isExported:!0},_p={description:Bo("Last day of a month before or after a date."),args:[ad("start_date (date)",Bo("The date from which to calculate the result.")),ad("months (number)",Bo("The number of months before (negative) or after (positive) 'start_date' to consider."))],compute:function(e,t){const o=Xi(e,this.locale),s=Math.trunc(Li(t,this.locale)),i=o.getFullYear(),n=o.getMonth();return{value:Bs(new xs(i,n+s+1,0)),format:this.locale.dateFormat}},isExported:!0},Dp={description:Bo("Hour component of a specific time."),args:[ad("time (date)",Bo("The time from which to calculate the hour component."))],compute:function(e){return Xi(e,this.locale).getHours()},isExported:!0},Op={description:Bo("ISO week number of the year."),args:[ad("date (date)",Bo("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){const t=Xi(e,this.locale),o=t.getFullYear();let s=1;for(;4!==new xs(o,0,s).getDay();)s+=1;const i=new xs(o,0,s-3);let n=31;for(;4!==new xs(o,11,n).getDay();)n-=1;const r=new xs(o,11,n+3);let a,l;switch(a=i.getTime()<=t.getTime()?t.getTime()<=r.getTime()?0:1:-1,a){case 0:l=i;break;case 1:l=new xs(o,11,n+3+1);break;case-1:let e=1;for(;4!==new xs(o-1,0,e).getDay();)e+=1;l=new xs(o-1,0,e-3)}const c=(t.getTime()-l.getTime())/Is;return Math.floor(c/7)+1},isExported:!0},Fp={description:Bo("Minute component of a specific time."),args:[ad("time (date)",Bo("The time from which to calculate the minute component."))],compute:function(e){return Xi(e,this.locale).getMinutes()},isExported:!0},Mp={description:Bo("Month of the year a specific date falls in"),args:[ad("date (date)",Bo("The date from which to extract the month."))],compute:function(e){return Xi(e,this.locale).getMonth()+1},isExported:!0},Pp={description:Bo("Net working days between two provided days."),args:[ad("start_date (date)",Bo("The start date of the period from which to calculate the number of net working days.")),ad("end_date (date)",Bo("The end date of the period from which to calculate the number of net working days.")),ad("holidays (date, range<date>, optional)",Bo("A range or array constant containing the date serial numbers to consider holidays."))],compute:function(e,t,o){return kp.compute.bind(this)(e,t,{value:1},o)},isExported:!0};function Np(e){const t=e?.value;if("string"==typeof t){Pi((()=>{if(7!==t.length)return!1;for(let e of t)if("0"!==e&&"1"!==e)return!1;return!0}),Bo('When weekend is a string (%s) it must be composed of "0" or "1".',t));let e=[];for(let o=0;o<7;o++)"1"===t[o]&&e.push((o+1)%7);return e}if("number"==typeof t)return Pi((()=>1<=t&&t<=7||11<=t&&t<=17),Bo("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 Ri(Bo("The weekend must be a number or a string."))}const kp={description:Bo("Net working days between two dates (specifying weekends)."),args:[ad("start_date (date)",Bo("The start date of the period from which to calculate the number of net working days.")),ad("end_date (date)",Bo("The end date of the period from which to calculate the number of net working days.")),ad("weekend (any, default=1)",Bo("A number or string representing which days of the week are considered weekends.")),ad("holidays (date, range<date>, optional)",Bo("A range or array constant containing the dates to consider as holidays."))],compute:function(e,t,o={value:1},s){const i=Xi(e,this.locale),n=Xi(t,this.locale),r=Np(o);let a=new Set;void 0!==s&&Qi([s],(e=>{const t=Xi(e,this.locale);a.add(t.getTime())}));const l=i.getTime()>n.getTime(),c=xs.fromTimestamp((l?i:n).getTime());let h=xs.fromTimestamp((l?n:i).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)r.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},Vp={description:Bo("Current date and time as a date value."),args:[],compute:function(){const e=xs.now(),t=e.getTime()-Es.getTime(),o=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return{value:Math.floor(t/Is)+o,format:gl(this.locale)}},isExported:!0},Lp={description:Bo("Minute component of a specific time."),args:[ad("time (date)",Bo("The time from which to calculate the second component."))],compute:function(e){return Xi(e,this.locale).getSeconds()},isExported:!0},Hp={description:Bo("Converts hour/minute/second into a time."),args:[ad("hour (number)",Bo("The hour component of the time.")),ad("minute (number)",Bo("The minute component of the time.")),ad("second (number)",Bo("The second component of the time."))],compute:function(e,t,o){let s=Math.trunc(Li(e,this.locale)),i=Math.trunc(Li(t,this.locale)),n=Math.trunc(Li(o,this.locale));return i+=Math.floor(n/60),n=n%60+(n<0?60:0),s+=Math.floor(i/60),i=i%60+(i<0?60:0),s%=24,Pi((()=>s>=0),Bo("The function [[FUNCTION_NAME]] result cannot be negative")),{value:s/24+i/1440+n/86400,format:this.locale.timeFormat}},isExported:!0},Up={description:Bo("Converts a time string into its serial number representation."),args:[ad("time_string (string)",Bo("The string that holds the time representation."))],compute:function(e){const t=qi(e),o=Hs(t,this.locale);Pi((()=>null!==o),Bo("The time_string (%s) cannot be parsed to date/time.",t));const s=o.value-Math.trunc(o.value);return s<0?1+s:s},isExported:!0},Bp={description:Bo("Current date as a date value."),args:[],compute:function(){const e=xs.now();return{value:Bs(new xs(e.getFullYear(),e.getMonth(),e.getDate())),format:this.locale.dateFormat}},isExported:!0},zp={description:Bo("Day of the week of the date provided (as number)."),args:[ad("date (date)",Bo("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.")),ad("type (number, default=1)",Bo("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1."))],compute:function(e,t={value:1}){const o=Xi(e,this.locale),s=Math.round(Li(t,this.locale)),i=o.getDay();return Pi((()=>[1,2,3].includes(s)),Bo("The type (%s) must be 1, 2 or 3.",s.toString())),1===s?i+1:2===s?0===i?7:i:0===i?6:i-1},isExported:!0},$p={description:Bo("Week number of the year."),args:[ad("date (date)",Bo("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.")),ad("type (number, default=1)",Bo("A number representing the day that a week starts on. Sunday = 1."))],compute:function(e,t={value:1}){const o=Xi(e,this.locale),s=Math.round(Li(t,this.locale));if(Pi((()=>1===s||2===s||11<=s&&s<=17||21===s),Bo("The type (%s) is out of range.",s.toString())),21===s)return Op.compute.bind(this)(e);let i;i=1===s||2===s?s-1:s-10==7?0:s-10;const n=o.getFullYear();let r=1,a=new xs(n,0,r);for(;a.getDay()!==i;)r+=1,a=new xs(n,0,r);const l=(o.getTime()-a.getTime())/Is;return l<0?1:Math.floor(l/7)+(1===r?1:2)},isExported:!0},Gp={description:Bo("Date after a number of workdays."),args:[ad("start_date (date)",Bo("The date from which to begin counting.")),ad("num_days (number)",Bo("The number of working days to advance from start_date. If negative, counts backwards.")),ad("holidays (date, range<date>, optional)",Bo("A range or array constant containing the dates to consider holidays."))],compute:function(e,t,o={value:null}){return Wp.compute.bind(this)(e,t,{value:1},o)},isExported:!0},Wp={description:Bo("Date after a number of workdays (specifying weekends)."),args:[ad("start_date (date)",Bo("The date from which to begin counting.")),ad("num_days (number)",Bo("The number of working days to advance from start_date. If negative, counts backwards.")),ad("weekend (any, default=1)",Bo("A number or string representing which days of the week are considered weekends.")),ad("holidays (date, range<date>, optional)",Bo("A range or array constant containing the dates to consider holidays."))],compute:function(e,t,o={value:1},s){let i=Xi(e,this.locale),n=Math.trunc(Li(t,this.locale));"string"==typeof o.value&&Pi((()=>"1111111"!==o.value),Bo("The weekend must be different from '1111111'."));const r=Np(o);let a=new Set;void 0!==s&&Qi([s],(e=>{const t=Xi(e,this.locale);a.add(t.getTime())}));let l=xs.fromTimestamp(i.getTime()),c=l.getTime();const h=Math.sign(n);let d=Math.abs(n);for(;d>0;)l.setDate(l.getDate()+h),c=l.getTime(),r.includes(l.getDay())||a.has(c)||(d-=1);const u=c-Es.getTime();return{value:Math.round(u/Is),format:this.locale.dateFormat}},isExported:!0},qp={description:Bo("Year specified by a given date."),args:[ad("date (date)",Bo("The date from which to extract the year."))],compute:function(e){return Xi(e,this.locale).getFullYear()},isExported:!0},Zp={description:Bo("Exact number of years between two dates."),args:[ad("start_date (date)",Bo("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.")),ad("end_date (date)",Bo("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.")),ad("day_count_convention (number, default=0)",Bo("An indicator of what day count method to use."))],compute:function(e,t,o={value:0}){let s=Math.trunc(Li(e,this.locale)),i=Math.trunc(Li(t,this.locale));const n=Math.trunc(Li(o,this.locale));return Pi((()=>s>=0),Bo("The start_date (%s) must be positive or null.",s.toString())),Pi((()=>i>=0),Bo("The end_date (%s) must be positive or null.",i.toString())),Pi((()=>0<=n&&n<=4),Bo("The day_count_convention (%s) must be between 0 and 4 inclusive.",n.toString())),Zs(s,i,n)}},jp={description:Bo("First day of the month preceding a date."),args:[ad("date (date)",Bo("The date from which to calculate the result."))],compute:function(e){const t=Xi(e,this.locale),o=t.getFullYear(),s=t.getMonth();return{value:Bs(new xs(o,s,1)),format:this.locale.dateFormat}}},Yp={description:Bo("Last day of the month following a date."),args:[ad("date (date)",Bo("The date from which to calculate the result."))],compute:function(e){return _p.compute.bind(this)(e,{value:0})}},Xp={description:Bo("Quarter of the year a specific date falls in"),args:[ad("date (date)",Bo("The date from which to extract the quarter."))],compute:function(e){return Math.ceil((Xi(e,this.locale).getMonth()+1)/3)}},Kp={description:Bo("First day of the quarter of the year a specific date falls in."),args:[ad("date (date)",Bo("The date from which to calculate the start of quarter."))],compute:function(e){const t=Xp.compute.bind(this)(e),o=qp.compute.bind(this)(e);return{value:Bs(new xs(o,3*(t-1),1)),format:this.locale.dateFormat}}},Jp={description:Bo("Last day of the quarter of the year a specific date falls in."),args:[ad("date (date)",Bo("The date from which to calculate the end of quarter."))],compute:function(e){const t=Xp.compute.bind(this)(e),o=qp.compute.bind(this)(e);return{value:Bs(new xs(o,3*t,0)),format:this.locale.dateFormat}}},Qp={description:Bo("First day of the year a specific date falls in."),args:[ad("date (date)",Bo("The date from which to calculate the start of the year."))],compute:function(e){const t=qp.compute.bind(this)(e);return{value:Bs(new xs(t,0,1)),format:this.locale.dateFormat}}},em={description:Bo("Last day of the year a specific date falls in."),args:[ad("date (date)",Bo("The date from which to calculate the end of the year."))],compute:function(e){const t=qp.compute.bind(this)(e);return{value:Bs(new xs(t+1,0,0)),format:this.locale.dateFormat}}};var tm=Object.freeze({__proto__:null,DATE:wp,DATEDIF:xp,DATEVALUE:Ep,DAY:Ip,DAYS:Rp,DAYS360:Tp,EDATE:Ap,EOMONTH:_p,HOUR:Dp,ISOWEEKNUM:Op,MINUTE:Fp,MONTH:Mp,MONTH_END:Yp,MONTH_START:jp,NETWORKDAYS:Pp,NETWORKDAYS_INTL:kp,NOW:Vp,QUARTER:Xp,QUARTER_END:Jp,QUARTER_START:Kp,SECOND:Lp,TIME:Hp,TIMEVALUE:Up,TODAY:Bp,WEEKDAY:zp,WEEKNUM:$p,WORKDAY:Gp,WORKDAY_INTL:Wp,YEAR:qp,YEARFRAC:Zp,YEAR_END:em,YEAR_START:Qp});const om={description:Bo("Compare two numeric values, returning 1 if they're equal."),args:[ad("number1 (number)",Bo("The first number to compare.")),ad("number2 (number, default=0)",Bo("The second number to compare."))],compute:function(e,t={value:0}){return Li(e,this.locale)===Li(t,this.locale)?1:0},isExported:!0};var sm=Object.freeze({__proto__:null,DELTA:om});const im=[ii.number,ii.error,ii.text,ii.boolean];function nm(e){const t="asc"===e?1:-1;return(e,o)=>{if(e.type===ii.empty)return o.type===ii.empty?0:1;if(o.type===ii.empty)return-1;let s=im.indexOf(e.type)-im.indexOf(o.type);return 0===s&&(s=e.type===ii.text||e.type===ii.error?e.value.localeCompare(o.value):e.value-o.value),t*s}}function rm(e,t,o,s,i){let n=s.right>s.left;if(e.model.getters.doesIntersectMerge(t,s)){let o;n=!1;for(let i=s.top;i<=s.bottom;i++){o=[];for(let n=s.left;n<=s.right;n++){let s=e.model.getters.getMerge({sheetId:t,col:n,row:i});s&&!o.includes(s.id.toString())&&o.push(s.id.toString())}if(o.length>=2){n=!0;break}}}if(n)return void am(e,t,o,s,i);const r=e.model.getters.getContiguousZone(t,s);es(r,s)?am(e,t,o,s,i):e.askConfirmation(Bo("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>am(e,t,o,r,i)),(()=>am(e,t,o,s,i)))}function am(e,t,o,s,i,n){const r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:o.col,row:o.row,zone:s,sortDirection:i,sortOptions:n});if(r.isCancelledBecause("InvalidSortZone")){const{col:t,row:i}=o;e.model.selection.selectZone({cell:{col:t,row:i},zone:s}),e.raiseError(Bo("Cannot sort. To sort, select only cells or only merges that have the same size."))}if(r.isCancelledBecause("SortZoneWithArrayFormulas")){const{col:t,row:i}=o;e.model.selection.selectZone({cell:{col:t,row:i},zone:s}),e.raiseError(Bo("Cannot sort a zone with array formulas."))}}function lm(e,t,...o){for(let e=0;e<o.length;e++){Pi((()=>void 0!==o[e]),Bo("Value for parameter %s is missing in [[FUNCTION_NAME]].",e%2==0?"sort_column":"is_ascending"))}const s=[],i=[],n=e.length;for(let r=0;r<o.length;r+=2){s.push(Yi(wl(o[r+1])?.value)?"asc":"desc");const a=o[r];if(yi(a)&&(a.length>1||a[0].length>1))Pi((()=>1===a.length&&a[0].length===n),Bo("Wrong size for %s. Expected a range of size 1x%s. Got %sx%s.",`sort_column${r+1}`,n,a.length,a[0].length)),i.push(a.flat().map((e=>e.value)));else{const o=Li(wl(a)?.value,t);if(o<1||o>e[0].length)return e;i.push(e.map((e=>e[o-1].value)))}}if(0===i.length)for(let t=0;t<e[0].length;t++)i.push(e.map((e=>e[t].value))),s.push("asc");const r={desc:nm("desc"),asc:nm("asc")},a=je(0,e.length);return a.sort(((e,t)=>{for(const[o,n]of i.entries()){const i=n[e],a=n[t],l={value:i,type:null===i?ii.empty:"string"==typeof i?ii.text:typeof i},c={value:a,type:null===a?ii.empty:"string"==typeof a?ii.text:typeof a},h=r[s[o]](l,c);if(0!==h)return h}return 0})),a.map((t=>e[t]))}const cm={description:Bo("Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions."),args:[ad("range (any, range<any>)",Bo("The data to be filtered.")),ad("condition1 (boolean, range<boolean>)",Bo("A column or row containing true or false values corresponding to the first column or row of range.")),ad("condition2 (boolean, range<boolean>, repeating)",Bo("Additional column or row containing true or false values."))],compute:function(e,...t){let o=Sn(e);const s=t.map((e=>an(Sn(e),(e=>e.value))));s.map((e=>cd(Bo("The arguments condition must be a single column or row."),e))),hd(Bo("The arguments conditions must have the same dimensions."),...t);const i=s.map((e=>e.flat())),n=1===s[0].length?"row":"col";o="row"===n?ln(o):o,Pi((()=>i.every((e=>e.length===o.length))),Bo("FILTER has mismatched sizes on the range and conditions."));const r=[];for(let e=0;e<o.length;e++){const t=o[e];i.every((t=>("boolean"==typeof t[e]||"number"==typeof t[e])&&t[e]))&&r.push(t)}return r.length?"row"===n?ln(r):r:new Di(Bo("No match found in FILTER evaluation"))},isExported:!1},hm={description:Bo("Sorts the rows of a given array or range by the values in one or more columns."),args:[ad("range (range)",Bo("The data to be sorted.")),ad("sort_column (any, range<number>, repeating)",Bo("The index of the column in range or a range outside of range containing the values by which to sort.")),ad("is_ascending (boolean, repeating)",Bo("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order."))],compute:function(e,...t){const o=ln(e);return ln(lm(o,this.locale,...t))},isExported:!0},dm={description:Bo("Returns the first n items in a data set after performing a sort."),args:[ad("range (range)",Bo("The data to be sorted.")),ad("n (number, default=1)",Bo("The number of items to return.")),ad("display_ties_mode (number, default=0)",Bo("A number representing the way to display ties.")),ad("sort_column (number, range<number>, repeating)",Bo("The index of the column in range or a range outside of range containing the values by which to sort.")),ad("is_ascending (boolean, repeating)",Bo("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order."))],compute:function(e,t,o,...s){const i=Li(t?.value??1,this.locale);Pi((()=>i>=0),Bo("Wrong value of 'n'. Expected a positive number. Got %s.",i));const n=Li(o?.value??0,this.locale);Pi((()=>n>=0&&n<=3),Bo("Wrong value of 'display_ties_mode'. Expected a positive number between 0 and 3. Got %s.",n));const r=lm(ln(e),this.locale,...s),a=(e,t)=>JSON.stringify(r[e].map((e=>e.value)))===JSON.stringify(r[t].map((e=>e.value)));switch(n){case 0:return ln(r.slice(0,i));case 1:for(let e=i;e<r.length;e++)if(!a(e,i-1))return ln(r.slice(0,e));return ln(r);case 2:{const e=[r[0]];for(let t=1;t<r.length;t++)for(let o=0;o<t&&!a(t,o);o++)o===t-1&&e.push(r[t]);return ln(e.slice(0,i))}case 3:{const e=[r[0]];let t=1;for(let o=1;o<r.length&&(a(o,o-1)||t++,!(t>i));o++)e.push(r[o]);return ln(e)}}},isExported:!1},um={description:Bo("Unique rows in the provided source range."),args:[ad("range (any, range<any>)",Bo("The data to filter by unique entries.")),ad("by_column (boolean, default=FALSE)",Bo("Whether to filter the data by columns or by rows.")),ad("exactly_once (boolean, default=FALSE)",Bo("Whether to return only entries with no duplicates."))],compute:function(e={value:""},t,o){if(!yi(e))return[[e]];const s=Yi(t?.value)||!1,i=Yi(o?.value)||!1;s||(e=ln(e));const n=new Map;for(const t of e){const e=JSON.stringify(t.map((e=>e.value))),o=n.get(e);o?o.count++:n.set(e,{data:t,count:1})}const r=[];for(const e of n.values())i&&e.count>1||r.push(e.data);return r.length?s?r:ln(r):new Ri(Bo("No unique values found"))},isExported:!0};var gm=Object.freeze({__proto__:null,FILTER:cm,SORT:hm,SORTN:dm,UNIQUE:um});function pm(e,t){Pi((()=>e<t),Bo("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function mm(e,t){Pi((()=>t<e),Bo("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function fm(e){Pi((()=>[1,2,4].includes(e)),Bo("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function vm(e){Pi((()=>0<=e&&e<=4),Bo("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function bm(e){Pi((()=>e>0),Bo("The redemption (%s) must be strictly positive.",e.toString()))}function Sm(e){Pi((()=>e>0),Bo("The price (%s) must be strictly positive.",e.toString()))}function ym(e){Pi((()=>e>0),Bo("The number_of_periods (%s) must be greater than 0.",e.toString()))}function Cm(e){Pi((()=>e>0),Bo("The rate (%s) must be strictly positive.",e.toString()))}function wm(e){Pi((()=>e>0),Bo("The life (%s) must be strictly positive.",e.toString()))}function xm(e){Pi((()=>e>=0),Bo("The cost (%s) must be positive or null.",e.toString()))}function Em(e){Pi((()=>e>0),Bo("The period (%s) must be strictly positive.",e.toString()))}function Im(e){Pi((()=>e>=0),Bo("The salvage (%s) must be positive or null.",e.toString()))}function Rm(e){Pi((()=>e>0),Bo("The present value (%s) must be strictly positive.",e.toString()))}function Tm(e,t){Pi((()=>e<=t),Bo("The period (%s) must be less than or equal life (%s).",e.toString(),t.toString()))}function Am(e){Pi((()=>e>0),Bo("The investment (%s) must be strictly positive.",e.toString()))}function _m(e){Pi((()=>e>0),Bo("The discount (%s) must be strictly positive.",e.toString()))}function Dm(e){Pi((()=>e<1),Bo("The discount (%s) must be smaller than 1.",e.toString()))}function Om(e){Pi((()=>e>0),Bo("The depreciation factor (%s) must be strictly positive.",e.toString()))}function Fm(e,t,o){const s=Xi(e,o),i=Xi(t,o),n=Xi(e,o);n.setFullYear(s.getFullYear()+1),Pi((()=>i.getTime()<=n.getTime()),Bo("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function Mm(e,t,o){ym(o),Pi((()=>e>0),Bo("The first_period (%s) must be strictly positive.",e.toString())),Pi((()=>t>0),Bo("The last_period (%s) must be strictly positive.",t.toString())),Pi((()=>e<=t),Bo("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),Pi((()=>t<=o),Bo("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),o.toString()))}function Pm(e){Pi((()=>e>-1),Bo("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function Nm(e,t){Pi((()=>e.length===t.length&&e[0].length===t[0].length),Bo("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function km(e){Pi((()=>e.every((t=>t>=e[0]))),Bo("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const Vm=[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("frequency (number)",Bo("The number of interest or coupon payments per year (1, 2, or 4).")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))];function Lm(e,t,o,s,i=1e-10,n){let r,a,l,c,h=o,d=!1,u=0;do{l=e(h),isNaN(l)?(Pi((()=>u<s&&void 0!==n),Bo("Function [[FUNCTION_NAME]] didn't find any result.")),u++,h=n(c),c=h):(r=h-l/t(h),a=Math.abs(r-h),h=r,d=a<i||Math.abs(l)<i,Pi((()=>u<s),Bo("Function [[FUNCTION_NAME]] didn't find any result.")),u++)}while(!d);return h}const Hm={description:Bo("Accrued interest of security paying at maturity."),args:[ad("issue (date)",Bo("The date the security was initially issued.")),ad("maturity (date)",Bo("The maturity date of the security.")),ad("rate (number)",Bo("The annualized rate of interest.")),ad("redemption (number)",Bo("The redemption amount per 100 face value, or par.")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){const n=Math.trunc(Li(e,this.locale)),r=Math.trunc(Li(t,this.locale)),a=Li(s,this.locale),l=Li(o,this.locale),c=Math.trunc(Li(i,this.locale));!function(e){Pi((()=>e>=0),Bo("The issue (%s) must be positive or null.",e.toString()))}(n),mm(r,n),vm(c),bm(a),Cm(l);return a*l*Zs(n,r,c)},isExported:!0},Um={description:Bo("Depreciation for an accounting period."),args:[ad("cost (number)",Bo("The initial cost of the asset.")),ad("purchase_date (date)",Bo("The date the asset was purchased.")),ad("first_period_end (date)",Bo("The date the first period ended.")),ad("salvage (number)",Bo("The value of the asset at the end of depreciation.")),ad("period (number)",Bo("The single period within life for which to calculate depreciation.")),ad("rate (number)",Bo("The deprecation rate.")),ad("day_count_convention (number, optional)",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=Li(e,this.locale),l=Math.trunc(Li(t,this.locale)),c=Math.trunc(Li(o,this.locale)),h=Li(s,this.locale),d=Li(i,this.locale),u=Li(n,this.locale),g=Math.trunc(Li(r,this.locale));!function(e){Pi((()=>e>0),Bo("The cost (%s) must be strictly positive.",e.toString()))}(a),function(e){Pi((()=>e>=0),Bo("The purchase_date (%s) must be positive or null.",e.toString()))}(l),Im(h),function(e,t){Pi((()=>e<=t),Bo("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(h,a),function(e){Pi((()=>e>=0),Bo("The period (%s) must be positive or null.",e.toString()))}(d),Cm(u),vm(g),Pi((()=>l<=c),Bo("The purchase_date (%s) must be before the first_period_end (%s).",l.toString(),c.toString()));const p=d<1&&d>0?1:Math.trunc(d),m=a*u,f=Zs(l,c,g),v=l===c?m:m*f,b=a-v-m*p;return b>=h?0===p?v:m:h-b<m?m-(h-b):0},isExported:!0},Bm={description:Bo("Days in coupon period containing settlement date."),args:Vm,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Li(e,this.locale)),n=Math.trunc(Li(t,this.locale)),r=Math.trunc(Li(o,this.locale)),a=Math.trunc(Li(s,this.locale));if(pm(i,n),fm(r),vm(a),1===a){const i=qm.compute.bind(this)(e,t,o,s).value;return Gm.compute.bind(this)(e,t,o,s).value-i}return(3===a?365:360)/r},isExported:!0},zm={description:Bo("Days from settlement until next coupon."),args:Vm,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Li(e,this.locale)),n=Math.trunc(Li(t,this.locale)),r=Math.trunc(Li(o,this.locale)),a=Math.trunc(Li(s,this.locale));pm(i,n),fm(r),vm(a);const l=qm.compute.bind(this)(e,t,o,s).value;if([1,2,3].includes(a))return i-l;if(4===a){const e=Zs(l,i,a);return Math.round(360*e)}const c=Xi(i,this.locale),h=Xi(l,this.locale),d=h.getFullYear(),u=c.getFullYear(),g=h.getMonth()+1,p=c.getMonth()+1;let m=h.getDate(),f=c.getDate();return 2===g&&2===p&&Gs(h)&&Gs(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&Gs(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},$m={description:Bo("Days from settlement until next coupon."),args:Vm,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Li(e,this.locale)),n=Math.trunc(Li(t,this.locale)),r=Math.trunc(Li(o,this.locale)),a=Math.trunc(Li(s,this.locale));pm(i,n),fm(r),vm(a);const l=Gm.compute.bind(this)(e,t,o,s).value;if([1,2,3].includes(a))return l-i;if(4===a){const e=Zs(i,l,a);return Math.round(360*e)}const c=zm.compute.bind(this)(e,t,o,s);return Bm.compute.bind(this)(e,t,o,s)-c},isExported:!0},Gm={description:Bo("Next coupon date after the settlement date."),args:Vm,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Li(e,this.locale)),n=Math.trunc(Li(t,this.locale)),r=Math.trunc(Li(o,this.locale)),a=Math.trunc(Li(s,this.locale));pm(i,n),fm(r),vm(a);const l=12/r,c=Wm.compute.bind(this)(e,t,o,s);return{value:Bs(Ws(Xi(n,this.locale),-(c-1)*l,!0)),format:this.locale.dateFormat}},isExported:!0},Wm={description:Bo("Number of coupons between settlement and maturity."),args:Vm,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Li(e,this.locale)),n=Math.trunc(Li(t,this.locale)),r=Math.trunc(Li(o,this.locale)),a=Math.trunc(Li(s,this.locale));pm(i,n),fm(r),vm(a);let l=1,c=n;const h=12/r;for(;c>i;)c=Bs(Ws(Xi(c,this.locale),-h,!1)),l++;return l-1},isExported:!0},qm={description:Bo("Last coupon date prior to or on the settlement date."),args:Vm,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Li(e,this.locale)),n=Math.trunc(Li(t,this.locale)),r=Math.trunc(Li(o,this.locale)),a=Math.trunc(Li(s,this.locale));pm(i,n),fm(r),vm(a);const l=12/r,c=Wm.compute.bind(this)(e,t,o,s);return{value:Bs(Ws(Xi(n,this.locale),-c*l,!0)),format:this.locale.dateFormat}},isExported:!0},Zm={description:Bo("Cumulative interest paid over a set of periods."),args:[ad("rate (number)",Bo("The interest rate.")),ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("present_value (number)",Bo("The current value of the annuity.")),ad("first_period (number)",Bo("The number of the payment period to begin the cumulative calculation.")),ad("last_period (number)",Bo("The number of the payment period to end the cumulative calculation.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s,i,n={value:0}){const r=Li(s,this.locale),a=Li(i,this.locale),l=Li(e,this.locale),c=Li(o,this.locale),h=Li(t,this.locale),d=Yi(n)?1:0;Mm(r,a,h),Cm(l),Rm(c);let u=0;for(let e=r;e<=a;e++)u+=lf(l,e,h,c,0,d);return u},isExported:!0},jm={description:Bo("Cumulative principal paid over a set of periods."),args:[ad("rate (number)",Bo("The interest rate.")),ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("present_value (number)",Bo("The current value of the annuity.")),ad("first_period (number)",Bo("The number of the payment period to begin the cumulative calculation.")),ad("last_period (number)",Bo("The number of the payment period to end the cumulative calculation.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s,i,n={value:0}){const r=Li(s,this.locale),a=Li(i,this.locale),l=Li(e,this.locale),c=Li(o,this.locale),h=Li(t,this.locale),d=Yi(n)?1:0;Mm(r,a,h),Cm(l),Rm(c);let u=0;for(let e=r;e<=a;e++)u+=Cf(l,e,h,c,0,d);return u},isExported:!0},Ym={description:Bo("Depreciation via declining balance method."),args:[ad("cost (number)",Bo("The initial cost of the asset.")),ad("salvage (number)",Bo("The value of the asset at the end of depreciation.")),ad("life (number)",Bo("The number of periods over which the asset is depreciated.")),ad("period (number)",Bo("The single period within life for which to calculate depreciation.")),ad("month (number, optional)",Bo("The number of months in the first year of depreciation."))],compute:function(e,t,o,s,...i){const n=Li(e,this.locale),r=Li(t,this.locale),a=Li(o,this.locale),l=Math.trunc(Li(s,this.locale)),c=i.length?Math.trunc(Li(i[0],this.locale)):12,h=a+(12===c?0:1);xm(n),Im(r),Em(l),wm(a),Pi((()=>1<=c&&c<=12),Bo("The month (%s) must be between 1 and 12 inclusive.",c.toString())),Pi((()=>l<=h),Bo("The period (%s) must be less than or equal to %s.",l.toString(),h.toString()));const d=c/12;let u=1-Math.pow(r/n,1/a);u=Math.round(1e3*u)/1e3;let g=n,p=n*(1-u*d);for(let e=1;e<l;e++)g=p,p=g*(1-u),e===a&&(p=g*(1-u*(1-d)));return{value:g-p,format:"#,##0.00"}},isExported:!0};function Xm(e,t,o,s,i){if(xm(e),Im(t),Em(s),wm(o),Tm(s,o),Om(i),0===e||t>=e)return 0;const n=i/o;if(n>1)return 1===s?e-t:0;if(s<=1)return e*n;const r=e*Math.pow(1-n,s-1),a=e*Math.pow(1-n,s),l=a<t?r-t:r-a;return Math.max(l,0)}const Km={description:Bo("Depreciation via double-declining balance method."),args:[ad("cost (number)",Bo("The initial cost of the asset.")),ad("salvage (number)",Bo("The value of the asset at the end of depreciation.")),ad("life (number)",Bo("The number of periods over which the asset is depreciated.")),ad("period (number)",Bo("The single period within life for which to calculate depreciation.")),ad("factor (number, default=2)",Bo("The factor by which depreciation decreases."))],compute:function(e,t,o,s,i={value:2}){return{value:Xm(Li(e,this.locale),Li(t,this.locale),Li(o,this.locale),Li(s,this.locale),Li(i,this.locale)),format:"#,##0.00"}},isExported:!0},Jm={description:Bo("Discount rate of a security based on price."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("price (number)",Bo("The price at which the security is bought per 100 face value.")),ad("redemption (number)",Bo("The redemption amount per 100 face value, or par.")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(Li(e,this.locale)),r=Math.trunc(Li(t,this.locale)),a=Li(o,this.locale),l=Li(s,this.locale),c=Math.trunc(Li(i,this.locale));pm(n,r),vm(c),Sm(a),bm(l);return(l-a)/l/Zs(n,r,c)},isExported:!0},Qm={description:Bo("Convert a decimal fraction to decimal value."),args:[ad("fractional_price (number)",Bo("The price quotation given using fractional decimal conventions.")),ad("unit (number)",Bo("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],compute:function(e,t){const o=Li(e,this.locale),s=Math.trunc(Li(t,this.locale));Pi((()=>s>0),Bo("The unit (%s) must be strictly positive.",s.toString()));const i=Math.trunc(o);return i+(o-i)*(10**Math.ceil(Math.log10(s))/s)},isExported:!0},ef={description:Bo("Convert a decimal value to decimal fraction."),args:[ad("decimal_price (number)",Bo("The price quotation given as a decimal value.")),ad("unit (number)",Bo("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],compute:function(e,t){const o=Li(e,this.locale),s=Math.trunc(Li(t,this.locale));Pi((()=>s>0),Bo("The unit (%s) must be strictly positive.",s.toString()));const i=Math.trunc(o);return i+(o-i)*(s/10**Math.ceil(Math.log10(s)))},isExported:!0},tf={description:Bo("Number of periods for an investment to reach a value."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("rate (number)",Bo("The annualized rate of interest.")),ad("yield (number)",Bo("The expected annual yield of the security.")),ad("frequency (number)",Bo("The number of interest or coupon payments per year (1, 2, or 4).")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n={value:0}){const r=Math.trunc(Li(e,this.locale)),a=Math.trunc(Li(t,this.locale)),l=Li(o,this.locale),c=Li(s,this.locale),h=Math.trunc(Li(i,this.locale)),d=Math.trunc(Li(n,this.locale));pm(r,a),fm(h),vm(d),Pi((()=>l>=0),Bo("The rate (%s) must be positive or null.",l.toString())),Pi((()=>c>=0),Bo("The yield (%s) must be positive or null.",c.toString()));const u=Zs(r,a,d),g=u-Math.trunc(u)||1/h,p=Math.ceil(u*h),m=l/h,f=c/h;let v=0,b=0;for(let e=1;e<=p;e++){const t=(m+(e===p?1:0))/(1+f)**e;b+=(g+(e-1)/h)*t,v+=t}return 0===v?0:b/v},isExported:!0},of={description:Bo("Annual effective interest rate."),args:[ad("nominal_rate (number)",Bo("The nominal interest rate per year.")),ad("periods_per_year (number)",Bo("The number of compounding periods per year."))],compute:function(e,t){const o=Li(e,this.locale),s=Math.trunc(Li(t,this.locale));return Pi((()=>o>0),Bo("The nominal rate (%s) must be strictly greater than 0.",o.toString())),Pi((()=>s>0),Bo("The number of periods by year (%s) must strictly greater than 0.",s.toString())),Math.pow(1+o/s,s)-1},isExported:!0};function sf(e,t,o,s,i){return 0===e?-(s+o*t):-s*(1+e)**t-o*(1+e*i)*((1+e)**t-1)/e}const nf={description:Bo("Future value of an annuity investment."),args:[ad("rate (number)",Bo("The interest rate.")),ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("payment_amount (number)",Bo("The amount per period to be paid.")),ad("present_value (number, default=0)",Bo("The current value of the annuity.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;return{value:sf(Li(e,this.locale),Li(t,this.locale),Li(o,this.locale),Li(s,this.locale),Yi(i)?1:0),format:"#,##0.00"}},isExported:!0},rf={description:Bo("Future value of principal from series of rates."),args:[ad("principal (number)",Bo("The amount of initial capital or value to compound against.")),ad("rate_schedule (number, range<number>)",Bo("A series of interest rates to compound against the principal."))],compute:function(e,t){return on([t],((e,t)=>e*(1+Li(t,this.locale))),Li(e,this.locale))},isExported:!0},af={description:Bo("Calculates effective interest rate."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("investment (number)",Bo("The amount invested in the security.")),ad("redemption (number)",Bo("The amount to be received at maturity.")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){const n=Math.trunc(Li(e,this.locale)),r=Math.trunc(Li(t,this.locale)),a=Li(s,this.locale),l=Li(o,this.locale),c=Math.trunc(Li(i,this.locale));pm(n,r),Am(l),bm(a),vm(c);return(a-l)/l/Zs(n,r,c)},isExported:!0};function lf(e,t,o,s,i,n){return Sf(e,o,s,i,n)-Cf(e,t,o,s,i,n)}const cf={description:Bo("Payment on the principal of an investment."),args:[ad("rate (number)",Bo("The annualized rate of interest.")),ad("period (number)",Bo("The amortization period, in terms of number of periods.")),ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("present_value (number)",Bo("The current value of the annuity.")),ad("future_value (number, default=0)",Bo("The future value remaining after the final payment has been made.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s,i={value:0},n={value:0}){return{value:lf(Li(e,this.locale),Li(t,this.locale),Li(o,this.locale),Li(s,this.locale),Li(i,this.locale),Yi(n)?1:0),format:"#,##0.00"}},isExported:!0},hf={description:Bo("Internal rate of return given periodic cashflows."),args:[ad("cashflow_amounts (number, range<number>)",Bo("An array or range containing the income or payments associated with the investment.")),ad("rate_guess (number, default=0.1)",Bo("An estimate for what the internal rate of return will be."))],compute:function(e,t={value:.1}){const o=Li(t,this.locale);Pm(o);let s=!1,i=!1,n=[];en([e],(({value:e})=>{e>0&&(s=!0),e<0&&(i=!0),n.push(e)}),this.locale),Pi((()=>s&&i),Bo("The cashflow_amounts must include negative and positive values."));const r=n.shift();return{value:Lm((function(e){return function(e,t,o){const s=o.length;let i=0;return o.reduce(((t,o)=>(i++,t+o*e**(s-i))),t*e**s)}(e,r,n)}),(function(e){return function(e,t,o){const s=o.length;let i=0;return o.reduce(((t,o)=>(i++,t+o*(s-i)*e**(s-i-1))),t*s*e**(s-1))}(e,r,n)}),o+1,20,1e-5)-1,format:"0%"}},isExported:!0},df={description:Bo("Returns the interest paid at a particular period of an investment."),args:[ad("rate (number)",Bo("The interest rate.")),ad("period (number)",Bo("The period for which you want to view the interest payment.")),ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("present_value (number)",Bo("The current value of the annuity."))],compute:function(e,t,o,s){const i=Li(e,this.locale),n=Li(t,this.locale),r=Li(o,this.locale),a=Li(s,this.locale);Pi((()=>0!==r),Bo("The number of periods must be different than 0.",r.toString()));return-1*(a-a*(n/r))*i},isExported:!0},uf={description:Bo("Modified Macaulay duration."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("rate (number)",Bo("The annualized rate of interest.")),ad("yield (number)",Bo("The expected annual yield of the security.")),ad("frequency (number)",Bo("The number of interest or coupon payments per year (1, 2, or 4).")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n={value:0}){return tf.compute.bind(this)(e,t,o,s,i,n)/(1+Li(s,this.locale)/Math.trunc(Li(i,this.locale)))},isExported:!0},gf={description:Bo("Modified internal rate of return."),args:[ad("cashflow_amounts (range<number>)",Bo("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")),ad("financing_rate (number)",Bo("The interest rate paid on funds invested.")),ad("reinvestment_return_rate (number)",Bo("The return (as a percentage) earned on reinvestment of income received from the investment."))],compute:function(e,t,o){const s=Li(t,this.locale),i=Li(o,this.locale),n=ln(e).flat().filter((e=>null!==e.value)).map((e=>Li(e,this.locale))),r=n.length;let a=0,l=0;for(const e of je(0,r)){const t=n[e];t>=0?a+=t*(i+1)**(r-e-1):l+=t/(s+1)**e}Pi((()=>0!==l&&0!==a),Bo("There must be both positive and negative values in cashflow_amounts."));return(-a/l)**(1/(r-1))-1},isExported:!0},pf={description:Bo("Annual nominal interest rate."),args:[ad("effective_rate (number)",Bo("The effective interest rate per year.")),ad("periods_per_year (number)",Bo("The number of compounding periods per year."))],compute:function(e,t){const o=Li(e,this.locale),s=Math.trunc(Li(t,this.locale));return Pi((()=>o>0),Bo("The effective rate (%s) must must strictly greater than 0.",o.toString())),Pi((()=>s>0),Bo("The number of periods by year (%s) must strictly greater than 0.",s.toString())),(Math.pow(o+1,1/s)-1)*s},isExported:!0},mf={description:Bo("Number of payment periods for an investment."),args:[ad("rate (number)",Bo("The interest rate.")),ad("payment_amount (number)",Bo("The amount of each payment made.")),ad("present_value (number)",Bo("The current value of the annuity.")),ad("future_value (number, default=0)",Bo("The future value remaining after the final payment has been made.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;const n=Li(e,this.locale),r=Li(t,this.locale),a=Li(o,this.locale),l=Li(s,this.locale),c=Yi(i)?1:0;if(0===n)return-(l+a)/r;const h=r*(1+n*c)/n;return Math.log((h-l)/(a+h))/Math.log(1+n)},isExported:!0};function ff(e,t,o,s){let i=0;return sn(o,((t,o)=>(i++,t+o/(1+e)**i)),t,s)}const vf={description:Bo("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:[ad("discount (number)",Bo("The discount rate of the investment over one period.")),ad("cashflow1 (number, range<number>)",Bo("The first future cash flow.")),ad("cashflow2 (number, range<number>, repeating)",Bo("Additional future cash flows."))],compute:function(e,...t){const o=Li(e,this.locale);return Pi((()=>-1!==o),Bo("The discount (%s) must be different from -1.",o.toString())),{value:ff(o,0,t,this.locale),format:"#,##0.00"}},isExported:!0},bf={description:Bo("Computes the number of periods needed for an investment to reach a value."),args:[ad("rate (number)",Bo("The rate at which the investment grows each period.")),ad("present_value (number)",Bo("The investment's current value.")),ad("future_value (number)",Bo("The investment's desired future value."))],compute:function(e,t,o){const s=Li(e,this.locale),i=Li(t,this.locale),n=Li(o,this.locale);return Cm(s),Pi((()=>i>0),Bo("The present_value (%s) must be strictly positive.",i.toString())),Pi((()=>n>0),Bo("The future_value (%s) must be strictly positive.",n.toString())),(Math.log(n)-Math.log(i))/Math.log(1+s)},isExported:!0};function Sf(e,t,o,s,i){if(ym(t),0===e)return-(s+o)/t;let n=-(o*(1+e)**t+s);return n=n*e/((1+e*i)*((1+e)**t-1)),n}const yf={description:Bo("Periodic payment for an annuity investment."),args:[ad("rate (number)",Bo("The annualized rate of interest.")),ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("present_value (number)",Bo("The current value of the annuity.")),ad("future_value (number, default=0)",Bo("The future value remaining after the final payment has been made.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s={value:0},i={value:0}){const n=Li(t,this.locale),r=Li(e,this.locale),a=Yi(i)?1:0,l=Li(s,this.locale);return{value:Sf(r,n,Li(o,this.locale),l,a),format:"#,##0.00"}},isExported:!0};function Cf(e,t,o,s,i,n){ym(o),Pi((()=>t>0&&t<=o),Bo("The period must be between 1 and number_of_periods (%s)",o));const r=Sf(e,o,s,i,n);if(1===n&&1===t)return r;return r+-sf(e,0===n?t-1:t-2,r,s+r*n,0)*e}const wf={description:Bo("Payment on the principal of an investment."),args:[ad("rate (number)",Bo("The annualized rate of interest.")),ad("period (number)",Bo("The amortization period, in terms of number of periods.")),ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("present_value (number)",Bo("The current value of the annuity.")),ad("future_value (number, default=0)",Bo("The future value remaining after the final payment has been made.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s,i={value:0},n={value:0}){const r=Li(o,this.locale),a=Li(e,this.locale),l=Li(t,this.locale),c=Yi(n)?1:0,h=Li(i,this.locale);return{value:Cf(a,l,r,Li(s,this.locale),h,c),format:"#,##0.00"}},isExported:!0},xf={description:Bo("Present value of an annuity investment."),args:[ad("rate (number)",Bo("The interest rate.")),ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("payment_amount (number)",Bo("The amount per period to be paid.")),ad("future_value (number, default=0)",Bo("The future value remaining after the final payment has been made.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;const n=Li(e,this.locale),r=Li(t,this.locale),a=Li(o,this.locale),l=Li(s,this.locale),c=Yi(i)?1:0;return{value:n?-(a*(1+n*c)*((1+n)**r-1)/n+l)/(1+n)**r:-(l+a*r),format:"#,##0.00"}},isExported:!0},Ef={description:Bo("Price of a security paying periodic interest."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("rate (number)",Bo("The annualized rate of interest.")),ad("yield (number)",Bo("The expected annual yield of the security.")),ad("redemption (number)",Bo("The redemption amount per 100 face value, or par.")),ad("frequency (number)",Bo("The number of interest or coupon payments per year (1, 2, or 4).")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=Math.trunc(Li(e,this.locale)),l=Math.trunc(Li(t,this.locale)),c=Li(o,this.locale),h=Li(s,this.locale),d=Li(i,this.locale),u=Math.trunc(Li(n,this.locale)),g=Math.trunc(Li(r,this.locale));pm(a,l),fm(u),vm(g),Pi((()=>c>=0),Bo("The rate (%s) must be positive or null.",c.toString())),Pi((()=>h>=0),Bo("The yield (%s) must be positive or null.",h.toString())),bm(d);const p=Zs(a,l,g)*u,m=Math.ceil(p),f=p-Math.floor(p)||1,v=1+h/u,b=100*c/u;if(1===m)return(b+d)/(f*h/u+1)-b*(1-f);let S=0;for(let e=1;e<=m;e++)S+=b/v**(e-1+f);return d/v**(m-1+f)+S-b*(1-f)},isExported:!0},If={description:Bo("Price of a discount security."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("discount (number)",Bo("The discount rate of the security at time of purchase.")),ad("redemption (number)",Bo("The redemption amount per 100 face value, or par.")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(Li(e,this.locale)),r=Math.trunc(Li(t,this.locale)),a=Li(o,this.locale),l=Li(s,this.locale),c=Math.trunc(Li(i,this.locale));pm(n,r),vm(c),_m(a),bm(l);return l-a*l*Zs(n,r,c)},isExported:!0},Rf={description:Bo("Calculates the price of a security paying interest at maturity, based on expected yield."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("issue (date)",Bo("The date the security was initially issued.")),ad("rate (number)",Bo("The annualized rate of interest.")),ad("yield (number)",Bo("The expected annual yield of the security.")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n={value:0}){n=n||0;const r=Math.trunc(Li(e,this.locale)),a=Math.trunc(Li(t,this.locale)),l=Math.trunc(Li(o,this.locale)),c=Li(s,this.locale),h=Li(i,this.locale),d=Math.trunc(Li(n,this.locale));mm(r,l),pm(r,a),vm(d),Pi((()=>c>=0),Bo("The rate (%s) must be positive or null.",c.toString())),Pi((()=>h>=0),Bo("The yield (%s) must be positive or null.",h.toString()));const u=Zs(r,a,d),g=Zs(r,l,d);return(100+Zs(l,a,d)*c*100)/(1+u*h)-g*c*100},isExported:!0},Tf=.1,Af={description:Bo("Interest rate of an annuity investment."),args:[ad("number_of_periods (number)",Bo("The number of payments to be made.")),ad("payment_per_period (number)",Bo("The amount per period to be paid.")),ad("present_value (number)",Bo("The current value of the annuity.")),ad("future_value (number, default=0)",Bo("The future value remaining after the final payment has been made.")),ad("end_or_beginning (number, default=0)",Bo("Whether payments are due at the end (0) or beginning (1) of each period.")),ad("rate_guess (number, default=0.1)",Bo("An estimate for what the interest rate will be."))],compute:function(e,t,o,s={value:0},i={value:0},n={value:Tf}){const r=Li(e,this.locale),a=Li(t,this.locale),l=Yi(i)?1:0,c=Li(n,this.locale)||Tf;let h=Li(s,this.locale),d=Li(o,this.locale);ym(r),Pi((()=>[a,d,h].some((e=>e>0))&&[a,d,h].some((e=>e<0))),Bo("There must be both positive and negative values in [payment_amount, present_value, future_value].",r.toString())),Pm(c),h-=a*l,d+=a*l;return{value:Lm((e=>{const t=Math.pow(1+e,r);return h+d*t+a*((t-1)/e)}),(e=>{const t=Math.pow(1+e,r-1),o=Math.pow(1+e,r);return d*r*t+a*(r*t/e-(o-1)/e/e)}),c,40,1e-5),format:"0%"}},isExported:!0},_f={description:Bo("Amount received at maturity for a security."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("investment (number)",Bo("The amount invested (irrespective of face value of each security).")),ad("discount (number)",Bo("The discount rate of the security invested in.")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(Li(e,this.locale)),r=Math.trunc(Li(t,this.locale)),a=Li(o,this.locale),l=Li(s,this.locale),c=Math.trunc(Li(i,this.locale));pm(n,r),vm(c),Am(a),_m(l);return a/(1-l*Zs(n,r,c))},isExported:!0},Df={description:Bo("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:[ad("number_of_periods (number)",Bo("The number of periods.")),ad("present_value (number)",Bo("The present value of the investment.")),ad("future_value (number)",Bo("The future value of the investment."))],compute:function(e,t,o){const s=Li(e,this.locale),i=Li(t,this.locale),n=Li(o,this.locale);return ym(s),(n/i)**(1/s)-1},isExported:!0},Of={description:Bo("Depreciation of an asset using the straight-line method."),args:[ad("cost (number)",Bo("The initial cost of the asset.")),ad("salvage (number)",Bo("The value of the asset at the end of depreciation.")),ad("life (number)",Bo("The number of periods over which the asset is depreciated."))],compute:function(e,t,o){return{value:(Li(e,this.locale)-Li(t,this.locale))/Li(o,this.locale),format:"#,##0.00"}},isExported:!0},Ff={description:Bo("Depreciation via sum of years digit method."),args:[ad("cost (number)",Bo("The initial cost of the asset.")),ad("salvage (number)",Bo("The value of the asset at the end of depreciation.")),ad("life (number)",Bo("The number of periods over which the asset is depreciated.")),ad("period (number)",Bo("The single period within life for which to calculate depreciation."))],compute:function(e,t,o,s){const i=Li(e,this.locale),n=Li(t,this.locale),r=Li(o,this.locale),a=Li(s,this.locale);Em(a),wm(r),Tm(a,r);return{value:(r-a+1)/(r*(r+1)/2)*(i-n),format:"#,##0.00"}},isExported:!0};function Mf(e,t,o){return 100*(1-o*Zs(e,t,2))}const Pf={description:Bo("Price of a US Treasury bill."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("discount (number)",Bo("The discount rate of the bill at time of purchase."))],compute:function(e,t,o){const s=Math.trunc(Li(e,this.locale)),i=Math.trunc(Li(t,this.locale)),n=Li(o,this.locale);return pm(s,i),Fm(s,i,this.locale),_m(n),Dm(n),Mf(s,i,n)},isExported:!0},Nf={description:Bo("Equivalent rate of return for a US Treasury bill."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("discount (number)",Bo("The discount rate of the bill at time of purchase."))],compute:function(e,t,o){const s=Math.trunc(Li(e,this.locale)),i=Math.trunc(Li(t,this.locale)),n=Li(o,this.locale);pm(s,i),Fm(s,i,this.locale),_m(n),Dm(n);const r=Rp.compute.bind(this)({value:i},{value:s});if(r<=182)return 365*n/(360-n*r);const a=Mf(s,i,n)/100,l=r/(366===r?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},kf={description:Bo("The yield of a US Treasury bill based on price."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("price (number)",Bo("The price at which the security is bought per 100 face value."))],compute:function(e,t,o){const s=Math.trunc(Li(e,this.locale)),i=Math.trunc(Li(t,this.locale)),n=Li(o,this.locale);pm(s,i),Fm(s,i,this.locale),Sm(n);return(100-n)/n*(1/Zs(s,i,2))},isExported:!0},Vf={description:Bo("Variable declining balance. WARNING : does not handle decimal periods."),args:[ad("cost (number)",Bo("The initial cost of the asset.")),ad("salvage (number)",Bo("The value of the asset at the end of depreciation.")),ad("life (number)",Bo("The number of periods over which the asset is depreciated.")),ad("start (number)",Bo("Starting period to calculate depreciation.")),ad("end (number)",Bo("Ending period to calculate depreciation.")),ad("factor (number, default=2)",Bo("The number of months in the first year of depreciation.")),ad("no_switch (number, default=false)",Bo("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation."))],compute:function(e,t,o,s,i,n={value:2},r={value:false}){n=n||0;const a=Li(e,this.locale),l=Li(t,this.locale),c=Li(o,this.locale),h=Math.trunc(Li(s,this.locale)),d=Math.trunc(Li(i,this.locale)),u=Li(n,this.locale),g=Yi(r);if(xm(a),Im(l),function(e,t,o){wm(o),Pi((()=>e>=0),Bo("The start_period (%s) must be greater or equal than 0.",e.toString())),Pi((()=>t>=0),Bo("The end_period (%s) must be greater or equal than 0.",t.toString())),Pi((()=>e<=t),Bo("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),Pi((()=>t<=o),Bo("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),o.toString()))}(h,d,c),Om(u),0===a)return 0;if(l>=a)return h<1?a-l:0;const p=u/c;if(p>=1)return h<1?a-l:0;let m=a,f=0,v=0,b=!1;for(let e=0;e<d;e++){if(!b||g){const t=m*p,o=(m-l)/(c-e);!g&&o>t?(b=!0,f=o):f=t}const t=Math.max(m-f,l);e>=h&&(v+=m-t),m=t}return v},isExported:!0},Lf={description:Bo("Internal rate of return given non-periodic cash flows."),args:[ad("cashflow_amounts (range<number>)",Bo("An range containing the income or payments associated with the investment.")),ad("cashflow_dates (range<number>)",Bo("An range with dates corresponding to the cash flows in cashflow_amounts.")),ad("rate_guess (number, default=0.1)",Bo("An estimate for what the internal rate of return will be."))],compute:function(e,t,o={value:Tf}){const s=Li(o,this.locale),i=e.flat().map((e=>Li(e,this.locale))),n=t.flat().map((e=>Li(e,this.locale)));var r;Nm(e,t),r=i,Pi((()=>r.some((e=>e>0))&&r.some((e=>e<0))),Bo("There must be both positive and negative values in cashflow_amounts.")),km(n),Pm(s);const a=new Map;for(const e of je(0,n.length)){const t=n[e];a.has(t)?a.set(t,a.get(t)+i[e]):a.set(t,i[e])}const l=Array.from(a.keys()),c=l.map((e=>a.get(e)));return Lm((e=>{let t=c[0];for(const o of je(1,c.length)){const s=(l[0]-l[o])/365;t+=c[o]*(1+e)**s}return t}),(e=>{let t=0;for(const o of je(1,c.length)){const s=(l[0]-l[o])/365;t+=s*c[o]*(1+e)**(s-1)}return t}),s,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},Hf={description:Bo("Net present value given to non-periodic cash flows.."),args:[ad("discount (number)",Bo("The discount rate of the investment over one period.")),ad("cashflow_amounts (number, range<number>)",Bo("An range containing the income or payments associated with the investment.")),ad("cashflow_dates (number, range<number>)",Bo("An range with dates corresponding to the cash flows in cashflow_amounts."))],compute:function(e,t,o){const s=Li(e,this.locale),i=yi(t)?t.flat().map((e=>Bi(e,this.locale))):[Bi(t,this.locale)],n=yi(o)?o.flat().map((e=>Bi(e,this.locale))):[Bi(o,this.locale)];if(yi(o)&&yi(t)?Nm(t,o):Pi((()=>i.length===n.length),Bo("There must be the same number of values in cashflow_amounts and cashflow_dates.")),km(n),Cm(s),1===i.length)return i[0];const r=new Map;for(const e of je(0,n.length)){const t=n[e];r.has(t)?r.set(t,r.get(t)+i[e]):r.set(t,i[e])}const a=Array.from(r.keys()),l=a.map((e=>r.get(e)));let c=l[0];for(const e of je(1,l.length)){const t=(a[0]-a[e])/365;c+=l[e]*(1+s)**t}return c},isExported:!0},Uf={description:Bo("Annual yield of a security paying periodic interest."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("rate (number)",Bo("The annualized rate of interest.")),ad("price (number)",Bo("The price at which the security is bought per 100 face value.")),ad("redemption (number)",Bo("The redemption amount per 100 face value, or par.")),ad("frequency (number)",Bo("The number of interest or coupon payments per year (1, 2, or 4).")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=Math.trunc(Li(e,this.locale)),l=Math.trunc(Li(t,this.locale)),c=Li(o,this.locale),h=Li(s,this.locale),d=Li(i,this.locale),u=Math.trunc(Li(n,this.locale)),g=Math.trunc(Li(r,this.locale));pm(a,l),fm(u),vm(g),Pi((()=>c>=0),Bo("The rate (%s) must be positive or null.",c.toString())),Sm(h),bm(d);const p=Zs(a,l,g)*u,m=Math.ceil(p),f=p-Math.floor(p)||1,v=100*c/u;if(1===m){const e=h+v*(1-f);return(d+v-e)*u*(1/f)/e}const b=Lm((function(e){return function(e,t,o,s,i,n){let r=n-(e+i*(1-t))*s**(o-1+t);for(let e=1;e<=o;e++)r+=i*s**(e-1);return r}(h,f,m,e,v,d)}),(function(e){return function(e,t,o,s,i){let n=-(e+i*(1-t))*(o-1+t)*s**(o-2+t);for(let e=1;e<=o;e++)n+=i*(e-1)*s**(e-2);return n}(h,f,m,e,v)}),1+(c+1)/u,100,1e-5);return(b-1)*u},isExported:!0},Bf={description:Bo("Annual yield of a discount security."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("price (number)",Bo("The price at which the security is bought per 100 face value.")),ad("redemption (number)",Bo("The redemption amount per 100 face value, or par.")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(Li(e,this.locale)),r=Math.trunc(Li(t,this.locale)),a=Li(o,this.locale),l=Li(s,this.locale),c=Math.trunc(Li(i,this.locale));pm(n,r),vm(c),Sm(a),bm(l);return(l/a-1)/Zs(n,r,c)},isExported:!0},zf={description:Bo("Annual yield of a security paying interest at maturity."),args:[ad("settlement (date)",Bo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ad("maturity (date)",Bo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ad("issue (date)",Bo("The date the security was initially issued.")),ad("rate (number)",Bo("The annualized rate of interest.")),ad("price (number)",Bo("The price at which the security is bought.")),ad("day_count_convention (number, default=0 )",Bo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n={value:0}){n=n||0;const r=Math.trunc(Li(e,this.locale)),a=Math.trunc(Li(t,this.locale)),l=Math.trunc(Li(o,this.locale)),c=Li(s,this.locale),h=Li(i,this.locale),d=Math.trunc(Li(n,this.locale));pm(r,a),vm(d),Pi((()=>r>=l),Bo("The settlement (%s) must be greater than or equal to the issue (%s).",r.toString(),l.toString())),Pi((()=>c>=0),Bo("The rate (%s) must be positive or null.",c.toString())),Sm(h);const u=Zs(l,a,d),g=Zs(l,r,d),p=Zs(r,a,d);return(100*(1+c*u)/(h+100*c*g)-1)/p},isExported:!0};var $f,Gf=Object.freeze({__proto__:null,ACCRINTM:Hm,AMORLINC:Um,COUPDAYBS:zm,COUPDAYS:Bm,COUPDAYSNC:$m,COUPNCD:Gm,COUPNUM:Wm,COUPPCD:qm,CUMIPMT:Zm,CUMPRINC:jm,DB:Ym,DDB:Km,DISC:Jm,DOLLARDE:Qm,DOLLARFR:ef,DURATION:tf,EFFECT:of,FV:nf,FVSCHEDULE:rf,INTRATE:af,IPMT:cf,IRR:hf,ISPMT:df,MDURATION:uf,MIRR:gf,NOMINAL:pf,NPER:mf,NPV:vf,PDURATION:bf,PMT:yf,PPMT:wf,PRICE:Ef,PRICEDISC:If,PRICEMAT:Rf,PV:xf,RATE:Af,RECEIVED:_f,RRI:Df,SLN:Of,SYD:Ff,TBILLEQ:Nf,TBILLPRICE:Pf,TBILLYIELD:kf,VDB:Vf,XIRR:Lf,XNPV:Hf,YIELD:Uf,YIELDDISC:Bf,YIELDMAT:zf});!function(e){e[e.LeftRef=0]="LeftRef",e[e.RightRef=1]="RightRef",e[e.Separator=2]="Separator",e[e.FullColumnSeparator=3]="FullColumnSeparator",e[e.FullRowSeparator=4]="FullRowSeparator",e[e.RightColumnRef=5]="RightColumnRef",e[e.RightRowRef=6]="RightRowRef",e[e.Found=7]="Found"}($f||($f={}));const Wf=(e,t=(()=>!0))=>[{goTo:e,guard:t}],qf=(e,t=(()=>!0))=>({goTo:e,guard:t}),Zf={[$f.LeftRef]:{REFERENCE:Wf($f.Separator),NUMBER:Wf($f.FullRowSeparator),SYMBOL:[qf($f.FullColumnSeparator,(e=>{return t=e.value,Br.test(t);var t})),qf($f.FullRowSeparator,(e=>Gr(e.value)))]},[$f.FullColumnSeparator]:{SPACE:Wf($f.FullColumnSeparator),OPERATOR:Wf($f.RightColumnRef,(e=>":"===e.value))},[$f.FullRowSeparator]:{SPACE:Wf($f.FullRowSeparator),OPERATOR:Wf($f.RightRowRef,(e=>":"===e.value))},[$f.Separator]:{SPACE:Wf($f.Separator),OPERATOR:Wf($f.RightRef,(e=>":"===e.value))},[$f.RightRef]:{SPACE:Wf($f.RightRef),NUMBER:Wf($f.Found),REFERENCE:Wf($f.Found,(e=>Zr(e.value))),SYMBOL:Wf($f.Found,(e=>Wr(e.value)||qr(e.value)))},[$f.RightColumnRef]:{SPACE:Wf($f.RightColumnRef),SYMBOL:Wf($f.Found,(e=>Wr(e.value))),REFERENCE:Wf($f.Found,(e=>Zr(e.value)))},[$f.RightRowRef]:{SPACE:Wf($f.RightRowRef),NUMBER:Wf($f.Found),REFERENCE:Wf($f.Found,(e=>Zr(e.value))),SYMBOL:Wf($f.Found,(e=>qr(e.value)))},[$f.Found]:{}};function jf(e){let t=0,o=Zf[$f.LeftRef],s="";for(;void 0!==o;){const i=e[t++];if(!i)return null;const n=o[i.type]?.find((e=>e.guard(i))),r=n?n.goTo:void 0;switch(r){case void 0:return null;case $f.Found:return s+=i.value,e.splice(0,t),{type:"REFERENCE",value:s};default:o=Zf[r],s+=i.value}}return null}function Yf(e,t=bi){const o=Va(e,t),s=[];for(;o.length;)s.push(jf(o)||o.shift());return s}const Xf=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,Kf=["-","+"],Jf=["%"],Qf=["*","+","&"],ev={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10};function tv(e){const t=e.shift();if(!t)throw new Ti;switch(t.type){case"DEBUGGER":const o=iv(e,1e3);return o.debug=!0,o;case"NUMBER":return{type:"NUMBER",value:oi(t.value,bi)};case"STRING":return{type:"STRING",value:Ue(t.value)};case"INVALID_REFERENCE":return{type:"REFERENCE",value:Ei.InvalidReference};case"REFERENCE":if(":"===e[0]?.value&&"REFERENCE"===e[1]?.type){e.shift();const o=e.shift();return{type:"REFERENCE",value:`${t.value}:${o?.value}`}}return{type:"REFERENCE",value:t.value};case"SYMBOL":const s=t.value,i=e[0];if("LEFT_PAREN"===i?.type&&Xf.test(t.value)&&s===Ge(s,"'")){const t=function(e){sv(e,"LEFT_PAREN",Bo("Missing opening parenthesis"));const t=e[0];if("RIGHT_PAREN"===t?.type)return sv(e,"RIGHT_PAREN"),[];const o=[];o.push(ov(e));for(;"RIGHT_PAREN"!==e[0]?.type;)sv(e,"ARG_SEPARATOR",Bo("Wrong function call")),o.push(ov(e));return sv(e,"RIGHT_PAREN"),o}(e);return{type:"FUNCALL",value:s,args:t}}const n=s.toUpperCase();return"TRUE"===n||"FALSE"===n?{type:"BOOLEAN",value:"TRUE"===n}:{type:"SYMBOL",value:Ge(t.value,"'")};case"LEFT_PAREN":const r=iv(e);return sv(e,"RIGHT_PAREN",Bo("Missing closing parenthesis")),r;case"OPERATOR":const a=t.value;if(Kf.includes(a))return{type:"UNARY_OPERATION",value:a,operand:iv(e,ev[a])};throw new Ti(Bo("Unexpected token: %s",t.value));default:throw new Ti(Bo("Unexpected token: %s",t.value))}}function ov(e){const t=e[0];return"ARG_SEPARATOR"===t?.type||"RIGHT_PAREN"===t?.type?{type:"EMPTY",value:""}:iv(e)}function sv(e,t,o){const s=e.shift();if(!s||s.type!==t)throw new Ti(o)}function iv(e,t=0){if(0===e.length)throw new Ti;let o=tv(e);for(;"OPERATOR"===e[0]?.type&&ev[e[0].value]>t;){const t=e.shift().value;if(Jf.includes(t))o={type:"UNARY_OPERATION",value:t,operand:o,postfix:!0};else{o={type:"BIN_OPERATION",value:t,left:o,right:iv(e,ev[t])}}}return o}function nv(e){return rv(Yf(e))}function rv(e){e=e.filter((e=>"SPACE"!==e.type)),"="===e[0]?.value&&e.splice(0,1);const t=iv(e);if(e.length)throw new Ti;return t}function av(e,t,o){return hv(e,(e=>e.type===t?o(e):e))}function lv(e){return Array.from(cv(e))}function*cv(e){switch(yield e,e.type){case"FUNCALL":for(const t of e.args)yield*cv(t);break;case"UNARY_OPERATION":yield*cv(e.operand);break;case"BIN_OPERATION":yield*cv(e.left),yield*cv(e.right)}}function hv(e,t){switch((e=t(e)).type){case"FUNCALL":return{...e,args:e.args.map((e=>hv(e,t)))};case"UNARY_OPERATION":return{...e,operand:hv(e.operand,t)};case"BIN_OPERATION":return{...e,right:hv(e.right,t),left:hv(e.left,t)};default:return e}}function dv(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>dv(e)));return`${e.value}(${t.join(",")})`;case"NUMBER":return e.value.toString();case"REFERENCE":default:return e.value;case"STRING":return`"${e.value}"`;case"BOOLEAN":return e.value?"TRUE":"FALSE";case"UNARY_OPERATION":return e.postfix?uv(e)+e.value:e.value+gv(e);case"BIN_OPERATION":return uv(e)+e.value+gv(e)}}function uv(e){const t=e.value,o="left"in e?e.left:e.operand,s=o.value;return"BIN_OPERATION"===o.type&&ev[s]<ev[t]?`(${dv(o)})`:dv(o)}function gv(e){const t=e.value,o="right"in e?e.right:e.operand,s=ev[o.value],i=ev[t];let n=!1;return"BIN_OPERATION"!==o.type?n=!1:s<i?n=!0:s!==i||Qf.includes(t)||(n=!0),n?`(${dv(o)})`:dv(o)}function pv(e,t){return function(e){for(const t of e)if(t.functionContext){const{argsTokens:e,args:o}=t.functionContext;if(delete t.functionContext.argsTokens,o.length||!e)continue;"LEFT_PAREN"===e[0]?.[0]?.type&&(e[0]=e[0].slice(1));for(const t of e){let e=t;"ARG_SEPARATOR"===e.at(-1)?.type&&(e=e.slice(0,-1));try{o.push(rv(e))}catch(e){o.push(void 0)}}}return e}(function(e){let t=[],o="";function s(e){if(0===t.length)return;const o=t.at(-1);if(o&&o.argsTokens){const{argsTokens:t,argPosition:s}=o;t[s]||(t[s]=[]),t[s].push({value:e.value,type:e.type})}}return e.map(((e,i)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(o=""),e.type){case"SYMBOL":s(e),o=e.value;break;case"LEFT_PAREN":t.push({parent:o,argPosition:0,argsTokens:[],args:[]}),s(e),o="";break;case"RIGHT_PAREN":const i=t.pop();i?.argsTokens?.flat().forEach(s),s(e);break;case"ARG_SEPARATOR":s(e),t.length&&t[t.length-1].argPosition++;break;default:s(e)}if(t.length){const o=t[t.length-1];o.parent&&(e.functionContext=Object.assign({},o))}return e}))}(function(e){let t=[],o=0;return e.map(((s,i)=>{if("LEFT_PAREN"===s.type){t.push(o+1),o=0;for(let o=i-1;o>=0;o--){if("SPACE"!==e[o].type){"SYMBOL"===e[o].type&&(e[o].parenthesesCode=t.join(":"));break}e[o].parenthesesCode=t.join(":")}}return s.parenthesesCode=t.join(":"),"RIGHT_PAREN"===s.type&&t.length&&(o=t.pop()),s}))}(function(e){let t=0;return e.map((e=>{const o=e.value.toString().length,s=Object.assign({},e,{start:t,end:t+o,length:o});return t=s.end,s}))}(Yf(e,t)))))}function mv(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:o}=jr(e.value),[s,i]=t.split(":"),n=fv(s),r=i?`:${fv(i)}`:"";return{...e,value:Yr(o,n+r)}}function fv(e){switch(function(e){if(function(e){return e.startsWith("$")&&e.length>1&&e.slice(1).includes("$")}(e))return"colrow";if(function(e){return e.startsWith("$")}(e))return"col";if(function(e){return e.includes("$",1)}(e))return"row";return"none"}(e)){case"none":e=vv(e,"colrow");break;case"colrow":e=vv(e,"row");break;case"row":e=vv(e,"col");break;case"col":e=vv(e,"none")}return e}function vv(e,t){let o;({sheetName:o,xc:e}=jr(e)),o=o?o+"!":"";const s=(e=e.replace(/\$/g,"")).indexOf(":");return s>=0?`${o}${bv(e.slice(0,s),t)}:${bv(e.slice(s+1),t)}`:o+bv(e,t)}function bv(e,t){const o=e.search(/[0-9]/),s=0!==o,i=o>=0;switch(t){case"col":return s?"$"+e:e;case"row":return i?e.slice(0,o)+"$"+e.slice(o):e;case"colrow":return i&&s?"$"+e.slice(0,o)+"$"+e.slice(o):"$"+e;case"none":return e}}function Sv(e,t,o){const s=(t.startsWith("=")?pv(t,o):[]).filter((t=>t.start<=e.start&&t.end>=e.start||t.start>=e.start&&t.start<e.end)),i=s.filter((e=>"REFERENCE"===e.type));if(0===i.length)return;const n=s.map(mv).map((e=>e.value)).join(""),r=s[0].start,a=s[s.length-1].end,l=t.slice(0,r)+n+t.slice(a),c=l.length-t.length,h={start:i[0].start,end:i[i.length-1].end+c};return 1===i.length&&e.start===e.end&&(h.start=h.end),{content:l,selection:h}}const yv=["address","col","contents","format","row","type"],Cv={description:Bo("Gets information about a cell."),args:[ad("info_type (string)",Bo("The type of information requested. Can be one of %s",yv.join(", "))),ad("reference (meta)",Bo("The reference to the cell."))],compute:function(e,t){const o=qi(e).toLowerCase();Pi((()=>yv.includes(o)),Bo("The info_type should be one of %s.",yv.join(", ")));const s=this.__originSheetId,i=qi(t),n=i.includes(":")?i.split(":")[0]:i;let{sheetName:r,xc:a}=jr(n);r=r===this.getters.getSheetName(s)?void 0:r;const l=Yr(r,vv(a,"colrow")),c=this.getters.getRangeFromSheetXC(s,l);switch(o){case"address":return this.getters.getRangeString(c,s);case"col":return c.zone.left+1;case"contents":{const e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top};return this.getters.getEvaluatedCell(e).value}case"format":{const e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top};return this.getters.getEvaluatedCell(e).format||""}case"row":return c.zone.top+1;case"type":{const e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top},t=this.getters.getEvaluatedCell(e).type;return t===ii.empty?"b":t===ii.text?"l":"v"}}return""},isExported:!0},wv={description:Bo("Whether a value is an error other than #N/A."),args:[ad("value (any)",Bo("The value to be verified as an error type."))],compute:function(e){const t=e?.value;return ki(t)&&t!==Ei.NotAvailable},isExported:!0},xv={description:Bo("Whether a value is an error."),args:[ad("value (any)",Bo("The value to be verified as an error type."))],compute:function(e){const t=e?.value;return ki(t)},isExported:!0},Ev={description:Bo("Whether a value is `true` or `false`."),args:[ad("value (any)",Bo("The value to be verified as a logical TRUE or FALSE."))],compute:function(e){return"boolean"==typeof e?.value},isExported:!0},Iv={description:Bo("Whether a value is the error #N/A."),args:[ad("value (any)",Bo("The value to be verified as an error type."))],compute:function(e){return e?.value===Ei.NotAvailable},isExported:!0},Rv={description:Bo("Whether a value is non-textual."),args:[ad("value (any)",Bo("The value to be checked."))],compute:function(e){return!Av.compute.bind(this)(e)},isExported:!0},Tv={description:Bo("Whether a value is a number."),args:[ad("value (any)",Bo("The value to be verified as a number."))],compute:function(e){return"number"==typeof e?.value},isExported:!0},Av={description:Bo("Whether a value is text."),args:[ad("value (any)",Bo("The value to be verified as text."))],compute:function(e){return"string"==typeof e?.value&&!1===ki(e?.value)},isExported:!0},_v={description:Bo("Whether the referenced cell is empty"),args:[ad("value (any)",Bo("Reference to the cell that will be checked for emptiness."))],compute:function(e){return null===e?.value},isExported:!0},Dv={description:Bo("Returns the error value #N/A."),args:[],compute:function(){return{value:Ei.NotAvailable}},isExported:!0};var Ov=Object.freeze({__proto__:null,CELL:Cv,ISBLANK:_v,ISERR:wv,ISERROR:xv,ISLOGICAL:Ev,ISNA:Iv,ISNONTEXT:Rv,ISNUMBER:Tv,ISTEXT:Av,NA:Dv});const Fv={description:Bo("Logical `and` operator."),args:[ad("logical_expression1 (boolean, range<boolean>)",Bo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),ad("logical_expression2 (boolean, range<boolean>, repeating)",Bo("More expressions that represent logical values."))],compute:function(...e){const{result:t,foundBoolean:o}=pl(e);return Pi((()=>o),Bo("[[FUNCTION_NAME]] has no valid input data.")),t},isExported:!0},Mv={description:Bo("Logical value `false`."),args:[],compute:function(){return!1},isExported:!0},Pv={description:Bo("Returns value depending on logical expression."),args:[ad("logical_expression (boolean, range<boolean>)",Bo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")),ad("value_if_true (any, range)",Bo("The value the function returns if logical_expression is TRUE.")),ad("value_if_false (any, range, default=FALSE)",Bo("The value the function returns if logical_expression is FALSE."))],compute:function(e,t,o){if(El(e))return cn(Pv.compute,[e,t,o]);let s=Yi(wl(e))?t:o;return El(s)||(s=wl(s)),void 0===s?{value:""}:yi(s)||null!==s.value?s:{...s,value:""}},isExported:!0},Nv={description:Bo("Value if it is not an error, otherwise 2nd argument."),args:[ad("value (any, range)",Bo("The value to return if value itself is not an error.")),ad('value_if_error (any, range, default="empty")',Bo("The value the function returns if value is an error."))],compute:function(e,t){if(El(e))return cn(Nv.compute,[e,t]);let o=ki(wl(e)?.value)?t:e;return El(o)||(o=wl(o)),void 0===o?{value:""}:yi(o)||null!==o.value?o:{...o,value:""}},isExported:!0},kv={description:Bo("Value if it is not an #N/A error, otherwise 2nd argument."),args:[ad("value (any, range)",Bo("The value to return if value itself is not #N/A an error.")),ad('value_if_error (any, range, default="empty")',Bo("The value the function returns if value is an #N/A error."))],compute:function(e,t){if(El(e))return cn(kv.compute,[e,t]);let o=wl(e)?.value===Ei.NotAvailable?t:e;return El(o)||(o=wl(o)),void 0===o?{value:""}:yi(o)||null!==o.value?o:{...o,value:""}},isExported:!0},Vv={description:Bo("Returns a value depending on multiple logical expressions."),args:[ad("condition1 (boolean, range<boolean>)",Bo("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")),ad("value1 (any, range)",Bo("The returned value if condition1 is TRUE.")),ad("condition2 (boolean, any, range, repeating)",Bo("Additional conditions to be evaluated if the previous ones are FALSE.")),ad("value2 (any, range, repeating)",Bo("Additional values to be returned if their corresponding conditions are TRUE."))],compute:function(...e){for(Pi((()=>e.length%2==0),Bo("Wrong number of arguments. Expected an even number of arguments."));e.length>0;){if(El(e[0]))return cn(Vv.compute,e);const t=Yi(wl(e.shift()));let o=e.shift();if(t)return El(o)||(o=wl(o)),void 0===o?{value:""}:yi(o)||null!==o.value?o:{...o,value:""}}return new Ri(Bo("No match."))},isExported:!0},Lv={description:Bo("Returns opposite of provided logical value."),args:[ad("logical_expression (boolean)",Bo("An expression or reference to a cell holding an expression that represents some logical value."))],compute:function(e){return!Yi(e)},isExported:!0},Hv={description:Bo("Logical `or` operator."),args:[ad("logical_expression1 (boolean, range<boolean>)",Bo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),ad("logical_expression2 (boolean, range<boolean>, repeating)",Bo("More expressions that evaluate to logical values."))],compute:function(...e){const{result:t,foundBoolean:o}=ml(e);return Pi((()=>o),Bo("[[FUNCTION_NAME]] has no valid input data.")),t},isExported:!0},Uv={description:Bo("Logical value `true`."),args:[],compute:function(){return!0},isExported:!0},Bv={description:Bo("Logical `xor` operator."),args:[ad("logical_expression1 (boolean, range<boolean>)",Bo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),ad("logical_expression2 (boolean, range<boolean>, repeating)",Bo("More expressions that evaluate to logical values."))],compute:function(...e){let t=!1,o=!1;return hn(e,(e=>(t=!0,o=o?!e:e,!0))),Pi((()=>t),Bo("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0};var zv=Object.freeze({__proto__:null,AND:Fv,FALSE:Mv,IF:Pv,IFERROR:Nv,IFNA:kv,IFS:Vv,NOT:Lv,OR:Hv,TRUE:Uv,XOR:Bv});function $v(e,t){const o=t.getPivotId(e);if(!o)throw new Ri(Bo('There is no pivot with id "%s"',e));return o}function Gv(e){if(e.length%2!=0)throw new Ri(Bo("Function PIVOT takes an even number of arguments."))}function Wv(e,t,o){const s=[];if("SPREADSHEET"===t.type&&t.dataSet){const{sheetId:o,zone:i}=t.dataSet,n=Zo(i),r=e.getters.getRangeFromSheetXC(o,n);if(void 0===r||r.invalidXc||r.invalidSheetName)throw new _i;if(e.__originCellPosition&&r.sheetId===e.__originSheetId&&ss(ds(e.__originCellPosition),i))throw new Ai;s.push(r)}for(const t of o)if(t.computedBy){const o=e.getters.getMeasureCompiledFormula(t);s.push(...o.dependencies.filter((e=>!e.invalidXc)))}const i=e.__originCellPosition;i&&s.length&&(e.updateDependencies?.(i),e.addDependencies?.(i,s))}const qv=!0;function Zv(e){return{value:Ei.NotAvailable,message:Bo("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",qi(e))}}const jv={description:Bo("Returns a cell reference as a string. "),args:[ad("row (number)",Bo("The row number of the cell reference. ")),ad("column (number)",Bo("The column number (not name) of the cell reference. A is column number 1. ")),ad("absolute_relative_mode (number, default=1)",Bo("An indicator of whether the reference is row/column absolute. 1 is row and column absolute (e.g. $A$1), 2 is row absolute and column relative (e.g. A$1), 3 is row relative and column absolute (e.g. $A1), and 4 is row and column relative (e.g. A1).")),ad("use_a1_notation (boolean, default=TRUE)",Bo("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).")),ad("sheet (string, optional)",Bo("A string indicating the name of the sheet into which the address points."))],compute:function(e,t,o={value:1},s={value:!0},i){const n=$i(e,this.locale),r=$i(t,this.locale);Gi(n),Gi(r);const a=$i(o,this.locale);var l,c;Pi((()=>[1,2,3,4].includes(a)),(l=4,c=a,Bo("The function [[FUNCTION_NAME]] expects a number value between %s and %s inclusive, but receives %s.",1..toString(),l.toString(),c.toString())));let h;if(Yi(s)){h=_o(r-1,n-1,{rowFixed:[1,2].includes(a),colFixed:[1,3].includes(a)})}else{h=([1,2].includes(a)?`R${n}`:`R[${n}]`)+([1,3].includes(a)?`C${r}`:`C[${r}]`)}return void 0!==i?Yr(qi(i),h):h},isExported:!0},Yv={description:Bo("Column number of a specified cell."),args:[ad("cell_reference (meta, default='this cell')",Bo("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."))],compute:function(e){if(ki(e?.value))return e;if(void 0===e)return Pi((()=>void 0!==this.__originCellPosition?.col),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter."),this.__originCellPosition.col+1;const t=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),e.value).zone;return t.left===t.right?t.left+1:rn(t.right-t.left+1,1,((e,o)=>({value:t.left+e+1})))},isExported:!0},Xv={description:Bo("Number of columns in a specified array or range."),args:[ad("range (meta)",Bo("The range whose column count will be returned."))],compute:function(e){if(ki(e?.value))return e;const t=Go(e.value);return t.right-t.left+1},isExported:!0},Kv={description:Bo("Horizontal lookup"),args:[ad("search_key (string, number, boolean)",Bo("The value to search for. For example, 42, 'Cats', or I24.")),ad("range (any, range)",Bo("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")),ad("index (number)",Bo("The row index of the value to be returned, where the first row in range is numbered 1.")),ad("is_sorted (boolean, default=true)",Bo("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."))],compute:function(e,t,o,s={value:qv}){const i=Math.trunc(Li(o?.value,this.locale)),n=Sn(t);Pi((()=>1<=i&&i<=n[0].length),Bo("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const r=(e,t)=>e[t][0].value,a=Yi(s.value)?mn(n,e,"nextSmaller","asc",n.length,r):fn(n,e,"wildcard",n.length,r,this.lookupCaches),l=n[a];return void 0===l?Zv(e):l[i-1]},isExported:!0},Jv={description:Bo("Returns the content of a cell, specified by row and column offset."),args:[ad("reference (any, range)",Bo("The range of cells from which the values are returned.")),ad("row (number, default=0)",Bo("The index of the row to be returned from within the reference range of cells.")),ad("column (number, default=0)",Bo("The index of the column to be returned from within the reference range of cells."))],compute:function(e,t={value:0},o={value:0}){const s=Sn(e),i=Li(t.value,this.locale),n=Li(o.value,this.locale);return Pi((()=>n>=0&&n-1<s.length&&i>=0&&i-1<s[0].length),Bo("Index out of range.")),0===i&&0===n?s:0===i?[s[n-1]]:0===n?s.map((e=>[e[i-1]])):s[n-1][i-1]},isExported:!0},Qv={description:Bo("Returns the content of a cell, specified by a string."),args:[ad("reference (string)",Bo("The range of cells from which the values are returned.")),ad("use_a1_notation (boolean, default=TRUE)",Bo("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE)."))],compute:function(e,t={value:!0}){let o=e?.value?.toString();if(!o)return new _i(Bo("Reference should be defined."));if(!Yi(t))return new Ri(Bo("R1C1 notation is not supported."));const s=this.__originSheetId,i=this.__originCellPosition;i&&this.updateDependencies?.(i);const n=this.getters.getRangeFromSheetXC(s,o);if(void 0===n||n.invalidXc||n.invalidSheetName)return new _i;i&&this.addDependencies?.(i,[n]);const r=[];for(let e=n.zone.left;e<=n.zone.right;e++){const t=[];for(let o=n.zone.top;o<=n.zone.bottom;o++){const s={sheetId:n.sheetId,col:e,row:o};t.push(this.getters.getEvaluatedCell(s))}r.push(t)}return 1===r.length&&1===r[0].length?r[0][0]:r},isExported:!0},eb={description:Bo("Look up a value."),args:[ad("search_key (string, number, boolean)",Bo("The value to search for. For example, 42, 'Cats', or I24.")),ad("search_array (any, range)",Bo("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.")),ad("result_range (any, range, optional)",Bo("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,o){const s=Sn(t),i=Sn(o);let n=s.length,r=s[0].length;const a=r>=n,l=a?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,c=mn(s,e,"nextSmaller","asc",a?r:n,l);return-1===c||a&&void 0===s[0][c]||!a&&void 0===s[c][r-1]?Zv(e):0===i[0].length?a?s[n-1][c]:s[c][r-1]:(n=i.length,r=i[0].length,Pi((()=>1===n||1===r),Bo("The result_range must be a single row or a single column.")),n>1?(Pi((()=>c<=n-1),Bo("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(c+1).toString())),i[c][0]):(Pi((()=>c<=r-1),Bo("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(c+1).toString())),i[0][c]))},isExported:!0},tb={description:Bo("Position of item in range that matches value."),args:[ad("search_key (string, number, boolean)",Bo("The value to search for. For example, 42, 'Cats', or I24.")),ad("range (any, range)",Bo("The one-dimensional array to be searched.")),ad("search_type (number, default=1)",Bo("The search method. 1 (default) 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."))],compute:function(e,t,o={value:1}){let s=Li(o,this.locale);const i=Sn(t),n=i.length,r=i[0].length;Pi((()=>1===n||1===r),Bo("The range must be a single row or a single column."));let a=-1;const l=1===n?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,c=1===n?i[0].length:i.length;switch(s=Math.sign(s),s){case 1:a=mn(i,e,"nextSmaller","asc",c,l);break;case 0:a=fn(i,e,"wildcard",c,l,this.lookupCaches);break;case-1:a=mn(i,e,"nextGreater","desc",c,l)}return 1===n&&void 0===i[0][a]||1!==n&&void 0===i[a]?Zv(e):a+1},isExported:!0},ob={description:Bo("Row number of a specified cell."),args:[ad("cell_reference (meta, default='this cell')",Bo("The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered."))],compute:function(e){if(ki(e?.value))return e;if(void 0===e)return Pi((()=>void 0!==this.__originCellPosition?.row),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter."),this.__originCellPosition.row+1;const t=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),e.value).zone;return t.top===t.bottom?t.top+1:rn(1,t.bottom-t.top+1,((e,o)=>({value:t.top+o+1})))},isExported:!0},sb={description:Bo("Number of rows in a specified array or range."),args:[ad("range (meta)",Bo("The range whose row count will be returned."))],compute:function(e){if(ki(e?.value))return e;const t=Go(e.value);return t.bottom-t.top+1},isExported:!0},ib={description:Bo("Vertical lookup."),args:[ad("search_key (string, number, boolean)",Bo("The value to search for. For example, 42, 'Cats', or I24.")),ad("range (any, range)",Bo("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")),ad("index (number)",Bo("The column index of the value to be returned, where the first column in range is numbered 1.")),ad("is_sorted (boolean, default=true)",Bo("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."))],compute:function(e,t,o,s={value:qv}){const i=Math.trunc(Li(o?.value,this.locale)),n=Sn(t);Pi((()=>1<=i&&i<=n.length),Bo("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const r=(e,t)=>e[0][t].value,a=Yi(s.value)?mn(n,e,"nextSmaller","asc",n[0].length,r):fn(n,e,"wildcard",n[0].length,r,this.lookupCaches),l=n[i-1][a];return void 0===l?Zv(e):l},isExported:!0},nb={0:"strict",1:"nextGreater","-1":"nextSmaller",2:"wildcard"},rb={description:Bo("Search a range for a match and return the corresponding item from a second range."),args:[ad("search_key (string,number,boolean)",Bo("The value to search for.")),ad("lookup_range (any, range)",Bo("The range to consider for the search. Should be a single column or a single row.")),ad("return_range (any, range)",Bo("The range containing the return value. Should have the same dimensions as lookup_range.")),ad("if_not_found (any, optional)",Bo("If a valid match is not found, return this value.")),ad("match_mode (any, default=0)",Bo("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match. (2) Wildcard match.")),ad("search_mode (any, default=1)",Bo("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. "))],compute:function(e,t,o,s,i={value:0},n={value:1}){const r=Math.trunc(Li(i.value,this.locale)),a=Math.trunc(Li(n.value,this.locale)),l=Sn(t),c=Sn(o);Pi((()=>1===l.length||1===l[0].length),Bo("lookup_range should be either a single row or single column.")),Pi((()=>[-1,1,-2,2].includes(a)),Bo("search_mode should be a value in [-1, 1, -2, 2].")),Pi((()=>[-1,0,1,2].includes(r)),Bo("match_mode should be a value in [-1, 0, 1, 2]."));const h=1===l.length?"col":"row";Pi((()=>!(2===r&&[-2,2].includes(a))),Bo("the search and match mode combination is not supported for XLOOKUP evaluation.")),Pi((()=>"col"===h?c[0].length===l[0].length:c.length===l.length),Bo("return_range should have the same dimensions as lookup_range."));const d="col"===h?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,u="col"===h?l[0].length:l.length,g=nb[r],p=-1===a,m=2===a||-2===a?mn(l,e,g,2===a?"asc":"desc",u,d):fn(l,e,g,u,d,this.lookupCaches,p);return-1!==m?"col"===h?c.map((e=>[e[m]])):[c[m]]:void 0===s?Zv(e):[[s]]},isExported:!0},ab={description:Bo("Get the value from a pivot."),args:[ad("pivot_id (number,string)",Bo("ID of the pivot.")),ad("measure_name (string)",Bo("Name of the measure.")),ad("domain_field_name (string,optional,repeating)",Bo("Field name.")),ad("domain_value (number,string,boolean,optional,repeating)",Bo("Value."))],compute:function(e,t,...o){const s=qi(e),i=qi(t),n=$v(s,this.getters);!function(e,t,o){const{measures:s}=o.getPivotCoreDefinition(e);if(!s.find((e=>e.id===t))){const e=`(${s.map((e=>e.id)).join(", ")})`;throw new Ri(Bo("The argument %s is not a valid measure. Here are the measures: %s",t,e))}}(n,i,this.getters),Gv(o);const r=this.getters.getPivot(n),a=this.getters.getPivotCoreDefinition(n);Wv(this,a,a.measures.filter((e=>e.id===i))),r.init({reload:r.needsReevaluation});const l=r.assertIsValid({throwOnError:!1});if(l)return l;if(!r.areDomainArgsFieldsValid(o)){const e=Bo("Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.",`=PIVOT(${s})`);return{value:Ei.GenericError,message:Bo("Dimensions don't match the pivot definition")+". "+e}}const c=r.parseArgsToPivotDomain(o);return this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(n)?.trackValue(i,c),r.getPivotCellValueAndFormat(i,c)}},lb={description:Bo("Get the header of a pivot."),args:[ad("pivot_id (number,string)",Bo("ID of the pivot.")),ad("domain_field_name (string,optional,repeating)",Bo("Field name.")),ad("domain_value (number,string,value,optional,repeating)",Bo("Value."))],compute:function(e,...t){const o=qi(e),s=$v(o,this.getters);Gv(t);const i=this.getters.getPivot(s);Wv(this,this.getters.getPivotCoreDefinition(s),[]),i.init({reload:i.needsReevaluation});const n=i.assertIsValid({throwOnError:!1});if(n)return n;if(!i.areDomainArgsFieldsValid(t)){const e=Bo("Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.",`=PIVOT(${o})`);return{value:Ei.GenericError,message:Bo("Dimensions don't match the pivot definition")+". "+e}}const r=i.parseArgsToPivotDomain(t);this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(s)?.trackHeader(r);const a=r.at(-1);if("measure"===a?.field)return i.getPivotMeasureValue(qi(a.value),r);const{value:l,format:c}=i.getPivotHeaderValueAndFormat(r);return{value:l,format:a&&"measure"!==a.field&&"false"!==a.value?c:void 0}}},cb={description:Bo("Get a pivot table."),args:[ad("pivot_id (string)",Bo("ID of the pivot.")),ad("row_count (number, optional)",Bo("number of rows")),ad("include_total (boolean, default=TRUE)",Bo("Whether to include total/sub-totals or not.")),ad("include_column_titles (boolean, default=TRUE)",Bo("Whether to include the column titles or not.")),ad("column_count (number, optional)",Bo("number of columns"))],compute:function(e,t={value:1e4},o={value:!0},s={value:!0},i={value:Number.MAX_VALUE}){const n=qi(e),r=Li(t,this.locale);if(r<0)return new Ri(Bo("The number of rows must be positive."));const a=Li(i,this.locale);if(a<0)return new Ri(Bo("The number of columns must be positive."));const l=Yi(s),c=Yi(o),h=$v(n,this.getters),d=this.getters.getPivot(h),u=this.getters.getPivotCoreDefinition(h);Wv(this,u,u.measures),d.init({reload:d.needsReevaluation});const g=d.assertIsValid({throwOnError:!1});if(g)return g;const p=d.getTableStructure(),m=p.getPivotCells(c,l),f=l?p.columns.length:0,v=this.getters.getPivotDisplayName(h),b=Math.min(f+r,m[0].length);if(0===b)return[[{value:v}]];const S=Math.min(1+a,m.length),y=[];for(const e of je(0,S)){y[e]=[];for(const t of je(0,b)){const o=m[e][t];switch(o.type){case"EMPTY":y[e].push({value:""});break;case"HEADER":const t=d.getPivotHeaderValueAndFormat(o.domain);y[e].push(Nc(d,o.domain,t));break;case"MEASURE_HEADER":y[e].push(d.getPivotMeasureValue(o.measure,o.domain));break;case"VALUE":y[e].push(d.getPivotCellValueAndFormat(o.measure,o.domain))}}}return l&&(y[0][0]={value:v}),y}},hb={description:Bo("Returns a range reference shifted by a specified number of rows and columns from a starting cell reference."),args:[ad("cell_reference (meta)",Bo("The starting point from which to count the offset rows and columns.")),ad("offset_rows (number)",Bo("The number of rows to offset by.")),ad("offset_columns (number)",Bo("The number of columns to offset by.")),ad("height (number, default='height of cell_reference')",Bo("The number of rows of the range to return starting at the offset target.")),ad("width (number, default='width of cell_reference')",Bo("The number of columns of the range to return starting at the offset target."))],compute:function(e,t,o,s,i){if(ki(e?.value))return e;const n=e?.value;if(!n)return new Ri("In this context, the function OFFSET needs to have a cell or range in parameter.");const r=Go(n);let a=r.bottom-r.top+1,l=r.right-r.left+1;if(s){const e=Li(s,this.locale);dd(Bo("Height value is %(_height)s. It should be greater than or equal to 1.",{_height:e}),e),a=e}if(i){const e=Li(i,this.locale);dd(Bo("Width value is %(_width)s. It should be greater than or equal to 1.",{_width:e}),e),l=e}const{sheetName:c}=jr(n),h=c&&this.getters.getSheetIdByName(c)||this.getters.getActiveSheetId(),d=Li(t,this.locale),u=Li(o,this.locale),g=this.__originCellPosition;g&&this.updateDependencies?.(g);const p=r.left+u,m=r.top+d;if(p<0||m<0)return new _i(Bo("OFFSET evaluates to an out of bounds range."));const f={left:p,top:m,right:p+l-1,bottom:m+a-1},v=this.getters.getRangeFromZone(h,f);return v.invalidXc||v.invalidSheetName?new _i:(g&&this.addDependencies?.(g,[v]),rn(l,a,((e,t)=>this.getters.getEvaluatedCell({sheetId:h,col:p+e,row:m+t}))))}};var db=Object.freeze({__proto__:null,ADDRESS:jv,COLUMN:Yv,COLUMNS:Xv,HLOOKUP:Kv,INDEX:Jv,INDIRECT:Qv,LOOKUP:eb,MATCH:tb,OFFSET:hb,PIVOT:cb,PIVOT_HEADER:lb,PIVOT_VALUE:ab,ROW:ob,ROWS:sb,VLOOKUP:ib,XLOOKUP:rb});const ub={description:Bo("Sum of two numbers."),args:[ad("value1 (number)",Bo("The first addend.")),ad("value2 (number)",Bo("The second addend."))],compute:function(e,t){return{value:Li(e,this.locale)+Li(t,this.locale),format:e?.format||t?.format}}},gb={description:Bo("Concatenation of two values."),args:[ad("value1 (string)",Bo("The value to which value2 will be appended.")),ad("value2 (string)",Bo("The value to append to value1."))],compute:function(e,t){return qi(e)+qi(t)},isExported:!0},pb={description:Bo("One number divided by another."),args:[ad("dividend (number)",Bo("The number to be divided.")),ad("divisor (number)",Bo("The number to divide by."))],compute:function(e,t){const o=Li(t,this.locale);return Pi((()=>0!==o),Bo("The divisor must be different from zero."),Ei.DivisionByZero),{value:Li(e,this.locale)/o,format:e?.format||t?.format}}};function mb(e){return void 0===e||null===e.value}const fb={number:0,string:"",boolean:!1};function vb(e,t,o=2e-16){return Math.abs(e-t)<o}const bb={description:Bo("Equal."),args:[ad("value1 (string, number, boolean)",Bo("The first value.")),ad("value2 (string, number, boolean)",Bo("The value to test against value1 for equality."))],compute:function(e,t){if(ki(e?.value))return e;if(ki(t?.value))return t;let o=mb(e)?fb[typeof t?.value]:e?.value,s=mb(t)?fb[typeof e?.value]:t?.value;return"string"==typeof o&&(o=o.toUpperCase()),"string"==typeof s&&(s=s.toUpperCase()),"number"==typeof o&&"number"==typeof s?{value:vb(o,s)}:{value:o===s}}};function Sb(e,t,o){if(ki(e?.value))return e;if(ki(t?.value))return t;let s=mb(e)?fb[typeof t?.value]:e?.value,i=mb(t)?fb[typeof e?.value]:t?.value;"number"!=typeof s&&(s=qi(s).toUpperCase()),"number"!=typeof i&&(i=qi(i).toUpperCase());const n=typeof s,r=typeof i;return"string"===n&&"number"===r?{value:!0}:"string"===r&&"number"===n?{value:!1}:{value:o(s,i)}}const yb={description:Bo("Strictly greater than."),args:[ad("value1 (number, string, boolean)",Bo("The value to test as being greater than value2.")),ad("value2 (number, string, boolean)",Bo("The second value."))],compute:function(e,t){return Sb(e,t,((e,t)=>"number"==typeof e&&"number"==typeof t?!vb(e,t)&&e>t:e>t))}},Cb={description:Bo("Greater than or equal to."),args:[ad("value1 (number, string, boolean)",Bo("The value to test as being greater than or equal to value2.")),ad("value2 (number, string, boolean)",Bo("The second value."))],compute:function(e,t){return Sb(e,t,((e,t)=>"number"==typeof e&&"number"==typeof t?vb(e,t)||e>t:e>=t))}},wb={description:Bo("Less than."),args:[ad("value1 (number, string, boolean)",Bo("The value to test as being less than value2.")),ad("value2 (number, string, boolean)",Bo("The second value."))],compute:function(e,t){const o=Cb.compute.bind(this)(e,t);return ki(o.value)?o:{value:!o.value}}},xb={description:Bo("Less than or equal to."),args:[ad("value1 (number, string, boolean)",Bo("The value to test as being less than or equal to value2.")),ad("value2 (number, string, boolean)",Bo("The second value."))],compute:function(e,t){const o=yb.compute.bind(this)(e,t);return ki(o.value)?o:{value:!o.value}}},Eb={description:Bo("Difference of two numbers."),args:[ad("value1 (number)",Bo("The minuend, or number to be subtracted from.")),ad("value2 (number)",Bo("The subtrahend, or number to subtract from value1."))],compute:function(e,t){return{value:Li(e,this.locale)-Li(t,this.locale),format:e?.format||t?.format}}},Ib={description:Bo("Product of two numbers"),args:[ad("factor1 (number)",Bo("The first multiplicand.")),ad("factor2 (number)",Bo("The second multiplicand."))],compute:function(e,t){return{value:Li(e,this.locale)*Li(t,this.locale),format:e?.format||t?.format}}},Rb={description:Bo("Not equal."),args:[ad("value1 (string, number, boolean)",Bo("The first value.")),ad("value2 (string, number, boolean)",Bo("The value to test against value1 for inequality."))],compute:function(e,t){const o=bb.compute.bind(this)(e,t);return ki(o.value)?o:{value:!o.value}}},Tb={description:Bo("A number raised to a power."),args:[ad("base (number)",Bo("The number to raise to the exponent power.")),ad("exponent (number)",Bo("The exponent to raise base to."))],compute:function(e,t){return _u.compute.bind(this)(e,t)}},Ab={description:Bo("A number with the sign reversed."),args:[ad("value (number)",Bo("The number to have its sign reversed. Equivalently, the number to multiply by -1."))],compute:function(e){return{value:-Li(e,this.locale),format:e?.format}}},_b={description:Bo("Value interpreted as a percentage."),args:[ad("percentage (number)",Bo("The value to interpret as a percentage."))],compute:function(e){return Li(e,this.locale)/100}},Db={description:Bo("A specified number, unchanged."),args:[ad("value (any)",Bo("The number to return."))],compute:function(e={value:null}){return e}};var Ob=Object.freeze({__proto__:null,ADD:ub,CONCAT:gb,DIVIDE:pb,EQ:bb,GT:yb,GTE:Cb,LT:wb,LTE:xb,MINUS:Eb,MULTIPLY:Ib,NE:Rb,POW:Tb,UMINUS:Ab,UNARY_PERCENT:_b,UPLUS:Db});const Fb=e=>({transform:t=>t*e,inverseTransform:t=>t/e}),Mb={transform:e=>e,inverseTransform:e=>e},Pb=1e-10,Nb=.0254,kb=Nb/72,Vb=.3048,Lb=.9144,Hb=1609.34,Ub=1852,Bb=946073047258e4,zb={g:{...Mb,category:"weight"},u:{...Fb(166053e-29),category:"weight"},grain:{...Fb(.0647989),category:"weight"},ozm:{...Fb(28.3495),category:"weight"},lbm:{...Fb(453.592),category:"weight"},stone:{...Fb(6350.29),category:"weight"},sg:{...Fb(14593.90294),category:"weight"},cwt:{...Fb(45359.237),category:"weight"},uk_cwt:{...Fb(50802.3),category:"weight"},ton:{...Fb(907184.74),category:"weight"},uk_ton:{...Fb(1016046.9),category:"weight"},m:{...Mb,category:"distance"},km:{...Fb(1e3),category:"distance"},ang:{...Fb(Pb),category:"distance"},Picapt:{...Fb(kb),category:"distance"},pica:{...Fb(Nb/6),category:"distance"},in:{...Fb(Nb),category:"distance"},ft:{...Fb(Vb),category:"distance"},yd:{...Fb(Lb),category:"distance"},ell:{...Fb(1.143),category:"distance"},mi:{...Fb(Hb),category:"distance"},survey_mi:{...Fb(1609.34),category:"distance"},Nmi:{...Fb(Ub),category:"distance"},ly:{...Fb(Bb),category:"distance"},parsec:{...Fb(0x6da012f95c9fd0),category:"distance"},sec:{...Mb,category:"time"},min:{...Fb(60),category:"time"},hr:{...Fb(3600),category:"time"},day:{...Fb(86400),category:"time"},yr:{...Fb(31556952),category:"time"},Pa:{...Mb,category:"pressure"},bar:{...Fb(1e5),category:"pressure"},mmHg:{...Fb(133.322),category:"pressure"},Torr:{...Fb(133.322),category:"pressure"},psi:{...Fb(6894.76),category:"pressure"},atm:{...Fb(101325),category:"pressure"},N:{...Mb,category:"force"},dyn:{...Fb(1e-5),category:"force"},pond:{...Fb(.00980665),category:"force"},lbf:{...Fb(4.44822),category:"force"},J:{...Mb,category:"energy"},eV:{...Fb(160218e-24),category:"energy"},e:{...Fb(1e-7),category:"energy"},flb:{...Fb(1.3558179483),category:"energy"},c:{...Fb(4.184),category:"energy"},cal:{...Fb(4.1868),category:"energy"},BTU:{...Fb(1055.06),category:"energy"},Wh:{...Fb(3600),category:"energy"},HPh:{...Fb(2684520),category:"energy"},W:{...Mb,category:"power"},PS:{...Fb(735.499),category:"power"},HP:{...Fb(745.7),category:"power"},T:{...Mb,category:"magnetism"},ga:{...Fb(1e-4),category:"magnetism"},K:{...Mb,category:"temperature"},C:{transform:e=>e+273.15,inverseTransform:e=>e-273.15,category:"temperature"},F:{transform:e=>5*(e-32)/9+273.15,inverseTransform:e=>9*(e-273.15)/5+32,category:"temperature"},Rank:{...Fb(5/9),category:"temperature"},Reau:{transform:e=>1.25*e+273.15,inverseTransform:e=>(e-273.15)/1.25,category:"temperature"},"m^3":{...Mb,category:"volume",order:3},"ang^3":{...Fb(Math.pow(Pb,3)),category:"volume",order:3},"Picapt^3":{...Fb(Math.pow(kb,3)),category:"volume",order:3},tsp:{...Fb(492892e-11),category:"volume"},tspm:{...Fb(5e-6),category:"volume"},tbs:{...Fb(14786764825785619e-21),category:"volume"},"in^3":{...Fb(Math.pow(Nb,3)),category:"volume",order:3},oz:{...Fb(295735295625e-16),category:"volume"},cup:{...Fb(237e-6),category:"volume"},pt:{...Fb(.0004731765),category:"volume"},uk_pt:{...Fb(568261e-9),category:"volume"},qt:{...Fb(.0009463529),category:"volume"},l:{...Fb(.001),category:"volume"},uk_qt:{...Fb(.0011365225),category:"volume"},gal:{...Fb(.0037854118),category:"volume"},uk_gal:{...Fb(.00454609),category:"volume"},"ft^3":{...Fb(Math.pow(Vb,3)),category:"volume",order:3},bushel:{...Fb(.0352390704),category:"volume"},barrel:{...Fb(.158987295),category:"volume"},"yd^3":{...Fb(Math.pow(Lb,3)),category:"volume",order:3},MTON:{...Fb(1.13267386368),category:"volume"},GRT:{...Fb(2.83168),category:"volume"},"mi^3":{...Fb(Math.pow(Hb,3)),category:"volume",order:3},"Nmi^3":{...Fb(Math.pow(Ub,3)),category:"volume",order:3},"ly^3":{...Fb(Math.pow(Bb,3)),category:"volume",order:3},"m^2":{...Mb,category:"area",order:2},"ang^2":{...Fb(Math.pow(Pb,2)),category:"area",order:2},"Picapt^2":{...Fb(Math.pow(kb,2)),category:"area",order:2},"in^2":{...Fb(Math.pow(Nb,2)),category:"area",order:2},"ft^2":{...Fb(Math.pow(Vb,2)),category:"area",order:2},"yd^2":{...Fb(Math.pow(Lb,2)),category:"area",order:2},ar:{...Fb(100),category:"area"},Morgen:{...Fb(2500),category:"area"},uk_acre:{...Fb(4046.8564224),category:"area"},us_acre:{...Fb(4046.8726098743),category:"area"},ha:{...Fb(1e4),category:"area"},"mi^2":{...Fb(Math.pow(Hb,2)),category:"area",order:2},"Nmi^2":{...Fb(Math.pow(Ub,2)),category:"area",order:2},"ly^2":{...Fb(Math.pow(Bb,2)),category:"area",order:2},bit:{...Mb,category:"information"},byte:{...Fb(8),category:"information"},"m/s":{...Mb,category:"speed"},"m/hr":{...Fb(1/3600),category:"speed"},"km/hr":{...Fb(1/3.6),category:"speed"},mph:{...Fb(.44704),category:"speed"},kn:{...Fb(.5144444444),category:"speed"},admkn:{...Fb(.5147733333),category:"speed"}},$b={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"},Gb={"":1,Y:1e24,Z:1e21,E:1e18,P:1e15,T:1e12,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:Math.pow(2,80),Zi:Math.pow(2,70),Ei:Math.pow(2,60),Pi:Math.pow(2,50),Ti:Math.pow(2,40),Gi:Math.pow(2,30),Mi:Math.pow(2,20),ki:Math.pow(2,10)},Wb={weight:Bo("Weight"),distance:Bo("Distance"),time:Bo("Time"),pressure:Bo("Pressure"),force:Bo("Force"),energy:Bo("Energy"),power:Bo("Power"),magnetism:Bo("Magnetism"),temperature:Bo("Temperature"),volume:Bo("Volume"),area:Bo("Area"),information:Bo("Information"),speed:Bo("Speed")};function qb(e){return Wb[e]??""}function Zb(e){for(const[t,o]of Object.entries(Gb)){if(t&&!e.startsWith(t))continue;const s=e.slice(t.length);let i=zb[s];if(!i&&$b[s]&&(i=zb[$b[s]]),i)return{...i,factor:i.order?Math.pow(o,i.order):o}}}const jb={description:Bo("Converts a numeric value to a different unit of measure."),args:[ad("value (number)",Bo("the numeric value in start_unit to convert to end_unit")),ad("start_unit (string)",Bo("The starting unit, the unit currently assigned to value")),ad("end_unit (string)",Bo("The unit of measure into which to convert value"))],compute:function(e,t,o){const s=Li(e,this.locale),i=qi(t),n=qi(o),r=Zb(i),a=Zb(n);return r?a?r.category!==a.category?{value:Ei.GenericError,message:Bo("Incompatible units of measure ('%s' vs '%s')",qb(r.category),qb(a.category))}:{value:a.inverseTransform(r.factor*r.transform(s))/a.factor,format:e?.format}:{value:Ei.GenericError,message:Bo("Invalid units of measure ('%s')",n)}:{value:Ei.GenericError,message:Bo("Invalid units of measure ('%s')",i)}},isExported:!0};var Yb=Object.freeze({__proto__:null,CONVERT:jb});const Xb=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,Kb={description:Bo("Gets character associated with number."),args:[ad("table_number (number)",Bo("The number of the character to look up from the current Unicode table in decimal format."))],compute:function(e){const t=Math.trunc(Li(e,this.locale));return Pi((()=>t>=1),Bo("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},Jb={description:Bo("Remove non-printable characters from a piece of text."),args:[ad("text (string)",Bo("The text whose non-printable characters are to be removed."))],compute:function(e){const t=qi(e);let o="";for(const e of t)e&&e.charCodeAt(0)>31&&(o+=e);return o},isExported:!0},Qb={description:Bo("Appends strings to one another."),args:[ad("string1 (string, range<string>)",Bo("The initial string.")),ad("string2 (string, range<string>, repeating)",Bo("More strings to append in sequence."))],compute:function(...e){return on(e,((e,t)=>e+qi(t)),"")},isExported:!0},eS={description:Bo("Tests whether two strings are identical."),args:[ad("string1 (string)",Bo("The first string to compare.")),ad("string2 (string)",Bo("The second string to compare."))],compute:function(e,t){return qi(e)===qi(t)},isExported:!0},tS={description:Bo("First position of string found in text, case-sensitive."),args:[ad("search_for (string)",Bo("The string to look for within text_to_search.")),ad("text_to_search (string)",Bo("The text to search for the first occurrence of search_for.")),ad("starting_at (number, default=1)",Bo("The character within text_to_search at which to start the search."))],compute:function(e,t,o={value:1}){const s=qi(e),i=qi(t),n=Li(o,this.locale);Pi((()=>""!==i),Bo("The text_to_search must be non-empty.")),Pi((()=>n>=1),Bo("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const r=i.indexOf(s,n-1);return Pi((()=>r>=0),Bo("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",s.toString(),i)),r+1},isExported:!0},oS={description:Bo("Concatenates elements of arrays with delimiter."),args:[ad("delimiter (string)",Bo("The character or string to place between each concatenated value.")),ad("value_or_array1 (string, range<string>)",Bo("The value or values to be appended using delimiter.")),ad("value_or_array2 (string, range<string>, repeating)",Bo("More values to be appended using delimiter."))],compute:function(e,...t){const o=qi(e);return on(t,((e,t)=>(e?e+o:"")+qi(t)),"")}},sS={description:Bo("Substring from beginning of specified string."),args:[ad("text (string)",Bo("The string from which the left portion will be returned.")),ad("number_of_characters (number, optional)",Bo("The number of characters to return from the left side of string."))],compute:function(e,...t){const o=t.length?Li(t[0],this.locale):1;return Pi((()=>o>=0),Bo("The number_of_characters (%s) must be positive or null.",o.toString())),qi(e).substring(0,o)},isExported:!0},iS={description:Bo("Length of a string."),args:[ad("text (string)",Bo("The string whose length will be returned."))],compute:function(e){return qi(e).length},isExported:!0},nS={description:Bo("Converts a specified string to lowercase."),args:[ad("text (string)",Bo("The string to convert to lowercase."))],compute:function(e){return qi(e).toLowerCase()},isExported:!0},rS={description:Bo("A segment of a string."),args:[ad("text (string)",Bo("The string to extract a segment from.")),ad("starting_at (number)",Bo("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),ad("extract_length (number)",Bo("The length of the segment to extract."))],compute:function(e,t,o){const s=qi(e),i=Li(t,this.locale),n=Li(o,this.locale);return Pi((()=>i>=1),Bo("The starting_at argument (%s) must be positive greater than one.",i.toString())),Pi((()=>n>=0),Bo("The extract_length argument (%s) must be positive or null.",n.toString())),s.slice(i-1,i+n-1)},isExported:!0},aS={description:Bo("Capitalizes each word in a specified string."),args:[ad("text_to_capitalize (string)",Bo("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 qi(e).replace(Xb,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},lS={description:Bo("Replaces part of a text string with different text."),args:[ad("text (string)",Bo("The text, a part of which will be replaced.")),ad("position (number)",Bo("The position where the replacement will begin (starting from 1).")),ad("length (number)",Bo("The number of characters in the text to be replaced.")),ad("new_text (string)",Bo("The text which will be inserted into the original text."))],compute:function(e,t,o,s){const i=Li(t,this.locale);Pi((()=>i>=1),Bo("The position (%s) must be greater than or equal to 1.",i.toString()));const n=qi(e),r=Li(o,this.locale),a=qi(s);return n.substring(0,i-1)+a+n.substring(i-1+r)},isExported:!0},cS={description:Bo("A substring from the end of a specified string."),args:[ad("text (string)",Bo("The string from which the right portion will be returned.")),ad("number_of_characters (number, optional)",Bo("The number of characters to return from the right side of string."))],compute:function(e,...t){const o=t.length?Li(t[0],this.locale):1;Pi((()=>o>=0),Bo("The number_of_characters (%s) must be positive or null.",o.toString()));const s=qi(e),i=s.length;return s.substring(i-o,i)},isExported:!0},hS={description:Bo("First position of string found in text, ignoring case."),args:[ad("search_for (string)",Bo("The string to look for within text_to_search.")),ad("text_to_search (string)",Bo("The text to search for the first occurrence of search_for.")),ad("starting_at (number, default=1)",Bo("The character within text_to_search at which to start the search."))],compute:function(e,t,o={value:1}){const s=qi(e).toLowerCase(),i=qi(t).toLowerCase(),n=Li(o,this.locale);if(""===i)return{value:Ei.GenericError,message:Bo("The text_to_search must be non-empty.")};if(n<1)return{value:Ei.GenericError,message:Bo("The starting_at (%s) must be greater than or equal to 1.",n)};const r=i.indexOf(s,n-1);return-1===r?{value:Ei.GenericError,message:Bo("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",s,i)}:{value:r+1}},isExported:!0},dS={description:Bo("Split text by specific character delimiter(s)."),args:[ad("text (string)",Bo("The text to divide.")),ad("delimiter (string)",Bo("The character or characters to use to split text.")),ad("split_by_each (boolean, default=true})",Bo("Whether or not to divide text around each character contained in delimiter.")),ad("remove_empty_text (boolean, default=true)",Bo("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."))],compute:function(e,t,o={value:true},s={value:true}){const i=qi(e),n=Be(qi(t)),r=Yi(o),a=Yi(s);Pi((()=>n.length>0),Bo("The _delimiter (%s) must be not be empty.",n));const l=r?new RegExp(`[${n}]`,"g"):new RegExp(n,"g");let c=i.split(l);return a&&(c=c.filter((e=>""!==e))),ln([c])},isExported:!1},uS={description:Bo("Replaces existing text with new text in a string."),args:[ad("text_to_search (string)",Bo("The text within which to search and replace.")),ad("search_for (string)",Bo("The string to search for within text_to_search.")),ad("replace_with (string)",Bo("The string that will replace search_for.")),ad("occurrence_number (number, optional)",Bo("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,o,s){const i=Li(s,this.locale);Pi((()=>i>=0),Bo("The occurrenceNumber (%s) must be positive or null.",i.toString()));const n=qi(e),r=qi(t);if(""===r)return n;const a=qi(o),l=new RegExp(Be(r),"g");if(0===i)return n.replace(l,a);let c=0;return n.replace(l,(e=>++c===i?a:e))},isExported:!0},gS={description:Bo("Combines text from multiple strings and/or arrays."),args:[ad("delimiter (string)",Bo(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")),ad("ignore_empty (boolean)",Bo("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")),ad("text1 (string, range<string>)",Bo("Any text item. This could be a string, or an array of strings in a range.")),ad("text2 (string, range<string>, repeating)",Bo("Additional text item(s)."))],compute:function(e,t,...o){const s=qi(e),i=Yi(t);let n=0;return on(o,((e,t)=>i&&""===qi(t)?e:(n++?e+s:"")+qi(t)),"")},isExported:!0},pS={description:Bo("Removes space characters."),args:[ad("text (string)",Bo("The text or reference to a cell containing text to be trimmed."))],compute:function(e){return _t(qi(e))},isExported:!0},mS={description:Bo("Converts a specified string to uppercase."),args:[ad("text (string)",Bo("The string to convert to uppercase."))],compute:function(e){return qi(e).toUpperCase()},isExported:!0},fS={description:Bo("Converts a number to text according to a specified format."),args:[ad("number (number)",Bo("The number, date or time to format.")),ad("format (string)",Bo("The pattern by which to format the number, enclosed in quotation marks."))],compute:function(e,t){return Qn(Li(e,this.locale),{format:qi(t),locale:this.locale})},isExported:!0},vS={description:Bo("Converts a string to a numeric value."),args:[ad("value (number)",Bo("the string to be converted"))],compute:function(e){return Li(e,this.locale)},isExported:!0};var bS=Object.freeze({__proto__:null,CHAR:Kb,CLEAN:Jb,CONCATENATE:Qb,EXACT:eS,FIND:tS,JOIN:oS,LEFT:sS,LEN:iS,LOWER:nS,MID:rS,PROPER:aS,REPLACE:lS,RIGHT:cS,SEARCH:hS,SPLIT:dS,SUBSTITUTE:uS,TEXT:fS,TEXTJOIN:gS,TRIM:pS,UPPER:mS,VALUE:vS});const SS={description:Bo("Creates a hyperlink in a cell."),args:[ad("url (string)",Bo("The full URL of the link enclosed in quotation marks.")),ad("link_label (string, optional)",Bo("The text to display in the cell, enclosed in quotation marks."))],compute:function(e,t){const o=qi(e).trim(),s=qi(t)||o;return""===o?s:ot(s,o)},isExported:!0};var yS=Object.freeze({__proto__:null,HYPERLINK:SS});const CS=[{name:Bo("Array"),functions:Vd},{name:Bo("Database"),functions:yp},{name:Bo("Date"),functions:tm},{name:Bo("Filter"),functions:gm},{name:Bo("Financial"),functions:Gf},{name:Bo("Info"),functions:Ov},{name:Bo("Lookup"),functions:db},{name:Bo("Logical"),functions:zv},{name:Bo("Math"),functions:Ku},{name:Bo("Misc"),functions:Hd},{name:Bo("Operator"),functions:Ob},{name:Bo("Statistical"),functions:np},{name:Bo("Text"),functions:bS},{name:Bo("Engineering"),functions:sm},{name:Bo("Web"),functions:yS},{name:Bo("Parser"),functions:Yb}],wS=/^[A-Z0-9\_\.]+$/;const xS=new class extends n{mapping={};add(e,t){if(e=e.toUpperCase(),!wS.test(e))throw new Error(Bo("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const o=ld(t);return function(e){let t=!1,o=!1,s=!1;for(let i of e){if(i.type.includes("META")&&i.type.length>1)throw new Error(Bo("Function ${name} has an argument that has been declared with more than one type whose type 'META'. The 'META' type can only be declared alone."));if(t&&!i.repeating)throw new Error(Bo("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=o||t||s,n=!(i.optional||i.repeating||i.default);if(e&&n)throw new Error(Bo("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=i.repeating,o=i.optional,s=i.default}}(o.args),this.mapping[e]=function(e,t){function o(...o){const i=[];for(let s=0;s<o.length;s++){const n=e.args[e.getArgToFocus(s+1)-1];if(!yi(o[s])&&n.acceptMatrixOnly)throw new Ti(Bo("Function %s expects the parameter '%s' to be reference to a cell or range.",t,(s+1).toString()));i.push(!n.acceptMatrix)}return cn(s.bind(this),o,i)}function s(...o){for(let t=0;t<o.length;t++){const s=o[t];if(!e.args[e.getArgToFocus(t+1)-1].acceptErrors&&!yi(s)&&ki(s?.value))return s}try{return i.apply(this,o)}catch(e){return ES(e,t)}}function i(...o){this.debug;const s=e.compute.apply(this,o);return yi(s)?"object"==typeof s[0][0]&&null!==s[0][0]&&"value"in s[0][0]?(function(e,t){const o=e.length,s=e[0]?.length??0;for(let i=0;i<o;i++)for(let o=0;o<s;o++)t(e[i][o])}(s,(e=>IS(e,t))),s):an(s,(e=>({value:e}))):"object"==typeof s&&null!==s&&"value"in s?(IS(s,t),s):{value:s}}return o}(o,e),super.add(e,o),this}};for(let e of CS){const t=e.functions;for(let o in t){const s=t[o];s.category=s.category||e.name,o=o.replace(/_/g,"."),xS.add(o,{isExported:!1,...s})}}function ES(e,t){return o=e,void 0!==o?.value&&"string"==typeof o.value&&ki(e.value)?(TS(e)&&IS(e,t),e):(console.error(e),new Ri(RS+(TS(e)?" "+e.message:"")));var o}function IS(e,t){e.message?.includes("[[FUNCTION_NAME]]")&&(e.message=e.message.replace("[[FUNCTION_NAME]]",t))}const RS=Bo("An unexpected error occurred. Submit a support ticket at odoo.com/help.");function TS(e){return void 0!==e?.message&&"string"==typeof e.message}function AS(e,t,o){const{x:s,y:i,width:n,height:r}=o;if(n<0||r<0)return;const l=t.color||a,{ctx:c}=e;c.save(),t.noBorder||(t.dashed&&c.setLineDash([5,3]),c.strokeStyle=l,t.thinLine?(c.lineWidth=1,c.strokeRect(s,i,n,r)):(c.lineWidth=2,c.strokeRect(s+.5,i+.5,n,r))),t.noFill||(c.fillStyle=eo($t(l),t.fillAlpha??.12),c.fillRect(s,i,n,r)),c.restore()}sd.add("functions",{sequence:100,autoSelectFirstProposal:!0,maxDisplayedProposals:10,getProposals(e){if("SYMBOL"!==e.type)return[];const t=e.value;if(!this.composer.currentContent.startsWith("="))return[];const o=Object.entries(xS.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:o}])=>({text:e,description:o,htmlContent:id(t,e,I,"o-semi-bold")}))).sort(((e,t)=>e.text.length-t.text.length||e.text.localeCompare(t.text)));return o},selectProposal(e,t){let o=e.end,s=e.end;["SYMBOL","FUNCTION"].includes(e.type)&&(o=e.start);const i=this.composer.currentTokens;t+="(";const n=i.map((e=>e.start)).indexOf(e.start);if(n+1<i.length){const e=i[n+1];"LEFT_PAREN"===e?.type&&s++}this.composer.changeComposerCursorSelection(o,s),this.composer.replaceComposerCursorSelection(t)}});class _S extends th{mutators=["register","unRegister"];providers=[];constructor(e){super(e),this.onDispose((()=>{this.providers=[]}))}get renderingLayers(){return["Highlights"]}get highlights(){const e=this.getters.getActiveSheetId();return this.providers.flatMap((e=>e.highlights)).filter((t=>t.sheetId===e)).map((e=>{const{numberOfRows:t,numberOfCols:o}=is(e.zone),s=t*o==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:s}}))}register(e){this.providers.push(e)}unRegister(e){this.providers=this.providers.filter((t=>t!==e))}drawLayer(e,t){if("Highlights"===t)for(const t of this.highlights){AS(e,t,this.getters.getVisibleRect(t.zone))}}}class DS{mutators=["notifyUser","raiseError","askConfirmation","updateNotificationCallbacks"];notifyUser=e=>window.alert(e.text);askConfirmation=(e,t,o)=>{window.confirm(e)?t():o?.()};raiseError=(e,t)=>{window.alert(e),t?.()};updateNotificationCallbacks(e){this.notifyUser=e.notifyUser||this.notifyUser,this.raiseError=e.raiseError||this.raiseError,this.askConfirmation=e.askConfirmation||this.askConfirmation}}const OS="#000000",FS="#3da4ab",MS={OPERATOR:FS,NUMBER:"#02c39a",STRING:"#00a82d",FUNCTION:OS,DEBUGGER:FS,LEFT_PAREN:OS,RIGHT_PAREN:OS,ARG_SEPARATOR:OS,ORPHAN_RIGHT_PAREN:"#ff0000"};class PS extends th{mutators=["startEdition","setCurrentContent","stopEdition","stopComposerRangeSelection","cancelEdition","cycleReferences","toggleEditionMode","changeComposerCursorSelection","replaceComposerCursorSelection"];col=0;row=0;editionMode="inactive";sheetId="";_currentContent="";currentTokens=[];selectionStart=0;selectionEnd=0;initialContent="";colorIndexByRange={};notificationStore=this.get(DS);highlightStore=this.get(_S);constructor(e){super(e),this.highlightStore.register(this),this.onDispose((()=>{this.highlightStore.unRegister(this),this._cancelEdition()}))}handleEvent(e){const t=this.getters.getActiveSheetId();let o;if(o=e.options.unbounded?this.getters.getUnboundedZone(t,e.anchor.zone):e.anchor.zone,"newAnchor"===e.mode)"selecting"===this.editionMode&&this.insertSelectedRange(o);else"selecting"===this.editionMode?this.replaceSelectedRange(o):this.updateComposerRange(e.previousAnchor.zone,o)}changeComposerCursorSelection(e,t){this.isSelectionValid(this._currentContent.length,e,t)&&(this.selectionStart=e,this.selectionEnd=t,this.editionMode="editing",this.computeFormulaCursorContext(),this.computeParenthesisRelatedToCursor())}stopComposerRangeSelection(){this.isSelectingRange&&(this.editionMode="editing")}startEdition(e,t){if(t){const o=e||this.getComposerContent(this.getters.getActivePosition());if(!this.isSelectionValid(o.length,t.start,t.end))return}const{col:o,row:s}=this.getters.getActivePosition();this.model.dispatch("SELECT_FIGURE",{id:null}),this.model.dispatch("SCROLL_TO_CELL",{col:o,row:s}),"inactive"!==this.editionMode&&e?this.setContent(e,t):this._startEdition(e,t),this.updateTokenColor(),this.computeFormulaCursorContext(),this.computeParenthesisRelatedToCursor()}cancelEdition(){this.resetContent(),this.cancelEditionAndActivateSheet()}setCurrentContent(e,t){t&&!this.isSelectionValid(e.length,t.start,t.end)||(this.setContent(e,t,!0),this.updateTokenColor(),this.computeFormulaCursorContext(),this.computeParenthesisRelatedToCursor())}replaceComposerCursorSelection(e){this.replaceSelection(e)}handle(e){switch(e.type){case"SELECT_FIGURE":e.id&&(this.resetContent(),this.cancelEditionAndActivateSheet());break;case"START_CHANGE_HIGHLIGHT":const{left:t,top:o}=e.zone;this.isSelectingRange&&(this.editionMode="editing"),this.model.selection.resetAnchor(this,{cell:{col:t,row:o},zone:e.zone})}}get currentContent(){return"inactive"===this.editionMode?this.getComposerContent(this.getters.getActivePosition()):this._currentContent}get composerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}get isSelectingRange(){return"selecting"===this.editionMode}get showSelectionIndicator(){return this.isSelectingRange&&this.canStartComposerRangeSelection()}get tokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((o=>o.start<=e&&o.end>=t))}cycleReferences(){const e=this.getters.getLocale(),t=Sv(this.composerSelection,this._currentContent,e);void 0!==t&&this.setCurrentContent(t.content,t.selection)}toggleEditionMode(){if("inactive"===this.editionMode)return;const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd),o=[...this.currentTokens].reverse().find((o=>o.end>=e&&t>=o.start&&"REFERENCE"===o.type));if("editing"===this.editionMode&&o){const e=this.getters.getActiveSheetId(),{sheetName:t,xc:s}=jr(o.value),i=this.getters.getSheetIdByName(t);i&&i!==e&&this.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e,sheetIdTo:i}),this.selectionStart=this.selectionEnd=o.end;const n=this.getters.getRangeFromSheetXC(this.sheetId,s).zone;this.captureSelection(n),this.editionMode="selecting"}else this.editionMode="editing"}captureSelection(e,t,o){this.model.selection.capture(this,{cell:{col:t??e.left,row:o??e.right},zone:e},{handleEvent:this.handleEvent.bind(this),release:()=>{this._stopEdition()}})}isSelectionValid(e,t,o){return t>=0&&t<=e&&o>=0&&o<=e}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=ds({col:this.col,row:this.row});this.model.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.editionMode="selecting"}_startEdition(e,t){const o=this.getters.getActiveCell(),s=this.getters.getLocale();e&&o.format?.includes("%")&&ei(e,s)&&(t=t||{start:e.length,end:e.length},e=`${e}%`);const{col:i,row:n,sheetId:r}=this.getters.getActivePosition();this.col=i,this.sheetId=r,this.row=n,this.initialContent=this.getComposerContent({sheetId:r,col:i,row:n}),this.editionMode="editing",this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const a=ds({col:this.col,row:this.row});this.captureSelection(a,i,n)}_stopEdition(){if("inactive"!==this.editionMode){this.cancelEditionAndActivateSheet();let e=this.getCurrentCanonicalContent();if(!(this.initialContent!==e))return;if(e&&e.startsWith("=")){const t=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length-this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length;t>0&&(e+=ut(new Array(t).fill(")")))}this.confirmEdition(e)}}getCurrentCanonicalContent(){return el(this._currentContent,this.getters.getLocale())}cancelEditionAndActivateSheet(){if("inactive"===this.editionMode)return;this._cancelEdition();this.getters.getActiveSheetId()!==this.sheetId&&this.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}_cancelEdition(){"inactive"!==this.editionMode&&(this.editionMode="inactive",this.model.selection.release(this),this.colorIndexByRange={})}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,o){const s=this._currentContent!==e;if(this._currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,s||"inactive"!==this.editionMode){const t=this.getters.getLocale();this.currentTokens=e.startsWith("=")?pv(e,t):[],this.currentTokens.length>100&&o&&this.notificationStore.raiseError(Bo("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells"))}this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}getAutoCompleteProviders(){return sd.getAll()}insertSelectedRange(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=this.getZoneReference(e);this.canStartComposerRangeSelection()?this.insertText(o,t):this.insertText(","+o,t)}replaceSelectedRange(e){const t=this.getZoneReference(e),o=this.tokenAtCursor,s="REFERENCE"===o?.type?o.start:this.selectionStart;this.replaceText(t,s,this.selectionEnd)}updateComposerRange(e,t){const o=this.getters.getActiveSheetId(),s=this.tokenAtCursor,i=(s?[s,...this.currentTokens]:this.currentTokens).filter((e=>"REFERENCE"===e.type)).find((t=>{const{xc:s,sheetName:i}=jr(t.value),n=i||this.getters.getSheetName(this.sheetId);if(!aa(this.getters.getSheetName(o),n))return!1;const r=this.getters.getRangeFromSheetXC(o,s);return es(this.getters.expandZone(o,r.zone),e)}));if(!i)return;const n=this.getters.getRangeFromSheetXC(o,i.value);this.selectionStart=i.start,this.selectionEnd=this.selectionStart+i.value.length;const r=this.getters.getRangeFromZone(o,t),a=this.getRangeReference(r,n.parts);this.replaceSelection(a)}getZoneReference(e){const t=this.sheetId,o=this.getters.getActiveSheetId(),s=this.getters.getRangeFromZone(o,e);return this.getters.getSelectionRangeString(s,t)}getRangeReference(e,t){let o=[...t];const s=e.clone({parts:o});return this.getters.getSelectionRangeString(s,this.sheetId)}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,o)}replaceText(e,t,o){this._currentContent=this._currentContent.slice(0,t)+this._currentContent.slice(o,this._currentContent.length),this.insertText(e,t)}insertText(e,t){const o=this._currentContent.slice(0,t)+e+this._currentContent.slice(t),s=t+e.length;this.setCurrentContent(o,{start:s,end:s})}updateTokenColor(){this.updateRangeColor();for(let e=0;e<this.currentTokens.length;e++)this.currentTokens[e].color=this.getTokenColor(this.currentTokens[e])}getTokenColor(e){if("REFERENCE"===e.type){const{xc:t,sheetName:o}=jr(e.value);return this.rangeColor(t,o)||OS}if("SYMBOL"===e.type){const t=e.value.toUpperCase();if("TRUE"===t||"FALSE"===t)return MS.NUMBER;if(t in xS.content)return MS.FUNCTION}return["LEFT_PAREN","RIGHT_PAREN"].includes(e.type)&&""===e.parenthesesCode?MS.ORPHAN_RIGHT_PAREN:MS[e.type]||OS}rangeColor(e,t){const o=t?this.model.getters.getSheetIdByName(t):this.sheetId,s=this.highlights.find((t=>{if(t.sheetId!==o)return!1;let s=this.model.getters.getRangeFromSheetXC(o,e).zone;return s=1===ps(s)?this.model.getters.expandZone(o,s):s,es(s,t.zone)}));return s&&s.color?s.color:void 0}computeFormulaCursorContext(){for(let e=0;e<this.currentTokens.length;e++)this.currentTokens[e].isBlurred=!1;if(this.selectionStart!==this.selectionEnd)return;const e=this.getParenthesesCodeAfterCursor(),t=[...this.currentTokens].reverse().find((t=>e.startsWith(t.parenthesesCode)&&"SYMBOL"===t.type));if(t)for(let e=0;e<this.currentTokens.length;e++)(this.currentTokens[e].parenthesesCode||"").startsWith(t.parenthesesCode||"")||(this.currentTokens[e].isBlurred=!0)}getParenthesesCodeAfterCursor(){const e=this.tokenAtCursor?.parenthesesCode||"";return"RIGHT_PAREN"===this.tokenAtCursor?.type?e.slice(0,-1)||"":e}computeParenthesisRelatedToCursor(){for(let e=0;e<this.currentTokens.length;e++)this.currentTokens[e].isParenthesisLinkedToCursor=!1;const e=this.tokenAtCursor;if(e&&""!==e.parenthesesCode&&["LEFT_PAREN","RIGHT_PAREN"].includes(e.type))for(let t=0;t<this.currentTokens.length;t++){const o=this.currentTokens[t];["LEFT_PAREN","RIGHT_PAREN"].includes(o.type)&&o.parenthesesCode===e.parenthesesCode&&o!==e&&(this.currentTokens[t].isParenthesisLinkedToCursor=!0,this.tokenAtCursor.isParenthesisLinkedToCursor=!0)}}updateRangeColor(){if(!this._currentContent.startsWith("=")||"inactive"===this.editionMode)return;const e=this.sheetId,t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),o={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(o[e]=this.colorIndexByRange[e]);const s=new Set(Object.values(o));let i=0;const n=()=>{for(;s.has(i);)i++;return s.add(i),i};for(const e of t){const t=e in o?o[e]:n();o[e]=t}this.colorIndexByRange=o}get highlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.editionMode)return[];const e=this.sheetId,t=e=>{const t=this.colorIndexByRange[e];return Ut[t%Ut.length]};return this.getReferencedRanges().map((o=>{const s=this.getters.getRangeString(o,e),{numberOfRows:i,numberOfCols:n}=is(o.zone);return{zone:i*n==1?this.getters.expandZone(o.sheetId,o.zone):o.zone,color:t(s),sheetId:o.sheetId,interactive:!0}}))}getReferencedRanges(){const e=this.sheetId;return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value))).filter((e=>!e.invalidSheetName&&!e.invalidXc))}get autocompleteProvider(){const e=this.currentContent,t=e.startsWith("=")?this.tokenAtCursor:{type:"STRING",value:e};if("inactive"===this.editionMode||!t||["TRUE","FALSE"].includes(t.value.toUpperCase())||!this.canStartComposerRangeSelection()&&!["SYMBOL","STRING","UNKNOWN"].includes(t.type))return;const o={composer:this,getters:this.getters},s=this.getAutoCompleteProviders().sort(((e,t)=>(e.sequence??1/0)-(t.sequence??1/0))).map((s=>({...s,getProposals:s.getProposals.bind(o,t,e),selectProposal:s.selectProposal.bind(o,t)})));for(const e of s){let o=e.getProposals();const s=o?.find((e=>e.text===t.value)),i=t.value.replace(/[ ,\(\)]/g,"");if(this._currentContent===this.initialContent&&e.displayAllOnInitialContent&&o?.length)return{proposals:o,selectProposal:e.selectProposal,autoSelectFirstProposal:e.autoSelectFirstProposal??!1,canBeToggled:e.canBeToggled};if(s&&this._currentContent!==this.initialContent)return;if(i&&o&&!["ARG_SEPARATOR","LEFT_PAREN","OPERATOR"].includes(t.type)){const e=ta(i,o,(e=>e.fuzzySearchKey||e.text));s&&!e.length||(o=e)}if(e.maxDisplayedProposals&&(o=o?.slice(0,e.maxDisplayedProposals)),o?.length)return{proposals:o,selectProposal:e.selectProposal,autoSelectFirstProposal:e.autoSelectFirstProposal??!1,canBeToggled:e.canBeToggled}}}canStartComposerRangeSelection(){if(this._currentContent.startsWith("=")){const e=this.tokenAtCursor;if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let o=t,s=e;for(;!["ARG_SEPARATOR","LEFT_PAREN","OPERATOR"].includes(s.type)||Na.includes(s.value);){if("SPACE"!==s.type||o<1)return!1;o--,s=this.currentTokens[o]}for(o=t+1,s=this.currentTokens[o];s&&!["ARG_SEPARATOR","RIGHT_PAREN","OPERATOR"].includes(s.type);){if("SPACE"!==s.type)return!1;o++,s=this.currentTokens[o]}return!0}return!1}}class NS{scope;code="";constructor(e=new VS){this.scope=e}append(...e){this.code+=e.map((e=>e.toString())).join("\n")+"\n"}return(e){return new kS(this.scope,this.code,e)}toString(){return LS(this.code)}}class kS{scope;returnExpression;code;constructor(e,t,o){this.scope=e,this.returnExpression=o,this.code=LS(t)}toString(){return this.code}assignResultToVariable(){if(this.scope.isAlreadyDeclared(this.returnExpression))return this;const e=this.scope.nextVariableName(),t=new NS(this.scope);return t.append(this.code),t.append(`const ${e} = ${this.returnExpression};`),t.return(e)}}class VS{nextId=1;declaredVariables=new Set;nextVariableName(){const e="_"+this.nextId++;return this.declaredVariables.add(e),e}isAlreadyDeclared(e){return this.declaredVariables.has(e)}}function LS(e){let t="",o=0;const s=e.split("\n").map((e=>e.trim())).filter((e=>""!==e));for(const e of s)e.startsWith("}")&&o--,t+="\t".repeat(o)+e+"\n",e.endsWith("{")&&o++;return t.trim()}const HS=xS.content,US={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},BS={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"},zS={};function $S(e){return GS(Yf(e))}function GS(e){try{return function(e){const{dependencies:t,literalValues:o,symbols:s}=function(e){const t={numbers:[],strings:[]},o=[],s=[];for(const i of e)switch(i.type){case"INVALID_REFERENCE":case"REFERENCE":o.push(i.value);break;case"STRING":const e=Ue(i.value);t.strings.push({value:e});break;case"NUMBER":{const e=oi(i.value,bi);t.numbers.push({value:e});break}case"SYMBOL":s.push(Ge(i.value,"'"))}return{dependencies:o,literalValues:t,symbols:s}}(e),i=function(e){let t="";for(const o of e)switch(o.type){case"STRING":t+="|S|";break;case"NUMBER":t+="|N|";break;case"REFERENCE":case"INVALID_REFERENCE":o.value.includes(":")?t+="|R|":t+="|C|";break;case"SPACE":break;default:t+=o.value}return t}(e);if(!zS[i]){const r=rv([...e]),a=new VS;let l=0,c=0,h=0;if("BIN_OPERATION"===r.type&&":"===r.value)throw new Ti(Bo("Invalid formula"));if("EMPTY"===r.type)throw new Ti(Bo("Invalid formula"));const d=m(r),u=new NS;u.append(`// ${i}`),u.append(d),u.append(`return ${d.returnExpression};`);let g=new Function("deps","ref","range","getSymbolValue","ctx",u.toString());function p(e){const{args:t}=e,o=e.value.toUpperCase(),s=HS[o];if(!s)throw new Oi(Bo('Unknown function: "%s"',e.value));!function(e){const t=e.args.length,o=e.value.toUpperCase(),s=HS[o];if(t<s.minArgRequired)throw new Ti(Bo("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",o,s.minArgRequired.toString(),t.toString()));if(t>s.maxArgPossible)throw new Ti(Bo("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",o,s.maxArgPossible.toString(),t.toString()));const i=s.nbrArgRepeating;if(i>1){const e=s.args.length-i;if((t-e)%i!=0)throw new Ti(Bo("Invalid number of arguments for the %s function. Expected all arguments after position %s to be supplied by groups of %s arguments",o,e.toString(),i.toString()))}}(e);const i=[];for(let e=0;e<t.length;e++){const o=s.getArgToFocus(e+1)-1,n=s.args[o],r=t[e],a=n.type||[],l=a.includes("META"),c=a.some((e=>WS(e)));i.push(m(r,l,c))}return i}function m(e,t=!1,o=!1){const i=new NS(a);if("REFERENCE"!==e.type&&("BIN_OPERATION"!==e.type||":"!==e.value)&&t)throw new Ti(Bo("Argument must be a reference to a cell or range."));switch(e.debug&&(i.append("debugger;"),i.append('ctx["debug"] = true;')),e.type){case"BOOLEAN":return i.return(`{ value: ${e.value} }`);case"NUMBER":return i.return(`this.literalValues.numbers[${c++}]`);case"STRING":return i.return(`this.literalValues.strings[${l++}]`);case"REFERENCE":return!t&&e.value.includes(":")||o?i.return(`range(deps[${h++}])`):i.return(`ref(deps[${h++}], ${t?"true":"false"})`);case"FUNCALL":const n=p(e).map((e=>e.assignResultToVariable()));i.append(...n);const r=e.value.toUpperCase();return i.return(`ctx['${r}'](${n.map((e=>e.returnExpression))})`);case"UNARY_OPERATION":{const t=BS[e.value],o=m(e.operand,!1,!1).assignResultToVariable();return i.append(o),i.return(`ctx['${t}'](${o.returnExpression})`)}case"BIN_OPERATION":{const t=US[e.value],o=m(e.left,!1,!1).assignResultToVariable(),s=m(e.right,!1,!1).assignResultToVariable();return i.append(o),i.append(s),i.return(`ctx['${t}'](${o.returnExpression}, ${s.returnExpression})`)}case"SYMBOL":const a=s.indexOf(e.value);return i.return(`getSymbolValue(this.symbols[${a}])`);case"EMPTY":return i.return("undefined")}}zS[i]=g}const n={execute:zS[i],dependencies:t,literalValues:o,symbols:s,tokens:e,isBadExpression:!1,normalizedFormula:i};return n}(e)}catch(t){return{tokens:e,dependencies:[],execute:function(){return t},isBadExpression:!0,normalizedFormula:e.map((e=>e.value)).join("")}}}function WS(e){return e.startsWith("RANGE")}const qS=xS.content;function ZS(e){try{return 0===lv(rv(e)).filter((e=>"FUNCALL"===e.type&&!qS[e.value.toUpperCase()]?.isExported)).length}catch(e){return!1}}function jS(e,t){if(!e.some((e=>"SYMBOL"===e.type&&t.includes(e.value.toUpperCase()))))return[];let o;try{o=rv(e)}catch{return[]}return function(e,t){return lv(e).filter((e=>"FUNCALL"===e.type&&t.includes(e.value.toUpperCase()))).map((e=>({functionName:e.value.toUpperCase(),args:e.args})))}(o,t)}const YS=["PIVOT.VALUE","PIVOT.HEADER","PIVOT"];function XS(e,t){const o=`"${t?`${e.name}:${t}`:e.name}"`,s=e.string!==e.name?e.string+o:o;return{text:o,description:e.string+(e.help?` (${e.help})`:""),htmlContent:[{value:o,color:MS.STRING}],fuzzySearchKey:s}}function KS(e,t){let o=e.end;const s=e.end;"ARG_SEPARATOR"!==e.type&&(o=e.start),this.composer.changeComposerCursorSelection(o,s),this.composer.replaceComposerCursorSelection(t)}function JS(e,t){let o=e.end;const s=e.end;"LEFT_PAREN"!==e.type&&(o=e.start),this.composer.changeComposerCursorSelection(o,s),this.composer.replaceComposerCursorSelection(t)}function QS(e){const t=e.functionContext?.args[0];if(t&&["STRING","NUMBER"].includes(t.type))return t.value}function ey(e){return jS(e,YS)[0]}function ty(e){return jS(e,YS).length}const oy=new n;oy.add("SPREADSHEET",!1),sd.add("pivot_ids",{sequence:50,autoSelectFirstProposal:!0,getProposals(e){const t=e.functionContext;if(!t||!["PIVOT.VALUE","PIVOT.HEADER","PIVOT"].includes(t.parent.toUpperCase())||0!==t.argPosition)return;const o=this.getters.getPivotIds();return o.includes(e.value)?void 0:o.map((e=>{const t=this.getters.getPivotCoreDefinition(e),o=`${this.getters.getPivotFormulaId(e)}`;return{text:o,description:t.name,htmlContent:[{value:o,color:MS.NUMBER}],fuzzySearchKey:o+t.name,alwaysExpanded:!0}})).filter(lt)},selectProposal:JS}),sd.add("pivot_measures",{sequence:50,autoSelectFirstProposal:!0,getProposals(e){const t=e.functionContext;if("PIVOT.VALUE"!==t?.parent.toUpperCase()||1!==t.argPosition)return[];const o=QS(e),s=this.getters.getPivotId(o);if(!s||!this.getters.isExistingPivot(s))return[];const i=this.getters.getPivot(s);return i.init(),i.isValid()?i.definition.measures.map((e=>{if("__count"===e.fieldName){const e='"__count"';return{text:e,description:Bo("Count"),htmlContent:[{value:e,color:MS.STRING}],fuzzySearchKey:Bo("Count")+e}}return function(e){const t=`"${e.id}"`,o=e.displayName+e.fieldName+t;return{text:t,description:e.displayName,htmlContent:[{value:t,color:MS.STRING}],fuzzySearchKey:o}}(e)})).filter(lt):[]},selectProposal:KS}),sd.add("pivot_group_fields",{sequence:50,autoSelectFirstProposal:!0,getProposals(e){const t=e.functionContext;if(!t||!function(e){const t=e.functionContext;return"PIVOT.VALUE"===t?.parent.toUpperCase()&&t.argPosition>=2&&t.argPosition%2==0}(e)&&!function(e){const t=e.functionContext;return"PIVOT.HEADER"===t?.parent.toUpperCase()&&t.argPosition>=1&&t.argPosition%2==1}(e))return;const o=QS(e),s=this.getters.getPivotId(o);if(!s||!this.getters.isExistingPivot(s))return;const i=this.getters.getPivot(s);i.init();const n=i.getFields(),{columns:r,rows:a}=i.definition;let l=t.args;"PIVOT.VALUE"===t?.parent.toUpperCase()?(l=l.filter(((e,t)=>t%2==0)),l=l.slice(1,t.argPosition)):l=l.filter(((e,t)=>t%2==1));const c=l.map((e=>e?.value)).filter(lt),h=r.map((e=>e.nameWithGranularity)),d=a.map((e=>e.nameWithGranularity)),u=[];let g=["ARG_SEPARATOR","SPACE"].includes(e.type)?c.at(-1):c.at(-2);const p=oy.get(i.type);if(p&&g?.startsWith("#")&&(g=g.slice(1)),void 0===g&&(u.push(h[0]),u.push(d[0])),d.includes(g)){const e=d[d.indexOf(g)+1];u.push(e),u.push(h[0])}if(h.includes(g)){const e=h[h.indexOf(g)+1];u.push(e)}const m=u.filter(lt);return m.map((e=>{const[t,o]=e.split(":"),s=n[t];return s?XS(s,o):void 0})).concat(m.map((e=>{if(!p)return;const t=e.split(":")[0],o=n[t];if(!o)return;const s=`"#${e}"`;return{text:s,description:Bo("%s (positional)",o.string)+(o.help?` (${o.help})`:""),htmlContent:[{value:s,color:MS.STRING}],fuzzySearchKey:o.string+s}}))).filter(lt)},selectProposal:KS}),sd.add("pivot_group_values",{sequence:50,autoSelectFirstProposal:!0,getProposals(e){const t=e.functionContext;if(!t||!e||!function(e){const t=e.functionContext;return"PIVOT.VALUE"===t?.parent.toUpperCase()&&t.argPosition>=2&&t.argPosition%2==1}(e)&&!function(e){const t=e.functionContext;return"PIVOT.HEADER"===t?.parent.toUpperCase()&&t.argPosition>=1&&t.argPosition%2==0}(e))return;const o=QS(e),s=this.getters.getPivotId(o);if(!s||!this.getters.isExistingPivot(s))return;const i=this.getters.getPivot(s);if(!i.isValid())return;const n=t.argPosition,r=e.functionContext?.args[n-1]?.value;if(!r)return;let a;try{a=i.definition.getDimension(r)}catch(e){return}return"month_number"===a.granularity?Object.values(Kn).map(((e,t)=>({text:`${t+1}`,fuzzySearchKey:e.toString(),description:e.toString(),htmlContent:[{value:`${t+1}`,color:MS.NUMBER}]}))):"quarter_number"===a.granularity?[1,2,3,4].map((e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:Bo("Quarter %s",e),htmlContent:[{value:`${e}`,color:MS.NUMBER}]}))):"day_of_month"===a.granularity?je(1,32).map((e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:"",htmlContent:[{value:`${e}`,color:MS.NUMBER}]}))):"iso_week_number"===a.granularity?je(0,54).map((e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:"",htmlContent:[{value:`${e}`,color:MS.NUMBER}]}))):"day_of_week"===a.granularity?je(1,8).map((e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:"",htmlContent:[{value:`${e}`,color:MS.NUMBER}]}))):"hour_number"===a.granularity?je(0,24).map((e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:"",htmlContent:[{value:`${e}`,color:MS.NUMBER}]}))):"minute_number"===a.granularity?je(0,60).map((e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:"",htmlContent:[{value:`${e}`,color:MS.NUMBER}]}))):"second_number"===a.granularity?je(0,60).map((e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:"",htmlContent:[{value:`${e}`,color:MS.NUMBER}]}))):i.getPossibleFieldValues(a).map((({value:e,label:t})=>{const o="string"==typeof e,s=o?`"${e}"`:e.toString(),i=t===e?"":t;return{text:s,description:i,htmlContent:[{value:s,color:o?MS.STRING:MS.NUMBER}],fuzzySearchKey:s+i}}))},selectProposal:KS}),sd.add("sheet_names",{sequence:150,autoSelectFirstProposal:!0,getProposals(e){return"SYMBOL"===e.type||"UNKNOWN"===e.type&&e.value.startsWith("'")?this.getters.getSheetIds().map((e=>{const t=We(this.getters.getSheetName(e));return{text:t,fuzzySearchKey:t.startsWith("'")?t:"'"+t}})):[]},selectProposal(e,t){const o=e.start,s=e.end;this.composer.changeComposerCursorSelection(o,s),this.composer.replaceComposerCursorSelection(t+"!")}});const sy=new n;sy.add("ALPHANUMERIC_INCREMENT_MODIFIER",{apply:(e,t)=>{e.current+=e.increment;const o=`${e.prefix}${e.current.toString().padStart(e.numberPostfixLength||0,"0")}`;return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:o},tooltip:{props:{content:o}}}}}).add("INCREMENT_MODIFIER",{apply:(e,t,o)=>{e.current+=e.increment;const s=e.current.toString(),i=o.getLocale(),n=Qn(e.current,{format:t.cell?.format,locale:i});return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:s},tooltip:s?{props:{content:n}}:void 0}}}).add("DATE_INCREMENT_MODIFIER",{apply:(e,t,o)=>{const s=Xi(e.current,o.getLocale());s.setFullYear(s.getFullYear()+e.increment.years||0),s.setMonth(s.getMonth()+e.increment.months||0),s.setDate(s.getDate()+e.increment.days||0);const i=zs(s);e.current=i;const n=o.getLocale(),r=Qn(i,{format:t.cell?.format,locale:n});return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:i.toString()},tooltip:i?{props:{content:r}}:void 0}}}).add("COPY_MODIFIER",{apply:(e,t,o)=>{const s=t.cell?.content||"",i={locale:o.getLocale(),format:t.cell?.format};return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:s},tooltip:s?{props:{content:t.cell?Rr(t.cell,i).formattedValue:""}}:void 0}}}).add("FORMULA_MODIFIER",{apply:(e,t,o,s)=>{e.current+=e.increment;let i=0,n=0;switch(s){case"up":i=0,n=-e.current;break;case"down":i=0,n=e.current;break;case"left":i=-e.current,n=0;break;case"right":i=e.current,n=0}const r=t.cell;if(!r||!r.isFormula)return{cellData:{}};const a=t.sheetId,l=o.getTranslatedCellFormula(a,i,n,r.compiledFormula.tokens);return{cellData:{border:t.border,style:r.style,format:r.format,content:l},tooltip:l?{props:{content:l}}:void 0}}});const iy=new n,ny=/(\d+)$/,ry=/^(.*\D+)/,ay=/^(.*\D+)(\d+)$/;function ly(e,t,o){let s=[],i=!1;for(let n of t){n===e&&(i=!0);const t=void 0===n||n.isFormula?void 0:Rr(n,{locale:bi,format:n.format});if(t&&o(t))s.push(t);else{if(i)return s;s=[]}}return s}function cy(e){let t=1;return e.length>=2&&(t=function(e){const t=[];let o=e[0];for(let s=1;s<e.length;s++){const i=e[s];t.push(i-o),o=i}return t.reduce(((e,t)=>e+t),0)/t.length}(e)*e.length),t}function hy(e){if(e.length<2)return 1;const t=e.map((e=>Xi(e,bi))),o=function(e){if(e.length<2)return[{years:0,months:0,days:0}];const t=e.map(((t,o)=>{if(0===o)return{years:0,months:0,days:0};const s=xs.fromTimestamp(e[o-1].getTime()),i=Xs(s,t),n=js(s,t)%12;s.setFullYear(s.getFullYear()+i),s.setMonth(s.getMonth()+n);return{years:i,months:n,days:Ys(s,t)}}));return t.slice(1)}(t),s=(i=o).length<2?i[0]||{years:0,months:0,days:0}:i.every((e=>e.years===i[0].years&&e.months===i[0].months&&e.days===i[0].days))?i[0]:void 0;var i;if(void 0===s)return;const n=1===Object.values(s).filter((e=>0!==e)).length,r=Object.values(s).every((e=>0===e));if(!n||r){const o=t.map(((e,o)=>{if(0===o)return 0;const s=t[o-1];return Math.floor(e.getTime())-Math.floor(s.getTime())})).slice(1);if(o.every((e=>e===o[0])))return e.length*(e[1]-e[0])}return{years:s.years*e.length,months:s.months*e.length,days:s.days*e.length}}iy.add("simple_value_copy",{condition:(e,t)=>!(1!==t.length||e.isFormula||e.format&&ar(e.format)),generateRule:()=>({type:"COPY_MODIFIER"}),sequence:10}).add("increment_alphanumeric_value",{condition:e=>!e.isFormula&&Rr(e,{locale:bi}).type===ii.text&&ay.test(e.content),generateRule:(e,t,o)=>{const s=parseInt(e.content.match(ny)[0]),i=e.content.match(ry)[0],n=e.content.length-i.length,r=ly(e,t,(e=>e.type===ii.text&&ay.test(e.value))).filter((e=>i===(e.value??"").toString().match(ry)[0])).map((e=>parseInt((e.value??"").toString().match(ny)[0])));let a=cy(r);return["up","left"].includes(o)&&1===r.length&&(a=-a),{type:"ALPHANUMERIC_INCREMENT_MODIFIER",prefix:i,current:s,increment:a,numberPostfixLength:n}},sequence:15}).add("copy_text",{condition:e=>!e.isFormula&&Rr(e,{locale:bi}).type===ii.text,generateRule:()=>({type:"COPY_MODIFIER"}),sequence:20}).add("update_formula",{condition:e=>e.isFormula,generateRule:(e,t)=>({type:"FORMULA_MODIFIER",increment:t.length,current:0}),sequence:30}).add("increment_dates",{condition:(e,t)=>!e.isFormula&&Rr(e,{locale:bi}).type===ii.number&&!!e.format&&ar(e.format),generateRule:(e,t)=>{const o=hy(ly(e,t,(e=>e.type===ii.number&&!!e.format&&ar(e.format))).map((e=>Number(e.value))));if(void 0===o)return{type:"COPY_MODIFIER"};const s=Rr(e,{locale:bi});return"object"==typeof o?{type:"DATE_INCREMENT_MODIFIER",increment:o,current:s.type===ii.number?s.value:0}:{type:"INCREMENT_MODIFIER",increment:o,current:s.type===ii.number?s.value:0}},sequence:25}).add("increment_number",{condition:e=>!e.isFormula&&Rr(e,{locale:bi}).type===ii.number,generateRule:(e,t,o)=>{const s=ly(e,t,(e=>e.type===ii.number&&!ar(e.format||""))).map((e=>Number(e.value)));let i=cy(s);["up","left"].includes(o)&&1===s.length&&(i=-i);const n=Rr(e,{locale:bi});return{type:"INCREMENT_MODIFIER",increment:i,current:n.type===ii.number?n.value:0}},sequence:40});const dy=new n,uy=30,gy=10,py=20,my=12,fy=80,vy="#F3F2F1",by=6,Sy=25;function yy(e,t){const o=e.getBoundingClientRect(),s=window.devicePixelRatio||1;e.width=s*o.width,e.height=s*o.height;const i=e.getContext("2d");i.scale(s,s);const n=function(e,t,o){const s=t.maxValue,i=t.minValue,n=t.gaugeValue,r=function(e,t){const o=t?Sy:0,s=e.height-py-o-gy,i=e.width-2*uy;let n,r;i>2*s?(n=2*s,r=s):(n=i,r=i/2);const a=o+gy+(s-r)/2;return{x:uy+(i-n)/2,y:a,width:n,height:r}}(e,t.title.text),a=r.width/6,l=n?(n.value-i.value)/(s.value-i.value):0,c={x:e.width/2,y:r.y+r.height-r.height/12};let h=fy;r.height<300&&(h*=r.height/300);const d=r.width/2,u=n?.label||"-";ua(o,u,{fontSize:h},"px")>d&&(h=function(e,t,o,s=.25){let i=1;if(o(i)>e)return i;if(o(t)<e)return t;let n=(i+t)/2,r=o(n),a=0;for(;Math.abs(r-e)>s&&a<20;)r>=e?t=(i+t)/2:i=(i+t)/2,n=(i+t)/2,r=o(n),a++;return n}(d,h,(e=>ua(o,u,{fontSize:e},"px"))));const g={x:r.x+a/2,y:r.y+r.height+my},p={x:r.x+r.width-a/2,y:r.y+r.height+my},m=Eh(t.background),f=function(e,t,o,s){const i=e.maxValue,n=e.minValue,r={x:t.x+t.width/2,y:t.y+t.height},a={fontSize:my},l=[],c=[];for(const h of e.inflectionValues){const e=(h.value-n.value)/(i.value-n.value),d=ua(s,h.label,a,"px"),u=Math.PI-Math.PI*e,g=Iy(u,t.height+by,r.x,r.y,d+2,my);let p=c.some((e=>Ey(e,g)))?my:0;c.push(g),l.push({rotation:u,label:h.label,fontSize:my,color:o,offset:p})}return l}(t,r,m,o);let v=0,b=0,S=0;t.title.text&&({width:b,height:S}=ma(o,t.title.text,{fontSize:X,...t.title},"px"));switch(t.title.align){case"right":v=e.width-b-Z;break;case"center":v=(e.width-b)/2;break;default:v=Z}return{width:e.width,height:e.height,title:{label:t.title.text??"",fontSize:t.title.fontSize??X,textPosition:{x:v,y:Y+S/2},color:t.title.color??m,bold:t.title.bold,italic:t.title.italic},backgroundColor:t.background,gauge:{rect:r,arcWidth:a,percentage:Ze(l,0,1),color:Cy(t)},inflectionValues:f,gaugeValue:{label:u,textPosition:c,fontSize:h,color:m},minLabel:{label:t.minValue.label,textPosition:g,fontSize:my,color:m},maxLabel:{label:t.maxValue.label,textPosition:p,fontSize:my,color:m}}}(o,t,i);!function(e,t){e.save(),e.fillStyle=t.backgroundColor,e.fillRect(0,0,t.width,t.height),e.restore()}(i,n),function(e,t){e.save();const o=t.gauge,s=o.rect.x+o.rect.width/2,i=o.rect.y+o.rect.height,n=o.rect.height-o.arcWidth/2;if(n<0)return;const r=1===o.percentage?0:Math.PI*(1+o.percentage);e.strokeStyle=vy,e.beginPath(),e.lineWidth=o.arcWidth,e.arc(s,i,n,r,0),e.stroke(),e.strokeStyle=o.color,e.beginPath(),e.arc(s,i,n,Math.PI,r),e.stroke(),e.restore()}(i,n),function(e,t){const{x:o,y:s,width:i,height:n}=t.gauge.rect;for(const r of t.inflectionValues){e.save(),e.translate(o+i/2-.5,s+n-.5),e.rotate(Math.PI/2-r.rotation),e.lineWidth=2,e.strokeStyle=Eh(t.backgroundColor)+"aa",e.beginPath(),e.moveTo(0,-(n-t.gauge.arcWidth)),e.lineTo(0,-n-3),e.stroke(),e.textAlign="center",e.font=`${r.fontSize}px ${ve}`,e.fillStyle=r.color;const a=-n-by-r.offset;e.fillText(r.label,0,a),e.restore()}}(i,n),function(e,t){for(const o of[t.minLabel,t.maxLabel,t.gaugeValue])e.save(),e.textAlign="center",e.fillStyle=o.color,e.font=`${o.fontSize}px ${ve}`,e.fillText(o.label,o.textPosition.x,o.textPosition.y),e.restore()}(i,n),function(e,t){e.save();const o=t.title;e.font=ha(o.fontSize,o.bold,o.italic),e.textBaseline="middle",e.fillStyle=o.color,e.fillText(o.label,o.textPosition.x,o.textPosition.y),e.restore()}(i,n)}function Cy(e){const t=e.gaugeValue?.value;if(void 0===t)return vy;for(let o=0;o<e.inflectionValues.length;o++){const s=e.inflectionValues[o];if("<"===s.operator&&t<s.value)return e.colors[o];if("<="===s.operator&&t<=s.value)return e.colors[o]}return e.colors.at(-1)}function wy(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 xy(e,t){const o=e.start,s=e.end,i=t.start,n=t.end;function r(e,t,o){return(o.y-e.y)*(t.x-e.x)>(t.y-e.y)*(o.x-e.x)}return r(o,i,n)!==r(s,i,n)&&r(o,s,i)!==r(o,s,n)}function Ey(e,t){const o=wy(e),s=wy(t);for(const e of o)for(const t of s)if(xy(e,t))return!0;return!1}function Iy(e,t,o,s,i,n){const r=Math.cos(e),a=Math.sin(e),l=r*t,c=a*t,h=a*(i/2),d=r*(i/2),u=r*(t+n),g=a*(t+n);return{bottomLeft:{x:l-h+o,y:s-(c+d)},bottomRight:{x:l+h+o,y:s-(c-d)},topRight:{x:u+h+o,y:s-(g-d)},topLeft:{x:u-h+o,y:s-(g+d)}}}class Ry extends t.Component{static template="o-spreadsheet-GaugeChartComponent";canvas=t.useRef("chartContainer");get runtime(){return this.env.model.getters.getChartRuntime(this.props.figure.id)}setup(){t.useEffect((()=>yy(this.canvas.el,this.runtime)),(()=>{const e=this.canvas.el.getBoundingClientRect();return[e.width,e.height,this.runtime,this.canvas.el,window.devicePixelRatio]}))}}function Ty(e){return 8===(e=$t(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}Ry.props={figure:Object};const Ay={responsive:!0,maintainAspectRatio:!1,elements:{line:{fill:!1},point:{hitRadius:15}},animation:!1,events:["mousemove","mouseout","click","touchstart","touchmove","mouseup"]};function _y(e,t,o){const s=document.createElement("div");s.style.width=`${t.width}px`,s.style.height=`${t.height}px`;const i=document.createElement("canvas");if(s.append(i),i.setAttribute("width",t.width.toString()),i.setAttribute("height",t.height.toString()),document.body.append(s),"chartJsConfig"in e){const t=ze(e.chartJsConfig);t.plugins=[Dy];const o=new window.Chart(i,t),n=o.toBase64Image();return o.destroy(),s.remove(),n}if("scorecard"===o){Xh(ed(t,e),i);const o=i.toDataURL();return s.remove(),o}if("gauge"===o){yy(i,e);const t=i.toDataURL();return s.remove(),t}}const Dy={id:"customCanvasBackgroundColor",beforeDraw:e=>{const{ctx:t}=e;t.save(),t.globalCompositeOperation="destination-over",t.fillStyle="#ffffff",t.fillRect(0,0,e.width,e.height),t.restore()}};class Oy{xmlString;constructor(e){this.xmlString=e}toString(){return this.xmlString}}const Fy=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart","comboChart","radarChart"],My="000000",Py={arrows:"3Arrows",smiley:"3Symbols",dots:"3TrafficLights1"},Ny={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"},ky="http://schemas.openxmlformats.org/drawingml/2006/main",Vy="http://schemas.openxmlformats.org/drawingml/2006/chart",Ly={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"},Hy={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"},Uy="bdbb8cdc-fa1e-496e-a857-3c3f30c029c3",By="http://schemas.openxmlformats.org/officeDocument/2006/relationships",zy=.75,$y=.143,Gy=8.43,Wy=12.75,qy=30,Zy=100,jy=164,Yy={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}]},Xy=["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"],Ky="[Content_Types].xml",Jy=new n;rh`
|
|
10
10
|
.o-spreadsheet {
|
|
11
11
|
.o-icon {
|
|
12
12
|
display: flex;
|
|
@@ -777,7 +777,7 @@
|
|
|
777
777
|
}
|
|
778
778
|
}
|
|
779
779
|
}
|
|
780
|
-
`;class _O extends t.Component{static template="o-spreadsheet-Composer";static props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},inputStyle:{type:String,optional:!0},rect:{type:Object,optional:!0},delimitation:{type:Object,optional:!0},onComposerCellFocused:{type:Function,optional:!0},onComposerContentFocused:Function,isDefaultFocus:{type:Boolean,optional:!0},onInputContextMenu:{type:Function,optional:!0},composerStore:Object,placeholder:{type:String,optional:!0}};static components={TextValueProvider:yO,FunctionDescriptionProvider:EO};static defaultProps={inputStyle:"",isDefaultFocus:!1};DOMFocusableElementStore;composerRef=t.useRef("o_composer");contentHelper=new wO(this.composerRef.el);composerState=t.useState({positionStart:0,positionEnd:0});autoCompleteState;functionDescriptionState=t.useState({showDescription:!1,functionName:"",functionDescription:{},argToFocus:0});assistant=t.useState({forcedClosed:!1});compositionActive=!1;spreadsheetRect=vR();get assistantStyleProperties(){const e=this.composerRef.el.getBoundingClientRect(),t={},o=Math.min(this.props.rect?.width||1/0,RO);t["min-width"]=`${o}px`;const s=this.autoCompleteState.provider?.proposals,i=s?.some((e=>e.description));if((this.functionDescriptionState.showDescription||i)&&(t.width="300px"),this.props.delimitation&&this.props.rect){const{x:e,y:o,height:s}=this.props.rect,i=this.props.delimitation.height-(o+s);if(t["max-height"]=`${i}px`,o>i){const e=o;t["max-height"]=e-9+"px",t.top="-3px",t.transform="translate(0, -100%)"}e+RO>this.props.delimitation.width&&(t.right="0px")}else t["max-height"]=this.spreadsheetRect.height-e.bottom-1+"px",e.left+RO+ie+9>this.spreadsheetRect.width&&(t.right="9px");return t}get assistantStyle(){const e=this.assistantStyleProperties;return ch({"max-height":e["max-height"],width:e.width,"min-width":e["min-width"]})}get assistantContainerStyle(){const e=this.assistantStyleProperties;return ch({top:e.top,right:e.right,transform:e.transform})}shouldProcessInputEvents=!1;tokens=[];keyMapping={Enter:e=>this.processEnterKey(e,"down"),"Shift+Enter":e=>this.processEnterKey(e,"up"),"Alt+Enter":this.processNewLineEvent,"Ctrl+Enter":this.processNewLineEvent,Escape:this.processEscapeKey,F2:e=>this.toggleEditionMode(e),F4:e=>this.processF4Key(e),Tab:e=>this.processTabKey(e,"right"),"Shift+Tab":e=>this.processTabKey(e,"left")};keyCodeMapping={NumpadDecimal:this.processNumpadDecimal};setup(){this.DOMFocusableElementStore=Zc(SO),this.autoCompleteState=jc(CO),t.onMounted((()=>{const e=this.composerRef.el;this.props.isDefaultFocus&&this.DOMFocusableElementStore.setFocusableElement(e),this.contentHelper.updateEl(e)})),this.env.model.selection.observe(this,{handleEvent:()=>this.autoCompleteState.hide()}),t.onWillUnmount((()=>{this.env.model.selection.detachObserver(this)})),t.useEffect((()=>{this.processContent(),document.activeElement!==this.contentHelper.el||"inactive"!==this.props.composerStore.editionMode||this.props.isDefaultFocus||this.DOMFocusableElementStore.focus()})),t.useEffect((()=>{this.processTokenAtCursor()}),(()=>["inactive"!==this.props.composerStore.editionMode]))}processArrowKeys(e){const t=this.props.composerStore.tokenAtCursor;if((this.props.composerStore.isSelectingRange||"inactive"===this.props.composerStore.editionMode)&&(!["ArrowUp","ArrowDown"].includes(e.key)||!this.autoCompleteState.provider||"REFERENCE"===t?.type))return this.functionDescriptionState.showDescription=!1,this.autoCompleteState.hide(),e.preventDefault(),e.stopPropagation(),void GD(e,this.env.model.selection);const o=this.props.composerStore.currentContent;"cellFocus"!==this.props.focus||this.autoCompleteState.provider||o.startsWith("=")?(e.stopPropagation(),this.handleArrowKeysForAutocomplete(e)):this.props.composerStore.stopEdition()}handleArrowKeysForAutocomplete(e){["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.provider&&(e.preventDefault(),this.autoCompleteState.moveSelection("ArrowDown"===e.key?"next":"previous"))}processTabKey(e,t){if(e.preventDefault(),e.stopPropagation(),"inactive"!==this.props.composerStore.editionMode){const e=this.autoCompleteState;if(e.provider&&void 0!==e.selectedIndex){const t=e.provider.proposals[e.selectedIndex]?.text;if(t)return void this.autoComplete(t)}this.props.composerStore.stopEdition(t)}}processEnterKey(e,t){e.preventDefault(),e.stopPropagation();const o=this.autoCompleteState;if(o.provider&&void 0!==o.selectedIndex){const e=o.provider.proposals[o.selectedIndex]?.text;if(e)return void this.autoComplete(e)}this.props.composerStore.stopEdition(t)}processNewLineEvent(e){e.preventDefault(),e.stopPropagation();const t=this.contentHelper.getText(),o=this.contentHelper.getCurrentSelection(),s=Math.min(o.start,o.end),i=Math.max(o.start,o.end);this.props.composerStore.stopComposerRangeSelection(),this.props.composerStore.setCurrentContent(t.slice(0,s)+Ne+t.slice(i),{start:s+1,end:s+1}),this.processContent()}processEscapeKey(e){this.props.composerStore.cancelEdition(),e.stopPropagation(),e.preventDefault()}processF4Key(e){e.stopPropagation(),this.props.composerStore.cycleReferences(),this.processContent()}toggleEditionMode(e){e.stopPropagation(),this.props.composerStore.toggleEditionMode(),this.processContent()}processNumpadDecimal(e){e.stopPropagation(),e.preventDefault();const t=this.env.model.getters.getLocale(),o=this.contentHelper.getCurrentSelection(),s=this.props.composerStore.currentContent,i=s.slice(0,o.start)+t.decimalSeparator+s.slice(o.end);this.props.composerStore.setCurrentContent(i,{start:o.start+1,end:o.start+1}),this.processContent()}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){if("inactive"===this.props.composerStore.editionMode)return;if(e.key.startsWith("Arrow"))return void this.processArrowKeys(e);let t=this.keyMapping[XR(e)]||this.keyCodeMapping[XR(e,"code")];t?t.call(this,e):e.stopPropagation()}onPaste(e){"inactive"!==this.props.composerStore.editionMode?e.stopPropagation():e.preventDefault()}onInput(e){if(!this.shouldProcessInputEvents)return;let t;if(e.stopPropagation(),t="inactive"===this.props.composerStore.editionMode?e.data||"":this.contentHelper.getText(),"inactive"===this.props.focus)return this.props.onComposerCellFocused?.(t);let o=this.contentHelper.getCurrentSelection();this.props.composerStore.stopComposerRangeSelection(),this.props.composerStore.setCurrentContent(t,o),this.processTokenAtCursor()}onKeyup(e){if(this.contentHelper.el===document.activeElement){if(this.autoCompleteState.provider&&["ArrowUp","ArrowDown"].includes(e.key))return;if(this.props.composerStore.isSelectingRange&&e.key?.startsWith("Arrow"))return;const{start:t,end:o}=this.props.composerStore.composerSelection,{start:s,end:i}=this.contentHelper.getCurrentSelection();s===t&&i===o||this.props.composerStore.changeComposerCursorSelection(s,i),this.processTokenAtCursor()}}onBlur(e){if("inactive"===this.props.composerStore.editionMode)return;const t=e.relatedTarget;t&&t instanceof HTMLElement?t.attributes.getNamedItem("composerFocusableElement")?this.contentHelper.el.focus():t.classList.contains("o-composer")||this.props.composerStore.stopEdition():this.props.composerStore.stopEdition()}updateAutoCompleteIndex(e){this.autoCompleteState.selectIndex(Ze(0,e,10))}onMousedown(e){e.button>0||this.contentHelper.removeSelection()}onClick(){if(this.env.model.getters.isReadonly())return;const e=this.contentHelper.getCurrentSelection();this.props.composerStore.stopComposerRangeSelection(),this.props.onComposerContentFocused(),this.props.composerStore.changeComposerCursorSelection(e.start,e.end),this.processTokenAtCursor()}onDblClick(){if(this.env.model.getters.isReadonly())return;const e=this.props.composerStore.currentContent;if(e.startsWith("=")){const t=this.props.composerStore.currentTokens,o=this.contentHelper.getCurrentSelection();if(o.start===o.end)return;const s=e.substring(o.start,o.end),i=t.filter((e=>e.value.includes(s)&&e.start<=o.start&&e.end>=o.end))[0];if(!i)return;"REFERENCE"===i.type&&this.props.composerStore.changeComposerCursorSelection(i.start,i.end)}}onContextMenu(e){"inactive"===this.props.composerStore.editionMode&&this.props.onInputContextMenu?.(e)}closeAssistant(){this.canBeToggled&&(this.assistant.forcedClosed=!0)}openAssistant(){this.canBeToggled&&(this.assistant.forcedClosed=!1)}onWheel(e){this.composerRef.el&&this.composerRef.el.scrollHeight>this.composerRef.el.clientHeight&&e.stopPropagation()}get canBeToggled(){return this.autoCompleteState.provider?.canBeToggled??!0}processContent(){if(this.compositionActive)return;this.shouldProcessInputEvents=!1,"inactive"!==this.props.focus&&document.activeElement!==this.contentHelper.el&&this.contentHelper.el.focus();const e=this.getContentLines();if(this.contentHelper.setText(e),0!==e.length&&0!==e.length[0]){if("inactive"!==this.props.focus){const{start:e,end:t}=this.props.composerStore.composerSelection;this.contentHelper.selectRange(e,t)}this.contentHelper.scrollSelectionIntoView()}this.shouldProcessInputEvents=!0}getContentLines(){let e=this.props.composerStore.currentContent;const t=e.startsWith("=");return""===e?[]:t&&"inactive"!==this.props.focus?this.splitHtmlContentIntoLines(this.getHtmlContentFromTokens()):this.splitHtmlContentIntoLines([{value:e}])}getHtmlContentFromTokens(){const e=this.props.composerStore.currentTokens,t=[],{end:o,start:s}=this.props.composerStore.composerSelection;for(const i of e){let e=i.color||OS;i.isBlurred&&(e=eo(e,.5)),t.push({value:i.value,color:e}),"REFERENCE"===i.type&&this.props.composerStore.tokenAtCursor===i&&"selecting"===this.props.composerStore.editionMode&&(t[t.length-1].class="text-decoration-underline"),o===s&&i.isParenthesisLinkedToCursor&&(t[t.length-1].class=AO),this.props.composerStore.showSelectionIndicator&&o===s&&o===i.end&&(t[t.length-1].class=TO)}return t}splitHtmlContentIntoLines(e){const t=[];let o=[];for(const s of e)if(s.value.includes(Ne)){const e=s.value.split(Ne),i=e.pop();for(const i of e)o.push({color:s.color,value:i}),t.push(o),o=[];o.push({...s,value:i})}else o.push(s);o.length&&t.push(o);const s=[];for(const e of t)e.every(this.isContentEmpty)?s.push([e[0]]):s.push(e.filter((e=>!this.isContentEmpty(e))));return s}isContentEmpty(e){return!(e.value||e.class)}processTokenAtCursor(){let e=this.props.composerStore.currentContent;this.autoCompleteState.provider&&this.autoCompleteState.hide(),this.functionDescriptionState.showDescription=!1;const t=this.props.composerStore.autocompleteProvider;t&&this.autoCompleteState.useProvider(t);const o=this.props.composerStore.tokenAtCursor;if(e.startsWith("=")&&o&&"SYMBOL"!==o.type){const e=o.functionContext,t=e?.parent.toUpperCase();if(e&&t&&t in IO&&"UNKNOWN"!==o.type){const o=IO[t],s=e.argPosition;this.functionDescriptionState.functionName=t,this.functionDescriptionState.functionDescription=o,this.functionDescriptionState.argToFocus=o.getArgToFocus(s+1)-1,this.functionDescriptionState.showDescription=!0}}}autoComplete(e){!e||this.assistant.forcedClosed&&this.canBeToggled||(this.autoCompleteState.provider?.selectProposal(e),this.processTokenAtCursor())}}class DO extends PS{args;constructor(e,t){super(e),this.args=t,this._currentContent=this.getComposerContent()}getAutoCompleteProviders(){const e=super.getAutoCompleteProviders(),t=this.args().contextualAutocomplete;return t&&e.push(t),e}getZoneReference(e){const t=super.getZoneReference(e);return this.args().defaultStatic?vv(t,"colrow"):t}getComposerContent(){let e=this._currentContent;if("inactive"===this.editionMode){const t=this.args().defaultRangeSheetId;e=Yf(this.args().content).map((e=>{if("REFERENCE"===e.type){const o=this.getters.getRangeFromSheetXC(t,e.value);return this.getters.getRangeString(o,this.getters.getActiveSheetId())}return e.value})).join("")}return ol(e,this.getters.getLocale())}stopEdition(){this._stopEdition()}confirmEdition(e){this.args().onConfirm(e)}getTokenColor(e){if("SYMBOL"===e.type){const t=this.args().getContextualColoredSymbolToken?.(e);if(t)return t}return super.getTokenColor(e)}}rh`
|
|
780
|
+
`;class _O extends t.Component{static template="o-spreadsheet-Composer";static props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},inputStyle:{type:String,optional:!0},rect:{type:Object,optional:!0},delimitation:{type:Object,optional:!0},onComposerCellFocused:{type:Function,optional:!0},onComposerContentFocused:Function,isDefaultFocus:{type:Boolean,optional:!0},onInputContextMenu:{type:Function,optional:!0},composerStore:Object,placeholder:{type:String,optional:!0}};static components={TextValueProvider:yO,FunctionDescriptionProvider:EO};static defaultProps={inputStyle:"",isDefaultFocus:!1};DOMFocusableElementStore;composerRef=t.useRef("o_composer");contentHelper=new wO(this.composerRef.el);composerState=t.useState({positionStart:0,positionEnd:0});autoCompleteState;functionDescriptionState=t.useState({showDescription:!1,functionName:"",functionDescription:{},argToFocus:0});assistant=t.useState({forcedClosed:!1});compositionActive=!1;spreadsheetRect=vR();get assistantStyleProperties(){const e=this.composerRef.el.getBoundingClientRect(),t={},o=Math.min(this.props.rect?.width||1/0,RO);t["min-width"]=`${o}px`;const s=this.autoCompleteState.provider?.proposals,i=s?.some((e=>e.description));if((this.functionDescriptionState.showDescription||i)&&(t.width="300px"),this.props.delimitation&&this.props.rect){const{x:e,y:o,height:s}=this.props.rect,i=this.props.delimitation.height-(o+s);if(t["max-height"]=`${i}px`,o>i){const e=o;t["max-height"]=e-9+"px",t.top="-3px",t.transform="translate(0, -100%)"}e+RO>this.props.delimitation.width&&(t.right="0px")}else t["max-height"]=this.spreadsheetRect.height-e.bottom-1+"px",e.left+RO+ie+9>this.spreadsheetRect.width&&(t.right="9px");return t}get assistantStyle(){const e=this.assistantStyleProperties;return ch({"max-height":e["max-height"],width:e.width,"min-width":e["min-width"]})}get assistantContainerStyle(){const e=this.assistantStyleProperties;return ch({top:e.top,right:e.right,transform:e.transform})}shouldProcessInputEvents=!1;tokens=[];keyMapping={Enter:e=>this.processEnterKey(e,"down"),"Shift+Enter":e=>this.processEnterKey(e,"up"),"Alt+Enter":this.processNewLineEvent,"Ctrl+Enter":this.processNewLineEvent,Escape:this.processEscapeKey,F2:e=>this.toggleEditionMode(e),F4:e=>this.processF4Key(e),Tab:e=>this.processTabKey(e,"right"),"Shift+Tab":e=>this.processTabKey(e,"left")};keyCodeMapping={NumpadDecimal:this.processNumpadDecimal};setup(){this.DOMFocusableElementStore=Zc(SO),this.autoCompleteState=jc(CO),t.onMounted((()=>{const e=this.composerRef.el;this.props.isDefaultFocus&&this.DOMFocusableElementStore.setFocusableElement(e),this.contentHelper.updateEl(e)})),this.env.model.selection.observe(this,{handleEvent:()=>this.autoCompleteState.hide()}),t.onWillUnmount((()=>{this.env.model.selection.detachObserver(this)})),t.useEffect((()=>{this.processContent(),document.activeElement!==this.contentHelper.el||"inactive"!==this.props.composerStore.editionMode||this.props.isDefaultFocus||this.DOMFocusableElementStore.focus()})),t.useEffect((()=>{this.processTokenAtCursor()}),(()=>["inactive"!==this.props.composerStore.editionMode]))}processArrowKeys(e){const t=this.props.composerStore.tokenAtCursor;if((this.props.composerStore.isSelectingRange||"inactive"===this.props.composerStore.editionMode)&&(!["ArrowUp","ArrowDown"].includes(e.key)||!this.autoCompleteState.provider||"REFERENCE"===t?.type))return this.functionDescriptionState.showDescription=!1,this.autoCompleteState.hide(),e.preventDefault(),e.stopPropagation(),void GD(e,this.env.model.selection);const o=this.props.composerStore.currentContent;"cellFocus"!==this.props.focus||this.autoCompleteState.provider||o.startsWith("=")?(e.stopPropagation(),this.handleArrowKeysForAutocomplete(e)):this.props.composerStore.stopEdition()}handleArrowKeysForAutocomplete(e){["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.provider&&(e.preventDefault(),this.autoCompleteState.moveSelection("ArrowDown"===e.key?"next":"previous"))}processTabKey(e,t){if(e.preventDefault(),e.stopPropagation(),"inactive"!==this.props.composerStore.editionMode){const e=this.autoCompleteState;if(e.provider&&void 0!==e.selectedIndex){const t=e.provider.proposals[e.selectedIndex]?.text;if(t)return void this.autoComplete(t)}this.props.composerStore.stopEdition(t)}}processEnterKey(e,t){e.preventDefault(),e.stopPropagation();const o=this.autoCompleteState;if(o.provider&&void 0!==o.selectedIndex){const e=o.provider.proposals[o.selectedIndex]?.text;if(e)return void this.autoComplete(e)}this.props.composerStore.stopEdition(t)}processNewLineEvent(e){e.preventDefault(),e.stopPropagation();const t=this.contentHelper.getText(),o=this.contentHelper.getCurrentSelection(),s=Math.min(o.start,o.end),i=Math.max(o.start,o.end);this.props.composerStore.stopComposerRangeSelection(),this.props.composerStore.setCurrentContent(t.slice(0,s)+Ne+t.slice(i),{start:s+1,end:s+1}),this.processContent()}processEscapeKey(e){this.props.composerStore.cancelEdition(),e.stopPropagation(),e.preventDefault()}processF4Key(e){e.stopPropagation(),this.props.composerStore.cycleReferences(),this.processContent()}toggleEditionMode(e){e.stopPropagation(),this.props.composerStore.toggleEditionMode(),this.processContent()}processNumpadDecimal(e){e.stopPropagation(),e.preventDefault();const t=this.env.model.getters.getLocale(),o=this.contentHelper.getCurrentSelection(),s=this.props.composerStore.currentContent,i=s.slice(0,o.start)+t.decimalSeparator+s.slice(o.end);this.props.composerStore.setCurrentContent(i,{start:o.start+1,end:o.start+1}),this.processContent()}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){if("inactive"===this.props.composerStore.editionMode)return;if(e.key.startsWith("Arrow"))return void this.processArrowKeys(e);let t=this.keyMapping[XR(e)]||this.keyCodeMapping[XR(e,"code")];t?t.call(this,e):e.stopPropagation()}onPaste(e){"inactive"!==this.props.composerStore.editionMode?e.stopPropagation():e.preventDefault()}onInput(e){if(!this.shouldProcessInputEvents)return;let t;if(e.stopPropagation(),t="inactive"===this.props.composerStore.editionMode?e.data||"":this.contentHelper.getText(),"inactive"===this.props.focus)return this.props.onComposerCellFocused?.(t);let o=this.contentHelper.getCurrentSelection();this.props.composerStore.stopComposerRangeSelection(),this.props.composerStore.setCurrentContent(t,o),this.processTokenAtCursor()}onKeyup(e){if(this.contentHelper.el===document.activeElement){if(this.autoCompleteState.provider&&["ArrowUp","ArrowDown"].includes(e.key))return;if(this.props.composerStore.isSelectingRange&&e.key?.startsWith("Arrow"))return;const{start:t,end:o}=this.props.composerStore.composerSelection,{start:s,end:i}=this.contentHelper.getCurrentSelection();s===t&&i===o||this.props.composerStore.changeComposerCursorSelection(s,i),this.processTokenAtCursor()}}onBlur(e){if("inactive"===this.props.composerStore.editionMode)return;const t=e.relatedTarget;t&&t instanceof HTMLElement?t.attributes.getNamedItem("composerFocusableElement")?this.contentHelper.el.focus():t.classList.contains("o-composer")||this.props.composerStore.stopEdition():this.props.composerStore.stopEdition()}updateAutoCompleteIndex(e){this.autoCompleteState.selectIndex(Ze(0,e,10))}onMousedown(e){e.button>0||this.contentHelper.removeSelection()}onClick(){if(this.env.model.getters.isReadonly())return;const e=this.contentHelper.getCurrentSelection();this.props.onComposerContentFocused(),this.props.composerStore.changeComposerCursorSelection(e.start,e.end),this.processTokenAtCursor()}onDblClick(){if(this.env.model.getters.isReadonly())return;const e=this.props.composerStore.currentContent;if(e.startsWith("=")){const t=this.props.composerStore.currentTokens,o=this.contentHelper.getCurrentSelection();if(o.start===o.end)return;const s=e.substring(o.start,o.end),i=t.filter((e=>e.value.includes(s)&&e.start<=o.start&&e.end>=o.end))[0];if(!i)return;"REFERENCE"===i.type&&this.props.composerStore.changeComposerCursorSelection(i.start,i.end)}}onContextMenu(e){"inactive"===this.props.composerStore.editionMode&&this.props.onInputContextMenu?.(e)}closeAssistant(){this.canBeToggled&&(this.assistant.forcedClosed=!0)}openAssistant(){this.canBeToggled&&(this.assistant.forcedClosed=!1)}onWheel(e){this.composerRef.el&&this.composerRef.el.scrollHeight>this.composerRef.el.clientHeight&&e.stopPropagation()}get canBeToggled(){return this.autoCompleteState.provider?.canBeToggled??!0}processContent(){if(this.compositionActive)return;this.shouldProcessInputEvents=!1,"inactive"!==this.props.focus&&document.activeElement!==this.contentHelper.el&&this.contentHelper.el.focus();const e=this.getContentLines();if(this.contentHelper.setText(e),0!==e.length&&0!==e.length[0]){if("inactive"!==this.props.focus){const{start:e,end:t}=this.props.composerStore.composerSelection;this.contentHelper.selectRange(e,t)}this.contentHelper.scrollSelectionIntoView()}this.shouldProcessInputEvents=!0}getContentLines(){let e=this.props.composerStore.currentContent;const t=e.startsWith("=");return""===e?[]:t&&"inactive"!==this.props.focus?this.splitHtmlContentIntoLines(this.getHtmlContentFromTokens()):this.splitHtmlContentIntoLines([{value:e}])}getHtmlContentFromTokens(){const e=this.props.composerStore.currentTokens,t=[],{end:o,start:s}=this.props.composerStore.composerSelection;for(const i of e){let e=i.color||OS;i.isBlurred&&(e=eo(e,.5)),t.push({value:i.value,color:e}),"REFERENCE"===i.type&&this.props.composerStore.tokenAtCursor===i&&"selecting"===this.props.composerStore.editionMode&&(t[t.length-1].class="text-decoration-underline"),o===s&&i.isParenthesisLinkedToCursor&&(t[t.length-1].class=AO),this.props.composerStore.showSelectionIndicator&&o===s&&o===i.end&&(t[t.length-1].class=TO)}return t}splitHtmlContentIntoLines(e){const t=[];let o=[];for(const s of e)if(s.value.includes(Ne)){const e=s.value.split(Ne),i=e.pop();for(const i of e)o.push({color:s.color,value:i}),t.push(o),o=[];o.push({...s,value:i})}else o.push(s);o.length&&t.push(o);const s=[];for(const e of t)e.every(this.isContentEmpty)?s.push([e[0]]):s.push(e.filter((e=>!this.isContentEmpty(e))));return s}isContentEmpty(e){return!(e.value||e.class)}processTokenAtCursor(){let e=this.props.composerStore.currentContent;this.autoCompleteState.provider&&this.autoCompleteState.hide(),this.functionDescriptionState.showDescription=!1;const t=this.props.composerStore.autocompleteProvider;t&&this.autoCompleteState.useProvider(t);const o=this.props.composerStore.tokenAtCursor;if(e.startsWith("=")&&o&&"SYMBOL"!==o.type){const e=o.functionContext,t=e?.parent.toUpperCase();if(e&&t&&t in IO&&"UNKNOWN"!==o.type){const o=IO[t],s=e.argPosition;this.functionDescriptionState.functionName=t,this.functionDescriptionState.functionDescription=o,this.functionDescriptionState.argToFocus=o.getArgToFocus(s+1)-1,this.functionDescriptionState.showDescription=!0}}}autoComplete(e){!e||this.assistant.forcedClosed&&this.canBeToggled||(this.autoCompleteState.provider?.selectProposal(e),this.processTokenAtCursor())}}class DO extends PS{args;constructor(e,t){super(e),this.args=t,this._currentContent=this.getComposerContent()}getAutoCompleteProviders(){const e=super.getAutoCompleteProviders(),t=this.args().contextualAutocomplete;return t&&e.push(t),e}getZoneReference(e){const t=super.getZoneReference(e);return this.args().defaultStatic?vv(t,"colrow"):t}getComposerContent(){let e=this._currentContent;if("inactive"===this.editionMode){const t=this.args().defaultRangeSheetId;e=Yf(this.args().content).map((e=>{if("REFERENCE"===e.type){const o=this.getters.getRangeFromSheetXC(t,e.value);return this.getters.getRangeString(o,this.getters.getActiveSheetId())}return e.value})).join("")}return ol(e,this.getters.getLocale())}stopEdition(){this._stopEdition()}confirmEdition(e){this.args().onConfirm(e)}getTokenColor(e){if("SYMBOL"===e.type){const t=this.args().getContextualColoredSymbolToken?.(e);if(t)return t}return super.getTokenColor(e)}}rh`
|
|
781
781
|
.o-spreadsheet {
|
|
782
782
|
.o-standalone-composer {
|
|
783
783
|
min-height: 24px;
|
|
@@ -1623,7 +1623,7 @@
|
|
|
1623
1623
|
.o-paint-format-cursor {
|
|
1624
1624
|
cursor: url("data:image/svg+xml,${encodeURIComponent('\n<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="14" height="16"><path d="M6.5.4c1.3-.8 2.9-.1 3.8 1.4l2.9 5.1c.2.4.9 1.6-.4 2.3l-1.6.9 1.8 3.1c.2.4.1 1-.2 1.2l-1.6 1c-.3.1-.9 0-1.1-.4l-1.8-3.1-1.6 1c-.6.4-1.7 0-2.2-.8L0 4.3"/><path fill="#fff" d="M9.1 2a1.4 1.1 60 0 0-1.7-.6L5.5 2.5l.9 1.6-1 .6-.9-1.6-.6.4 1.8 3.1-1.3.7-1.8-3.1-1 .6 3.8 6.6 6.8-3.98M3.9 8.8 10.82 5l.795 1.4-6.81 3.96"/></svg>\n')}"), auto;
|
|
1625
1625
|
}
|
|
1626
|
-
`;class cP extends t.Component{static template="o-spreadsheet-GridOverlay";static props={onCellHovered:{type:Function,optional:!0},onCellDoubleClicked:{type:Function,optional:!0},onCellClicked:{type:Function,optional:!0},onCellRightClicked:{type:Function,optional:!0},onGridResized:{type:Function,optional:!0},onFigureDeleted:{type:Function,optional:!0},onGridMoved:Function,gridOverlayDimensions:String};static components={FiguresContainer:oP,DataValidationOverlay:ZM,GridAddRowsFooter:nP,FilterIconsOverlay:iP};static defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{}};gridOverlay=t.useRef("gridOverlay");gridOverlayRect=bR(this.gridOverlay);cellPopovers;paintFormatStore;setup(){lP(this.env,this.gridOverlay,this.props.onCellHovered);const e=new ResizeObserver((()=>{const e=this.gridOverlayEl.getBoundingClientRect();this.props.onGridResized({x:e.left,y:e.top,height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})}));t.onMounted((()=>{e.observe(this.gridOverlayEl)})),t.onWillUnmount((()=>{e.disconnect()})),this.cellPopovers=Zc(gR),this.paintFormatStore=Zc(aP)}get gridOverlayEl(){if(!this.gridOverlay.el)throw new Error("GridOverlay el is not defined.");return this.gridOverlay.el}get style(){return this.props.gridOverlayDimensions}get isPaintingFormat(){return this.paintFormatStore.isActive}onMouseDown(e){if(e.button>0)return;e.target===this.gridOverlay.el&&this.cellPopovers.isOpen&&this.cellPopovers.close();const[t,o]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,o,{expandZone:e.shiftKey,addZone:JR(e)})}onDoubleClick(e){const[t,o]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,o)}onContextMenu(e){const[t,o]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,o,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){const t=e.clientX-this.gridOverlayRect.x,o=e.clientY-this.gridOverlayRect.y;return[this.env.model.getters.getColIndex(t),this.env.model.getters.getRowIndex(o)]}}class hP extends t.Component{static template="o-spreadsheet-GridPopover";static props={onClosePopover:Function,onMouseWheel:Function,gridRect:Object};static components={Popover:SR};cellPopovers;zIndex=Fe.GridPopover;setup(){this.cellPopovers=Zc(gR)}get cellPopover(){const e=this.cellPopovers.cellPopover;if(!e.isOpen)return{isOpen:!1};const t=e.anchorRect;return{...e,anchorRect:{...t,x:t.x+this.props.gridRect.x,y:t.y+this.props.gridRect.y}}}}class dP extends t.Component{static template="o-spreadsheet-UnhideRowHeaders";static props={headersGroups:Array,headerRange:Object,offset:{type:Number,optional:!0}};static defaultProps={offset:0};get sheetId(){return this.env.model.getters.getActiveSheetId()}getUnhidePreviousButtonStyle(e){const t=this.env.model.getters.getRect(ds({col:0,row:e}));return ch({top:t.y+t.height-ee-this.props.offset+"px","margin-right":"1px"})}getUnhideNextButtonStyle(e){return ch({top:this.env.model.getters.getRect(ds({col:0,row:e})).y-ee-this.props.offset+"px","margin-right":"1px"})}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.sheetId,dimension:"ROW",elements:e})}isVisible(e){return e>=this.props.headerRange.start&&e<=this.props.headerRange.end}}class uP extends t.Component{static template="o-spreadsheet-UnhideColumnHeaders";static props={headersGroups:Array,headerRange:Object,offset:{type:Number,optional:!0}};static defaultProps={offset:0};get sheetId(){return this.env.model.getters.getActiveSheetId()}getUnhidePreviousButtonStyle(e){const t=this.env.model.getters.getRect(ds({col:e,row:0}));return ch({left:t.x+t.width-te-this.props.offset+"px"})}getUnhideNextButtonStyle(e){return ch({left:this.env.model.getters.getRect(ds({col:e,row:0})).x-te-this.props.offset+"px"})}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.sheetId,dimension:"COL",elements:e})}isVisible(e){return e>=this.props.headerRange.start&&e<=this.props.headerRange.end}}class gP extends t.Component{static props={onOpenContextMenu:Function};composerFocusStore;PADDING=0;MAX_SIZE_MARGIN=0;MIN_ELEMENT_SIZE=0;lastSelectedElementIndex=null;state=t.useState({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0,position:"before"});setup(){this.composerFocusStore=Zc(sh)}_computeHandleDisplay(e){const t=this._getEvOffset(e),o=this._getElementIndex(t);if(o<0)return;const s=this._getDimensionsInViewport(o);t-s.start<this.PADDING&&o!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=s.start,this.state.activeElement=this._getPreviousVisibleElement(o)):s.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=s.end,this.state.activeElement=o):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),o=this._getActiveElements(),s=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();o.has(s)&&s<=t&&t<=i?this.state.waitingForMove=!0:this.state.waitingForMove=!1}onMouseMove(e){this.state.isResizing||this.state.isMoving||this.state.isSelecting||(this._computeHandleDisplay(e),this._computeGrabDisplay(e))}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(e){this._fitElementSize(this.state.activeElement),this.state.isResizing=!1,this._computeHandleDisplay(e),this._computeGrabDisplay(e)}onMouseDown(e){this.state.isResizing=!0,this.state.delta=0;const t=this._getClientPosition(e),o=this.state.draggerLinePosition,s=this._getElementSize(this.state.activeElement),i=o-s+this.MIN_ELEMENT_SIZE,n=this._getMaxSize();kD((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=o+this.state.delta,this.state.draggerLinePosition<i&&(this.state.draggerLinePosition=i,this.state.delta=this.MIN_ELEMENT_SIZE-s),this.state.draggerLinePosition>n&&(this.state.draggerLinePosition=n,this.state.delta=n-o)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(this.state.waitingForMove?this.env.model.getters.isGridSelectionActive()?this.startMovement(e):this._selectElement(t,!1):("editing"===this.composerFocusStore.activeComposer.editionMode&&this.env.model.selection.getBackToDefault(),this.startSelection(e,t)))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),o=this._getDimensionsInViewport(this._getSelectedZoneEnd()),s=t.start;this.state.draggerLinePosition=s,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=s,this.state.draggerShadowThickness=o.end-t.start;VD(this.env,((e,o)=>{let s="COL"===this._getType()?e:o;if(s>=0){const e=this._getDimensionsInViewport(s);s<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=s,this.state.position="before"):this._getSelectedZoneEnd()<s?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=s,this.state.position="after"):(this.state.draggerLinePosition=t.start,this.state.draggerShadowPosition=t.start,this.state.base=this._getSelectedZoneStart())}}),(()=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements(),this._computeGrabDisplay(e)}))}startSelection(e,t){this.state.isSelecting=!0,e.shiftKey?this._increaseSelection(t):this._selectElement(t,JR(e)),this.lastSelectedElementIndex=t;VD(this.env,((e,t)=>{let o="COL"===this._getType()?e:t;o!==this.lastSelectedElementIndex&&-1!==o&&(this._increaseSelection(o),this.lastSelectedElementIndex=o)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this._computeGrabDisplay(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const o=this._getType();this.props.onOpenContextMenu(o,e.clientX,e.clientY)}}rh`
|
|
1626
|
+
`;class cP extends t.Component{static template="o-spreadsheet-GridOverlay";static props={onCellHovered:{type:Function,optional:!0},onCellDoubleClicked:{type:Function,optional:!0},onCellClicked:{type:Function,optional:!0},onCellRightClicked:{type:Function,optional:!0},onGridResized:{type:Function,optional:!0},onFigureDeleted:{type:Function,optional:!0},onGridMoved:Function,gridOverlayDimensions:String};static components={FiguresContainer:oP,DataValidationOverlay:ZM,GridAddRowsFooter:nP,FilterIconsOverlay:iP};static defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{}};gridOverlay=t.useRef("gridOverlay");gridOverlayRect=bR(this.gridOverlay);cellPopovers;paintFormatStore;setup(){lP(this.env,this.gridOverlay,this.props.onCellHovered);const e=new ResizeObserver((()=>{const e=this.gridOverlayEl.getBoundingClientRect();this.props.onGridResized({x:e.left,y:e.top,height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})}));t.onMounted((()=>{e.observe(this.gridOverlayEl)})),t.onWillUnmount((()=>{e.disconnect()})),this.cellPopovers=Zc(gR),this.paintFormatStore=Zc(aP)}get gridOverlayEl(){if(!this.gridOverlay.el)throw new Error("GridOverlay el is not defined.");return this.gridOverlay.el}get style(){return this.props.gridOverlayDimensions}get isPaintingFormat(){return this.paintFormatStore.isActive}onMouseDown(e){if(e.button>0)return;e.target===this.gridOverlay.el&&this.cellPopovers.isOpen&&this.cellPopovers.close();const[t,o]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,o,{expandZone:e.shiftKey,addZone:JR(e)})}onDoubleClick(e){const[t,o]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,o)}onContextMenu(e){const[t,o]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,o,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){const t=e.clientX-this.gridOverlayRect.x,o=e.clientY-this.gridOverlayRect.y;return[this.env.model.getters.getColIndex(t),this.env.model.getters.getRowIndex(o)]}}class hP extends t.Component{static template="o-spreadsheet-GridPopover";static props={onClosePopover:Function,onMouseWheel:Function,gridRect:Object};static components={Popover:SR};cellPopovers;zIndex=Fe.GridPopover;setup(){this.cellPopovers=Zc(gR)}get cellPopover(){const e=this.cellPopovers.cellPopover;if(!e.isOpen)return{isOpen:!1};const t=e.anchorRect;return{...e,anchorRect:{...t,x:t.x+this.props.gridRect.x,y:t.y+this.props.gridRect.y}}}}class dP extends t.Component{static template="o-spreadsheet-UnhideRowHeaders";static props={headersGroups:Array,headerRange:Object,offset:{type:Number,optional:!0}};static defaultProps={offset:0};get sheetId(){return this.env.model.getters.getActiveSheetId()}getUnhidePreviousButtonStyle(e){const t=this.env.model.getters.getRect(ds({col:0,row:e}));return ch({top:t.y+t.height-ee-this.props.offset+"px","margin-right":"1px"})}getUnhideNextButtonStyle(e){return ch({top:this.env.model.getters.getRect(ds({col:0,row:e})).y-ee-this.props.offset+"px","margin-right":"1px"})}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.sheetId,dimension:"ROW",elements:e})}isVisible(e){return e>=this.props.headerRange.start&&e<=this.props.headerRange.end}}class uP extends t.Component{static template="o-spreadsheet-UnhideColumnHeaders";static props={headersGroups:Array,headerRange:Object,offset:{type:Number,optional:!0}};static defaultProps={offset:0};get sheetId(){return this.env.model.getters.getActiveSheetId()}getUnhidePreviousButtonStyle(e){const t=this.env.model.getters.getRect(ds({col:e,row:0}));return ch({left:t.x+t.width-te-this.props.offset+"px"})}getUnhideNextButtonStyle(e){return ch({left:this.env.model.getters.getRect(ds({col:e,row:0})).x-te-this.props.offset+"px"})}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.sheetId,dimension:"COL",elements:e})}isVisible(e){return e>=this.props.headerRange.start&&e<=this.props.headerRange.end}}class gP extends t.Component{static props={onOpenContextMenu:Function};composerFocusStore;PADDING=0;MAX_SIZE_MARGIN=0;MIN_ELEMENT_SIZE=0;lastSelectedElementIndex=null;state=t.useState({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0,position:"before"});setup(){this.composerFocusStore=Zc(sh)}_computeHandleDisplay(e){const t=this._getEvOffset(e),o=this._getElementIndex(t);if(o<0)return;const s=this._getDimensionsInViewport(o);t-s.start<this.PADDING&&o!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=s.start,this.state.activeElement=this._getPreviousVisibleElement(o)):s.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=s.end,this.state.activeElement=o):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),o=this._getActiveElements(),s=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();o.has(s)&&s<=t&&t<=i?this.state.waitingForMove=!0:this.state.waitingForMove=!1}onMouseMove(e){this.env.model.getters.isReadonly()||this.state.isResizing||this.state.isMoving||this.state.isSelecting||(this._computeHandleDisplay(e),this._computeGrabDisplay(e))}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(e){this._fitElementSize(this.state.activeElement),this.state.isResizing=!1,this._computeHandleDisplay(e),this._computeGrabDisplay(e)}onMouseDown(e){this.state.isResizing=!0,this.state.delta=0;const t=this._getClientPosition(e),o=this.state.draggerLinePosition,s=this._getElementSize(this.state.activeElement),i=o-s+this.MIN_ELEMENT_SIZE,n=this._getMaxSize();kD((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=o+this.state.delta,this.state.draggerLinePosition<i&&(this.state.draggerLinePosition=i,this.state.delta=this.MIN_ELEMENT_SIZE-s),this.state.draggerLinePosition>n&&(this.state.draggerLinePosition=n,this.state.delta=n-o)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(this.env.model.getters.isReadonly()?this._selectElement(t,!1):this.state.waitingForMove?this.env.model.getters.isGridSelectionActive()?this.startMovement(e):this._selectElement(t,!1):("editing"===this.composerFocusStore.activeComposer.editionMode&&this.env.model.selection.getBackToDefault(),this.startSelection(e,t)))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),o=this._getDimensionsInViewport(this._getSelectedZoneEnd()),s=t.start;this.state.draggerLinePosition=s,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=s,this.state.draggerShadowThickness=o.end-t.start;VD(this.env,((e,o)=>{let s="COL"===this._getType()?e:o;if(s>=0){const e=this._getDimensionsInViewport(s);s<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=s,this.state.position="before"):this._getSelectedZoneEnd()<s?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=s,this.state.position="after"):(this.state.draggerLinePosition=t.start,this.state.draggerShadowPosition=t.start,this.state.base=this._getSelectedZoneStart())}}),(()=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements(),this._computeGrabDisplay(e)}))}startSelection(e,t){this.state.isSelecting=!0,e.shiftKey?this._increaseSelection(t):this._selectElement(t,JR(e)),this.lastSelectedElementIndex=t;VD(this.env,((e,t)=>{let o="COL"===this._getType()?e:t;o!==this.lastSelectedElementIndex&&-1!==o&&(this._increaseSelection(o),this.lastSelectedElementIndex=o)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this._computeGrabDisplay(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const o=this._getType();this.props.onOpenContextMenu(o,e.clientX,e.clientY)}}rh`
|
|
1627
1627
|
.o-col-resizer {
|
|
1628
1628
|
position: absolute;
|
|
1629
1629
|
top: 0;
|
|
@@ -1812,7 +1812,7 @@
|
|
|
1812
1812
|
offset="offset"
|
|
1813
1813
|
direction="'vertical'"
|
|
1814
1814
|
onScroll.bind="onScroll"
|
|
1815
|
-
/>`;static defaultProps={topOffset:0};get offset(){return this.env.model.getters.getActiveSheetScrollInfo().scrollY}get height(){return this.env.model.getters.getMainViewportRect().height}get isDisplayed(){const{yRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{y:e}=this.env.model.getters.getMainViewportRect();return{top:`${this.props.topOffset+e}px`,right:"0px",width:"15px",bottom:QR()?"15px":"0"}}onScroll(e){const{scrollX:t}=this.env.model.getters.getActiveSheetScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:t,offsetY:e})}}const AP=350;class _P extends th{mutators=["open","toggle","close","changePanelSize","resetPanelSize"];
|
|
1815
|
+
/>`;static defaultProps={topOffset:0};get offset(){return this.env.model.getters.getActiveSheetScrollInfo().scrollY}get height(){return this.env.model.getters.getMainViewportRect().height}get isDisplayed(){const{yRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{y:e}=this.env.model.getters.getMainViewportRect();return{top:`${this.props.topOffset+e}px`,right:"0px",width:"15px",bottom:QR()?"15px":"0"}}onScroll(e){const{scrollX:t}=this.env.model.getters.getActiveSheetScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:t,offsetY:e})}}const AP=350;class _P extends th{mutators=["open","toggle","close","changePanelSize","resetPanelSize"];currentPanelProps={};componentTag="";panelSize=AP;get isOpen(){return!!this.componentTag&&this.computeState(this.componentTag,this.currentPanelProps).isOpen}get panelProps(){const e=this.computeState(this.componentTag,this.currentPanelProps);return e.isOpen?e.props??{}:{}}get panelKey(){const e=this.computeState(this.componentTag,this.currentPanelProps);if(e.isOpen)return e.key}open(e,t={}){const o=this.computeState(e,t);o.isOpen&&(this.isOpen&&e!==this.componentTag&&this.currentPanelProps?.onCloseSidePanel?.(),this.componentTag=e,this.currentPanelProps=o.props??{})}toggle(e,t){this.isOpen&&e===this.componentTag?this.close():this.open(e,t)}close(){this.currentPanelProps.onCloseSidePanel?.(),this.currentPanelProps={},this.componentTag=""}changePanelSize(e,t){this.panelSize=e<AP?AP:e>t-150?Math.max(t-150,AP):e}resetPanelSize(){this.panelSize=AP}computeState(e,t){const o=AM.get(e).computeState;if(o){const e=o(this.getters,t);return e.isOpen&&(this.currentPanelProps=e.props??this.currentPanelProps),e}return{isOpen:!0,props:t}}}const DP="#777";rh`
|
|
1816
1816
|
.o-table-resizer {
|
|
1817
1817
|
width: ${6}px;
|
|
1818
1818
|
height: ${6}px;
|
|
@@ -2481,7 +2481,7 @@
|
|
|
2481
2481
|
border-radius: 4px;
|
|
2482
2482
|
font-weight: 500;
|
|
2483
2483
|
font-size: 14px;
|
|
2484
|
-
height: 32px;
|
|
2484
|
+
min-height: 32px;
|
|
2485
2485
|
line-height: 16px;
|
|
2486
2486
|
flex-grow: 1;
|
|
2487
2487
|
background-color: ${V};
|
|
@@ -3287,4 +3287,4 @@
|
|
|
3287
3287
|
<tableParts count="${e.tables.length}">
|
|
3288
3288
|
${ux(a)}
|
|
3289
3289
|
</tableParts>
|
|
3290
|
-
`}var QV;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(QV||(QV={}));function eL(e,t={}){const o=ze(t);return o.type=e,o}const tL={},oL={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:ee,HEADER_WIDTH:te,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:oe,DEFAULT_CELL_HEIGHT:se,SCROLLBAR_WIDTH:ie},sL={autoCompleteProviders:sd,autofillModifiersRegistry:sy,autofillRulesRegistry:iy,cellMenuRegistry:VA,colMenuRegistry:TD,errorTypes:Ii,linkMenuRegistry:UR,functionRegistry:xS,featurePluginRegistry:hk,iconsOnCellRegistry:Jy,statefulUIPluginRegistry:dk,coreViewsPluginRegistry:uk,corePluginRegistry:ck,rowMenuRegistry:OD,sidePanelRegistry:AM,figureRegistry:sR,chartSidePanelComponentRegistry:$O,chartComponentRegistry:XI,chartRegistry:YI,chartSubtypeRegistry:JI,topbarMenuRegistry:MD,topbarComponentRegistry:_M,clickableCellRegistry:gk,otRegistry:PD,inverseCommandRegistry:aR,urlRegistry:xn,cellPopoverRegistry:dy,numberFormatMenuRegistry:AD,repeatLocalCommandTransformRegistry:ik,repeatCommandTransformRegistry:sk,clipboardHandlersRegistries:Hc,pivotRegistry:eM,pivotTimeAdapterRegistry:tc,pivotSidePanelRegistry:iM,pivotNormalizationValueRegistry:Fc,supportedPivotPositionalFormulaRegistry:oy,pivotToFunctionValueRegistry:Mc,migrationStepRegistry:Nx,chartJsExtensionRegistry:hh},iL={arg:ad,isEvaluationError:ki,toBoolean:Yi,toJsDate:Xi,toNumber:Li,toString:qi,toNormalizedPivotValue:Ac,toXC:_o,toZone:Go,toUnboundedZone:$o,toCartesian:Ao,numberToLetters:bo,lettersToNumber:So,UuidGenerator:Ia,formatValue:Qn,createCurrencyFormat:gr,ColorGenerator:go,computeTextWidth:ua,createEmptyWorkbookData:$x,createEmptySheet:zx,createEmptyExcelSheet:Gx,rgbaToHex:jt,colorToRGBA:Yt,positionToZone:ds,isDefined:lt,isMatrix:yi,lazy:gt,genericRepeat:nk,createAction:i,createActions:o,transformRangeData:Bc,deepEquals:ft,overlap:ts,union:Jo,isInside:os,deepCopy:ze,expandZoneOnInsertion:jo,reduceZoneOnDeletion:Ko,unquote:Ge,getMaxObjectId:yc,getFunctionsFromTokens:jS,getFirstPivotFunction:ey,getNumberOfPivotFunctions:ty,parseDimension:xc,isDateOrDatetimeField:Ec,makeFieldProposal:XS,insertTokenAfterArgSeparator:KS,insertTokenAfterLeftParenthesis:JS,mergeContiguousZones:fs,getPivotHighlights:FD,pivotTimeAdapter:oc,UNDO_REDO_PIVOT_COMMANDS:DN,createPivotFormula:Tc,areDomainArgsFieldsValid:Rc,splitReference:jr,sanitizeSheetName:qe,getUniqueText:Vt,isNumber:ei,isDateTime:Vs},nL={isMarkdownLink:et,parseMarkdownLink:st,markdownLink:ot,openLink:An,urlRepresentation:Tn},rL={Checkbox:IR,Section:ND,RoundColorPicker:hO,ChartDataSeries:jD,ChartErrorSection:XD,ChartLabelRange:KD,ChartTitle:lO,ChartPanel:qO,ChartFigure:eR,ChartJsComponent:Bh,Grid:MP,GridOverlay:cP,ScorecardChart:od,LineConfigPanel:VO,BarConfigPanel:QD,PieChartDesignPanel:LO,GenericChartConfigPanel:JD,ChartWithAxisDesignPanel:fO,GaugeChartConfigPanel:bO,GaugeChartDesignPanel:FO,ScorecardChartConfigPanel:UO,ScorecardChartDesignPanel:BO,RadarChartDesignPanel:HO,WaterfallChartDesignPanel:zO,ComboChartDesignPanel:vO,ChartTypePicker:GO,FigureComponent:DM,Menu:eT,Popover:SR,SelectionInput:ZD,ValidationMessages:YD,AddDimensionButton:_F,PivotDimensionGranularity:MF,PivotDimensionOrder:PF,PivotDimension:FF,PivotLayoutConfigurator:VF,PivotHTMLRenderer:PP,PivotDeferUpdate:AF,PivotTitleSection:LF,CogWheelMenu:OF,TextInput:DF,SidePanelCollapsible:tO,RadioSelection:gO},aL={useDragAndDropListItems:LD,useHighlights:XO,useHighlightsOnHover:YO},lL={useStoreProvider:qc,DependencyContainer:$c,CellPopoverStore:gR,ComposerFocusStore:sh,CellComposerStore:BM,FindAndReplaceStore:wF,HighlightStore:_S,HoveredCellStore:uR,ModelStore:Jc,NotificationStore:DS,RendererStore:eh,SelectionInputStore:qD,SpreadsheetStore:th,useStore:Zc,useLocalStore:jc,SidePanelStore:_P,PivotSidePanelStore:oM,PivotMeasureDisplayPanelStore:RF};const cL={DEFAULT_LOCALE:bi,HIGHLIGHT_COLOR:a,PIVOT_TABLE_CONFIG:Ve,ChartTerms:Kx},hL={...lT,...RI};e.AbstractCellClipboardHandler=Pa,e.AbstractChart=zh,e.AbstractFigureClipboardHandler=Lc,e.CellErrorType=Ei,e.CorePlugin=kP,e.CoreViewPlugin=GP,e.DispatchResult=pi,e.EvaluationError=Ri,e.Model=class extends zc{corePlugins=[];statefulUIPlugins=[];range;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;coreViewPluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},o={},s=[],i=new Ia,n=!1){const r=performance.now();console.debug("##### Model creation #####"),super(),Lo===ko&&Ho===Vo&&(Ho=()=>!0),s=Ux(e,s);const a=Hx(e,n);this.state=new Qk,this.uuidGenerator=i,this.config=this.setupConfig(o),this.session=this.setupSession(a.revisionId),this.coreGetters={},this.range=new zP(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.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.adaptFormulaStringDependencies=this.range.adaptFormulaStringDependencies.bind(this.range),this.coreGetters.copyFormulaStringForSheet=this.range.copyFormulaStringForSheet.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode},this.selection=new Kk(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 ck.getAll())this.setupCorePlugin(e,a);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(s);for(let e of uk.getAll()){const t=this.setupCoreViewPlugin(e);this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of dk.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of hk.getAll()){const t=this.setupUiPlugin(e);this.handlers.push(t),this.uiHandlers.push(t)}if(this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.joinSession(),o.snapshotRequested||e["[Content_Types].xml"]&&!this.getters.isReadonly()){const e=performance.now();console.debug("Snapshot requested"),this.session.snapshot(this.exportData()),this.garbageCollectExternalResources(),console.debug("Snapshot taken in",performance.now()-e,"ms")}t.markRaw(this),console.debug("Model created in",performance.now()-r,"ms"),console.debug("######")}joinSession(){this.session.join(this.config.client)}async leaveSession(){const e=this.getters.isReadonly()?void 0:gt((()=>this.exportData()));await this.session.leave(e)}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}for(const o of e.layers)this.renderers[o]||(this.renderers[o]=[]),this.renderers[o].push(t);return t}setupCoreViewPlugin(e){const t=new e(this.coreViewPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}return t}setupCorePlugin(e,t){const o=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in o))throw new Error(`Invalid getter name: ${t} for plugin ${o.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=o[t].bind(o)}o.import(t),this.corePlugins.push(o),this.coreHandlers.push(o),this.handlers.push(o)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new qN(jk({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{this.checkDispatchAllowed(e).isSuccessful?(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1):this.dispatchToHandlers(this.coreHandlers,{type:"UNDO",commands:[e]})}}),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-undone",this,(({commands:e})=>{this.dispatchFromCorePlugin("UNDO",{commands:e}),this.finalize()})),this.session.on("revision-redone",this,(({commands:e})=>{this.dispatchFromCorePlugin("REDO",{commands:e}),this.finalize()})),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.smallUuid(),name:Bo("Anonymous").toString()},o=e.transportService||new Uk;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:o,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){const t=e.loadLocales||(()=>Promise.resolve(vi));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,custom:this.config.custom,external:this.config.external}}setupCoreViewPluginConfig(){return{getters:this.getters,stateObserver:this.state,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}}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}}checkDispatchAllowed(e){const t=gi(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some((e=>"Success"!==e))?new pi(t.flat()):pi.Success}checkDispatchAllowedCoreCommand(e){const t=this.corePlugins.map((t=>t.allowDispatch(e)));return t.push(this.range.allowDispatch(e)),t}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map((t=>t.allowDispatch(e)))}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0,this.trigger("command-finalized")}canDispatch=(e,t)=>this.checkDispatchAllowed(eL(e,t));dispatch=(e,t)=>{const o=eL(e,t);let s=this.status;if(this.getters.isReadonly()&&(i=o,!di.has(i.type)))return new pi("Readonly");var i;if(!this.session.canApplyOptimisticUpdate())return new pi("WaitingSessionConfirmation");switch(s){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return this.trigger("update"),t;this.status=1;const{changes:s,commands:i}=this.state.recordChanges((()=>{const t=performance.now();gi(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize();const s=performance.now()-t;s>5&&console.debug(e,s,"ms")}));this.session.save(o,i,s),this.status=0,this.trigger("update");break;case 1:if(gi(o)){const e=this.checkDispatchAllowed(o);if(!e.isSuccessful)return e;this.state.addCommand(o)}this.dispatchToHandlers(this.handlers,o);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(gi(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return pi.Success};dispatchFromCorePlugin=(e,t)=>{const o=eL(e,t),s=this.status;this.status=2;const i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,o),this.status=s,pi.Success};dispatchToHandlers(e,t){const o=gi(t);for(const s of e)!o&&s instanceof kP||s.beforeHandle(t);for(const s of e)!o&&s instanceof kP||s.handle(t);this.trigger("command-dispatched",t)}drawLayer(e,t){const o=this.renderers[t];if(o)for(const s of o)e.ctx.save(),s.drawLayer(e,t),e.ctx.restore()}exportData(){let e=$x();for(let t of this.handlers)t instanceof kP&&t.export(e);return e.revisionId=this.session.getRevisionId()||ye,e=ze(e),e}updateMode(e){this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...$x(),sheets:[Gx(Lx,"Sheet1")]};for(let t of this.handlers)t instanceof NP&&t.exportForExcel(e);return e=ze(e),KV(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.PivotRuntimeDefinition=HF,e.Registry=n,e.Revision=GN,e.SPREADSHEET_DIMENSIONS=oL,e.Spreadsheet=Hk,e.SpreadsheetPivotTable=zF,e.UIPlugin=FN,e.__info__=tL,e.addFunction=function e(t,o){return xS.add(t,o),{addFunction:(t,o)=>e(t,o)}},e.addRenderingLayer=function(e,t){if(wi[e])throw new Error(`Layer ${e} already exists`);wi[e]=t},e.astToFormula=dv,e.chartHelpers=hL,e.compile=$S,e.compileTokens=GS,e.components=rL,e.constants=cL,e.convertAstNodes=av,e.coreTypes=ui,e.findCellInNewZone=hs,e.functionCache=zS,e.helpers=iL,e.hooks=aL,e.invalidateCFEvaluationCommands=ci,e.invalidateDependenciesCommands=li,e.invalidateEvaluationCommands=ri,e.iterateAstNodes=lv,e.links=nL,e.load=Hx,e.parse=nv,e.parseTokens=rv,e.readonlyAllowedCommands=di,e.registries=sL,e.setDefaultSheetViewSize=function(e){Me=e},e.setTranslationMethod=function(e,t=(()=>!0)){Lo=e,Ho=t},e.stores=lL,e.tokenColors=MS,e.tokenize=Va,tL.version="18.2.34",tL.date="2025-11-12T14:15:32.431Z",tL.hash="9ca0c4c"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|
|
3290
|
+
`}var QV;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(QV||(QV={}));function eL(e,t={}){const o=ze(t);return o.type=e,o}const tL={},oL={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:ee,HEADER_WIDTH:te,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:oe,DEFAULT_CELL_HEIGHT:se,SCROLLBAR_WIDTH:ie},sL={autoCompleteProviders:sd,autofillModifiersRegistry:sy,autofillRulesRegistry:iy,cellMenuRegistry:VA,colMenuRegistry:TD,errorTypes:Ii,linkMenuRegistry:UR,functionRegistry:xS,featurePluginRegistry:hk,iconsOnCellRegistry:Jy,statefulUIPluginRegistry:dk,coreViewsPluginRegistry:uk,corePluginRegistry:ck,rowMenuRegistry:OD,sidePanelRegistry:AM,figureRegistry:sR,chartSidePanelComponentRegistry:$O,chartComponentRegistry:XI,chartRegistry:YI,chartSubtypeRegistry:JI,topbarMenuRegistry:MD,topbarComponentRegistry:_M,clickableCellRegistry:gk,otRegistry:PD,inverseCommandRegistry:aR,urlRegistry:xn,cellPopoverRegistry:dy,numberFormatMenuRegistry:AD,repeatLocalCommandTransformRegistry:ik,repeatCommandTransformRegistry:sk,clipboardHandlersRegistries:Hc,pivotRegistry:eM,pivotTimeAdapterRegistry:tc,pivotSidePanelRegistry:iM,pivotNormalizationValueRegistry:Fc,supportedPivotPositionalFormulaRegistry:oy,pivotToFunctionValueRegistry:Mc,migrationStepRegistry:Nx,chartJsExtensionRegistry:hh},iL={arg:ad,isEvaluationError:ki,toBoolean:Yi,toJsDate:Xi,toNumber:Li,toString:qi,toNormalizedPivotValue:Ac,toXC:_o,toZone:Go,toUnboundedZone:$o,toCartesian:Ao,numberToLetters:bo,lettersToNumber:So,UuidGenerator:Ia,formatValue:Qn,createCurrencyFormat:gr,ColorGenerator:go,computeTextWidth:ua,createEmptyWorkbookData:$x,createEmptySheet:zx,createEmptyExcelSheet:Gx,rgbaToHex:jt,colorToRGBA:Yt,positionToZone:ds,isDefined:lt,isMatrix:yi,lazy:gt,genericRepeat:nk,createAction:i,createActions:o,transformRangeData:Bc,deepEquals:ft,overlap:ts,union:Jo,isInside:os,deepCopy:ze,expandZoneOnInsertion:jo,reduceZoneOnDeletion:Ko,unquote:Ge,getMaxObjectId:yc,getFunctionsFromTokens:jS,getFirstPivotFunction:ey,getNumberOfPivotFunctions:ty,parseDimension:xc,isDateOrDatetimeField:Ec,makeFieldProposal:XS,insertTokenAfterArgSeparator:KS,insertTokenAfterLeftParenthesis:JS,mergeContiguousZones:fs,getPivotHighlights:FD,pivotTimeAdapter:oc,UNDO_REDO_PIVOT_COMMANDS:DN,createPivotFormula:Tc,areDomainArgsFieldsValid:Rc,splitReference:jr,sanitizeSheetName:qe,getUniqueText:Vt,isNumber:ei,isDateTime:Vs},nL={isMarkdownLink:et,parseMarkdownLink:st,markdownLink:ot,openLink:An,urlRepresentation:Tn},rL={Checkbox:IR,Section:ND,RoundColorPicker:hO,ChartDataSeries:jD,ChartErrorSection:XD,ChartLabelRange:KD,ChartTitle:lO,ChartPanel:qO,ChartFigure:eR,ChartJsComponent:Bh,Grid:MP,GridOverlay:cP,ScorecardChart:od,LineConfigPanel:VO,BarConfigPanel:QD,PieChartDesignPanel:LO,GenericChartConfigPanel:JD,ChartWithAxisDesignPanel:fO,GaugeChartConfigPanel:bO,GaugeChartDesignPanel:FO,ScorecardChartConfigPanel:UO,ScorecardChartDesignPanel:BO,RadarChartDesignPanel:HO,WaterfallChartDesignPanel:zO,ComboChartDesignPanel:vO,ChartTypePicker:GO,FigureComponent:DM,Menu:eT,Popover:SR,SelectionInput:ZD,ValidationMessages:YD,AddDimensionButton:_F,PivotDimensionGranularity:MF,PivotDimensionOrder:PF,PivotDimension:FF,PivotLayoutConfigurator:VF,PivotHTMLRenderer:PP,PivotDeferUpdate:AF,PivotTitleSection:LF,CogWheelMenu:OF,TextInput:DF,SidePanelCollapsible:tO,RadioSelection:gO},aL={useDragAndDropListItems:LD,useHighlights:XO,useHighlightsOnHover:YO},lL={useStoreProvider:qc,DependencyContainer:$c,CellPopoverStore:gR,ComposerFocusStore:sh,CellComposerStore:BM,FindAndReplaceStore:wF,HighlightStore:_S,HoveredCellStore:uR,ModelStore:Jc,NotificationStore:DS,RendererStore:eh,SelectionInputStore:qD,SpreadsheetStore:th,useStore:Zc,useLocalStore:jc,SidePanelStore:_P,PivotSidePanelStore:oM,PivotMeasureDisplayPanelStore:RF};const cL={DEFAULT_LOCALE:bi,HIGHLIGHT_COLOR:a,PIVOT_TABLE_CONFIG:Ve,ChartTerms:Kx},hL={...lT,...RI};e.AbstractCellClipboardHandler=Pa,e.AbstractChart=zh,e.AbstractFigureClipboardHandler=Lc,e.CellErrorType=Ei,e.CorePlugin=kP,e.CoreViewPlugin=GP,e.DispatchResult=pi,e.EvaluationError=Ri,e.Model=class extends zc{corePlugins=[];statefulUIPlugins=[];range;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;coreViewPluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},o={},s=[],i=new Ia,n=!1){const r=performance.now();console.debug("##### Model creation #####"),super(),Lo===ko&&Ho===Vo&&(Ho=()=>!0),s=Ux(e,s);const a=Hx(e,n);this.state=new Qk,this.uuidGenerator=i,this.config=this.setupConfig(o),this.session=this.setupSession(a.revisionId),this.coreGetters={},this.range=new zP(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.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.adaptFormulaStringDependencies=this.range.adaptFormulaStringDependencies.bind(this.range),this.coreGetters.copyFormulaStringForSheet=this.range.copyFormulaStringForSheet.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode},this.selection=new Kk(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 ck.getAll())this.setupCorePlugin(e,a);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(s);for(let e of uk.getAll()){const t=this.setupCoreViewPlugin(e);this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of dk.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of hk.getAll()){const t=this.setupUiPlugin(e);this.handlers.push(t),this.uiHandlers.push(t)}if(this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.joinSession(),o.snapshotRequested||e["[Content_Types].xml"]&&!this.getters.isReadonly()){const e=performance.now();console.debug("Snapshot requested"),this.session.snapshot(this.exportData()),this.garbageCollectExternalResources(),console.debug("Snapshot taken in",performance.now()-e,"ms")}t.markRaw(this),console.debug("Model created in",performance.now()-r,"ms"),console.debug("######")}joinSession(){this.session.join(this.config.client)}async leaveSession(){const e=this.getters.isReadonly()?void 0:gt((()=>this.exportData()));await this.session.leave(e)}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}for(const o of e.layers)this.renderers[o]||(this.renderers[o]=[]),this.renderers[o].push(t);return t}setupCoreViewPlugin(e){const t=new e(this.coreViewPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}return t}setupCorePlugin(e,t){const o=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in o))throw new Error(`Invalid getter name: ${t} for plugin ${o.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=o[t].bind(o)}o.import(t),this.corePlugins.push(o),this.coreHandlers.push(o),this.handlers.push(o)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new qN(jk({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{this.checkDispatchAllowed(e).isSuccessful?(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1):this.dispatchToHandlers(this.coreHandlers,{type:"UNDO",commands:[e]})}}),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-undone",this,(({commands:e})=>{this.dispatchFromCorePlugin("UNDO",{commands:e}),this.finalize()})),this.session.on("revision-redone",this,(({commands:e})=>{this.dispatchFromCorePlugin("REDO",{commands:e}),this.finalize()})),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.smallUuid(),name:Bo("Anonymous").toString()},o=e.transportService||new Uk;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:o,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){const t=e.loadLocales||(()=>Promise.resolve(vi));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,custom:this.config.custom,external:this.config.external}}setupCoreViewPluginConfig(){return{getters:this.getters,stateObserver:this.state,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}}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}}checkDispatchAllowed(e){const t=gi(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some((e=>"Success"!==e))?new pi(t.flat()):pi.Success}checkDispatchAllowedCoreCommand(e){const t=this.corePlugins.map((t=>t.allowDispatch(e)));return t.push(this.range.allowDispatch(e)),t}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map((t=>t.allowDispatch(e)))}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0,this.trigger("command-finalized")}canDispatch=(e,t)=>this.checkDispatchAllowed(eL(e,t));dispatch=(e,t)=>{const o=eL(e,t);let s=this.status;if(this.getters.isReadonly()&&(i=o,!di.has(i.type)))return new pi("Readonly");var i;if(!this.session.canApplyOptimisticUpdate())return new pi("WaitingSessionConfirmation");switch(s){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return this.trigger("update"),t;this.status=1;const{changes:s,commands:i}=this.state.recordChanges((()=>{const t=performance.now();gi(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize();const s=performance.now()-t;s>5&&console.debug(e,s,"ms")}));this.session.save(o,i,s),this.status=0,this.trigger("update");break;case 1:if(gi(o)){const e=this.checkDispatchAllowed(o);if(!e.isSuccessful)return e;this.state.addCommand(o)}this.dispatchToHandlers(this.handlers,o);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(gi(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return pi.Success};dispatchFromCorePlugin=(e,t)=>{const o=eL(e,t),s=this.status;this.status=2;const i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,o),this.status=s,pi.Success};dispatchToHandlers(e,t){const o=gi(t);for(const s of e)!o&&s instanceof kP||s.beforeHandle(t);for(const s of e)!o&&s instanceof kP||s.handle(t);this.trigger("command-dispatched",t)}drawLayer(e,t){const o=this.renderers[t];if(o)for(const s of o)e.ctx.save(),s.drawLayer(e,t),e.ctx.restore()}exportData(){let e=$x();for(let t of this.handlers)t instanceof kP&&t.export(e);return e.revisionId=this.session.getRevisionId()||ye,e=ze(e),e}updateMode(e){this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...$x(),sheets:[Gx(Lx,"Sheet1")]};for(let t of this.handlers)t instanceof NP&&t.exportForExcel(e);return e=ze(e),KV(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.PivotRuntimeDefinition=HF,e.Registry=n,e.Revision=GN,e.SPREADSHEET_DIMENSIONS=oL,e.Spreadsheet=Hk,e.SpreadsheetPivotTable=zF,e.UIPlugin=FN,e.__info__=tL,e.addFunction=function e(t,o){return xS.add(t,o),{addFunction:(t,o)=>e(t,o)}},e.addRenderingLayer=function(e,t){if(wi[e])throw new Error(`Layer ${e} already exists`);wi[e]=t},e.astToFormula=dv,e.chartHelpers=hL,e.compile=$S,e.compileTokens=GS,e.components=rL,e.constants=cL,e.convertAstNodes=av,e.coreTypes=ui,e.findCellInNewZone=hs,e.functionCache=zS,e.helpers=iL,e.hooks=aL,e.invalidateCFEvaluationCommands=ci,e.invalidateDependenciesCommands=li,e.invalidateEvaluationCommands=ri,e.iterateAstNodes=lv,e.links=nL,e.load=Hx,e.parse=nv,e.parseTokens=rv,e.readonlyAllowedCommands=di,e.registries=sL,e.setDefaultSheetViewSize=function(e){Me=e},e.setTranslationMethod=function(e,t=(()=>!0)){Lo=e,Ho=t},e.stores=lL,e.tokenColors=MS,e.tokenize=Va,tL.version="18.2.35",tL.date="2025-11-24T07:40:00.240Z",tL.hash="2e9a842"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|