@odoo/o-spreadsheet 16.0.40 → 16.0.41

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.
@@ -18754,7 +18754,7 @@ function matchReference(tokens) {
18754
18754
  var _a;
18755
18755
  let head = 0;
18756
18756
  let transitions = machine[State.LeftRef];
18757
- const matchedTokens = [];
18757
+ let matchedTokens = "";
18758
18758
  while (transitions !== undefined) {
18759
18759
  const token = tokens[head++];
18760
18760
  if (!token) {
@@ -18766,15 +18766,15 @@ function matchReference(tokens) {
18766
18766
  case undefined:
18767
18767
  return null;
18768
18768
  case State.Found:
18769
- matchedTokens.push(token);
18769
+ matchedTokens += token.value;
18770
18770
  tokens.splice(0, head);
18771
18771
  return {
18772
18772
  type: "REFERENCE",
18773
- value: concat(matchedTokens.map((token) => token.value)),
18773
+ value: matchedTokens,
18774
18774
  };
18775
18775
  default:
18776
18776
  transitions = machine[nextState];
18777
- matchedTokens.push(token);
18777
+ matchedTokens += token.value;
18778
18778
  break;
18779
18779
  }
18780
18780
  }
@@ -43323,6 +43323,6 @@ exports.setTranslationMethod = setTranslationMethod;
43323
43323
  exports.tokenize = tokenize;
43324
43324
 
43325
43325
 
43326
- __info__.version = '16.0.40';
43327
- __info__.date = '2024-04-26T07:39:46.758Z';
43328
- __info__.hash = '70a6783';
43326
+ __info__.version = '16.0.41';
43327
+ __info__.date = '2024-05-15T09:15:13.021Z';
43328
+ __info__.hash = '3b3f648';
@@ -18750,7 +18750,7 @@ function matchReference(tokens) {
18750
18750
  var _a;
18751
18751
  let head = 0;
18752
18752
  let transitions = machine[State.LeftRef];
18753
- const matchedTokens = [];
18753
+ let matchedTokens = "";
18754
18754
  while (transitions !== undefined) {
18755
18755
  const token = tokens[head++];
18756
18756
  if (!token) {
@@ -18762,15 +18762,15 @@ function matchReference(tokens) {
18762
18762
  case undefined:
18763
18763
  return null;
18764
18764
  case State.Found:
18765
- matchedTokens.push(token);
18765
+ matchedTokens += token.value;
18766
18766
  tokens.splice(0, head);
18767
18767
  return {
18768
18768
  type: "REFERENCE",
18769
- value: concat(matchedTokens.map((token) => token.value)),
18769
+ value: matchedTokens,
18770
18770
  };
18771
18771
  default:
18772
18772
  transitions = machine[nextState];
18773
- matchedTokens.push(token);
18773
+ matchedTokens += token.value;
18774
18774
  break;
18775
18775
  }
18776
18776
  }
@@ -43291,6 +43291,6 @@ function addFunction(functionName, functionDescription) {
43291
43291
  export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, cellTypes, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, load, parse, readonlyAllowedCommands, registries, setTranslationMethod, tokenize };
43292
43292
 
43293
43293
 
43294
- __info__.version = '16.0.40';
43295
- __info__.date = '2024-04-26T07:39:46.758Z';
43296
- __info__.hash = '70a6783';
43294
+ __info__.version = '16.0.41';
43295
+ __info__.date = '2024-05-15T09:15:13.021Z';
43296
+ __info__.hash = '3b3f648';
@@ -18751,7 +18751,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
18751
18751
  var _a;
18752
18752
  let head = 0;
18753
18753
  let transitions = machine[State.LeftRef];
18754
- const matchedTokens = [];
18754
+ let matchedTokens = "";
18755
18755
  while (transitions !== undefined) {
18756
18756
  const token = tokens[head++];
18757
18757
  if (!token) {
@@ -18763,15 +18763,15 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
18763
18763
  case undefined:
18764
18764
  return null;
18765
18765
  case State.Found:
18766
- matchedTokens.push(token);
18766
+ matchedTokens += token.value;
18767
18767
  tokens.splice(0, head);
18768
18768
  return {
18769
18769
  type: "REFERENCE",
18770
- value: concat(matchedTokens.map((token) => token.value)),
18770
+ value: matchedTokens,
18771
18771
  };
18772
18772
  default:
18773
18773
  transitions = machine[nextState];
18774
- matchedTokens.push(token);
18774
+ matchedTokens += token.value;
18775
18775
  break;
18776
18776
  }
18777
18777
  }
@@ -43322,9 +43322,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43322
43322
  Object.defineProperty(exports, '__esModule', { value: true });
43323
43323
 
43324
43324
 
43325
- __info__.version = '16.0.40';
43326
- __info__.date = '2024-04-26T07:39:46.758Z';
43327
- __info__.hash = '70a6783';
43325
+ __info__.version = '16.0.41';
43326
+ __info__.date = '2024-05-15T09:15:13.021Z';
43327
+ __info__.hash = '3b3f648';
43328
43328
 
43329
43329
 
43330
43330
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
@@ -980,7 +980,7 @@
980
980
  opacity: 0;
981
981
  pointer-events: none;
982
982
  }
983
- `;class Ns extends t.Component{get tagStyle(){const{col:e,row:t,color:i}=this.props,{height:n}=this.env.model.getters.getSheetViewDimensionWithHeaders(),{x:o,y:r}=this.env.model.getters.getVisibleRect({left:e,top:t,right:e,bottom:t});return`bottom: ${n-r+15}px;left: ${o-1}px;border: 1px solid ${i};background-color: ${i};${this.props.active?"opacity:1 !important":""}`}}Ns.template="o-spreadsheet-ClientTag";const Ms=/(.*?)\((.*?)\)(.*)/,Os=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function _s(e){let t=e.split("\n");const i=[];for(let e of t)e=e.trim(),e&&i.push(Fs(e));return i}function Fs(e){let t,i=e.match(Ms),n=i[1].trim(),o=[],r=!1,s=!1,a=!1;for(let e of i[2].split(",")){const i=e.trim().toUpperCase();let n=Os.find((e=>i===e));n?o.push(n):"RANGE<ANY>"===i?o.push("RANGE"):"OPTIONAL"===i?r=!0:"REPEATING"===i?s=!0:"LAZY"===i?a=!0:i.startsWith("DEFAULT=")&&(t=e.trim().slice(8))}const l={name:n,description:i[3].trim(),type:o};return r&&(l.optional=!0),s&&(l.repeating=!0),a&&(l.lazy=!0),void 0!==t&&(l.default=!0,l.defaultValue=t),l}function Ds(e){let t=0,i=0,n=0;for(let o of e.args)t++,o.optional||o.repeating||o.default||i++,o.repeating&&n++;const o=e;return o.minArgRequired=i,o.maxArgPossible=n?1/0:t,o.nbrArgRepeating=n,o.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const i=e-t;return e=>{if(e<=i)return e;return i+((e-i)%t||t)}}(t,n),o}const ks=["number","string","boolean","undefined"];function $s(e,t){if(!e())throw new Error(t)}const Ls=e=>r("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Ps(e){switch(typeof e){case"number":return e;case"boolean":return e?1:0;case"string":if(Ci(e)||""===e)return wi(e);const t=ve(e);if(t)return t.value;throw new Error(Ls(e));default:return 0}}function Us(e){if(""===e)throw new Error(Ls(e));return Ps(e)}function Vs(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}const zs=function(e){const t=new Map,i=e.name?e.name+" (memoized)":"memoized";return{[i]:(...i)=>(t.has(i[0])||t.set(i[0],e(...i)),t.get(i[0]))}[i]}((function(e){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")}));function Bs(e){return"string"==typeof e?zs(e):e}const Hs=e=>r("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function Ws(e){switch(typeof e){case"boolean":return e;case"string":if(e){let t=e.toUpperCase();if("TRUE"===t)return!0;if("FALSE"===t)return!1;throw new Error(Hs(e))}return!1;case"number":return!!e;default:return!1}}function Gs(e){return Se(Ps(e))}function qs(e,t,i){for(let n of e)if(Array.isArray(n)){const e=n.length,i=n[0].length;for(let o=0;o<i;o++)for(let i=0;i<e;i++)t(n[i][o])}else i(n)}function Zs(e,t){qs(e,t,t)}function js(e,t){qs(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(Us(e))}))}function Ys(e,t,i,n){let o=n;for(let n of e)if(Array.isArray(n)){const e=n.length,i=n[0].length;for(let r=0;r<i;r++)for(let i=0;i<e;i++)o=t(o,n[i][r])}else o=i(o,n);return o}function Xs(e,t,i){return Ys(e,t,t,i)}function Ks(e,t,i){return Ys(e,((e,i)=>"number"==typeof i?t(e,i):e),((e,i)=>t(e,Us(i))),i)}function Qs(e,t,i){return Ys(e,((e,i)=>null!=i?t(e,"number"==typeof i?i:"boolean"==typeof i?Ps(i):0):e),((e,i)=>t(e,Ps(i))),i)}function Js(e,t){return function(e,t,i){for(let n of e)if(Array.isArray(n)){const e=n.length,i=n[0].length;for(let o=0;o<i;o++)for(let i=0;i<e;i++)if(!t(n[i][o]))return}else if(!i(n))return}(e,(e=>"boolean"==typeof e?t(e):"number"!=typeof e||t(!!e)),(e=>null==e||t(function(e){if(""===e)throw new Error(Hs(e));return Ws(e)}(e))))}function ea(e,t){let i,n,o=e.substring(0,2);"<="===o||">="===o||"<>"===o?(i=o,n=e.substring(2)):(o=e.substring(0,1),"<"===o||">"===o||"="===o?(i=o,n=e.substring(1)):(i="=",n=e)),Ci(n)?n=Ps(n):"TRUE"!==n&&"FALSE"!==n||(n=Ws(n));const r={operator:i,operand:n};return"string"==typeof n&&(t&&(n+="*"),r.regexp=function(e){let t="",i="";for(let n of e)"?"===n&&"~"!==i?t+=".":"*"===n&&"~"!==i?t+=".*":("*"!==n&&"?"!==n||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(n)&&(t+="\\"),t+=n),i=n;return new RegExp("^"+t+"$","i")}(n)),r}function ta(e,t){const{operator:i,operand:n}=t;if(void 0===e||void 0===n)return!1;if("number"==typeof n&&"="===i)return Vs(e)===Vs(n);if("<>"===i||"="===i){let o;return o=typeof e==typeof n&&("string"==typeof e&&t.regexp?t.regexp.test(e):e===n),"="===i?o:!o}if(typeof e==typeof n)switch(i){case"<":return e<n;case">":return e>n;case"<=":return e<=n;case">=":return e>=n}return!1}function ia(e,t,i=!1){const n=e.length;if(n%2==1)throw new Error(r("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const o=e[0].length,s=e[0][0].length;let a=[];for(let t=0;t<n-1;t+=2){const n=e[t];if(!Array.isArray(n)||n.length!==o||n[0].length!==s)throw new Error(r("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const l=Vs(e[t+1]);a.push(ea(l,i))}for(let i=0;i<o;i++)for(let o=0;o<s;o++){let r=!0;for(let t=0;t<n-1;t+=2){if(r=ta(e[t][i][o],a[t/2]),!r)break}r&&t(i,o)}}function na(e,t){return Bs(e[0][t])}function oa(e,t){return Bs(e[t][0])}function ra(e,t,i,n,o,r){if(null==t)return-1;const s=typeof t;let a,l,c,h,d,u,g=0,p=o-1;for(;p-g>=0;){for(c=Math.floor((g+p)/2),h=c,d=r(e,h),u=typeof d;g<h&&s!==u;)h--,d=r(e,h),u=typeof d;u===s&&void 0!==d?("strict"===i&&d===t?(a=d,l=h):"nextSmaller"===i&&d<=t?(void 0===a||a<d||a===d&&"asc"===n&&l<h||a===d&&"desc"===n&&l>h)&&(a=d,l=h):"nextGreater"===i&&d>=t&&(void 0===a||a>d||a===d&&"asc"===n&&l<h||a===d&&"desc"===n&&l>h)&&(a=d,l=h),"asc"===n&&d>t||"desc"===n&&d<=t?p=h-1:g=c+1):g=c+1}return void 0!==l?l:-1}function sa(e,t,i,n,o,r=!1){if(null==t)return-1;const s=r?(e,t)=>o(e,n-t-1):o;let a,l=-1;for(let o=0;o<n;o++){const c=s(e,o);if(c===t)return r?n-o-1:o;"nextSmaller"===i?(!a&&aa(t,c)>=0||aa(t,c)>=0&&aa(c,a)>0)&&(a=c,l=o):"nextGreater"===i&&(!a&&aa(t,c)<=0||aa(t,c)<=0&&aa(c,a)<0)&&(a=c,l=o)}return r?n-l-1:l}function aa(e,t){let i=ks.indexOf(typeof e)-ks.indexOf(typeof t);return 0===i&&("string"==typeof e&&"string"==typeof t?i=e.localeCompare(t):"number"==typeof e&&"number"==typeof t?i=e-t:"boolean"==typeof e&&"boolean"==typeof t&&(i=Number(e)-Number(t))),i}const la={description:r("Apply a large number format"),args:_s(`\n value (number) ${r("The number.")}\n unit (string, optional) ${r("The formatting unit. Use 'k', 'm', or 'b' to force the unit")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>{const i=Math.abs(Ps(e.value)),n=e.format;if(void 0!==t){switch(null==t?void 0:t.value){case"k":return li(n,1e3,"k");case"m":return li(n,1e6,"m");case"b":return li(n,1e9,"b");default:throw new Error(r("The formatting unit should be 'k', 'm' or 'b'."))}}return i<1e5?li(n,0,""):i<1e8?li(n,1e3,"k"):i<1e11?li(n,1e6,"m"):li(n,1e9,"b")},compute:function(e){return Ps(e)}};var ca=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:la});const ha={description:r("Absolute value of a number."),args:_s(`\n value (number) ${r("The number of which to return the absolute value.")}\n `),returns:["NUMBER"],compute:function(e){return Math.abs(Ps(e))},isExported:!0},da={description:r("Inverse cosine of a value, in radians."),args:_s(`\n value (number) ${r("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},ua={description:r("Inverse hyperbolic cosine of a number."),args:_s(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>t>=1),r("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},ga={description:r("Inverse cotangent of a value."),args:_s(`\n value (number) ${r("The value for which to calculate the inverse cotangent.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},pa={description:r("Inverse hyperbolic cotangent of a value."),args:_s(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>Math.abs(t)>1),r("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},ma={description:r("Inverse sine of a value, in radians."),args:_s(`\n value (number) ${r("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},fa={description:r("Inverse hyperbolic sine of a number."),args:_s(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic sine.")}\n `),returns:["NUMBER"],compute:function(e){return Math.asinh(Ps(e))},isExported:!0},va={description:r("Inverse tangent of a value, in radians."),args:_s(`\n value (number) ${r("The value for which to calculate the inverse tangent.")}\n `),returns:["NUMBER"],compute:function(e){return Math.atan(Ps(e))},isExported:!0},ba={description:r("Angle from the X axis to a point (x,y), in radians."),args:_s(`\n x (number) ${r("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n y (number) ${r("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Ps(e),n=Ps(t);return $s((()=>0!==i||0!==n),r("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(n,i)},isExported:!0},Sa={description:r("Inverse hyperbolic tangent of a number."),args:_s(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>Math.abs(t)<1),r("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},Ca={description:r("Rounds number up to nearest multiple of factor."),args:_s(`\n value (number) ${r("The value to round up to the nearest integer multiple of factor.")}\n factor (number, default=1) ${r("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Ps(e),n=Ps(t);return $s((()=>n>=0||i<=0),r("The factor (%s) must be positive when the value (%s) is positive.",n.toString(),i.toString())),n?Math.ceil(i/n)*n:0},isExported:!0},Ea={description:r("Rounds number up to nearest multiple of factor."),args:_s(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n mode (number, default=0) ${r("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let n=Ps(t);if(0===n)return 0;const o=Ps(e);if(n=Math.abs(n),o>=0)return Math.ceil(o/n)*n;return 0===Ps(i)?-Math.floor(Math.abs(o)/n)*n:-Math.ceil(Math.abs(o)/n)*n},isExported:!0},wa={description:r("Rounds number up to nearest multiple of factor."),args:_s(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){return Ea.compute(e,t,0)},isExported:!0},ya={description:r("Cosine of an angle provided in radians."),args:_s(`\n angle (number) ${r("The angle to find the cosine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cos(Ps(e))},isExported:!0},xa={description:r("Hyperbolic cosine of any real number."),args:_s(`\n value (number) ${r("Any real value to calculate the hyperbolic cosine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cosh(Ps(e))},isExported:!0},Ra={description:r("Cotangent of an angle provided in radians."),args:_s(`\n angle (number) ${r("The angle to find the cotangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},Ia={description:r("Hyperbolic cotangent of any real number."),args:_s(`\n value (number) ${r("Any real value to calculate the hyperbolic cotangent of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},Ta={description:r("Number of empty values."),args:_s(`\n value1 (any, range) ${r("The first value or range in which to count the number of blanks.")}\n value2 (any, range, repeating) ${r("Additional values or ranges in which to count the number of blanks.")}\n `),returns:["NUMBER"],compute:function(...e){return Xs(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},Aa={description:r("A conditional count across a range."),args:_s(`\n range (range) ${r("The range that is tested against criterion.")}\n criterion (string) ${r("The pattern or test to apply to range.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return ia(e,((e,i)=>{t+=1})),t},isExported:!0},Na={description:r("Count values depending on multiple criteria."),args:_s(`\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("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.")}\n criterion2 (string, repeating) ${r("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return ia(e,((e,i)=>{t+=1})),t},isExported:!0};function Ma(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const Oa={description:r("Counts number of unique values in a range."),args:_s(`\n value1 (any, range) ${r("The first value or range to consider for uniqueness.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider for uniqueness.")}\n `),returns:["NUMBER"],compute:function(...e){return Xs(e,((e,t)=>Ma(t)?e.add(t):e),new Set).size}},_a={description:r("Counts number of unique values in a range, filtered by a set of criteria."),args:_s(`\n range (range) ${r("The range of cells from which the number of unique values will be counted.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("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.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=new Set;return ia(t,((t,n)=>{const o=e[t][n];Ma(o)&&i.add(o)})),i.size}},Fa={description:r("Cosecant of an angle provided in radians."),args:_s(`\n angle (number) ${r("The angle to find the cosecant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},Da={description:r("Hyperbolic cosecant of any real number."),args:_s(`\n value (number) ${r("Any real value to calculate the hyperbolic cosecant of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},ka={description:r("Converts from another base to decimal."),args:_s(`\n value (string) ${r("The number to convert.")},\n base (number) ${r("The base to convert the value from.")},\n `),returns:["NUMBER"],compute:function(e,t){let i=Ps(t);i=Math.floor(i),$s((()=>2<=i&&i<=36),r("The base (%s) must be between 2 and 36 inclusive.",i.toString()));const n=Vs(e);if(""===n)return 0;$s((()=>!!n.match(/^-?[a-z0-9]+$/i)),r("The value (%s) must be a valid base %s representation.",n,i.toString()));const o=parseInt(n,i);return $s((()=>!isNaN(o)),r("The value (%s) must be a valid base %s representation.",n,i.toString())),o},isExported:!0},$a={description:r("Converts an angle value in radians to degrees."),args:_s(`\n angle (number) ${r("The angle to convert from radians to degrees.")}\n `),returns:["NUMBER"],compute:function(e){return 180*Ps(e)/Math.PI},isExported:!0},La={description:r("Euler's number, e (~2.718) raised to a power."),args:_s(`\n value (number) ${r("The exponent to raise e.")}\n `),returns:["NUMBER"],compute:function(e){return Math.exp(Ps(e))},isExported:!0},Pa={description:r("Rounds number down to nearest multiple of factor."),args:_s(`\n value (number) ${r("The value to round down to the nearest integer multiple of factor.")}\n factor (number, default=1) ${r("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Ps(e),n=Ps(t);return $s((()=>n>=0||i<=0),r("The factor (%s) must be positive when the value (%s) is positive.",n.toString(),i.toString())),n?Math.floor(i/n)*n:0},isExported:!0},Ua={description:r("Rounds number down to nearest multiple of factor."),args:_s(`\n number (number) ${r("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n mode (number, default=0) ${r("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let n=Ps(t);if(0===n)return 0;const o=Ps(e);if(n=Math.abs(n),o>=0)return Math.floor(o/n)*n;return 0===Ps(i)?-Math.ceil(Math.abs(o)/n)*n:-Math.floor(Math.abs(o)/n)*n},isExported:!0},Va={description:r("Rounds number down to nearest multiple of factor."),args:_s(`\n number (number) ${r("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return Ua.compute(e,t,0)},isExported:!0},za={description:r("Whether the provided value is even."),args:_s(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=Us(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},Ba={description:r("Rounds number up to nearest multiple of factor."),args:_s(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return Ea.compute(e,t,0)},isExported:!0},Ha={description:r("Whether the provided value is even."),args:_s(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=Us(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},Wa={description:r("The logarithm of a number, base e (euler's number)."),args:_s(`\n value (number) ${r("The value for which to calculate the logarithm, base e.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>t>0),r("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},Ga={description:r("Modulo (remainder) operator."),args:_s(`\n dividend (number) ${r("The number to be divided to find the remainder.")}\n divisor (number) ${r("The number to divide by.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Ps(t);$s((()=>0!==i),r("The divisor must be different from 0."));const n=Ps(e)%i;return n>0&&i<0||n<0&&i>0?n+i:n},isExported:!0},qa={description:r("Rounds a number up to the nearest odd integer."),args:_s(`\n value (number) ${r("The value to round to the next greatest odd number.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Ps(e);let i=Math.ceil(Math.abs(t));return i=1&i?i:i+1,t<0?-i:i},isExported:!0},Za={description:r("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},ja={description:r("A number raised to a power."),args:_s(`\n base (number) ${r("The number to raise to the exponent power.")}\n exponent (number) ${r("The exponent to raise base to.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Ps(e),n=Ps(t);return $s((()=>i>=0||Number.isInteger(n)),r("The exponent (%s) must be an integer when the base is negative.",n.toString())),Math.pow(i,n)},isExported:!0},Ya={description:r("Result of multiplying a series of numbers together."),args:_s(`\n factor1 (number, range<number>) ${r("The first number or range to calculate for the product.")}\n factor2 (number, range<number>, repeating) ${r("More numbers or ranges to calculate for the product.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0,i=1;for(let n of e)if(Array.isArray(n))for(let e of n)for(let n of e)"number"==typeof n&&(i*=n,t+=1);else null!=n&&(i*=Us(n),t+=1);return 0===t?0:i},isExported:!0},Xa={description:r("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},Ka={description:r("Random integer between two values, inclusive."),args:_s(`\n low (number) ${r("The low end of the random range.")}\n high (number) ${r("The high end of the random range.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){let i=Ps(e);Number.isInteger(i)||(i=Math.ceil(i));let n=Ps(t);return Number.isInteger(n)||(n=Math.floor(n)),$s((()=>i<=n),r("The high (%s) must be greater than or equal to the low (%s).",n.toString(),i.toString())),i+Math.ceil((n-i+1)*Math.random())-1},isExported:!0},Qa={description:r("Rounds a number according to standard rules."),args:_s(`\n value (number) ${r("The value to round to places number of places.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Ps(e);let n=Ps(t);const o=Math.abs(i);let r;return 0===n?r=Math.round(o):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.round(o*Math.pow(10,n))/Math.pow(10,n)),i>=0?r:-r},isExported:!0},Ja={description:r("Rounds down a number."),args:_s(`\n value (number) ${r("The value to round to places number of places, always rounding down.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Ps(e);let n=Ps(t);const o=Math.abs(i);let r;return 0===n?r=Math.floor(o):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.floor(o*Math.pow(10,n))/Math.pow(10,n)),i>=0?r:-r},isExported:!0},el={description:r("Rounds up a number."),args:_s(`\n value (number) ${r("The value to round to places number of places, always rounding up.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Ps(e);let n=Ps(t);const o=Math.abs(i);let r;return 0===n?r=Math.ceil(o):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.ceil(o*Math.pow(10,n))/Math.pow(10,n)),i>=0?r:-r},isExported:!0},tl={description:r("Secant of an angle provided in radians."),args:_s(`\n angle (number) ${r("The angle to find the secant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cos(Ps(e))},isExported:!0},il={description:r("Hyperbolic secant of any real number."),args:_s(`\n value (number) ${r("Any real value to calculate the hyperbolic secant of.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Ps(e))},isExported:!0},nl={description:r("Sine of an angle provided in radians."),args:_s(`\n angle (number) ${r("The angle to find the sine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sin(Ps(e))},isExported:!0},ol={description:r("Hyperbolic sine of any real number."),args:_s(`\n value (number) ${r("Any real value to calculate the hyperbolic sine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sinh(Ps(e))},isExported:!0},rl={description:r("Positive square root of a positive number."),args:_s(`\n value (number) ${r("The number for which to calculate the positive square root.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Ps(e);return $s((()=>t>=0),r("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},sl={description:r("Sum of a series of numbers and/or cells."),args:_s(`\n value1 (number, range<number>) ${r("The first number or range to add together.")}\n value2 (number, range<number>, repeating) ${r("Additional numbers or ranges to add to value1.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){return Ks(e,((e,t)=>e+t),0)},isExported:!0},al={description:r("A conditional sum across a range."),args:_s(`\n criteria_range (range) ${r("The range which is tested against criterion.")}\n criterion (string) ${r("The pattern or test to apply to range.")}\n sum_range (range, default=criteria_range) ${r("The range to be summed, if different from range.")}\n `),returns:["NUMBER"],compute:function(e,t,i){void 0===i&&(i=e);let n=0;return ia([e,t],((e,t)=>{const o=i[e][t];"number"==typeof o&&(n+=o)})),n},isExported:!0},ll={description:r("Sums a range depending on multiple criteria."),args:_s(`\n sum_range (range) ${r("The range to sum.")}\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges to check.")}\n criterion2 (string, repeating) ${r("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=0;return ia(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i+=o)})),i},isExported:!0},cl={description:r("Tangent of an angle provided in radians."),args:_s(`\n angle (number) ${r("The angle to find the tangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tan(Ps(e))},isExported:!0},hl={description:r("Hyperbolic tangent of any real number."),args:_s(`\n value (number) ${r("Any real value to calculate the hyperbolic tangent of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tanh(Ps(e))},isExported:!0},dl={description:r("Truncates a number."),args:_s(`\n value (number) ${r("The value to be truncated.")}\n places (number, default=0) ${r("The number of significant digits to the right of the decimal point to retain.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Ps(e);let n=Ps(t);return 0===n?Math.trunc(i):(Number.isInteger(n)||(n=Math.trunc(n)),Math.trunc(i*Math.pow(10,n))/Math.pow(10,n))},isExported:!0};var ul=Object.freeze({__proto__:null,ABS:ha,ACOS:da,ACOSH:ua,ACOT:ga,ACOTH:pa,ASIN:ma,ASINH:fa,ATAN:va,ATAN2:ba,ATANH:Sa,CEILING:Ca,CEILING_MATH:Ea,CEILING_PRECISE:wa,COS:ya,COSH:xa,COT:Ra,COTH:Ia,COUNTBLANK:Ta,COUNTIF:Aa,COUNTIFS:Na,COUNTUNIQUE:Oa,COUNTUNIQUEIFS:_a,CSC:Fa,CSCH:Da,DECIMAL:ka,DEGREES:$a,EXP:La,FLOOR:Pa,FLOOR_MATH:Ua,FLOOR_PRECISE:Va,ISEVEN:za,ISO_CEILING:Ba,ISODD:Ha,LN:Wa,MOD:Ga,ODD:qa,PI:Za,POWER:ja,PRODUCT:Ya,RAND:Xa,RANDBETWEEN:Ka,ROUND:Qa,ROUNDDOWN:Ja,ROUNDUP:el,SEC:tl,SECH:il,SIN:nl,SINH:ol,SQRT:rl,SUM:sl,SUMIF:al,SUMIFS:ll,TAN:cl,TANH:hl,TRUNC:dl});function gl(e,t,i){let n=[],o=[],s=0,a=0;Zs([e],(e=>{n.push(e),s+=1})),Zs([t],(e=>{o.push(e),a+=1})),$s((()=>s===a),r("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",s.toString(),a.toString()));let l=0,c=0,h=0;for(let e=0;e<s;e++){const t=n[e],i=o[e];"number"==typeof t&&"number"==typeof i&&(l+=1,c+=t,h+=i)}$s((()=>0!==l&&(!i||1!==l)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const d=c/l,u=h/l;let g=0;for(let e=0;e<s;e++){const t=n[e],i=o[e];"number"==typeof t&&"number"==typeof i&&(g+=(t-d)*(i-u))}return g/(l-(i?1:0))}function pl(e,t,i){let n=0,o=0;const s=i?Qs:Ks;o=s(e,((e,t)=>(n+=1,e+t)),0),$s((()=>0!==n&&(!t||1!==n)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const a=o/n;return s(e,((e,t)=>e+Math.pow(t-a,2)),0)/(n-(t?1:0))}function ml(e,t,i){const n=Ps(t);$s((()=>i?0<=n&&n<=1:0<n&&n<1),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let o,s=[],a=0;return Zs(e,(e=>{"number"==typeof e&&(o=ra(s,e,"nextSmaller","asc",s.length,((e,t)=>e[t])),s.splice(o+1,0,e),a++)})),$s((()=>0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),i||$s((()=>1/(a+1)<=n&&n<=a/(a+1)),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),yi(s,n,i)}const fl={description:r("Average magnitude of deviations from mean."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;const i=Ks(e,((e,i)=>(t+=1,e+i)),0);$s((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const n=i/t;return Ks(e,((e,t)=>e+Math.abs(n-t)),0)/t},isExported:!0},vl={description:r("Numerical average value in a dataset, ignoring text."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=Ks(e,((e,i)=>(t+=1,e+i)),0);return $s((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},bl=r("[[FUNCTION_NAME]] has mismatched range sizes."),Sl=r("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),Cl={description:r("Weighted average."),args:_s(`\n values (number, range<number>) ${r("Values to average.")}\n weights (number, range<number>) ${r("Weights for each corresponding value.")}\n additional_values (number, range<number>, repeating) ${r("Additional values to average.")}\n additional_weights (number, range<number>, repeating) ${r("Additional weights.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t,i,n=0,o=0;$s((()=>e.length%2==0),r("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let s=0;s<e.length-1;s+=2)if(t=e[s],i=e[s+1],Array.isArray(t)){$s((()=>Array.isArray(i)),bl);let e=t.length,s=t[0].length;$s((()=>e===i.length&&s===i[0].length),bl);for(let a=0;a<e;a++)for(let e=0;e<s;e++){let s=t[a][e],l=i[a][e],c="number"==typeof s,h="number"==typeof l;$s((()=>c===h),r("[[FUNCTION_NAME]] expects number values.")),h&&($s((()=>l>=0),Sl),n+=s*l,o+=l)}}else i=Ps(i),t=Ps(t),$s((()=>i>=0),Sl),n+=t*i,o+=i;return $s((()=>0!==o),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/o}},El={description:r("Numerical average value in a dataset."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=Qs(e,((e,i)=>(t+=1,e+i)),0);return $s((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},wl={description:r("Average of values depending on criteria."),args:_s(`\n criteria_range (range) ${r("The range to check against criterion.")}\n criterion (string) ${r("The pattern or test to apply to criteria_range.")}\n average_range (range, default=criteria_range) ${r("The range to average. If not included, criteria_range is used for the average instead.")}\n `),returns:["NUMBER"],compute:function(e,t,i){null==i&&(i=e);let n=0,o=0;return ia([e,t],((t,r)=>{const s=(i||e)[t][r];"number"==typeof s&&(n+=1,o+=s)})),$s((()=>0!==n),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/n},isExported:!0},yl={description:r("Average of values depending on multiple criteria."),args:_s(`\n average_range (range) ${r("The range to average.")}\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional criteria_range and criterion to check.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=0,n=0;return ia(t,((t,o)=>{const r=e[t][o];"number"==typeof r&&(i+=1,n+=r)})),$s((()=>0!==i),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/i},isExported:!0},xl={description:r("The number of numeric values in dataset."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range to consider when counting.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;for(let i of e)if(Array.isArray(i))for(let e of i)for(let i of e)"number"==typeof i&&(t+=1);else("string"!=typeof i||Ci(i)||ve(i))&&(t+=1);return t},isExported:!0},Rl={description:r("The number of values in a dataset."),args:_s(`\n value1 (any, range) ${r("The first value or range to consider when counting.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){return Xs(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Il={description:r("The covariance of a dataset."),args:_s(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return gl(e,t,!1)},isExported:!0},Tl={description:r("The covariance of a dataset."),args:_s(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return gl(e,t,!1)},isExported:!0},Al={description:r("The sample covariance of a dataset."),args:_s(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return gl(e,t,!0)},isExported:!0},Nl={description:r("Nth largest element from a data set."),args:_s(`\n data (any, range) ${r("Array or range containing the dataset to consider.")}\n n (number) ${r("The rank from largest to smallest of the element to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Ps(t));let n,o=[],s=0;Zs([e],(e=>{"number"==typeof e&&(n=ra(o,e,"nextSmaller","asc",o.length,((e,t)=>e[t])),o.splice(n+1,0,e),s++,s>i&&(o.shift(),s--))}));const a=o.shift();return $s((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),$s((()=>s>=i),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},Ml={description:r("Maximum value in a numeric dataset."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the maximum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Ks(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},Ol={description:r("Maximum numeric value in a dataset."),args:_s(`\n value1 (any, range) ${r("The first value or range to consider when calculating the maximum value.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Qs(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},_l={description:r("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:_s(`\n range (range) ${r("The range of cells from which the maximum will be determined.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("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.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=-1/0;return ia(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i=i<o?o:i)})),i===-1/0?0:i},isExported:!0},Fl={description:r("Median value in a numeric dataset."),args:_s(`\n value1 (any, range) ${r("The first value or range to consider when calculating the median value.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when calculating the median value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=[];return js(e,(e=>{t.push(e)})),ml(t,.5,!0)},isExported:!0},Dl={description:r("Minimum value in a numeric dataset."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Ks(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},kl={description:r("Minimum numeric value in a dataset."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Qs(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},$l={description:r("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:_s(`\n range (range) ${r("The range of cells from which the minimum will be determined.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("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.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=1/0;return ia(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i=i>o?o:i)})),i===1/0?0:i},isExported:!0},Ll={description:r("Value at a given percentile of a dataset."),args:_s(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Ul.compute(e,t)},isExported:!0},Pl={description:r("Value at a given percentile of a dataset exclusive of 0 and 1."),args:_s(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return ml([e],t,!1)},isExported:!0},Ul={description:r("Value at a given percentile of a dataset."),args:_s(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return ml([e],t,!0)},isExported:!0},Vl={description:r("Value nearest to a specific quartile of a dataset."),args:_s(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Bl.compute(e,t)},isExported:!0},zl={description:r("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:_s(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value, exclusive of 0 and 4, to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return ml([e],.25*Math.trunc(Ps(t)),!1)},isExported:!0},Bl={description:r("Value nearest to a specific quartile of a dataset."),args:_s(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return ml([e],.25*Math.trunc(Ps(t)),!0)},isExported:!0},Hl={description:r("Nth smallest element in a data set."),args:_s(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n n (number) ${r("The rank from smallest to largest of the element to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Ps(t));let n,o=[],s=0;Zs([e],(e=>{"number"==typeof e&&(n=ra(o,e,"nextSmaller","asc",o.length,((e,t)=>e[t])),o.splice(n+1,0,e),s++,s>i&&(o.pop(),s--))}));const a=o.pop();return $s((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),$s((()=>s>=i),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},Wl={description:r("Standard deviation."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Xl.compute(...e))},isExported:!0},Gl={description:r("Standard deviation of entire population."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Kl.compute(...e))},isExported:!0},ql={description:r("Standard deviation."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Ql.compute(...e))},isExported:!0},Zl={description:r("Standard deviation of sample (text as 0)."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Jl.compute(...e))},isExported:!0},jl={description:r("Standard deviation of entire population."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(ec.compute(...e))},isExported:!0},Yl={description:r("Standard deviation of entire population (text as 0)."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(tc.compute(...e))},isExported:!0},Xl={description:r("Variance."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return pl(e,!0,!1)},isExported:!0},Kl={description:r("Variance of entire population."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return pl(e,!1,!1)},isExported:!0},Ql={description:r("Variance."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return pl(e,!0,!1)},isExported:!0},Jl={description:r("Variance of sample (text as 0)."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return pl(e,!0,!0)},isExported:!0},ec={description:r("Variance of entire population."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return pl(e,!1,!1)},isExported:!0},tc={description:r("Variance of entire population (text as 0)."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return pl(e,!1,!0)},isExported:!0};var ic=Object.freeze({__proto__:null,AVEDEV:fl,AVERAGE:vl,AVERAGE_WEIGHTED:Cl,AVERAGEA:El,AVERAGEIF:wl,AVERAGEIFS:yl,COUNT:xl,COUNTA:Rl,COVAR:Il,COVARIANCE_P:Tl,COVARIANCE_S:Al,LARGE:Nl,MAX:Ml,MAXA:Ol,MAXIFS:_l,MEDIAN:Fl,MIN:Dl,MINA:kl,MINIFS:$l,PERCENTILE:Ll,PERCENTILE_EXC:Pl,PERCENTILE_INC:Ul,QUARTILE:Vl,QUARTILE_EXC:zl,QUARTILE_INC:Bl,SMALL:Hl,STDEV:Wl,STDEV_P:Gl,STDEV_S:ql,STDEVA:Zl,STDEVP:jl,STDEVPA:Yl,VAR:Xl,VAR_P:Kl,VAR_S:Ql,VARA:Jl,VARP:ec,VARPA:tc});function nc(e,t,i){var n;const o=new Map,s=e.length;for(let t=s-1;t>=0;t--)o.set(Vs(e[t][0]).toUpperCase(),t);if("number"!=typeof t&&"string"!=typeof t)throw new Error(r("The field must be a number or a string"));let a;if("number"==typeof t){if(a=Math.trunc(t)-1,a<0||s-1<a)throw new Error(r("The field (%s) must be one of %s or must be a number between 1 and %s inclusive.",t.toString(),s.toString()))}else{const e=Vs(t).toUpperCase();if(a=null!==(n=o.get(e))&&void 0!==n?n:-1,-1===a)throw new Error(r("The field (%s) must be one of %s.",Vs(t),[...o.keys()].toString()))}const l=i[0].length;if(l<2)throw new Error(r("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<i.length;s++){const a=Vs(i[s][0]).toUpperCase(),l=o.get(a),c=i[s][t];if(void 0!==c){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}ia(n,((e,t)=>{c.add(t)}),!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const oc=_s(`\n database (range) ${r("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.")}\n field (any) ${r("Indicates which column in database contains the values to be extracted and operated on.")}\n criteria (range) ${r("An array or range containing zero or more criteria to filter the database values by before operating.")}\n`),rc={description:r("Average of a set of values from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return vl.compute([n])},isExported:!0},sc={description:r("Counts values from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return xl.compute([n])},isExported:!0},ac={description:r("Counts values and text from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return Rl.compute([n])},isExported:!0},lc={description:r("Single value from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return $s((()=>1===n.length),r("More than one match found in DGET evaluation.")),n[0]},isExported:!0},cc={description:r("Maximum of values from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return Ml.compute([n])},isExported:!0},hc={description:r("Minimum of values from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return Dl.compute([n])},isExported:!0},dc={description:r("Product of values from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return Ya.compute([n])},isExported:!0},uc={description:r("Standard deviation of population sample from table."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return Wl.compute([n])},isExported:!0},gc={description:r("Standard deviation of entire population from table."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return jl.compute([n])},isExported:!0},pc={description:r("Sum of values from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return sl.compute([n])},isExported:!0},mc={description:r("Variance of population sample from table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return Xl.compute([n])},isExported:!0},fc={description:r("Variance of a population from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return ec.compute([n])},isExported:!0};var vc=Object.freeze({__proto__:null,DAVERAGE:rc,DCOUNT:sc,DCOUNTA:ac,DGET:lc,DMAX:cc,DMIN:hc,DPRODUCT:dc,DSTDEV:uc,DSTDEVP:gc,DSUM:pc,DVAR:mc,DVARP:fc});const bc={description:r("Converts year/month/day into a date."),args:_s(`\n year (number) ${r("The year component of the date.")}\n month (number) ${r("The month component of the date.")}\n day (number) ${r("The day component of the date.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){let n=Math.trunc(Ps(e));const o=Math.trunc(Ps(t)),s=Math.trunc(Ps(i));$s((()=>0<=n&&n<=9999),r("The year (%s) must be between 0 and 9999 inclusive.",n.toString())),n<1900&&(n+=1900);const a=Ce(new ae(n,o-1,s));return $s((()=>a>=0),r("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},Sc={description:r("Converts a date string to a date value."),args:_s(`\n date_string (string) ${r("The string representing the date.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e),i=ve(t);return $s((()=>null!==i),r("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(i.value)},isExported:!0},Cc={description:r("Day of the month that a specific date falls on."),args:_s(`\n date (string) ${r("The date from which to extract the day.")}\n `),returns:["NUMBER"],compute:function(e){return Gs(e).getDate()},isExported:!0},Ec={description:r("Number of days between two dates."),args:_s(`\n end_date (date) ${r("The end of the date range.")}\n start_date (date) ${r("The start of the date range.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Gs(e),n=Gs(t),o=i.getTime()-n.getTime();return Math.round(o/ce)},isExported:!0},wc={description:r("Number of days between two dates on a 360-day year (months of 30 days)."),args:_s(`\n start_date (date) ${r("The start date to consider in the calculation.")}\n end_date (date) ${r("The end date to consider in the calculation.")}\n method (number, default=0) ${r("An indicator of what day count method to use. (0) US NASD method (1) European method")}\n `),returns:["NUMBER"],compute:function(e,t,i=0){const n=Ps(e),o=Ps(t),r=Ws(i)?4:0,s=Bc.compute(e,t,r);return Math.sign(o-n)*Math.round(360*s)},isExported:!0},yc={description:r("Date a number of months before/after another date."),args:_s(`\n start_date (date) ${r("The date from which to calculate the result.")}\n months (number) ${r("The number of months before (negative) or after (positive) 'start_date' to calculate.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){return Ce(ye(Gs(e),Math.trunc(Ps(t)),!1))},isExported:!0},xc={description:r("Last day of a month before or after a date."),args:_s(`\n start_date (date) ${r("The date from which to calculate the result.")}\n months (number) ${r("The number of months before (negative) or after (positive) 'start_date' to consider.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){const i=Gs(e),n=Math.trunc(Ps(t)),o=i.getFullYear(),r=i.getMonth();return Ce(new ae(o,r+n+1,0))},isExported:!0},Rc={description:r("Hour component of a specific time."),args:_s(`\n time (date) ${r("The time from which to calculate the hour component.")}\n `),returns:["NUMBER"],compute:function(e){return Gs(e).getHours()},isExported:!0},Ic={description:r("ISO week number of the year."),args:_s(`\n date (date) ${r("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.")}\n `),returns:["NUMBER"],compute:function(e){const t=Gs(e),i=t.getFullYear();let n=1;for(;4!==new ae(i,0,n).getDay();)n+=1;const o=new ae(i,0,n-3);let r=31;for(;4!==new ae(i,11,r).getDay();)r-=1;const s=new ae(i,11,r+3);let a,l;switch(a=o.getTime()<=t.getTime()?t.getTime()<=s.getTime()?0:1:-1,a){case 0:l=o;break;case 1:l=new ae(i,11,r+3+1);break;case-1:let e=1;for(;4!==new ae(i-1,0,e).getDay();)e+=1;l=new ae(i-1,0,e-3)}const c=(t.getTime()-l.getTime())/ce;return Math.floor(c/7)+1},isExported:!0},Tc={description:r("Minute component of a specific time."),args:_s(`\n time (date) ${r("The time from which to calculate the minute component.")}\n `),returns:["NUMBER"],compute:function(e){return Gs(e).getMinutes()},isExported:!0},Ac={description:r("Month of the year a specific date falls in"),args:_s(`\n date (date) ${r("The date from which to extract the month.")}\n `),returns:["NUMBER"],compute:function(e){return Gs(e).getMonth()+1},isExported:!0},Nc={description:r("Net working days between two provided days."),args:_s(`\n start_date (date) ${r("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${r("The end date of the period from which to calculate the number of net working days.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the date serial numbers to consider holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,i){return Oc.compute(e,t,1,i)},isExported:!0};function Mc(e){if("string"==typeof e){$s((()=>{if(7!==e.length)return!1;for(let t of e)if("0"!==t&&"1"!==t)return!1;return!0}),r('When weekend is a string (%s) it must be composed of "0" or "1".',e));let t=[];for(let i=0;i<7;i++)"1"===e[i]&&t.push((i+1)%7);return t}if("number"==typeof e)return $s((()=>1<=e&&e<=7||11<=e&&e<=17),r("The weekend (%s) must be a string or a number in the range 1-7 or 11-17.",e.toString())),e<=7?[e-2==-1?6:e-2,e-1]:[e-11];throw Error(r("The weekend must be a number or a string."))}const Oc={description:r("Net working days between two dates (specifying weekends)."),args:_s(`\n start_date (date) ${r("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${r("The end date of the period from which to calculate the number of net working days.")}\n weekend (any, default=1) ${r("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider as holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1,n){const o=Gs(e),r=Gs(t),s=Mc(i);let a=new Set;void 0!==n&&Zs([n],(e=>{const t=Gs(e);a.add(t.getTime())}));const l=o.getTime()>r.getTime(),c=ae.fromTimestamp((l?o:r).getTime());let h=ae.fromTimestamp((l?r:o).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)s.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},_c={description:r("Current date and time as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy hh:mm:ss",compute:function(){let e=ae.now();const t=e.getTime()-le.getTime(),i=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/ce)+i},isExported:!0},Fc={description:r("Minute component of a specific time."),args:_s(`\n time (date) ${r("The time from which to calculate the second component.")}\n `),returns:["NUMBER"],compute:function(e){return Gs(e).getSeconds()},isExported:!0},Dc={description:r("Converts hour/minute/second into a time."),args:_s(`\n hour (number) ${r("The hour component of the time.")}\n minute (number) ${r("The minute component of the time.")}\n second (number) ${r("The second component of the time.")}\n `),returns:["DATE"],computeFormat:()=>"hh:mm:ss a",compute:function(e,t,i){let n=Math.trunc(Ps(e)),o=Math.trunc(Ps(t)),s=Math.trunc(Ps(i));return o+=Math.floor(s/60),s=s%60+(s<0?60:0),n+=Math.floor(o/60),o=o%60+(o<0?60:0),n%=24,$s((()=>n>=0),r("The function [[FUNCTION_NAME]] result cannot be negative")),n/24+o/1440+s/86400},isExported:!0},kc={description:r("Converts a time string into its serial number representation."),args:_s(`\n time_string (string) ${r("The string that holds the time representation.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e),i=ve(t);$s((()=>null!==i),r("The time_string (%s) cannot be parsed to date/time.",t));const n=i.value-Math.trunc(i.value);return n<0?1+n:n},isExported:!0},$c={description:r("Current date as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(){const e=ae.now();return Ce(new ae(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},Lc={description:r("Day of the week of the date provided (as number)."),args:_s(`\n date (date) ${r("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.")}\n type (number, default=1) ${r("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const i=Gs(e),n=Math.round(Ps(t)),o=i.getDay();return $s((()=>[1,2,3].includes(n)),r("The type (%s) must be 1, 2 or 3.",n.toString())),1===n?o+1:2===n?0===o?7:o:0===o?6:o-1},isExported:!0},Pc={description:r("Week number of the year."),args:_s(`\n date (date) ${r("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.")}\n type (number, default=1) ${r("A number representing the day that a week starts on. Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const i=Gs(e),n=Math.round(Ps(t));if($s((()=>1===n||2===n||11<=n&&n<=17||21===n),r("The type (%s) is out of range.",n.toString())),21===n)return Ic.compute(e);let o;o=1===n||2===n?n-1:n-10==7?0:n-10;const s=i.getFullYear();let a=1,l=new ae(s,0,a);for(;l.getDay()!==o;)a+=1,l=new ae(s,0,a);const c=(i.getTime()-l.getTime())/ce;return c<0?1:Math.floor(c/7)+(1===a?1:2)},isExported:!0},Uc={description:r("Date after a number of workdays."),args:_s(`\n start_date (date) ${r("The date from which to begin counting.")}\n num_days (number) ${r("The number of working days to advance from start_date. If negative, counts backwards.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider holidays.")}\n `),returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){return Vc.compute(e,t,1,i)},isExported:!0},Vc={description:r("Date after a number of workdays (specifying weekends)."),args:_s(`\n start_date (date) ${r("The date from which to begin counting.")}\n num_days (number) ${r("The number of working days to advance from start_date. If negative, counts backwards.")}\n weekend (any, default=1) ${r("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider holidays.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i=1,n){let o=Gs(e),s=Math.trunc(Ps(t));"string"==typeof i&&$s((()=>"1111111"!==i),r("The weekend (%s) must be different from '1111111'.",i));const a=Mc(i);let l=new Set;void 0!==n&&Zs([n],(e=>{const t=Gs(e);l.add(t.getTime())}));let c=ae.fromTimestamp(o.getTime()),h=c.getTime();const d=Math.sign(s);let u=Math.abs(s);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),a.includes(c.getDay())||l.has(h)||(u-=1);const g=h-le.getTime();return Math.round(g/ce)},isExported:!0},zc={description:r("Year specified by a given date."),args:_s(`\n date (date) ${r("The date from which to extract the year.")}\n `),returns:["NUMBER"],compute:function(e){return Gs(e).getFullYear()},isExported:!0},Bc={description:r("Exact number of years between two dates."),args:_s(`\n start_date (date) ${r("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.")}\n end_date (date) ${r("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.")}\n day_count_convention (number, default=0) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i=0){let n=Math.trunc(Ps(e)),o=Math.trunc(Ps(t));const s=Math.trunc(Ps(i));return $s((()=>n>=0),r("The start_date (%s) must be positive or null.",n.toString())),$s((()=>o>=0),r("The end_date (%s) must be positive or null.",o.toString())),$s((()=>0<=s&&s<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",s.toString())),Re(n,o,s)}},Hc={description:r("First day of the month preceding a date."),args:_s(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Gs(e),i=t.getFullYear(),n=t.getMonth();return Ce(new ae(i,n,1))}},Wc={description:r("Last day of the month following a date."),args:_s(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){return xc.compute(e,0)}},Gc={description:r("Quarter of the year a specific date falls in"),args:_s(`\n date (date) ${r("The date from which to extract the quarter.")}\n `),returns:["NUMBER"],compute:function(e){return Math.ceil((Gs(e).getMonth()+1)/3)}},qc={description:r("First day of the quarter of the year a specific date falls in."),args:_s(`\n date (date) ${r("The date from which to calculate the start of quarter.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Gc.compute(e),i=zc.compute(e);return Ce(new ae(i,3*(t-1),1))}},Zc={description:r("Last day of the quarter of the year a specific date falls in."),args:_s(`\n date (date) ${r("The date from which to calculate the end of quarter.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Gc.compute(e),i=zc.compute(e);return Ce(new ae(i,3*t,0))}},jc={description:r("First day of the year a specific date falls in."),args:_s(`\n date (date) ${r("The date from which to calculate the start of the year.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=zc.compute(e);return Ce(new ae(t,0,1))}},Yc={description:r("Last day of the year a specific date falls in."),args:_s(`\n date (date) ${r("The date from which to calculate the end of the year.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=zc.compute(e);return Ce(new ae(t+1,0,0))}};var Xc=Object.freeze({__proto__:null,DATE:bc,DATEVALUE:Sc,DAY:Cc,DAYS:Ec,DAYS360:wc,EDATE:yc,EOMONTH:xc,HOUR:Rc,ISOWEEKNUM:Ic,MINUTE:Tc,MONTH:Ac,NETWORKDAYS:Nc,NETWORKDAYS_INTL:Oc,NOW:_c,SECOND:Fc,TIME:Dc,TIMEVALUE:kc,TODAY:$c,WEEKDAY:Lc,WEEKNUM:Pc,WORKDAY:Uc,WORKDAY_INTL:Vc,YEAR:zc,YEARFRAC:Bc,MONTH_START:Hc,MONTH_END:Wc,QUARTER:Gc,QUARTER_START:qc,QUARTER_END:Zc,YEAR_START:jc,YEAR_END:Yc});const Kc={description:r("Compare two numeric values, returning 1 if they're equal."),args:_s(`\n number1 (number) ${r("The first number to compare.")}\n number2 (number, default=0) ${r("The second number to compare.")}\n `),returns:["NUMBER"],compute:function(e,t=0){return Ps(e)===Ps(t)?1:0},isExported:!0};var Qc=Object.freeze({__proto__:null,DELTA:Kc});function Jc(e,t){$s((()=>e<t),r("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function eh(e,t){$s((()=>t<e),r("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function th(e){$s((()=>[1,2,4].includes(e)),r("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function ih(e){$s((()=>0<=e&&e<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function nh(e){$s((()=>e>0),r("The redemption (%s) must be strictly positive.",e.toString()))}function oh(e){$s((()=>e>0),r("The price (%s) must be strictly positive.",e.toString()))}function rh(e){$s((()=>e>0),r("The number_of_periods (%s) must be greater than 0.",e.toString()))}function sh(e){$s((()=>e>0),r("The rate (%s) must be strictly positive.",e.toString()))}function ah(e){$s((()=>e>0),r("The life (%s) must be strictly positive.",e.toString()))}function lh(e){$s((()=>e>=0),r("The cost (%s) must be positive or null.",e.toString()))}function ch(e){$s((()=>e>0),r("The period (%s) must be strictly positive.",e.toString()))}function hh(e){$s((()=>e>=0),r("The salvage (%s) must be positive or null.",e.toString()))}function dh(e){$s((()=>e>0),r("The present value (%s) must be strictly positive.",e.toString()))}function uh(e,t){$s((()=>e<=t),r("The period (%s) must be less than or equal life (%.",e.toString(),t.toString()))}function gh(e){$s((()=>e>0),r("The investment (%s) must be strictly positive.",e.toString()))}function ph(e){$s((()=>e>0),r("The discount (%s) must be strictly positive.",e.toString()))}function mh(e){$s((()=>e<1),r("The discount (%s) must be smaller than 1.",e.toString()))}function fh(e){$s((()=>e>0),r("The depreciation factor (%s) must be strictly positive.",e.toString()))}function vh(e,t){const i=Gs(e),n=Gs(t),o=Gs(e);o.setFullYear(i.getFullYear()+1),$s((()=>n.getTime()<=o.getTime()),r("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function bh(e,t,i){rh(i),$s((()=>e>0),r("The first_period (%s) must be strictly positive.",e.toString())),$s((()=>t>0),r("The last_period (%s) must be strictly positive.",t.toString())),$s((()=>e<=t),r("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),$s((()=>t<=i),r("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),i.toString()))}function Sh(e){$s((()=>e>-1),r("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function Ch(e,t){$s((()=>e.length===t.length&&e[0].length===t[0].length),r("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function Eh(e){$s((()=>e.every((t=>t>=e[0]))),r("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const wh=_s(`\nsettlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\nmaturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\nfrequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\nday_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n`);function yh(e,t,i,n,o=1e-10,s){let a,l,c,h,d=i,u=!1,g=0;do{c=e(d),isNaN(c)?($s((()=>g<n&&void 0!==s),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++,d=s(h),h=d):(a=d-c/t(d),l=Math.abs(a-d),d=a,u=l<o||Math.abs(c)<o,$s((()=>g<n),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const xh={description:r("Accrued interest of security paying at maturity."),args:_s(`\n issue (date) ${r("The date the security was initially issued.")}\n maturity (date) ${r("The maturity date of the security.")}\n rate (number) ${r("The annualized rate of interest.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Ps(e)),s=Math.trunc(Ps(t)),a=Ps(n),l=Ps(i),c=Math.trunc(Ps(o));eh(s,r),ih(c),nh(a),sh(l);return a*l*Bc.compute(r,s,o)},isExported:!0},Rh={description:r("Depreciation for an accounting period."),args:_s(`\n cost (number) ${r("The initial cost of the asset.")}\n purchase_date (date) ${r("The date the asset was purchased.")}\n first_period_end (date) ${r("The date the first period ended.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n rate (number) ${r("The deprecation rate.")}\n day_count_convention (number, optional) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s,a=0){a=a||0;const l=Ps(e),c=Math.trunc(Ps(t)),h=Math.trunc(Ps(i)),d=Ps(n),u=Ps(o),g=Ps(s),p=Math.trunc(Ps(a));!function(e){$s((()=>e>0),r("The cost (%s) must be strictly positive.",e.toString()))}(l),hh(d),function(e,t){$s((()=>e<=t),r("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){$s((()=>e>=0),r("The period (%s) must be positive or null.",e.toString()))}(u),sh(g),ih(p),$s((()=>c<=h),r("The purchase_date (%s) must be before the first_period_end (%s).",c.toString(),h.toString()));const m=u<1&&u>0?1:Math.trunc(u),f=l*g,v=Bc.compute(c,h,p),b=c===h?f:f*v,S=l-b-f*m;return S>=d?0===m?b:f:d-S<f?f-(d-S):0},isExported:!0},Ih={description:r("Days in coupon period containing settlement date."),args:wh,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Ps(e)),r=Math.trunc(Ps(t)),s=Math.trunc(Ps(i)),a=Math.trunc(Ps(n));if(Jc(o,r),th(s),ih(a),1===a){const o=Oh.compute(e,t,i,n);return Nh.compute(e,t,i,n)-o}return(3===a?365:360)/s},isExported:!0},Th={description:r("Days from settlement until next coupon."),args:wh,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Ps(e)),r=Math.trunc(Ps(t)),s=Math.trunc(Ps(i)),a=Math.trunc(Ps(n));Jc(o,r),th(s),ih(a);const l=Oh.compute(o,r,i,n);if([1,2,3].includes(a))return o-l;if(4===a){const e=Re(l,o,a);return Math.round(360*e)}const c=Gs(o),h=Gs(l),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&&we(h)&&we(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&we(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Ah={description:r("Days from settlement until next coupon."),args:wh,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Ps(e)),r=Math.trunc(Ps(t)),s=Math.trunc(Ps(i)),a=Math.trunc(Ps(n));Jc(o,r),th(s),ih(a);const l=Nh.compute(o,r,i,n);if([1,2,3].includes(a))return l-o;if(4===a){const e=Re(o,l,a);return Math.round(360*e)}const c=Th.compute(e,t,i,a);return Ih.compute(e,t,i,a)-c},isExported:!0},Nh={description:r("Next coupon date after the settlement date."),args:wh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Ps(e)),r=Math.trunc(Ps(t)),s=Math.trunc(Ps(i)),a=Math.trunc(Ps(n));Jc(o,r),th(s),ih(a);const l=12/s,c=Mh.compute(e,t,i,n);return Ce(ye(Gs(r),-(c-1)*l,!0))},isExported:!0},Mh={description:r("Number of coupons between settlement and maturity."),args:wh,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Ps(e)),r=Math.trunc(Ps(t)),s=Math.trunc(Ps(i)),a=Math.trunc(Ps(n));Jc(o,r),th(s),ih(a);let l=1,c=r;const h=12/s;for(;c>o;)c=Ce(ye(Gs(c),-h,!1)),l++;return l-1},isExported:!0},Oh={description:r("Last coupon date prior to or on the settlement date."),args:wh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Ps(e)),r=Math.trunc(Ps(t)),s=Math.trunc(Ps(i)),a=Math.trunc(Ps(n));Jc(o,r),th(s),ih(a);const l=12/s,c=Mh.compute(e,t,i,n);return Ce(ye(Gs(r),-c*l,!0))},isExported:!0},_h={description:r("Cumulative interest paid over a set of periods."),args:_s(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n first_period (number) ${r("The number of the payment period to begin the cumulative calculation.")}\n last_period (number) ${r("The number of the payment period to end the cumulative calculation.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,r=0){const s=Ps(n),a=Ps(o),l=Ps(e),c=Ps(i),h=Ps(t);bh(s,a,h),sh(l),dh(c);let d=0;for(let t=s;t<=a;t++){d+=Wh.compute(e,t,h,i,0,r)}return d},isExported:!0},Fh={description:r("Cumulative principal paid over a set of periods."),args:_s(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n first_period (number) ${r("The number of the payment period to begin the cumulative calculation.")}\n last_period (number) ${r("The number of the payment period to end the cumulative calculation.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,r=0){const s=Ps(n),a=Ps(o),l=Ps(e),c=Ps(i),h=Ps(t);bh(s,a,h),sh(l),dh(c);let d=0;for(let t=s;t<=a;t++){d+=ed.compute(e,t,h,i,0,r)}return d},isExported:!0},Dh={description:r("Depreciation via declining balance method."),args:_s(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n month (number, optional) ${r("The number of months in the first year of depreciation.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n,...o){const s=Ps(e),a=Ps(t),l=Ps(i),c=Math.trunc(Ps(n)),h=o.length?Math.trunc(Ps(o[0])):12,d=l+(12===h?0:1);lh(s),hh(a),ch(c),ah(l),$s((()=>1<=h&&h<=12),r("The month (%s) must be between 1 and 12 inclusive.",h.toString())),$s((()=>c<=d),r("The period (%s) must be less than or equal to %s.",c.toString(),d.toString()));const u=h/12;let g=1-Math.pow(a/s,1/l);g=Math.round(1e3*g)/1e3;let p=s,m=s*(1-g*u);for(let e=1;e<c;e++)p=m,m=p*(1-g),e===l&&(m=p*(1-g*(1-u)));return p-m},isExported:!0},kh={description:r("Depreciation via double-declining balance method."),args:_s(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n factor (number, default=2) ${r("The factor by which depreciation decreases.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n,o=2){o=o||0;const r=Ps(e),s=Ps(t),a=Ps(i),l=Ps(n),c=Ps(o);if(lh(r),hh(s),ch(l),ah(a),uh(l,a),fh(c),0===r||s>=r)return 0;const h=c/a;if(h>1)return 1===n?r-s:0;if(l<=1)return r*h;const d=r*Math.pow(1-h,l-1),u=r*Math.pow(1-h,l),g=u<s?d-s:d-u;return Math.max(g,0)},isExported:!0},$h={description:r("Discount rate of a security based on price."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Ps(e)),s=Math.trunc(Ps(t)),a=Ps(i),l=Ps(n),c=Math.trunc(Ps(o));Jc(r,s),ih(c),oh(a),nh(l);return(l-a)/l/Bc.compute(r,s,c)},isExported:!0},Lh={description:r("Convert a decimal fraction to decimal value."),args:_s(`\n fractional_price (number) ${r("The price quotation given using fractional decimal conventions.")}\n unit (number) ${r("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Ps(e),n=Math.trunc(Ps(t));$s((()=>n>0),r("The unit (%s) must be strictly positive.",n.toString()));const o=Math.trunc(i);return o+(i-o)*(10**Math.ceil(Math.log10(n))/n)},isExported:!0},Ph={description:r("Convert a decimal value to decimal fraction."),args:_s(`\n decimal_price (number) ${r("The price quotation given as a decimal value.")}\n unit (number) ${r("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Ps(e),n=Math.trunc(Ps(t));$s((()=>n>0),r("The unit (%s) must be strictly positive.",n.toString()));const o=Math.trunc(i);return o+(i-o)*(n/10**Math.ceil(Math.log10(n)))},isExported:!0},Uh={description:r("Number of periods for an investment to reach a value."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s=0){s=s||0;const a=Math.trunc(Ps(e)),l=Math.trunc(Ps(t)),c=Ps(i),h=Ps(n),d=Math.trunc(Ps(o)),u=Math.trunc(Ps(s));Jc(a,l),th(d),ih(u),$s((()=>c>=0),r("The rate (%s) must be positive or null.",c.toString())),$s((()=>h>=0),r("The yield (%s) must be positive or null.",h.toString()));const g=Bc.compute(a,l,u),p=g-Math.trunc(g)||1/d,m=Math.ceil(g*d),f=c/d,v=h/d;let b=0,S=0;for(let e=1;e<=m;e++){const t=(f+(e===m?1:0))/(1+v)**e;S+=(p+(e-1)/d)*t,b+=t}return 0===b?0:S/b},isExported:!0},Vh={description:r("Annual effective interest rate."),args:_s(`\n nominal_rate (number) ${r("The nominal interest rate per year.")}\n periods_per_year (number) ${r("The number of compounding periods per year.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Ps(e),n=Math.trunc(Ps(t));return $s((()=>i>0),r("The nominal rate (%s) must be strictly greater than 0.",i.toString())),$s((()=>n>0),r("The number of periods by year (%s) must strictly greater than 0.",n.toString())),Math.pow(1+i/n,n)-1},isExported:!0},zh={description:r("Future value of an annuity investment."),args:_s(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_amount (number) ${r("The amount per period to be paid.")}\n present_value (number, default=0) ${r("The current value of the annuity.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n=0,o=0){n=n||0,o=o||0;const r=Ps(e),s=Ps(t),a=Ps(i),l=Ps(n),c=Ws(o)?1:0;return r?-l*(1+r)**s-a*(1+r*c)*((1+r)**s-1)/r:-(l+a*s)},isExported:!0},Bh={description:r("Future value of principal from series of rates."),args:_s(`\n principal (number) ${r("The amount of initial capital or value to compound against.")}\n rate_schedule (number, range<number>) ${r("A series of interest rates to compound against the principal.")}\n `),returns:["NUMBER"],compute:function(e,t){return Xs([t],((e,t)=>e*(1+Ps(t))),Ps(e))},isExported:!0},Hh={description:r("Calculates effective interest rate."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n investment (number) ${r("The amount invested in the security.")}\n redemption (number) ${r("The amount to be received at maturity.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){const r=Math.trunc(Ps(e)),s=Math.trunc(Ps(t)),a=Ps(n),l=Ps(i);Jc(r,s),gh(l),nh(a);return(a-l)/l/Bc.compute(r,s,o)},isExported:!0},Wh={description:r("Payment on the principal of an investment."),args:_s(`\n rate (number) ${r("The annualized rate of interest.")}\n period (number) ${r("The amortization period, in terms of number of periods.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n,o=0,r=0){return Jh.compute(e,i,n,o,r)-ed.compute(e,t,i,n,o,r)},isExported:!0},Gh={description:r("Internal rate of return given periodic cashflows."),args:_s(`\n cashflow_amounts (number, range<number>) ${r("An array or range containing the income or payments associated with the investment.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t=.1){const i=Ps(t);Sh(i);let n=!1,o=!1,s=[];js([e],(e=>{e>0&&(n=!0),e<0&&(o=!0),s.push(e)})),$s((()=>n&&o),r("The cashflow_amounts must include negative and positive values."));const a=s.shift();return yh((function(e){return function(e,t,i){const n=i.length;let o=0;return i.reduce(((t,i)=>(o++,t+i*e**(n-o))),t*e**n)}(e,a,s)}),(function(e){return function(e,t,i){const n=i.length;let o=0;return i.reduce(((t,i)=>(o++,t+i*(n-o)*e**(n-o-1))),t*n*e**(n-1))}(e,a,s)}),i+1,20,1e-5)-1},isExported:!0},qh={description:r("Returns the interest paid at a particular period of an investment."),args:_s(`\n rate (number) ${r("The interest rate.")}\n period (number) ${r("The period for which you want to view the interest payment.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n){const o=Ps(e),s=Ps(t),a=Ps(i),l=Ps(n);$s((()=>0!==a),r("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(s/a))*o},isExported:!0},Zh={description:r("Modified Macaulay duration."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,r=0){return Uh.compute(e,t,i,n,o,r)/(1+Ps(n)/Math.trunc(Ps(o)))},isExported:!0},jh={description:r("Modified internal rate of return."),args:_s(`\n cashflow_amounts (range<number>) ${r("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")}\n financing_rate (number) ${r("The interest rate paid on funds invested.")}\n reinvestment_return_rate (number) ${r("The return (as a percentage) earned on reinvestment of income received from the investment.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Ps(t),o=Ps(i),s=(a=e,a.length?a[0].map(((e,t)=>a.map((e=>e[t])))):a).flat().filter(Xe).map(Ps);var a;const l=s.length;let c=0,h=0;for(const e of $e(0,l)){const t=s[e];t>=0?c+=t*(o+1)**(l-e-1):h+=t/(n+1)**e}$s((()=>0!==h&&0!==c),r("There must be both positive and negative values in cashflow_amounts."));return(-c/h)**(1/(l-1))-1},isExported:!0},Yh={description:r("Annual nominal interest rate."),args:_s(`\n effective_rate (number) ${r("The effective interest rate per year.")}\n periods_per_year (number) ${r("The number of compounding periods per year.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Ps(e),n=Math.trunc(Ps(t));return $s((()=>i>0),r("The effective rate (%s) must must strictly greater than 0.",i.toString())),$s((()=>n>0),r("The number of periods by year (%s) must strictly greater than 0.",n.toString())),(Math.pow(i+1,1/n)-1)*n},isExported:!0},Xh={description:r("Number of payment periods for an investment."),args:_s(`\n rate (number) ${r("The interest rate.")}\n payment_amount (number) ${r("The amount of each payment made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n=0,o=0){n=n||0,o=o||0;const r=Ps(e),s=Ps(t),a=Ps(i),l=Ps(n),c=Ws(o)?1:0;if(0===r)return-(l+a)/s;const h=s*(1+r*c)/r;return Math.log((h-l)/(a+h))/Math.log(1+r)},isExported:!0};const Kh={description:r("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:_s(`\n discount (number) ${r("The discount rate of the investment over one period.")}\n cashflow1 (number, range<number>) ${r("The first future cash flow.")}\n cashflow2 (number, range<number>, repeating) ${r("Additional future cash flows.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const i=Ps(e);return $s((()=>-1!==i),r("The discount (%s) must be different from -1.",i.toString())),function(e,t,i){let n=0;return Ks(i,((t,i)=>(n++,t+i/(1+e)**n)),t)}(i,0,t)},isExported:!0},Qh={description:r("Computes the number of periods needed for an investment to reach a value."),args:_s(`\n rate (number) ${r("The rate at which the investment grows each period.")}\n present_value (number) ${r("The investment's current value.")}\n future_value (number) ${r("The investment's desired future value.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Ps(e),o=Ps(t),s=Ps(i);return sh(n),$s((()=>o>0),r("The present_value (%s) must be strictly positive.",o.toString())),$s((()=>s>0),r("The future_value (%s) must be strictly positive.",s.toString())),(Math.log(s)-Math.log(o))/Math.log(1+n)},isExported:!0},Jh={description:r("Periodic payment for an annuity investment."),args:_s(`\n rate (number) ${r("The annualized rate of interest.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n=0,o=0){n=n||0,o=o||0;const r=Ps(t),s=Ps(e),a=Ws(o)?1:0;let l=Ps(n),c=Ps(i);if(rh(r),0===s)return-(l+c)/r;let h=-(c*(1+s)**r+l);return h=h*s/((1+s*a)*((1+s)**r-1)),h},isExported:!0},ed={description:r("Payment on the principal of an investment."),args:_s(`\n rate (number) ${r("The annualized rate of interest.")}\n period (number) ${r("The amortization period, in terms of number of periods.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n,o=0,s=0){o=o||0,s=s||0;const a=Ps(i),l=Ps(e),c=Ps(t),h=Ws(s)?1:0,d=Ps(o),u=Ps(n);rh(a),$s((()=>c>0&&c<=a),r("The period must be between 1 and number_of_periods",a.toString()));const g=Jh.compute(l,a,u,d,s);if(1===h&&1===c)return g;return g+-zh.compute(l,0===h?c-1:c-2,g,u+g*h,0)*l},isExported:!0},td={description:r("Present value of an annuity investment."),args:_s(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_amount (number) ${r("The amount per period to be paid.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n=0,o=0){n=n||0,o=o||0;const r=Ps(e),s=Ps(t),a=Ps(i),l=Ps(n),c=Ws(o)?1:0;return r?-(a*(1+r*c)*((1+r)**s-1)/r+l)/(1+r)**s:-(l+a*s)},isExported:!0},id={description:r("Price of a security paying periodic interest."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s,a=0){a=a||0;const l=Math.trunc(Ps(e)),c=Math.trunc(Ps(t)),h=Ps(i),d=Ps(n),u=Ps(o),g=Math.trunc(Ps(s)),p=Math.trunc(Ps(a));Jc(l,c),th(g),ih(p),$s((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),$s((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString())),nh(u);const m=Bc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=1+d/g,S=100*h/g;if(1===f)return(S+u)/(v*d/g+1)-S*(1-v);let C=0;for(let e=1;e<=f;e++)C+=S/b**(e-1+v);return u/b**(f-1+v)+C-S*(1-v)},isExported:!0},nd={description:r("Price of a discount security."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the security at time of purchase.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Ps(e)),s=Math.trunc(Ps(t)),a=Ps(i),l=Ps(n),c=Math.trunc(Ps(o));Jc(r,s),ih(c),ph(a),nh(l);return l-a*l*Bc.compute(r,s,c)},isExported:!0},od={description:r("Calculates the price of a security paying interest at maturity, based on expected yield."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${r("The date the security was initially issued.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s=0){s=s||0;const a=Math.trunc(Ps(e)),l=Math.trunc(Ps(t)),c=Math.trunc(Ps(i)),h=Ps(n),d=Ps(o),u=Math.trunc(Ps(s));eh(a,c),Jc(a,l),ih(u),$s((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),$s((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString()));const g=Bc.compute(a,l,u),p=Bc.compute(a,c,u);return(100+Bc.compute(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},rd=.1,sd={description:r("Interest rate of an annuity investment."),args:_s(`\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_per_period (number) ${r("The amount per period to be paid.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the interest rate will be.")}\n `),returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,i,n=0,o=0,s=.1){n=n||0,o=o||0,s=s||rd;const a=Ps(e),l=Ps(t),c=Ws(o)?1:0,h=Ps(s);let d=Ps(n),u=Ps(i);rh(a),$s((()=>[l,u,d].some((e=>e>0))&&[l,u,d].some((e=>e<0))),r("There must be both positive and negative values in [payment_amount, present_value, future_value].",a.toString())),Sh(h),d-=l*c,u+=l*c;return yh((e=>{const t=Math.pow(1+e,a);return d+u*t+l*((t-1)/e)}),(e=>{const t=Math.pow(1+e,a-1),i=Math.pow(1+e,a);return u*a*t+l*(a*t/e-(i-1)/e/e)}),h,40,1e-5)},isExported:!0},ad={description:r("Amount received at maturity for a security."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n investment (number) ${r("The amount invested (irrespective of face value of each security).")}\n discount (number) ${r("The discount rate of the security invested in.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Ps(e)),s=Math.trunc(Ps(t)),a=Ps(i),l=Ps(n),c=Math.trunc(Ps(o));Jc(r,s),ih(c),gh(a),ph(l);return a/(1-l*Bc.compute(r,s,c))},isExported:!0},ld={description:r("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:_s(`\n number_of_periods (number) ${r("The number of periods.")}\n present_value (number) ${r("The present value of the investment.")}\n future_value (number) ${r("The future value of the investment.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Ps(e),o=Ps(t),r=Ps(i);return rh(n),(r/o)**(1/n)-1},isExported:!0},cd={description:r("Depreciation of an asset using the straight-line method."),args:_s(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i){return(Ps(e)-Ps(t))/Ps(i)},isExported:!0},hd={description:r("Depreciation via sum of years digit method."),args:_s(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n){const o=Ps(e),r=Ps(t),s=Ps(i),a=Ps(n);ch(a),ah(s),uh(a,s);return(s-a+1)/(s*(s+1)/2)*(o-r)},isExported:!0},dd={description:r("Price of a US Treasury bill."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the bill at time of purchase.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Math.trunc(Ps(e)),o=Math.trunc(Ps(t)),r=Ps(i);Jc(n,o),vh(n,o),ph(r),mh(r);return 100*(1-r*Bc.compute(n,o,2))},isExported:!0},ud={description:r("Equivalent rate of return for a US Treasury bill."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the bill at time of purchase.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Math.trunc(Ps(e)),o=Math.trunc(Ps(t)),r=Ps(i);Jc(n,o),vh(n,o),ph(r),mh(r);const s=Ec.compute(o,n);if(s<=182)return 365*r/(360-r*s);const a=dd.compute(n,o,r)/100,l=s/(366===s?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},gd={description:r("The yield of a US Treasury bill based on price."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Math.trunc(Ps(e)),o=Math.trunc(Ps(t)),r=Ps(i);Jc(n,o),vh(n,o),oh(r);return(100-r)/r*(1/Bc.compute(n,o,2))},isExported:!0},pd={description:r("Variable declining balance. WARNING : does not handle decimal periods."),args:_s(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n start (number) ${r("Starting period to calculate depreciation.")}\n end (number) ${r("Ending period to calculate depreciation.")}\n factor (number, default=2) ${r("The number of months in the first year of depreciation.")}\n no_switch (number, default=false) ${r("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s=2,a=false){s=s||0;const l=Ps(e),c=Ps(t),h=Ps(i),d=Math.trunc(Ps(n)),u=Math.trunc(Ps(o)),g=Ps(s),p=Ws(a);if(lh(l),hh(c),function(e,t,i){ah(i),$s((()=>e>=0),r("The start_period (%s) must be greater or equal than 0.",e.toString())),$s((()=>t>=0),r("The end_period (%s) must be greater or equal than 0.",t.toString())),$s((()=>e<=t),r("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),$s((()=>t<=i),r("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),i.toString()))}(d,u,h),fh(g),0===l)return 0;if(c>=l)return d<1?l-c:0;const m=g/h;if(m>=1)return d<1?l-c:0;let f=l,v=0,b=0,S=!1;for(let e=0;e<u;e++){if(!S||p){const t=f*m,i=(f-c)/(h-e);!p&&i>t?(S=!0,v=i):v=t}const t=Math.max(f-v,c);e>=d&&(b+=f-t),f=t}return b},isExported:!0},md={description:r("Internal rate of return given non-periodic cash flows."),args:_s(`\n cashflow_amounts (range<number>) ${r("An range containing the income or payments associated with the investment.")}\n cashflow_dates (range<number>) ${r("An range with dates corresponding to the cash flows in cashflow_amounts.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],compute:function(e,t,i=.1){const n=Ps(i=i||0),o=e.flat().map(Ps),s=t.flat().map(Ps);var a;Ch(e,t),a=o,$s((()=>a.some((e=>e>0))&&a.some((e=>e<0))),r("There must be both positive and negative values in cashflow_amounts.")),Eh(s),Sh(n);const l=new Map;for(const e of $e(0,s.length)){const t=s[e];l.has(t)?l.set(t,l.get(t)+o[e]):l.set(t,o[e])}const c=Array.from(l.keys()),h=c.map((e=>l.get(e)));return yh((e=>{let t=h[0];for(const i of $e(1,h.length)){const n=(c[0]-c[i])/365;t+=h[i]*(1+e)**n}return t}),(e=>{let t=0;for(const i of $e(1,h.length)){const n=(c[0]-c[i])/365;t+=n*h[i]*(1+e)**(n-1)}return t}),n,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},fd={description:r("Net present value given to non-periodic cash flows.."),args:_s(`\n discount (number) ${r("The discount rate of the investment over one period.")}\n cashflow_amounts (number, range<number>) ${r("An range containing the income or payments associated with the investment.")}\n cashflow_dates (number, range<number>) ${r("An range with dates corresponding to the cash flows in cashflow_amounts.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Ps(e),o=Array.isArray(t)?t.flat().map(Us):[Us(t)],s=Array.isArray(i)?i.flat().map(Us):[Us(i)];if(Array.isArray(i)&&Array.isArray(t)?Ch(t,i):$s((()=>o.length===s.length),r("There must be the same number of values in cashflow_amounts and cashflow_dates.")),Eh(s),sh(n),1===o.length)return o[0];const a=new Map;for(const e of $e(0,s.length)){const t=s[e];a.has(t)?a.set(t,a.get(t)+o[e]):a.set(t,o[e])}const l=Array.from(a.keys()),c=l.map((e=>a.get(e)));let h=c[0];for(const e of $e(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+n)**t}return h},isExported:!0},vd={description:r("Annual yield of a security paying periodic interest."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s,a=0){a=a||0;const l=Math.trunc(Ps(e)),c=Math.trunc(Ps(t)),h=Ps(i),d=Ps(n),u=Ps(o),g=Math.trunc(Ps(s)),p=Math.trunc(Ps(a));Jc(l,c),th(g),ih(p),$s((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),oh(d),nh(u);const m=Bc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=100*h/g;if(1===f){const e=d+b*(1-v);return(u+b-e)*g*(1/v)/e}const S=yh((function(e){return function(e,t,i,n,o,r){let s=r-(e+o*(1-t))*n**(i-1+t);for(let e=1;e<=i;e++)s+=o*n**(e-1);return s}(d,v,f,e,b,u)}),(function(e){return function(e,t,i,n,o){let r=-(e+o*(1-t))*(i-1+t)*n**(i-2+t);for(let e=1;e<=i;e++)r+=o*(e-1)*n**(e-2);return r}(d,v,f,e,b)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},bd={description:r("Annual yield of a discount security."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Ps(e)),s=Math.trunc(Ps(t)),a=Ps(i),l=Ps(n),c=Math.trunc(Ps(o));Jc(r,s),ih(c),oh(a),nh(l);return(l/a-1)/Bc.compute(e,t,o)},isExported:!0},Sd={description:r("Annual yield of a security paying interest at maturity."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${r("The date the security was initially issued.")}\n rate (number) ${r("The annualized rate of interest.")}\n price (number) ${r("The price at which the security is bought.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s=0){s=s||0;const a=Math.trunc(Ps(e)),l=Math.trunc(Ps(t)),c=Math.trunc(Ps(i)),h=Ps(n),d=Ps(o),u=Math.trunc(Ps(s));Jc(a,l),ih(u),$s((()=>a>=c),r("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),$s((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),oh(d);const g=Bc.compute(c,l,u),p=Bc.compute(c,a,u),m=Bc.compute(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var Cd=Object.freeze({__proto__:null,ACCRINTM:xh,AMORLINC:Rh,COUPDAYS:Ih,COUPDAYBS:Th,COUPDAYSNC:Ah,COUPNCD:Nh,COUPNUM:Mh,COUPPCD:Oh,CUMIPMT:_h,CUMPRINC:Fh,DB:Dh,DDB:kh,DISC:$h,DOLLARDE:Lh,DOLLARFR:Ph,DURATION:Uh,EFFECT:Vh,FV:zh,FVSCHEDULE:Bh,INTRATE:Hh,IPMT:Wh,IRR:Gh,ISPMT:qh,MDURATION:Zh,MIRR:jh,NOMINAL:Yh,NPER:Xh,NPV:Kh,PDURATION:Qh,PMT:Jh,PPMT:ed,PV:td,PRICE:id,PRICEDISC:nd,PRICEMAT:od,RATE:sd,RECEIVED:ad,RRI:ld,SLN:cd,SYD:hd,TBILLPRICE:dd,TBILLEQ:ud,TBILLYIELD:gd,VDB:pd,XIRR:md,XNPV:fd,YIELD:vd,YIELDDISC:bd,YIELDMAT:Sd});const Ed={description:r("Whether a value is an error other than #N/A."),args:_s(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)!=a.NotAvailable}},isExported:!0},wd={description:r("Whether a value is an error."),args:_s(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return!0}},isExported:!0},yd={description:r("Whether a value is `true` or `false`."),args:_s(`value (any, lazy) ${r("The value to be verified as a logical TRUE or FALSE.")}`),returns:["BOOLEAN"],compute:function(e){try{return"boolean"==typeof e()}catch(e){return!1}},isExported:!0},xd={description:r("Whether a value is the error #N/A."),args:_s(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)==a.NotAvailable}},isExported:!0},Rd={description:r("Whether a value is non-textual."),args:_s(`value (any, lazy) ${r("The value to be checked.")}`),returns:["BOOLEAN"],compute:function(e){try{return"string"!=typeof e()}catch(e){return!0}},isExported:!0},Id={description:r("Whether a value is a number."),args:_s(`value (any, lazy) ${r("The value to be verified as a number.")}`),returns:["BOOLEAN"],compute:function(e){try{return"number"==typeof e()}catch(e){return!1}},isExported:!0},Td={description:r("Whether a value is text."),args:_s(`value (any, lazy) ${r("The value to be verified as text.")}`),returns:["BOOLEAN"],compute:function(e){try{return"string"==typeof e()}catch(e){return!1}},isExported:!0},Ad={description:r("Whether the referenced cell is empty"),args:_s(`value (any, lazy) ${r("Reference to the cell that will be checked for emptiness.")}`),returns:["BOOLEAN"],compute:function(e){try{return null===e()}catch(e){return!1}},isExported:!0},Nd={description:r("Returns the error value #N/A."),args:_s(""),returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var Md=Object.freeze({__proto__:null,ISERR:Ed,ISERROR:wd,ISLOGICAL:yd,ISNA:xd,ISNONTEXT:Rd,ISNUMBER:Id,ISTEXT:Td,ISBLANK:Ad,NA:Nd});const Od={description:r("Logical `and` operator."),args:_s(`\n logical_expression1 (boolean, range<boolean>) ${r("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.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that represent logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!0;return Js(e,(e=>(t=!0,i=i&&e,i))),$s((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},_d={description:r("Returns value depending on logical expression."),args:_s(`\n logical_expression (boolean) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")}\n value_if_true (any, lazy) ${r("The value the function returns if logical_expression is TRUE.")}\n value_if_false (any, lazy, default=FALSE) ${r("The value the function returns if logical_expression is FALSE.")}\n `),returns:["ANY"],compute:function(e,t,i=(()=>!1)){const n=Ws(e)?t():i();return null==n?"":n},isExported:!0},Fd={description:r("Value if it is not an error, otherwise 2nd argument."),args:_s(`\n value (any, lazy) ${r("The value to return if value itself is not an error.")}\n value_if_error (any, lazy, default=${r("An empty value")}) ${r("The value the function returns if value is an error.")}\n `),returns:["ANY"],computeFormat:(e,t=(()=>({value:""})))=>{var i;try{return e().format}catch(e){return null===(i=t())||void 0===i?void 0:i.format}},compute:function(e,t=(()=>"")){let i;try{i=e()}catch(e){i=t()}return null==i?"":i},isExported:!0},Dd={description:r("Value if it is not an #N/A error, otherwise 2nd argument."),args:_s(`\n value (any, lazy) ${r("The value to return if value itself is not #N/A an error.")}\n value_if_error (any, lazy, default=${r("An empty value")}) ${r("The value the function returns if value is an #N/A error.")}\n `),returns:["ANY"],compute:function(e,t=(()=>"")){let i;try{i=e()}catch(n){i=n.errorType===a.NotAvailable?t():e()}return null==i?"":i},isExported:!0},kd={description:r("Returns a value depending on multiple logical expressions."),args:_s(`\n condition1 (boolean, lazy) ${r("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")}\n value1 (any, lazy) ${r("The returned value if condition1 is TRUE.")}\n condition2 (boolean, lazy, repeating) ${r("Additional conditions to be evaluated if the previous ones are FALSE.")}\n value2 (any, lazy, repeating) ${r("Additional values to be returned if their corresponding conditions are TRUE.")}\n `),returns:["ANY"],compute:function(...e){$s((()=>e.length%2==0),r("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(Ws(e[t]())){const i=e[t+1]();return null!==i?i:""}throw new Error(r("No match."))},isExported:!0},$d={description:r("Returns opposite of provided logical value."),args:_s(`logical_expression (boolean) ${r("An expression or reference to a cell holding an expression that represents some logical value.")}\n `),returns:["BOOLEAN"],compute:function(e){return!Ws(e)},isExported:!0},Ld={description:r("Logical `or` operator."),args:_s(`\n logical_expression1 (boolean, range<boolean>) ${r("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.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return Js(e,(e=>(t=!0,i=i||e,!i))),$s((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Pd={description:r("Logical `xor` operator."),args:_s(`\n logical_expression1 (boolean, range<boolean>) ${r("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.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return Js(e,(e=>(t=!0,i=i?!e:e,!0))),$s((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0};var Ud=Object.freeze({__proto__:null,AND:Od,IF:_d,IFERROR:Fd,IFNA:Dd,IFS:kd,NOT:$d,OR:Ld,XOR:Pd});const Vd={description:r("Column number of a specified cell."),args:_s(`cell_reference (meta, default=${r("The cell in which the formula is entered")}) ${r("The cell whose column number will be returned. Column A corresponds to 1.")}\n `),returns:["NUMBER"],compute:function(e){var t;const i=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this));$s((()=>!!i),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Mi(i).left+1},isExported:!0},zd={description:r("Number of columns in a specified array or range."),args:_s(`range (meta) ${r("The range whose column count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=Mi(e);return t.right-t.left+1},isExported:!0},Bd={description:r("Horizontal lookup"),args:_s(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (range) ${r("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")}\n index (number) ${r("The row index of the value to be returned, where the first row in range is numbered 1.")}\n is_sorted (boolean, default=true) ${r("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.")}\n `),returns:["ANY"],compute:function(e,t,i,n=true){const o=Math.trunc(Ps(i)),s=Bs(e);$s((()=>1<=o&&o<=t[0].length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=Ws(n);let l;return l=a?ra(t,s,"nextSmaller","asc",t.length,oa):sa(t,s,"strict",t.length,oa),$s((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Vs(e))),t[l][o-1]},isExported:!0},Hd={description:r("Returns the content of a cell, specified by row and column offset."),args:_s(`\n reference (any, range) ${r("The range of cells from which the value is returned.")}\n row (number) ${r("The index of the row to be returned from within the reference range of cells.")}\n column (number) ${r("The index of the column to be returned from within the reference range of cells.")}\n`),returns:["ANY"],computeFormat:(e,t,i)=>{var n;const o=Ps(t.value);return null===(n=e[Ps(i.value)-1][o-1])||void 0===n?void 0:n.format},compute:function(e,t,i){const n=(o=e,Array.isArray(o)&&Array.isArray(o[0])?e:[[e]]);var o;const s=Ps(t),a=Ps(i);return $s((()=>a>=0&&a-1<n.length&&s>=0&&s-1<n[0].length),r("Index out of range.")),$s((()=>0!==t&&0!==i),r("This function can only return a single cell value, not an array. Provide valid row and column indices.")),n[a-1][s-1]},isExported:!0},Wd={description:r("Look up a value."),args:_s(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n search_array (range) ${r("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.")}\n result_range (range, optional) ${r("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.")}\n `),returns:["ANY"],compute:function(e,t,i){let n=t.length,o=t[0].length;const s=Bs(e),a=o>=n,l=ra(t,s,"nextSmaller","asc",a?o:n,a?na:oa);return $s((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Vs(e))),void 0===i?a?t[n-1][l]:t[l][o-1]:(n=i.length,o=i[0].length,$s((()=>1===n||1===o),r("The result_range must be a single row or a single column.")),n>1?($s((()=>l<=n-1),r("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),i[l][0]):($s((()=>l<=o-1),r("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),i[0][l]))},isExported:!0},Gd={description:r("Position of item in range that matches value."),args:_s(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${r("The one-dimensional array to be searched.")}\n search_type (number, default=1) ${r("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.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){let n=Ps(i);const o=Bs(e),s=t.length,a=t[0].length;$s((()=>1===s||1===a),r("The range must be a single row or a single column."));let l=-1;const c=1===s?na:oa,h=1===s?t[0].length:t.length;switch(n=Math.sign(n),n){case 1:l=ra(t,o,"nextSmaller","asc",h,c);break;case 0:l=sa(t,o,"strict",h,c);break;case-1:l=ra(t,o,"nextGreater","desc",h,c)}return $s((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Vs(e))),l+1},isExported:!0},qd={description:r("Row number of a specified cell."),args:_s(`cell_reference (meta, default=${r("The cell in which the formula is entered by default")}) ${r("The cell whose row number will be returned.")}`),returns:["NUMBER"],compute:function(e){var t;e=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this)),$s((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Mi(e).top+1},isExported:!0},Zd={description:r("Number of rows in a specified array or range."),args:_s(`range (meta) ${r("The range whose row count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=Mi(e);return t.bottom-t.top+1},isExported:!0},jd={description:r("Vertical lookup."),args:_s(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${r("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")}\n index (number) ${r("The column index of the value to be returned, where the first column in range is numbered 1.")}\n is_sorted (boolean, default=true) ${r("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.")}\n `),returns:["ANY"],compute:function(e,t,i,n=true){const o=Math.trunc(Ps(i)),s=Bs(e);$s((()=>1<=o&&o<=t.length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=Ws(n);let l;return l=a?ra(t,s,"nextSmaller","asc",t[0].length,na):sa(t,s,"strict",t[0].length,na),$s((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Vs(e))),t[o-1][l]},isExported:!0},Yd={description:r("Search a range for a match and return the corresponding item from a second range."),args:_s(`\n search_key (any) ${r("The value to search for.")}\n lookup_range (any, range) ${r("The range to consider for the search. Should be a single column or a single row.")}\n return_range (any, range) ${r("The range containing the return value. Should have the same dimensions as lookup_range.")}\n if_not_found (any, lazy, optional) ${r("If a valid match is not found, return this value.")}\n match_mode (any, default=0) ${r("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match.")}\n search_mode (any, default=1) ${r("(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. ")}\n\n `),returns:["ANY"],compute:function(e,t,i,n,o=0,s=1){const a=Math.trunc(Ps(o)),l=Math.trunc(Ps(s)),c=Bs(e);$s((()=>1===t.length||1===t[0].length),r("lookup_range should be either a single row or single column.")),$s((()=>1===i.length||1===i[0].length),r("return_range should be either a single row or single column.")),$s((()=>i.length===t.length&&i[0].length===t[0].length),r("return_range should have the same dimensions as lookup_range.")),$s((()=>[-1,1,-2,2].includes(l)),r("searchMode should be a value in [-1, 1, -2, 2].")),$s((()=>[-1,0,1].includes(a)),r("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?na:oa,d=1===t.length?t[0].length:t.length,u=0===a?"strict":1===a?"nextGreater":"nextSmaller",g=-1===l;let p;if(2===l||-2===l){p=ra(t,c,u,2===l?"asc":"desc",d,h)}else p=sa(t,c,u,d,h,g);if(-1!==p)return 1===t.length?i[0][p]:i[p][0];const m=null==n?void 0:n();return $s((()=>!!m),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Vs(e))),m},isExported:!0};var Xd=Object.freeze({__proto__:null,COLUMN:Vd,COLUMNS:zd,HLOOKUP:Bd,INDEX:Hd,LOOKUP:Wd,MATCH:Gd,ROW:qd,ROWS:Zd,VLOOKUP:jd,XLOOKUP:Yd});const Kd={description:r("Sum of two numbers."),args:_s(`\n value1 (number) ${r("The first addend.")}\n value2 (number) ${r("The second addend.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Ps(e)+Ps(t)}},Qd={description:r("Concatenation of two values."),args:_s(`\n value1 (string) ${r("The value to which value2 will be appended.")}\n value2 (string) ${r("The value to append to value1.")}\n `),returns:["STRING"],compute:function(e,t){return Vs(e)+Vs(t)},isExported:!0},Jd={description:r("One number divided by another."),args:_s(`\n dividend (number) ${r("The number to be divided.")}\n divisor (number) ${r("The number to divide by.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){const i=Ps(t);return $s((()=>0!==i),r("The divisor must be different from zero.")),Ps(e)/i}};function eu(e){return null==e}const tu={number:0,string:"",boolean:!1},iu={description:r("Equal."),args:_s(`\n value1 (any) ${r("The first value.")}\n value2 (any) ${r("The value to test against value1 for equality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return e=eu(e)?tu[typeof t]:e,t=eu(t)?tu[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function nu(e,t,i){e=eu(e)?tu[typeof t]:e,t=eu(t)?tu[typeof e]:t,"number"!=typeof e&&(e=Vs(e).toUpperCase()),"number"!=typeof t&&(t=Vs(t).toUpperCase());const n=typeof e,o=typeof t;return"string"===n&&"number"===o||("string"!==o||"number"!==n)&&i(e,t)}const ou={description:r("Strictly greater than."),args:_s(`\n value1 (any) ${r("The value to test as being greater than value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return nu(e,t,((e,t)=>e>t))}},ru={description:r("Greater than or equal to."),args:_s(`\n value1 (any) ${r("The value to test as being greater than or equal to value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return nu(e,t,((e,t)=>e>=t))}},su={description:r("Less than."),args:_s(`\n value1 (any) ${r("The value to test as being less than value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!ru.compute(e,t)}},au={description:r("Less than or equal to."),args:_s(`\n value1 (any) ${r("The value to test as being less than or equal to value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!ou.compute(e,t)}},lu={description:r("Difference of two numbers."),args:_s(`\n value1 (number) ${r("The minuend, or number to be subtracted from.")}\n value2 (number) ${r("The subtrahend, or number to subtract from value1.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Ps(e)-Ps(t)}},cu={description:r("Product of two numbers"),args:_s(`\n factor1 (number) ${r("The first multiplicand.")}\n factor2 (number) ${r("The second multiplicand.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Ps(e)*Ps(t)}},hu={description:r("Not equal."),args:_s(`\n value1 (any) ${r("The first value.")}\n value2 (any) ${r("The value to test against value1 for inequality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!iu.compute(e,t)}},du={description:r("A number raised to a power."),args:_s(`\n base (number) ${r("The number to raise to the exponent power.")}\n exponent (number) ${r("The exponent to raise base to.")}\n `),returns:["NUMBER"],compute:function(e,t){return ja.compute(e,t)}},uu={description:r("A number with the sign reversed."),args:_s(`\n value (number) ${r("The number to have its sign reversed. Equivalently, the number to multiply by -1.")}\n `),computeFormat:e=>null==e?void 0:e.format,returns:["NUMBER"],compute:function(e){return-Ps(e)}},gu={description:r("Value interpreted as a percentage."),args:_s(`\n percentage (number) ${r("The value to interpret as a percentage.")}\n `),returns:["NUMBER"],compute:function(e){return Ps(e)/100}},pu={description:r("A specified number, unchanged."),args:_s(`\n value (any) ${r("The number to return.")}\n `),returns:["ANY"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){return null===e?"":e}};var mu=Object.freeze({__proto__:null,ADD:Kd,CONCAT:Qd,DIVIDE:Jd,EQ:iu,GT:ou,GTE:ru,LT:su,LTE:au,MINUS:lu,MULTIPLY:cu,NE:hu,POW:du,UMINUS:uu,UNARY_PERCENT:gu,UPLUS:pu});const fu=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,vu={description:r("Gets character associated with number."),args:_s(`\n table_number (number) ${r("The number of the character to look up from the current Unicode table in decimal format.")}\n `),returns:["STRING"],compute:function(e){const t=Math.trunc(Ps(e));return $s((()=>t>=1),r("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},bu={description:r("Remove non-printable characters from a piece of text."),args:_s(`\n text (string) ${r("The text whose non-printable characters are to be removed.")}\n `),returns:["STRING"],compute:function(e){const t=Vs(e);let i="";for(const e of t)e&&e.charCodeAt(0)>31&&(i+=e);return i},isExported:!0},Su={description:r("Appends strings to one another."),args:_s(`\n string1 (string, range<string>) ${r("The initial string.")}\n string2 (string, range<string>, repeating) ${r("More strings to append in sequence.")}\n `),returns:["STRING"],compute:function(...e){return Xs(e,((e,t)=>e+Vs(t)),"")},isExported:!0},Cu={description:r("Tests whether two strings are identical."),args:_s(`\n string1 (string) ${r("The first string to compare.")}\n string2 (string) ${r("The second string to compare.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return Vs(e)===Vs(t)},isExported:!0},Eu={description:r("First position of string found in text, case-sensitive."),args:_s(`\n search_for (string) ${r("The string to look for within text_to_search.")}\n text_to_search (string) ${r("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${r("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){const n=Vs(e),o=Vs(t),s=Ps(i);$s((()=>""!==o),r("The text_to_search must be non-empty.")),$s((()=>s>=1),r("The starting_at (%s) must be greater than or equal to 1.",s.toString()));const a=o.indexOf(n,s-1);return $s((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",n.toString(),o)),a+1},isExported:!0},wu={description:r("Concatenates elements of arrays with delimiter."),args:_s(`\n delimiter (string) ${r("The character or string to place between each concatenated value.")}\n value_or_array1 (string, range<string>) ${r("The value or values to be appended using delimiter.")}\n value_or_array2 (string, range<string>, repeating) ${r("More values to be appended using delimiter.")}\n `),returns:["STRING"],compute:function(e,...t){const i=Vs(e);return Xs(t,((e,t)=>(e?e+i:"")+Vs(t)),"")}},yu={description:r("Substring from beginning of specified string."),args:_s(`\n text (string) ${r("The string from which the left portion will be returned.")}\n number_of_characters (number, optional) ${r("The number of characters to return from the left side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const i=t.length?Ps(t[0]):1;return $s((()=>i>=0),r("The number_of_characters (%s) must be positive or null.",i.toString())),Vs(e).substring(0,i)},isExported:!0},xu={description:r("Length of a string."),args:_s(`\n text (string) ${r("The string whose length will be returned.")}\n `),returns:["NUMBER"],compute:function(e){return Vs(e).length},isExported:!0},Ru={description:r("Converts a specified string to lowercase."),args:_s(`\n text (string) ${r("The string to convert to lowercase.")}\n `),returns:["STRING"],compute:function(e){return Vs(e).toLowerCase()},isExported:!0},Iu={description:r("A segment of a string."),args:_s(`\n text (string) ${r("The string to extract a segment from.")}\n starting_at (number) ${r("The index from the left of string from which to begin extracting. The first character in string has the index 1.")}\n extract_length (number) ${r("The length of the segment to extract.")}\n `),returns:["STRING"],compute:function(e,t,i){const n=Vs(e),o=Ps(t),s=Ps(i);return $s((()=>o>=1),r("The starting_at argument (%s) must be positive greater than one.",o.toString())),$s((()=>s>=0),r("The extract_length argument (%s) must be positive or null.",s.toString())),n.slice(o-1,o+s-1)},isExported:!0},Tu={description:r("Capitalizes each word in a specified string."),args:_s(`\n text_to_capitalize (string) ${r("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase.")}\n `),returns:["STRING"],compute:function(e){return Vs(e).replace(fu,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},Au={description:r("Replaces part of a text string with different text."),args:_s(`\n text (string) ${r("The text, a part of which will be replaced.")}\n position (number) ${r("The position where the replacement will begin (starting from 1).")}\n length (number) ${r("The number of characters in the text to be replaced.")}\n new_text (string) ${r("The text which will be inserted into the original text.")}\n `),returns:["STRING"],compute:function(e,t,i,n){const o=Ps(t);$s((()=>o>=1),r("The position (%s) must be greater than or equal to 1.",o.toString()));const s=Vs(e),a=Ps(i),l=Vs(n);return s.substring(0,o-1)+l+s.substring(o-1+a)},isExported:!0},Nu={description:r("A substring from the end of a specified string."),args:_s(`\n text (string) ${r("The string from which the right portion will be returned.")}\n number_of_characters (number, optional) ${r("The number of characters to return from the right side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const i=t.length?Ps(t[0]):1;$s((()=>i>=0),r("The number_of_characters (%s) must be positive or null.",i.toString()));const n=Vs(e),o=n.length;return n.substring(o-i,o)},isExported:!0},Mu={description:r("First position of string found in text, ignoring case."),args:_s(`\n search_for (string) ${r("The string to look for within text_to_search.")}\n text_to_search (string) ${r("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${r("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){const n=Vs(e).toLowerCase(),o=Vs(t).toLowerCase(),s=Ps(i);$s((()=>""!==o),r("The text_to_search must be non-empty.")),$s((()=>s>=1),r("The starting_at (%s) must be greater than or equal to 1.",s.toString()));const a=o.indexOf(n,s-1);return $s((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",n,o)),a+1},isExported:!0},Ou={description:r("Replaces existing text with new text in a string."),args:_s(`\n text_to_search (string) ${r("The text within which to search and replace.")}\n search_for (string) ${r("The string to search for within text_to_search.")}\n replace_with (string) ${r("The string that will replace search_for.")}\n occurrence_number (number, optional) ${r("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.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n){const o=Ps(n);$s((()=>o>=0),r("The occurrenceNumber (%s) must be positive or null.",o.toString()));const s=Vs(e),a=Vs(t);if(""===a)return s;const l=Vs(i),c=new RegExp(Te(a),"g");if(0===o)return s.replace(c,l);let h=0;return s.replace(c,(e=>++h===o?l:e))},isExported:!0},_u={description:r("Combines text from multiple strings and/or arrays."),args:_s(`\n delimiter (string) ${r(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")}\n ignore_empty (boolean) ${r("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")}\n text1 (string, range<string>) ${r("Any text item. This could be a string, or an array of strings in a range.")}\n text2 (string, range<string>, repeating) ${r("Additional text item(s).")}\n `),returns:["STRING"],compute:function(e,t,...i){const n=Vs(e),o=Ws(t);let r=0;return Xs(i,((e,t)=>o&&""===Vs(t)?e:(r++?e+n:"")+Vs(t)),"")},isExported:!0},Fu={description:r("Removes space characters."),args:_s(`\n text (string) ${r("The text or reference to a cell containing text to be trimmed.")}\n `),returns:["STRING"],compute:function(e){return Vs(e).trim()},isExported:!0},Du={description:r("Converts a specified string to uppercase."),args:_s(`\n text (string) ${r("The string to convert to uppercase.")}\n `),returns:["STRING"],compute:function(e){return Vs(e).toUpperCase()},isExported:!0},ku={description:r("Converts a number to text according to a specified format."),args:_s(`\n number (number) ${r("The number, date or time to format.")}\n format (string) ${r("The pattern by which to format the number, enclosed in quotation marks.")}\n `),returns:["STRING"],compute:function(e,t){return Qt(Ps(e),Vs(t))},isExported:!0};const $u={database:vc,date:Xc,financial:Cd,info:Md,lookup:Xd,logical:Ud,math:ul,misc:ca,operators:mu,statistical:ic,text:Object.freeze({__proto__:null,CHAR:vu,CLEAN:bu,CONCATENATE:Su,EXACT:Cu,FIND:Eu,JOIN:wu,LEFT:yu,LEN:xu,LOWER:Ru,MID:Iu,PROPER:Tu,REPLACE:Au,RIGHT:Nu,SEARCH:Mu,SUBSTITUTE:Ou,TEXTJOIN:_u,TRIM:Fu,UPPER:Du,TEXT:ku}),engineering:Qc},Lu=/^[A-Z0-9\_\.]+$/;function Pu(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>Uu(e()):Uu(e)}))}function Uu(e){return Array.isArray(e)?e.map((e=>e.map((e=>null==e?void 0:e.value)))):null==e?void 0:e.value}const Vu=new class extends tn{constructor(){super(...arguments),this.mapping={}}add(e,t){if(!(e=e.toUpperCase()).match(Lu))throw new Error(r("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const i=Ds(t);return function(e){let t=!1,i=!1,n=!1;for(let o of e){if(o.type.includes("META")&&o.type.length>1)throw new Error(r("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&&!o.repeating)throw new Error(r("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=i||t||n,s=!(o.optional||o.repeating||o.default);if(e&&s)throw new Error(r("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=o.repeating,i=o.optional,n=o.default}}(i.args),this.mapping[e]=function(...e){const t=i.compute.bind(this),n=i.computeFormat?i.computeFormat.bind(this):()=>{};return{value:t(...Pu(e)),format:n(...e)}},super.add(e,i),this}};for(let e in $u){const t=$u[e];for(let i in t){const n=t[i];n.category=e,i=i.replace(/_/g,"."),Vu.add(i,{isExported:!1,...n})}}const zu=Vu.content,Bu=["%"],Hu="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(Bu);function Wu(e){const t=e.split(""),i=[];for(;t.length;){let e=tg(t)||Zu(t)||Yu(t)||Ku(t)||Gu(t)||ig(t)||Xu(t)||Ju(t);e||(e={type:"UNKNOWN",value:t.shift()}),i.push(e)}return i}function Gu(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const qu={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function Zu(e){if(e[0]in qu){const t=e.shift();return{type:qu[t],value:t}}return null}function ju(e,t){for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function Yu(e){for(let t of Hu)if(ju(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function Xu(e){const t=et(e).match(pi);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function Ku(e){if('"'===e[0]){const t=e.shift();let i=t;for(;e[0]&&(e[0]!==t||"\\"===i[i.length-1]);)i+=e.shift();return'"'===e[0]&&(i+=e.shift()),{type:"STRING",value:i}}return null}const Qu=/\w|\.|!|\$/;function Ju(e){let t="";if("'"===e[0]){let i=e.shift();for(t+=i;e[0];)if(i=e.shift(),t+=i,"'"===i){if(!e[0]||"'"!==e[0])break;i=e.shift(),t+=i}if("'"!==i)return{type:"UNKNOWN",value:t}}for(;e[0]&&e[0].match(Qu);)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in zu)return{type:"FUNCTION",value:e};return e.match(Mt)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}const eg=/\s/;function tg(e){let t=0;for(;e[0]&&e[0].match(eg);)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function ig(e){return ju(e,X)?(e.splice(0,X.length),{type:"INVALID_REFERENCE",value:X}):null}const ng=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,og=["-","+"],rg=["%"],sg=["*","+","&"],ag={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10},lg=6;function cg(e){switch(e.type){case"NUMBER":case"SYMBOL":case"REFERENCE":return 0;case"COMMA":return 3;case"LEFT_PAREN":case"RIGHT_PAREN":return 5;case"OPERATOR":return ag[e.value]||15}throw new Error(r("Unknown token: %s",e.value))}function hg(e,t,i){if("OPERATOR"===t.type){const n=cg(t);if(rg.includes(t.value))return{type:"UNARY_OPERATION",value:t.value,operand:e,postfix:!0};{const o=dg(i,n);return{type:"BIN_OPERATION",value:t.value,left:e,right:o}}}throw new Error(ne)}function dg(e,t){const i=e.shift();if(!i)throw new Error(ne);let n=function(e,t){var i,n,o,s;switch(e.type){case"DEBUGGER":const a=dg(t,1e3);return a.debug=!0,a;case"NUMBER":return{type:"NUMBER",value:wi(e.value)};case"STRING":return{type:"STRING",value:Ie(e.value)};case"FUNCTION":if("LEFT_PAREN"!==t.shift().type)throw new Error(r("Wrong function call"));{const n=[];if(t[0]&&"RIGHT_PAREN"!==t[0].type)for("COMMA"===t[0].type?n.push({type:"UNKNOWN",value:""}):n.push(dg(t,lg));"COMMA"===(null===(i=t[0])||void 0===i?void 0:i.type);){t.shift();const e=t[0];if("RIGHT_PAREN"===(null==e?void 0:e.type)){n.push({type:"UNKNOWN",value:""});break}"COMMA"===(null==e?void 0:e.type)?n.push({type:"UNKNOWN",value:""}):n.push(dg(t,lg))}const o=t.shift();if(!o||"RIGHT_PAREN"!==o.type)throw new Error(r("Wrong function call"));return{type:"FUNCALL",value:e.value,args:n}}case"INVALID_REFERENCE":throw new u;case"REFERENCE":if(":"===(null===(n=t[0])||void 0===n?void 0:n.value)&&"REFERENCE"===(null===(o=t[1])||void 0===o?void 0:o.type)){t.shift();const i=t.shift();return{type:"REFERENCE",value:`${e.value}:${null==i?void 0:i.value}`}}return{type:"REFERENCE",value:e.value};case"SYMBOL":if(["TRUE","FALSE"].includes(e.value.toUpperCase()))return{type:"BOOLEAN",value:"TRUE"===e.value.toUpperCase()};if(e.value){if(ng.test(e.value)&&"LEFT_PAREN"===(null===(s=t[0])||void 0===s?void 0:s.type))throw new p(e.value);throw new Error(r("Invalid formula"))}return{type:"STRING",value:e.value};case"LEFT_PAREN":const l=dg(t,5);if(!t.length||"RIGHT_PAREN"!==t[0].type)throw new Error(r("Unmatched left parenthesis"));return t.shift(),l;default:if("OPERATOR"===e.type&&og.includes(e.value))return{type:"UNARY_OPERATION",value:e.value,operand:dg(t,ag[e.value])};throw new Error(r("Unexpected token: %s",e.value))}}(i,e);for(;e[0]&&cg(e[0])>t;)n=hg(n,e.shift(),e);return n}function ug(e){return gg(Wu(e))}function gg(e){"OPERATOR"===(e=e.filter((e=>"SPACE"!==e.type)))[0].type&&"="===e[0].value&&e.splice(0,1);const t=dg(e,0);if(e.length)throw new Error(ne);return t}function pg(e,t,i){switch(t===e.type&&(e=i(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>pg(e,t,i)))};case"UNARY_OPERATION":return{...e,operand:pg(e.operand,t,i)};case"BIN_OPERATION":return{...e,right:pg(e.right,t,i),left:pg(e.left,t,i)};default:return e}}function mg(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>mg(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?fg(e)+e.value:e.value+vg(e);case"BIN_OPERATION":return fg(e)+e.value+vg(e)}}function fg(e){const t=e.value,i="left"in e?e.left:e.operand,n=i.value;return"BIN_OPERATION"===i.type&&ag[n]<ag[t]?`(${mg(i)})`:mg(i)}function vg(e){const t=e.value,i="right"in e?e.right:e.operand,n=ag[i.value],o=ag[t];let r=!1;return"BIN_OPERATION"!==i.type?r=!1:n<o?r=!0:n!==o||sg.includes(t)||(r=!0),r?`(${mg(i)})`:mg(i)}var bg;!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"}(bg||(bg={}));const Sg=(e,t=(()=>!0))=>[{goTo:e,guard:t}],Cg=(e,t=(()=>!0))=>({goTo:e,guard:t}),Eg={[bg.LeftRef]:{REFERENCE:Sg(bg.Separator),NUMBER:Sg(bg.FullRowSeparator),SYMBOL:[Cg(bg.FullColumnSeparator,(e=>Ot(e.value))),Cg(bg.FullRowSeparator,(e=>_t(e.value)))]},[bg.FullColumnSeparator]:{SPACE:Sg(bg.FullColumnSeparator),OPERATOR:Sg(bg.RightColumnRef,(e=>":"===e.value))},[bg.FullRowSeparator]:{SPACE:Sg(bg.FullRowSeparator),OPERATOR:Sg(bg.RightRowRef,(e=>":"===e.value))},[bg.Separator]:{SPACE:Sg(bg.Separator),OPERATOR:Sg(bg.RightRef,(e=>":"===e.value))},[bg.RightRef]:{SPACE:Sg(bg.RightRef),NUMBER:Sg(bg.Found),REFERENCE:Sg(bg.Found,(e=>kt(e.value))),SYMBOL:Sg(bg.Found,(e=>Ft(e.value)||Dt(e.value)))},[bg.RightColumnRef]:{SPACE:Sg(bg.RightColumnRef),SYMBOL:Sg(bg.Found,(e=>Ft(e.value))),REFERENCE:Sg(bg.Found,(e=>kt(e.value)))},[bg.RightRowRef]:{SPACE:Sg(bg.RightRowRef),NUMBER:Sg(bg.Found),REFERENCE:Sg(bg.Found,(e=>kt(e.value))),SYMBOL:Sg(bg.Found,(e=>Dt(e.value)))},[bg.Found]:{}};function wg(e){var t;let i=0,n=Eg[bg.LeftRef];const o=[];for(;void 0!==n;){const r=e[i++];if(!r)return null;const s=null===(t=n[r.type])||void 0===t?void 0:t.find((e=>e.guard(r))),a=s?s.goTo:void 0;switch(a){case void 0:return null;case bg.Found:return o.push(r),e.splice(0,i),{type:"REFERENCE",value:et(o.map((e=>e.value)))};default:n=Eg[a],o.push(r)}}return null}function yg(e){const t=Wu(e),i=[];for(;t.length;)i.push(wg(t)||t.shift());return i}const xg=Vu.content,Rg={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},Ig={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"};function Tg(e){return e.join("\n").split("\n").filter((e=>""!==e.trim()))}const Ag={};function Ng(e){const t=yg(e),{dependencies:i,constantValues:n}=function(e){const t={numbers:[],strings:[]},i=[];for(const n of e)switch(n.type){case"INVALID_REFERENCE":case"REFERENCE":i.push(n.value);break;case"STRING":const e=Ie(n.value);t.strings.includes(e)||t.strings.push(e);break;case"NUMBER":{const e=wi(n.value);t.numbers.includes(e)||t.numbers.push(e);break}}return{dependencies:i,constantValues:t}}(t),o=function(e,t,i){return et(e.map((e=>{switch(e.type){case"STRING":const n=Ie(e.value);return`|S${i.strings.indexOf(n)}|`;case"NUMBER":return`|N${i.numbers.indexOf(wi(e.value))}|`;case"REFERENCE":case"INVALID_REFERENCE":return`|${t.indexOf(e.value)}|`;case"SPACE":return"";default:return e.value}})))}(t,i,n);if(!Ag[o]){const s=gg([...t]);let a=1;if("BIN_OPERATION"===s.type&&":"===s.value)throw new Error(r("Invalid formula"));if("UNKNOWN"===s.type)throw new Error(r("Invalid formula"));const l=u(s),c=Tg([`// ${o}`,l.code,`return ${l.id};`]).join("\n");let h=new Function("deps","ref","range","ctx",c);function d(e){const t=xg[e.value.toUpperCase()],i=e.args,n=i.length;if(n<t.minArgRequired)throw new Error(r("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",e.value.toUpperCase(),t.minArgRequired.toString(),n.toString()));if(n>t.maxArgPossible)throw new Error(r("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",e.value.toUpperCase(),t.maxArgPossible.toString(),n.toString()));const o=t.nbrArgRepeating;if(o>1){const i=t.args.length-o;if((n-i)%o!=0)throw new Error(r("Invalid number of arguments for the %s function. Expected all arguments after position %s to be supplied by groups of %s arguments",e.value.toUpperCase(),i.toString(),o.toString()))}let s=[];for(let o=0;o<n;o++){const n=t.getArgToFocus(o+1)-1;if(0<=n&&n<t.args.length){const a=i[o],l=t.args[n],c=l.type||[],h=c.includes("META"),d=l.lazy,g=c.some((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e)),p=c.every((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e));if(p&&"REFERENCE"!==a.type)throw new Error(r("Function %s expects the parameter %s to be reference to a cell or range, not a %s.",e.value.toUpperCase(),(o+1).toString(),a.type.toLowerCase()));const m=u(a,d,h,g,{functionName:e.value.toUpperCase(),paramIndex:o+1});s.push(m)}}return s}function u(e,t=!1,o=!1,s=!1,l={}){const c=[];let h,g,p;if("REFERENCE"!==e.type&&("BIN_OPERATION"!==e.type||":"!==e.value)&&o)throw new Error(r("Argument must be a reference to a cell or range."));switch(e.debug&&c.push("debugger;"),e.type){case"BOOLEAN":if(!t)return{id:`{ value: ${e.value} }`,code:""};h=a++,p=`{ value: ${e.value} }`;break;case"NUMBER":h=a++,p=`{ value: this.constantValues.numbers[${n.numbers.indexOf(e.value)}] }`;break;case"STRING":h=a++,p=`{ value: this.constantValues.strings[${n.strings.indexOf(e.value)}] }`;break;case"REFERENCE":const r=i.indexOf(e.value);h=a++,p=s?`range(deps[${r}])`:`ref(deps[${r}], ${o?"true":"false"}, "${l.functionName||Rg["="]}", ${l.paramIndex})`;break;case"FUNCALL":h=a++;const m=d(e);c.push(m.map((e=>e.code)).join("\n")),g=e.value.toUpperCase(),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${m.map((e=>e.id))})`;break;case"UNARY_OPERATION":{h=a++,g=Ig[e.value];const t=u(e.operand,!1,!1,!1,{functionName:g});c.push(t.code),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${t.id})`;break}case"BIN_OPERATION":{h=a++,g=Rg[e.value];const t=u(e.left,!1,!1,!1,{functionName:g}),i=u(e.right,!1,!1,!1,{functionName:g});c.push(t.code),c.push(i.code),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${t.id}, ${i.id})`;break}case"UNKNOWN":if(!t)return{id:"undefined",code:""};h=a++,p="undefined"}if(t){return{id:`_${h}`,code:`const _${h} = () => {\n\t${Tg(c).join("\n\t")}\n\treturn ${p};\n}`}}return c.push(`let _${h} = ${p};`),{id:`_${h}`,code:c.join("\n")}}Ag[o]={execute:h}}return{execute:Ag[o].execute,dependencies:i,constantValues:n,tokens:t}}function Mg(e){return function(e){let t=[],i="";return e.map(((e,n)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(i=""),e.type){case"FUNCTION":i=e.value;break;case"LEFT_PAREN":t.push({parent:i,argPosition:0}),i="";break;case"RIGHT_PAREN":t.pop();break;case"COMMA":t.length&&t[t.length-1].argPosition++}if(t.length){const i=t[t.length-1];i.parent&&(e.functionContext=Object.assign({},i))}return e}))}(function(e){let t=1;const i=[];return e.map((e=>("LEFT_PAREN"===e.type?(i.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=i.pop()),e)))}(function(e){let t=0;return e.map((e=>{const i=e.value.toString().length,n=Object.assign({},e,{start:t,end:t+i,length:i});return t=n.end,n}))}(yg(e))))}function Og(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:i}=$t(e.value),[n,o]=t.split(":"),r=i?`${Me(i)}!`:"",s=_g(n),a=o?`:${_g(o)}`:"";return{...e,value:r+s+a}}function _g(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=Fg(e,"colrow");break;case"colrow":e=Fg(e,"row");break;case"row":e=Fg(e,"col");break;case"col":e=Fg(e,"none")}return e}function Fg(e,t){let i;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return i=e.search(/[0-9]/),e.slice(0,i)+"$"+e.slice(i);case"colrow":return i=e.search(/[0-9]/),-1===i||0===i?"$"+e:"$"+(e=e.slice(0,i)+"$"+e.slice(i));case"none":return e}}class Dg{constructor(e,t,i){this.history=Object.assign(Object.create(e),{update:e.addChange.bind(e,this),selectCell:()=>{}}),this.dispatch=t}exportForExcel(e){}allowDispatch(e){return 0}beforeHandle(e){}handle(e){}finalize(){}batchValidations(...e){return t=>e.map((e=>e.call(this,t))).flat()}chainValidations(...e){return t=>{for(const i of e){let e=i.call(this,t);Array.isArray(e)||(e=[e]);const n=e.filter((e=>0!==e));if(n.length)return n}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}Dg.getters=[];class kg extends Dg{constructor(e,t,i,n,o){super(t,i,n),this.getters=e,this.ui=n,this.selection=o}drawGrid(e,t){}}kg.layers=[];const $g=r("The cell you are trying to edit has been deleted.");class Lg extends kg{constructor(){super(...arguments),this.col=0,this.row=0,this.mode="inactive",this.sheetId="",this.currentContent="",this.currentTokens=[],this.selectionStart=0,this.selectionEnd=0,this.selectionInitialStart=0,this.initialContent="",this.previousRef="",this.previousRange=void 0,this.colorIndexByRange={}}allowDispatch(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":return this.validateSelection(this.currentContent.length,e.start,e.end);case"SET_CURRENT_CONTENT":return e.selection?this.validateSelection(e.content.length,e.selection.start,e.selection.end):0;case"START_EDITION":if(e.selection){const t=this.getters.getActiveCell(),i=e.text||(null==t?void 0:t.composerContent)||"";return this.validateSelection(i.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handleEvent(e){if("selecting"===this.mode)if("newAnchor"===e.mode)this.insertSelectedRange(e.anchor.zone);else this.replaceSelectedRanges(e.anchor.zone)}handle(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":this.selectionStart=e.start,this.selectionEnd=e.end;break;case"STOP_COMPOSER_RANGE_SELECTION":this.isSelectingForComposer()&&(this.mode="editing");break;case"START_EDITION":this.startEdition(e.text,e.selection),this.updateRangeColor();break;case"STOP_EDITION":e.cancel?(this.cancelEditionAndActivateSheet(),this.resetContent()):this.stopEdition(),this.colorIndexByRange={};break;case"SET_CURRENT_CONTENT":this.setContent(e.content,e.selection,!0),this.updateRangeColor();break;case"REPLACE_COMPOSER_CURSOR_SELECTION":this.replaceSelection(e.text);break;case"SELECT_FIGURE":this.cancelEditionAndActivateSheet(),this.resetContent();break;case"ADD_COLUMNS_ROWS":this.onAddElements(e);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case"START_CHANGE_HIGHLIGHT":this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=this.getters.getRangeFromRangeData(e.range),i=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:i,sheetName:n}=$t(e.value),o=n||this.getters.getSheetName(this.sheetId),r=this.getters.getActiveSheetId();if(this.getters.getSheetName(r)!==o)return!1;const s=this.getters.getRangeFromSheetXC(r,i);return Ui(this.getters.expandZone(r,s.zone),t.zone)}));this.previousRef=i.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=i.start;break;case"CHANGE_HIGHLIGHT":const n=this.getters.getRangeFromRangeData(e.range),o=this.getRangeReference(n,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(o),this.previousRef=o,this.selectionStart=this.currentContent.length,this.selectionEnd=this.currentContent.length;break;case"ACTIVATE_SHEET":if(this.currentContent.startsWith("=")||(this.cancelEdition(),this.resetContent()),e.sheetIdFrom!==e.sheetIdTo){const{col:t,row:i}=this.getters.getNextVisibleCellPosition(e.sheetIdTo,0,0),n=this.getters.expandZone(e.sheetIdTo,Ki({col:t,row:i}));this.selection.resetAnchor(this,{cell:{col:t,row:i},zone:n})}break;case"DELETE_SHEET":case"UNDO":case"REDO":!!this.getters.tryGetSheet(this.sheetId)||"inactive"===this.mode||(this.sheetId=this.getters.getActiveSheetId(),this.cancelEditionAndActivateSheet(),this.resetContent(),this.ui.notifyUI({type:"ERROR",text:$g}));break;case"CYCLE_EDITION_REFERENCES":this.cycleReferences()}}getEditionMode(){return this.mode}getCurrentContent(){if("inactive"===this.mode){const e=this.getters.getActiveCell();return(null==e?void 0:e.composerContent)||""}return this.currentContent}getEditionSheet(){return this.sheetId}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}isSelectingForComposer(){return"selecting"===this.mode}showSelectionIndicator(){return this.isSelectingForComposer()&&this.canStartComposerRangeSelection()}getCurrentTokens(){return this.currentTokens}getTokenAtCursor(){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((i=>i.start<=e&&i.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const i=e.map(Og).map((e=>e.value)).join(""),n=this.currentContent,o=e[0].start,r=e[e.length-1].end,s=n.slice(0,o)+i+n.slice(r),a=s.length-n.length,l={start:t[0].start,end:t[t.length-1].end+a};1===t.length&&this.selectionStart===this.selectionEnd&&(l.start=l.end),this.dispatch("SET_CURRENT_CONTENT",{content:s,selection:l})}validateSelection(e,t,i){return t>=0&&t<=e&&i>=0&&i<=e?0:46}onColumnsRemoved(e){if(e.elements.includes(this.col)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:$g});const{top:t,left:i}=ki({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=i,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:$g});const{top:t,left:i}=ki({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=i,this.row=t}onAddElements(e){const{top:t,left:i}=Di({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=i,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=Ki({col:this.col,row:this.row});this.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.mode="selecting",this.selectionInitialStart=this.selectionStart}startEdition(e,t){var i;const n=this.getters.getActiveCell();e&&(null===(i=null==n?void 0:n.format)||void 0===i?void 0:i.includes("%"))&&Ci(e)&&(t=t||{start:e.length,end:e.length},e=`${e}%`),this.initialContent=(null==n?void 0:n.composerContent)||"",this.mode="editing";const{col:o,row:r}=this.getters.getPosition();this.col=o,this.row=r,this.sheetId=this.getters.getActiveSheetId(),this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const s=Ki({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:s},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if("inactive"!==this.mode){const e=this.getters.getActiveSheetId();this.cancelEditionAndActivateSheet();const{col:t,row:i}=this.getters.getMainCellPosition(this.sheetId,this.col,this.row);let n=this.currentContent;if(!(this.initialContent!==n))return;if(n){const o=this.getters.getCell(e,t,i);if(n.startsWith("=")){const e=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length,t=this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length,i=e-t;i>0&&(n+=et(new Array(i).fill(")")))}else(null==o?void 0:o.isLink())&&(n=We(n,o.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:t,row:i,content:n})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:t,row:i});this.setContent("")}}cancelEditionAndActivateSheet(){if("inactive"===this.mode)return;this.cancelEdition();this.getters.getActiveSheetId()!==this.sheetId&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,i){e=e.replace(/[\r\n]/g,"");const n=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(n||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?Mg(e):[],this.currentTokens.length>100&&i&&this.ui.notifyUI({type:"ERROR",text:r("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells")})),this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(i,t),this.selectionInitialStart=t):(this.insertText(","+i,t),this.selectionInitialStart=t+1)}replaceSelectedRanges(e){const t=this.getZoneReference(e);this.replaceText(t,this.selectionInitialStart,this.selectionEnd)}getZoneReference(e,t=[{colFixed:!1,rowFixed:!1}]){const i=this.getters.getActiveSheetId();let n=this.getters.zoneToXC(i,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){n=`${Me(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${n}`}return n}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){1===t.length&&Ji(e.zone)>1?t.push({...t[0]}):2===t.length&&1===Ji(e.zone)&&t.pop();const i=e.clone({parts:this.previousRange.parts});return this.getters.getSelectionRangeString(i,this.getters.getEditionSheet())}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,i)}replaceText(e,t,i){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(i,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const i=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),n=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:i,selection:{start:n,end:n}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getEditionSheet(),t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),i={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(i[e]=this.colorIndexByRange[e]);const n=new Set(Object.values(i));let o=0;const r=()=>{for(;n.has(o);)o++;return n.add(o),o};for(const e of t){const t=e in i?i[e]:r();i[e]=t}this.colorIndexByRange=i}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getEditionSheet(),t=e=>{const t=this.colorIndexByRange[e];return ut[t%ut.length]};return this.getReferencedRanges().map((i=>{const n=this.getters.getRangeString(i,e);return{zone:i.zone,color:t(n),sheetId:i.sheetId}}))}getReferencedRanges(){const e=this.getters.getEditionSheet();return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value))).filter((e=>!e.invalidSheetName&&!e.invalidXc))}canStartComposerRangeSelection(){if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let i=t,n=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(n.type)||Bu.includes(n.value);){if("SPACE"!==n.type||i<1)return!1;i--,n=this.currentTokens[i]}for(i=t+1,n=this.currentTokens[i];n&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(n.type);){if("SPACE"!==n.type)return!1;i++,n=this.currentTokens[i]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((i=>i.start<=e&&i.end>=e||i.start>=e&&i.start<t))}}Lg.getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights"];const Pg=Vu.content,Ug=new tn;Ug.add("functions",(()=>Object.keys(Pg).map((e=>({text:e,description:Pg[e].description}))))),Cn`
983
+ `;class Ns extends t.Component{get tagStyle(){const{col:e,row:t,color:i}=this.props,{height:n}=this.env.model.getters.getSheetViewDimensionWithHeaders(),{x:o,y:r}=this.env.model.getters.getVisibleRect({left:e,top:t,right:e,bottom:t});return`bottom: ${n-r+15}px;left: ${o-1}px;border: 1px solid ${i};background-color: ${i};${this.props.active?"opacity:1 !important":""}`}}Ns.template="o-spreadsheet-ClientTag";const Ms=/(.*?)\((.*?)\)(.*)/,Os=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function _s(e){let t=e.split("\n");const i=[];for(let e of t)e=e.trim(),e&&i.push(Fs(e));return i}function Fs(e){let t,i=e.match(Ms),n=i[1].trim(),o=[],r=!1,s=!1,a=!1;for(let e of i[2].split(",")){const i=e.trim().toUpperCase();let n=Os.find((e=>i===e));n?o.push(n):"RANGE<ANY>"===i?o.push("RANGE"):"OPTIONAL"===i?r=!0:"REPEATING"===i?s=!0:"LAZY"===i?a=!0:i.startsWith("DEFAULT=")&&(t=e.trim().slice(8))}const l={name:n,description:i[3].trim(),type:o};return r&&(l.optional=!0),s&&(l.repeating=!0),a&&(l.lazy=!0),void 0!==t&&(l.default=!0,l.defaultValue=t),l}function Ds(e){let t=0,i=0,n=0;for(let o of e.args)t++,o.optional||o.repeating||o.default||i++,o.repeating&&n++;const o=e;return o.minArgRequired=i,o.maxArgPossible=n?1/0:t,o.nbrArgRepeating=n,o.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const i=e-t;return e=>{if(e<=i)return e;return i+((e-i)%t||t)}}(t,n),o}const ks=["number","string","boolean","undefined"];function $s(e,t){if(!e())throw new Error(t)}const Ls=e=>r("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Ps(e){switch(typeof e){case"number":return e;case"boolean":return e?1:0;case"string":if(Ci(e)||""===e)return wi(e);const t=ve(e);if(t)return t.value;throw new Error(Ls(e));default:return 0}}function Us(e){if(""===e)throw new Error(Ls(e));return Ps(e)}function Vs(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}const zs=function(e){const t=new Map,i=e.name?e.name+" (memoized)":"memoized";return{[i]:(...i)=>(t.has(i[0])||t.set(i[0],e(...i)),t.get(i[0]))}[i]}((function(e){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")}));function Bs(e){return"string"==typeof e?zs(e):e}const Hs=e=>r("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function Ws(e){switch(typeof e){case"boolean":return e;case"string":if(e){let t=e.toUpperCase();if("TRUE"===t)return!0;if("FALSE"===t)return!1;throw new Error(Hs(e))}return!1;case"number":return!!e;default:return!1}}function Gs(e){return Se(Ps(e))}function qs(e,t,i){for(let n of e)if(Array.isArray(n)){const e=n.length,i=n[0].length;for(let o=0;o<i;o++)for(let i=0;i<e;i++)t(n[i][o])}else i(n)}function Zs(e,t){qs(e,t,t)}function js(e,t){qs(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(Us(e))}))}function Ys(e,t,i,n){let o=n;for(let n of e)if(Array.isArray(n)){const e=n.length,i=n[0].length;for(let r=0;r<i;r++)for(let i=0;i<e;i++)o=t(o,n[i][r])}else o=i(o,n);return o}function Xs(e,t,i){return Ys(e,t,t,i)}function Ks(e,t,i){return Ys(e,((e,i)=>"number"==typeof i?t(e,i):e),((e,i)=>t(e,Us(i))),i)}function Qs(e,t,i){return Ys(e,((e,i)=>null!=i?t(e,"number"==typeof i?i:"boolean"==typeof i?Ps(i):0):e),((e,i)=>t(e,Ps(i))),i)}function Js(e,t){return function(e,t,i){for(let n of e)if(Array.isArray(n)){const e=n.length,i=n[0].length;for(let o=0;o<i;o++)for(let i=0;i<e;i++)if(!t(n[i][o]))return}else if(!i(n))return}(e,(e=>"boolean"==typeof e?t(e):"number"!=typeof e||t(!!e)),(e=>null==e||t(function(e){if(""===e)throw new Error(Hs(e));return Ws(e)}(e))))}function ea(e,t){let i,n,o=e.substring(0,2);"<="===o||">="===o||"<>"===o?(i=o,n=e.substring(2)):(o=e.substring(0,1),"<"===o||">"===o||"="===o?(i=o,n=e.substring(1)):(i="=",n=e)),Ci(n)?n=Ps(n):"TRUE"!==n&&"FALSE"!==n||(n=Ws(n));const r={operator:i,operand:n};return"string"==typeof n&&(t&&(n+="*"),r.regexp=function(e){let t="",i="";for(let n of e)"?"===n&&"~"!==i?t+=".":"*"===n&&"~"!==i?t+=".*":("*"!==n&&"?"!==n||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(n)&&(t+="\\"),t+=n),i=n;return new RegExp("^"+t+"$","i")}(n)),r}function ta(e,t){const{operator:i,operand:n}=t;if(void 0===e||void 0===n)return!1;if("number"==typeof n&&"="===i)return Vs(e)===Vs(n);if("<>"===i||"="===i){let o;return o=typeof e==typeof n&&("string"==typeof e&&t.regexp?t.regexp.test(e):e===n),"="===i?o:!o}if(typeof e==typeof n)switch(i){case"<":return e<n;case">":return e>n;case"<=":return e<=n;case">=":return e>=n}return!1}function ia(e,t,i=!1){const n=e.length;if(n%2==1)throw new Error(r("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const o=e[0].length,s=e[0][0].length;let a=[];for(let t=0;t<n-1;t+=2){const n=e[t];if(!Array.isArray(n)||n.length!==o||n[0].length!==s)throw new Error(r("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const l=Vs(e[t+1]);a.push(ea(l,i))}for(let i=0;i<o;i++)for(let o=0;o<s;o++){let r=!0;for(let t=0;t<n-1;t+=2){if(r=ta(e[t][i][o],a[t/2]),!r)break}r&&t(i,o)}}function na(e,t){return Bs(e[0][t])}function oa(e,t){return Bs(e[t][0])}function ra(e,t,i,n,o,r){if(null==t)return-1;const s=typeof t;let a,l,c,h,d,u,g=0,p=o-1;for(;p-g>=0;){for(c=Math.floor((g+p)/2),h=c,d=r(e,h),u=typeof d;g<h&&s!==u;)h--,d=r(e,h),u=typeof d;u===s&&void 0!==d?("strict"===i&&d===t?(a=d,l=h):"nextSmaller"===i&&d<=t?(void 0===a||a<d||a===d&&"asc"===n&&l<h||a===d&&"desc"===n&&l>h)&&(a=d,l=h):"nextGreater"===i&&d>=t&&(void 0===a||a>d||a===d&&"asc"===n&&l<h||a===d&&"desc"===n&&l>h)&&(a=d,l=h),"asc"===n&&d>t||"desc"===n&&d<=t?p=h-1:g=c+1):g=c+1}return void 0!==l?l:-1}function sa(e,t,i,n,o,r=!1){if(null==t)return-1;const s=r?(e,t)=>o(e,n-t-1):o;let a,l=-1;for(let o=0;o<n;o++){const c=s(e,o);if(c===t)return r?n-o-1:o;"nextSmaller"===i?(!a&&aa(t,c)>=0||aa(t,c)>=0&&aa(c,a)>0)&&(a=c,l=o):"nextGreater"===i&&(!a&&aa(t,c)<=0||aa(t,c)<=0&&aa(c,a)<0)&&(a=c,l=o)}return r?n-l-1:l}function aa(e,t){let i=ks.indexOf(typeof e)-ks.indexOf(typeof t);return 0===i&&("string"==typeof e&&"string"==typeof t?i=e.localeCompare(t):"number"==typeof e&&"number"==typeof t?i=e-t:"boolean"==typeof e&&"boolean"==typeof t&&(i=Number(e)-Number(t))),i}const la={description:r("Apply a large number format"),args:_s(`\n value (number) ${r("The number.")}\n unit (string, optional) ${r("The formatting unit. Use 'k', 'm', or 'b' to force the unit")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>{const i=Math.abs(Ps(e.value)),n=e.format;if(void 0!==t){switch(null==t?void 0:t.value){case"k":return li(n,1e3,"k");case"m":return li(n,1e6,"m");case"b":return li(n,1e9,"b");default:throw new Error(r("The formatting unit should be 'k', 'm' or 'b'."))}}return i<1e5?li(n,0,""):i<1e8?li(n,1e3,"k"):i<1e11?li(n,1e6,"m"):li(n,1e9,"b")},compute:function(e){return Ps(e)}};var ca=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:la});const ha={description:r("Absolute value of a number."),args:_s(`\n value (number) ${r("The number of which to return the absolute value.")}\n `),returns:["NUMBER"],compute:function(e){return Math.abs(Ps(e))},isExported:!0},da={description:r("Inverse cosine of a value, in radians."),args:_s(`\n value (number) ${r("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},ua={description:r("Inverse hyperbolic cosine of a number."),args:_s(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>t>=1),r("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},ga={description:r("Inverse cotangent of a value."),args:_s(`\n value (number) ${r("The value for which to calculate the inverse cotangent.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},pa={description:r("Inverse hyperbolic cotangent of a value."),args:_s(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>Math.abs(t)>1),r("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},ma={description:r("Inverse sine of a value, in radians."),args:_s(`\n value (number) ${r("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},fa={description:r("Inverse hyperbolic sine of a number."),args:_s(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic sine.")}\n `),returns:["NUMBER"],compute:function(e){return Math.asinh(Ps(e))},isExported:!0},va={description:r("Inverse tangent of a value, in radians."),args:_s(`\n value (number) ${r("The value for which to calculate the inverse tangent.")}\n `),returns:["NUMBER"],compute:function(e){return Math.atan(Ps(e))},isExported:!0},ba={description:r("Angle from the X axis to a point (x,y), in radians."),args:_s(`\n x (number) ${r("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n y (number) ${r("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Ps(e),n=Ps(t);return $s((()=>0!==i||0!==n),r("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(n,i)},isExported:!0},Sa={description:r("Inverse hyperbolic tangent of a number."),args:_s(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>Math.abs(t)<1),r("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},Ca={description:r("Rounds number up to nearest multiple of factor."),args:_s(`\n value (number) ${r("The value to round up to the nearest integer multiple of factor.")}\n factor (number, default=1) ${r("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Ps(e),n=Ps(t);return $s((()=>n>=0||i<=0),r("The factor (%s) must be positive when the value (%s) is positive.",n.toString(),i.toString())),n?Math.ceil(i/n)*n:0},isExported:!0},Ea={description:r("Rounds number up to nearest multiple of factor."),args:_s(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n mode (number, default=0) ${r("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let n=Ps(t);if(0===n)return 0;const o=Ps(e);if(n=Math.abs(n),o>=0)return Math.ceil(o/n)*n;return 0===Ps(i)?-Math.floor(Math.abs(o)/n)*n:-Math.ceil(Math.abs(o)/n)*n},isExported:!0},wa={description:r("Rounds number up to nearest multiple of factor."),args:_s(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){return Ea.compute(e,t,0)},isExported:!0},ya={description:r("Cosine of an angle provided in radians."),args:_s(`\n angle (number) ${r("The angle to find the cosine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cos(Ps(e))},isExported:!0},xa={description:r("Hyperbolic cosine of any real number."),args:_s(`\n value (number) ${r("Any real value to calculate the hyperbolic cosine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cosh(Ps(e))},isExported:!0},Ra={description:r("Cotangent of an angle provided in radians."),args:_s(`\n angle (number) ${r("The angle to find the cotangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},Ia={description:r("Hyperbolic cotangent of any real number."),args:_s(`\n value (number) ${r("Any real value to calculate the hyperbolic cotangent of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},Ta={description:r("Number of empty values."),args:_s(`\n value1 (any, range) ${r("The first value or range in which to count the number of blanks.")}\n value2 (any, range, repeating) ${r("Additional values or ranges in which to count the number of blanks.")}\n `),returns:["NUMBER"],compute:function(...e){return Xs(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},Aa={description:r("A conditional count across a range."),args:_s(`\n range (range) ${r("The range that is tested against criterion.")}\n criterion (string) ${r("The pattern or test to apply to range.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return ia(e,((e,i)=>{t+=1})),t},isExported:!0},Na={description:r("Count values depending on multiple criteria."),args:_s(`\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("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.")}\n criterion2 (string, repeating) ${r("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return ia(e,((e,i)=>{t+=1})),t},isExported:!0};function Ma(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const Oa={description:r("Counts number of unique values in a range."),args:_s(`\n value1 (any, range) ${r("The first value or range to consider for uniqueness.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider for uniqueness.")}\n `),returns:["NUMBER"],compute:function(...e){return Xs(e,((e,t)=>Ma(t)?e.add(t):e),new Set).size}},_a={description:r("Counts number of unique values in a range, filtered by a set of criteria."),args:_s(`\n range (range) ${r("The range of cells from which the number of unique values will be counted.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("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.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=new Set;return ia(t,((t,n)=>{const o=e[t][n];Ma(o)&&i.add(o)})),i.size}},Fa={description:r("Cosecant of an angle provided in radians."),args:_s(`\n angle (number) ${r("The angle to find the cosecant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},Da={description:r("Hyperbolic cosecant of any real number."),args:_s(`\n value (number) ${r("Any real value to calculate the hyperbolic cosecant of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},ka={description:r("Converts from another base to decimal."),args:_s(`\n value (string) ${r("The number to convert.")},\n base (number) ${r("The base to convert the value from.")},\n `),returns:["NUMBER"],compute:function(e,t){let i=Ps(t);i=Math.floor(i),$s((()=>2<=i&&i<=36),r("The base (%s) must be between 2 and 36 inclusive.",i.toString()));const n=Vs(e);if(""===n)return 0;$s((()=>!!n.match(/^-?[a-z0-9]+$/i)),r("The value (%s) must be a valid base %s representation.",n,i.toString()));const o=parseInt(n,i);return $s((()=>!isNaN(o)),r("The value (%s) must be a valid base %s representation.",n,i.toString())),o},isExported:!0},$a={description:r("Converts an angle value in radians to degrees."),args:_s(`\n angle (number) ${r("The angle to convert from radians to degrees.")}\n `),returns:["NUMBER"],compute:function(e){return 180*Ps(e)/Math.PI},isExported:!0},La={description:r("Euler's number, e (~2.718) raised to a power."),args:_s(`\n value (number) ${r("The exponent to raise e.")}\n `),returns:["NUMBER"],compute:function(e){return Math.exp(Ps(e))},isExported:!0},Pa={description:r("Rounds number down to nearest multiple of factor."),args:_s(`\n value (number) ${r("The value to round down to the nearest integer multiple of factor.")}\n factor (number, default=1) ${r("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Ps(e),n=Ps(t);return $s((()=>n>=0||i<=0),r("The factor (%s) must be positive when the value (%s) is positive.",n.toString(),i.toString())),n?Math.floor(i/n)*n:0},isExported:!0},Ua={description:r("Rounds number down to nearest multiple of factor."),args:_s(`\n number (number) ${r("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n mode (number, default=0) ${r("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let n=Ps(t);if(0===n)return 0;const o=Ps(e);if(n=Math.abs(n),o>=0)return Math.floor(o/n)*n;return 0===Ps(i)?-Math.ceil(Math.abs(o)/n)*n:-Math.floor(Math.abs(o)/n)*n},isExported:!0},Va={description:r("Rounds number down to nearest multiple of factor."),args:_s(`\n number (number) ${r("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return Ua.compute(e,t,0)},isExported:!0},za={description:r("Whether the provided value is even."),args:_s(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=Us(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},Ba={description:r("Rounds number up to nearest multiple of factor."),args:_s(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return Ea.compute(e,t,0)},isExported:!0},Ha={description:r("Whether the provided value is even."),args:_s(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=Us(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},Wa={description:r("The logarithm of a number, base e (euler's number)."),args:_s(`\n value (number) ${r("The value for which to calculate the logarithm, base e.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ps(e);return $s((()=>t>0),r("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},Ga={description:r("Modulo (remainder) operator."),args:_s(`\n dividend (number) ${r("The number to be divided to find the remainder.")}\n divisor (number) ${r("The number to divide by.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Ps(t);$s((()=>0!==i),r("The divisor must be different from 0."));const n=Ps(e)%i;return n>0&&i<0||n<0&&i>0?n+i:n},isExported:!0},qa={description:r("Rounds a number up to the nearest odd integer."),args:_s(`\n value (number) ${r("The value to round to the next greatest odd number.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Ps(e);let i=Math.ceil(Math.abs(t));return i=1&i?i:i+1,t<0?-i:i},isExported:!0},Za={description:r("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},ja={description:r("A number raised to a power."),args:_s(`\n base (number) ${r("The number to raise to the exponent power.")}\n exponent (number) ${r("The exponent to raise base to.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Ps(e),n=Ps(t);return $s((()=>i>=0||Number.isInteger(n)),r("The exponent (%s) must be an integer when the base is negative.",n.toString())),Math.pow(i,n)},isExported:!0},Ya={description:r("Result of multiplying a series of numbers together."),args:_s(`\n factor1 (number, range<number>) ${r("The first number or range to calculate for the product.")}\n factor2 (number, range<number>, repeating) ${r("More numbers or ranges to calculate for the product.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0,i=1;for(let n of e)if(Array.isArray(n))for(let e of n)for(let n of e)"number"==typeof n&&(i*=n,t+=1);else null!=n&&(i*=Us(n),t+=1);return 0===t?0:i},isExported:!0},Xa={description:r("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},Ka={description:r("Random integer between two values, inclusive."),args:_s(`\n low (number) ${r("The low end of the random range.")}\n high (number) ${r("The high end of the random range.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){let i=Ps(e);Number.isInteger(i)||(i=Math.ceil(i));let n=Ps(t);return Number.isInteger(n)||(n=Math.floor(n)),$s((()=>i<=n),r("The high (%s) must be greater than or equal to the low (%s).",n.toString(),i.toString())),i+Math.ceil((n-i+1)*Math.random())-1},isExported:!0},Qa={description:r("Rounds a number according to standard rules."),args:_s(`\n value (number) ${r("The value to round to places number of places.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Ps(e);let n=Ps(t);const o=Math.abs(i);let r;return 0===n?r=Math.round(o):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.round(o*Math.pow(10,n))/Math.pow(10,n)),i>=0?r:-r},isExported:!0},Ja={description:r("Rounds down a number."),args:_s(`\n value (number) ${r("The value to round to places number of places, always rounding down.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Ps(e);let n=Ps(t);const o=Math.abs(i);let r;return 0===n?r=Math.floor(o):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.floor(o*Math.pow(10,n))/Math.pow(10,n)),i>=0?r:-r},isExported:!0},el={description:r("Rounds up a number."),args:_s(`\n value (number) ${r("The value to round to places number of places, always rounding up.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Ps(e);let n=Ps(t);const o=Math.abs(i);let r;return 0===n?r=Math.ceil(o):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.ceil(o*Math.pow(10,n))/Math.pow(10,n)),i>=0?r:-r},isExported:!0},tl={description:r("Secant of an angle provided in radians."),args:_s(`\n angle (number) ${r("The angle to find the secant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cos(Ps(e))},isExported:!0},il={description:r("Hyperbolic secant of any real number."),args:_s(`\n value (number) ${r("Any real value to calculate the hyperbolic secant of.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Ps(e))},isExported:!0},nl={description:r("Sine of an angle provided in radians."),args:_s(`\n angle (number) ${r("The angle to find the sine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sin(Ps(e))},isExported:!0},ol={description:r("Hyperbolic sine of any real number."),args:_s(`\n value (number) ${r("Any real value to calculate the hyperbolic sine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sinh(Ps(e))},isExported:!0},rl={description:r("Positive square root of a positive number."),args:_s(`\n value (number) ${r("The number for which to calculate the positive square root.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Ps(e);return $s((()=>t>=0),r("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},sl={description:r("Sum of a series of numbers and/or cells."),args:_s(`\n value1 (number, range<number>) ${r("The first number or range to add together.")}\n value2 (number, range<number>, repeating) ${r("Additional numbers or ranges to add to value1.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){return Ks(e,((e,t)=>e+t),0)},isExported:!0},al={description:r("A conditional sum across a range."),args:_s(`\n criteria_range (range) ${r("The range which is tested against criterion.")}\n criterion (string) ${r("The pattern or test to apply to range.")}\n sum_range (range, default=criteria_range) ${r("The range to be summed, if different from range.")}\n `),returns:["NUMBER"],compute:function(e,t,i){void 0===i&&(i=e);let n=0;return ia([e,t],((e,t)=>{const o=i[e][t];"number"==typeof o&&(n+=o)})),n},isExported:!0},ll={description:r("Sums a range depending on multiple criteria."),args:_s(`\n sum_range (range) ${r("The range to sum.")}\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges to check.")}\n criterion2 (string, repeating) ${r("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=0;return ia(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i+=o)})),i},isExported:!0},cl={description:r("Tangent of an angle provided in radians."),args:_s(`\n angle (number) ${r("The angle to find the tangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tan(Ps(e))},isExported:!0},hl={description:r("Hyperbolic tangent of any real number."),args:_s(`\n value (number) ${r("Any real value to calculate the hyperbolic tangent of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tanh(Ps(e))},isExported:!0},dl={description:r("Truncates a number."),args:_s(`\n value (number) ${r("The value to be truncated.")}\n places (number, default=0) ${r("The number of significant digits to the right of the decimal point to retain.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Ps(e);let n=Ps(t);return 0===n?Math.trunc(i):(Number.isInteger(n)||(n=Math.trunc(n)),Math.trunc(i*Math.pow(10,n))/Math.pow(10,n))},isExported:!0};var ul=Object.freeze({__proto__:null,ABS:ha,ACOS:da,ACOSH:ua,ACOT:ga,ACOTH:pa,ASIN:ma,ASINH:fa,ATAN:va,ATAN2:ba,ATANH:Sa,CEILING:Ca,CEILING_MATH:Ea,CEILING_PRECISE:wa,COS:ya,COSH:xa,COT:Ra,COTH:Ia,COUNTBLANK:Ta,COUNTIF:Aa,COUNTIFS:Na,COUNTUNIQUE:Oa,COUNTUNIQUEIFS:_a,CSC:Fa,CSCH:Da,DECIMAL:ka,DEGREES:$a,EXP:La,FLOOR:Pa,FLOOR_MATH:Ua,FLOOR_PRECISE:Va,ISEVEN:za,ISO_CEILING:Ba,ISODD:Ha,LN:Wa,MOD:Ga,ODD:qa,PI:Za,POWER:ja,PRODUCT:Ya,RAND:Xa,RANDBETWEEN:Ka,ROUND:Qa,ROUNDDOWN:Ja,ROUNDUP:el,SEC:tl,SECH:il,SIN:nl,SINH:ol,SQRT:rl,SUM:sl,SUMIF:al,SUMIFS:ll,TAN:cl,TANH:hl,TRUNC:dl});function gl(e,t,i){let n=[],o=[],s=0,a=0;Zs([e],(e=>{n.push(e),s+=1})),Zs([t],(e=>{o.push(e),a+=1})),$s((()=>s===a),r("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",s.toString(),a.toString()));let l=0,c=0,h=0;for(let e=0;e<s;e++){const t=n[e],i=o[e];"number"==typeof t&&"number"==typeof i&&(l+=1,c+=t,h+=i)}$s((()=>0!==l&&(!i||1!==l)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const d=c/l,u=h/l;let g=0;for(let e=0;e<s;e++){const t=n[e],i=o[e];"number"==typeof t&&"number"==typeof i&&(g+=(t-d)*(i-u))}return g/(l-(i?1:0))}function pl(e,t,i){let n=0,o=0;const s=i?Qs:Ks;o=s(e,((e,t)=>(n+=1,e+t)),0),$s((()=>0!==n&&(!t||1!==n)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const a=o/n;return s(e,((e,t)=>e+Math.pow(t-a,2)),0)/(n-(t?1:0))}function ml(e,t,i){const n=Ps(t);$s((()=>i?0<=n&&n<=1:0<n&&n<1),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let o,s=[],a=0;return Zs(e,(e=>{"number"==typeof e&&(o=ra(s,e,"nextSmaller","asc",s.length,((e,t)=>e[t])),s.splice(o+1,0,e),a++)})),$s((()=>0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),i||$s((()=>1/(a+1)<=n&&n<=a/(a+1)),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),yi(s,n,i)}const fl={description:r("Average magnitude of deviations from mean."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;const i=Ks(e,((e,i)=>(t+=1,e+i)),0);$s((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const n=i/t;return Ks(e,((e,t)=>e+Math.abs(n-t)),0)/t},isExported:!0},vl={description:r("Numerical average value in a dataset, ignoring text."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=Ks(e,((e,i)=>(t+=1,e+i)),0);return $s((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},bl=r("[[FUNCTION_NAME]] has mismatched range sizes."),Sl=r("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),Cl={description:r("Weighted average."),args:_s(`\n values (number, range<number>) ${r("Values to average.")}\n weights (number, range<number>) ${r("Weights for each corresponding value.")}\n additional_values (number, range<number>, repeating) ${r("Additional values to average.")}\n additional_weights (number, range<number>, repeating) ${r("Additional weights.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t,i,n=0,o=0;$s((()=>e.length%2==0),r("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let s=0;s<e.length-1;s+=2)if(t=e[s],i=e[s+1],Array.isArray(t)){$s((()=>Array.isArray(i)),bl);let e=t.length,s=t[0].length;$s((()=>e===i.length&&s===i[0].length),bl);for(let a=0;a<e;a++)for(let e=0;e<s;e++){let s=t[a][e],l=i[a][e],c="number"==typeof s,h="number"==typeof l;$s((()=>c===h),r("[[FUNCTION_NAME]] expects number values.")),h&&($s((()=>l>=0),Sl),n+=s*l,o+=l)}}else i=Ps(i),t=Ps(t),$s((()=>i>=0),Sl),n+=t*i,o+=i;return $s((()=>0!==o),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/o}},El={description:r("Numerical average value in a dataset."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=Qs(e,((e,i)=>(t+=1,e+i)),0);return $s((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},wl={description:r("Average of values depending on criteria."),args:_s(`\n criteria_range (range) ${r("The range to check against criterion.")}\n criterion (string) ${r("The pattern or test to apply to criteria_range.")}\n average_range (range, default=criteria_range) ${r("The range to average. If not included, criteria_range is used for the average instead.")}\n `),returns:["NUMBER"],compute:function(e,t,i){null==i&&(i=e);let n=0,o=0;return ia([e,t],((t,r)=>{const s=(i||e)[t][r];"number"==typeof s&&(n+=1,o+=s)})),$s((()=>0!==n),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/n},isExported:!0},yl={description:r("Average of values depending on multiple criteria."),args:_s(`\n average_range (range) ${r("The range to average.")}\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional criteria_range and criterion to check.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=0,n=0;return ia(t,((t,o)=>{const r=e[t][o];"number"==typeof r&&(i+=1,n+=r)})),$s((()=>0!==i),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/i},isExported:!0},xl={description:r("The number of numeric values in dataset."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range to consider when counting.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;for(let i of e)if(Array.isArray(i))for(let e of i)for(let i of e)"number"==typeof i&&(t+=1);else("string"!=typeof i||Ci(i)||ve(i))&&(t+=1);return t},isExported:!0},Rl={description:r("The number of values in a dataset."),args:_s(`\n value1 (any, range) ${r("The first value or range to consider when counting.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){return Xs(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Il={description:r("The covariance of a dataset."),args:_s(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return gl(e,t,!1)},isExported:!0},Tl={description:r("The covariance of a dataset."),args:_s(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return gl(e,t,!1)},isExported:!0},Al={description:r("The sample covariance of a dataset."),args:_s(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return gl(e,t,!0)},isExported:!0},Nl={description:r("Nth largest element from a data set."),args:_s(`\n data (any, range) ${r("Array or range containing the dataset to consider.")}\n n (number) ${r("The rank from largest to smallest of the element to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Ps(t));let n,o=[],s=0;Zs([e],(e=>{"number"==typeof e&&(n=ra(o,e,"nextSmaller","asc",o.length,((e,t)=>e[t])),o.splice(n+1,0,e),s++,s>i&&(o.shift(),s--))}));const a=o.shift();return $s((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),$s((()=>s>=i),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},Ml={description:r("Maximum value in a numeric dataset."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the maximum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Ks(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},Ol={description:r("Maximum numeric value in a dataset."),args:_s(`\n value1 (any, range) ${r("The first value or range to consider when calculating the maximum value.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Qs(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},_l={description:r("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:_s(`\n range (range) ${r("The range of cells from which the maximum will be determined.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("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.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=-1/0;return ia(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i=i<o?o:i)})),i===-1/0?0:i},isExported:!0},Fl={description:r("Median value in a numeric dataset."),args:_s(`\n value1 (any, range) ${r("The first value or range to consider when calculating the median value.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when calculating the median value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=[];return js(e,(e=>{t.push(e)})),ml(t,.5,!0)},isExported:!0},Dl={description:r("Minimum value in a numeric dataset."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Ks(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},kl={description:r("Minimum numeric value in a dataset."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Qs(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},$l={description:r("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:_s(`\n range (range) ${r("The range of cells from which the minimum will be determined.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("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.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let i=1/0;return ia(t,((t,n)=>{const o=e[t][n];"number"==typeof o&&(i=i>o?o:i)})),i===1/0?0:i},isExported:!0},Ll={description:r("Value at a given percentile of a dataset."),args:_s(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Ul.compute(e,t)},isExported:!0},Pl={description:r("Value at a given percentile of a dataset exclusive of 0 and 1."),args:_s(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return ml([e],t,!1)},isExported:!0},Ul={description:r("Value at a given percentile of a dataset."),args:_s(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return ml([e],t,!0)},isExported:!0},Vl={description:r("Value nearest to a specific quartile of a dataset."),args:_s(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Bl.compute(e,t)},isExported:!0},zl={description:r("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:_s(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value, exclusive of 0 and 4, to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return ml([e],.25*Math.trunc(Ps(t)),!1)},isExported:!0},Bl={description:r("Value nearest to a specific quartile of a dataset."),args:_s(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return ml([e],.25*Math.trunc(Ps(t)),!0)},isExported:!0},Hl={description:r("Nth smallest element in a data set."),args:_s(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n n (number) ${r("The rank from smallest to largest of the element to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Ps(t));let n,o=[],s=0;Zs([e],(e=>{"number"==typeof e&&(n=ra(o,e,"nextSmaller","asc",o.length,((e,t)=>e[t])),o.splice(n+1,0,e),s++,s>i&&(o.pop(),s--))}));const a=o.pop();return $s((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),$s((()=>s>=i),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},Wl={description:r("Standard deviation."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Xl.compute(...e))},isExported:!0},Gl={description:r("Standard deviation of entire population."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Kl.compute(...e))},isExported:!0},ql={description:r("Standard deviation."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Ql.compute(...e))},isExported:!0},Zl={description:r("Standard deviation of sample (text as 0)."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Jl.compute(...e))},isExported:!0},jl={description:r("Standard deviation of entire population."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(ec.compute(...e))},isExported:!0},Yl={description:r("Standard deviation of entire population (text as 0)."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(tc.compute(...e))},isExported:!0},Xl={description:r("Variance."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return pl(e,!0,!1)},isExported:!0},Kl={description:r("Variance of entire population."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return pl(e,!1,!1)},isExported:!0},Ql={description:r("Variance."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return pl(e,!0,!1)},isExported:!0},Jl={description:r("Variance of sample (text as 0)."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return pl(e,!0,!0)},isExported:!0},ec={description:r("Variance of entire population."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return pl(e,!1,!1)},isExported:!0},tc={description:r("Variance of entire population (text as 0)."),args:_s(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return pl(e,!1,!0)},isExported:!0};var ic=Object.freeze({__proto__:null,AVEDEV:fl,AVERAGE:vl,AVERAGE_WEIGHTED:Cl,AVERAGEA:El,AVERAGEIF:wl,AVERAGEIFS:yl,COUNT:xl,COUNTA:Rl,COVAR:Il,COVARIANCE_P:Tl,COVARIANCE_S:Al,LARGE:Nl,MAX:Ml,MAXA:Ol,MAXIFS:_l,MEDIAN:Fl,MIN:Dl,MINA:kl,MINIFS:$l,PERCENTILE:Ll,PERCENTILE_EXC:Pl,PERCENTILE_INC:Ul,QUARTILE:Vl,QUARTILE_EXC:zl,QUARTILE_INC:Bl,SMALL:Hl,STDEV:Wl,STDEV_P:Gl,STDEV_S:ql,STDEVA:Zl,STDEVP:jl,STDEVPA:Yl,VAR:Xl,VAR_P:Kl,VAR_S:Ql,VARA:Jl,VARP:ec,VARPA:tc});function nc(e,t,i){var n;const o=new Map,s=e.length;for(let t=s-1;t>=0;t--)o.set(Vs(e[t][0]).toUpperCase(),t);if("number"!=typeof t&&"string"!=typeof t)throw new Error(r("The field must be a number or a string"));let a;if("number"==typeof t){if(a=Math.trunc(t)-1,a<0||s-1<a)throw new Error(r("The field (%s) must be one of %s or must be a number between 1 and %s inclusive.",t.toString(),s.toString()))}else{const e=Vs(t).toUpperCase();if(a=null!==(n=o.get(e))&&void 0!==n?n:-1,-1===a)throw new Error(r("The field (%s) must be one of %s.",Vs(t),[...o.keys()].toString()))}const l=i[0].length;if(l<2)throw new Error(r("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<i.length;s++){const a=Vs(i[s][0]).toUpperCase(),l=o.get(a),c=i[s][t];if(void 0!==c){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}ia(n,((e,t)=>{c.add(t)}),!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const oc=_s(`\n database (range) ${r("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.")}\n field (any) ${r("Indicates which column in database contains the values to be extracted and operated on.")}\n criteria (range) ${r("An array or range containing zero or more criteria to filter the database values by before operating.")}\n`),rc={description:r("Average of a set of values from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return vl.compute([n])},isExported:!0},sc={description:r("Counts values from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return xl.compute([n])},isExported:!0},ac={description:r("Counts values and text from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return Rl.compute([n])},isExported:!0},lc={description:r("Single value from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return $s((()=>1===n.length),r("More than one match found in DGET evaluation.")),n[0]},isExported:!0},cc={description:r("Maximum of values from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return Ml.compute([n])},isExported:!0},hc={description:r("Minimum of values from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return Dl.compute([n])},isExported:!0},dc={description:r("Product of values from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return Ya.compute([n])},isExported:!0},uc={description:r("Standard deviation of population sample from table."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return Wl.compute([n])},isExported:!0},gc={description:r("Standard deviation of entire population from table."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return jl.compute([n])},isExported:!0},pc={description:r("Sum of values from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return sl.compute([n])},isExported:!0},mc={description:r("Variance of population sample from table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return Xl.compute([n])},isExported:!0},fc={description:r("Variance of a population from a table-like range."),args:oc,returns:["NUMBER"],compute:function(e,t,i){const n=nc(e,t,i);return ec.compute([n])},isExported:!0};var vc=Object.freeze({__proto__:null,DAVERAGE:rc,DCOUNT:sc,DCOUNTA:ac,DGET:lc,DMAX:cc,DMIN:hc,DPRODUCT:dc,DSTDEV:uc,DSTDEVP:gc,DSUM:pc,DVAR:mc,DVARP:fc});const bc={description:r("Converts year/month/day into a date."),args:_s(`\n year (number) ${r("The year component of the date.")}\n month (number) ${r("The month component of the date.")}\n day (number) ${r("The day component of the date.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){let n=Math.trunc(Ps(e));const o=Math.trunc(Ps(t)),s=Math.trunc(Ps(i));$s((()=>0<=n&&n<=9999),r("The year (%s) must be between 0 and 9999 inclusive.",n.toString())),n<1900&&(n+=1900);const a=Ce(new ae(n,o-1,s));return $s((()=>a>=0),r("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},Sc={description:r("Converts a date string to a date value."),args:_s(`\n date_string (string) ${r("The string representing the date.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e),i=ve(t);return $s((()=>null!==i),r("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(i.value)},isExported:!0},Cc={description:r("Day of the month that a specific date falls on."),args:_s(`\n date (string) ${r("The date from which to extract the day.")}\n `),returns:["NUMBER"],compute:function(e){return Gs(e).getDate()},isExported:!0},Ec={description:r("Number of days between two dates."),args:_s(`\n end_date (date) ${r("The end of the date range.")}\n start_date (date) ${r("The start of the date range.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Gs(e),n=Gs(t),o=i.getTime()-n.getTime();return Math.round(o/ce)},isExported:!0},wc={description:r("Number of days between two dates on a 360-day year (months of 30 days)."),args:_s(`\n start_date (date) ${r("The start date to consider in the calculation.")}\n end_date (date) ${r("The end date to consider in the calculation.")}\n method (number, default=0) ${r("An indicator of what day count method to use. (0) US NASD method (1) European method")}\n `),returns:["NUMBER"],compute:function(e,t,i=0){const n=Ps(e),o=Ps(t),r=Ws(i)?4:0,s=Bc.compute(e,t,r);return Math.sign(o-n)*Math.round(360*s)},isExported:!0},yc={description:r("Date a number of months before/after another date."),args:_s(`\n start_date (date) ${r("The date from which to calculate the result.")}\n months (number) ${r("The number of months before (negative) or after (positive) 'start_date' to calculate.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){return Ce(ye(Gs(e),Math.trunc(Ps(t)),!1))},isExported:!0},xc={description:r("Last day of a month before or after a date."),args:_s(`\n start_date (date) ${r("The date from which to calculate the result.")}\n months (number) ${r("The number of months before (negative) or after (positive) 'start_date' to consider.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){const i=Gs(e),n=Math.trunc(Ps(t)),o=i.getFullYear(),r=i.getMonth();return Ce(new ae(o,r+n+1,0))},isExported:!0},Rc={description:r("Hour component of a specific time."),args:_s(`\n time (date) ${r("The time from which to calculate the hour component.")}\n `),returns:["NUMBER"],compute:function(e){return Gs(e).getHours()},isExported:!0},Ic={description:r("ISO week number of the year."),args:_s(`\n date (date) ${r("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.")}\n `),returns:["NUMBER"],compute:function(e){const t=Gs(e),i=t.getFullYear();let n=1;for(;4!==new ae(i,0,n).getDay();)n+=1;const o=new ae(i,0,n-3);let r=31;for(;4!==new ae(i,11,r).getDay();)r-=1;const s=new ae(i,11,r+3);let a,l;switch(a=o.getTime()<=t.getTime()?t.getTime()<=s.getTime()?0:1:-1,a){case 0:l=o;break;case 1:l=new ae(i,11,r+3+1);break;case-1:let e=1;for(;4!==new ae(i-1,0,e).getDay();)e+=1;l=new ae(i-1,0,e-3)}const c=(t.getTime()-l.getTime())/ce;return Math.floor(c/7)+1},isExported:!0},Tc={description:r("Minute component of a specific time."),args:_s(`\n time (date) ${r("The time from which to calculate the minute component.")}\n `),returns:["NUMBER"],compute:function(e){return Gs(e).getMinutes()},isExported:!0},Ac={description:r("Month of the year a specific date falls in"),args:_s(`\n date (date) ${r("The date from which to extract the month.")}\n `),returns:["NUMBER"],compute:function(e){return Gs(e).getMonth()+1},isExported:!0},Nc={description:r("Net working days between two provided days."),args:_s(`\n start_date (date) ${r("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${r("The end date of the period from which to calculate the number of net working days.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the date serial numbers to consider holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,i){return Oc.compute(e,t,1,i)},isExported:!0};function Mc(e){if("string"==typeof e){$s((()=>{if(7!==e.length)return!1;for(let t of e)if("0"!==t&&"1"!==t)return!1;return!0}),r('When weekend is a string (%s) it must be composed of "0" or "1".',e));let t=[];for(let i=0;i<7;i++)"1"===e[i]&&t.push((i+1)%7);return t}if("number"==typeof e)return $s((()=>1<=e&&e<=7||11<=e&&e<=17),r("The weekend (%s) must be a string or a number in the range 1-7 or 11-17.",e.toString())),e<=7?[e-2==-1?6:e-2,e-1]:[e-11];throw Error(r("The weekend must be a number or a string."))}const Oc={description:r("Net working days between two dates (specifying weekends)."),args:_s(`\n start_date (date) ${r("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${r("The end date of the period from which to calculate the number of net working days.")}\n weekend (any, default=1) ${r("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider as holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1,n){const o=Gs(e),r=Gs(t),s=Mc(i);let a=new Set;void 0!==n&&Zs([n],(e=>{const t=Gs(e);a.add(t.getTime())}));const l=o.getTime()>r.getTime(),c=ae.fromTimestamp((l?o:r).getTime());let h=ae.fromTimestamp((l?r:o).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)s.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},_c={description:r("Current date and time as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy hh:mm:ss",compute:function(){let e=ae.now();const t=e.getTime()-le.getTime(),i=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/ce)+i},isExported:!0},Fc={description:r("Minute component of a specific time."),args:_s(`\n time (date) ${r("The time from which to calculate the second component.")}\n `),returns:["NUMBER"],compute:function(e){return Gs(e).getSeconds()},isExported:!0},Dc={description:r("Converts hour/minute/second into a time."),args:_s(`\n hour (number) ${r("The hour component of the time.")}\n minute (number) ${r("The minute component of the time.")}\n second (number) ${r("The second component of the time.")}\n `),returns:["DATE"],computeFormat:()=>"hh:mm:ss a",compute:function(e,t,i){let n=Math.trunc(Ps(e)),o=Math.trunc(Ps(t)),s=Math.trunc(Ps(i));return o+=Math.floor(s/60),s=s%60+(s<0?60:0),n+=Math.floor(o/60),o=o%60+(o<0?60:0),n%=24,$s((()=>n>=0),r("The function [[FUNCTION_NAME]] result cannot be negative")),n/24+o/1440+s/86400},isExported:!0},kc={description:r("Converts a time string into its serial number representation."),args:_s(`\n time_string (string) ${r("The string that holds the time representation.")}\n `),returns:["NUMBER"],compute:function(e){const t=Vs(e),i=ve(t);$s((()=>null!==i),r("The time_string (%s) cannot be parsed to date/time.",t));const n=i.value-Math.trunc(i.value);return n<0?1+n:n},isExported:!0},$c={description:r("Current date as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(){const e=ae.now();return Ce(new ae(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},Lc={description:r("Day of the week of the date provided (as number)."),args:_s(`\n date (date) ${r("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.")}\n type (number, default=1) ${r("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const i=Gs(e),n=Math.round(Ps(t)),o=i.getDay();return $s((()=>[1,2,3].includes(n)),r("The type (%s) must be 1, 2 or 3.",n.toString())),1===n?o+1:2===n?0===o?7:o:0===o?6:o-1},isExported:!0},Pc={description:r("Week number of the year."),args:_s(`\n date (date) ${r("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.")}\n type (number, default=1) ${r("A number representing the day that a week starts on. Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const i=Gs(e),n=Math.round(Ps(t));if($s((()=>1===n||2===n||11<=n&&n<=17||21===n),r("The type (%s) is out of range.",n.toString())),21===n)return Ic.compute(e);let o;o=1===n||2===n?n-1:n-10==7?0:n-10;const s=i.getFullYear();let a=1,l=new ae(s,0,a);for(;l.getDay()!==o;)a+=1,l=new ae(s,0,a);const c=(i.getTime()-l.getTime())/ce;return c<0?1:Math.floor(c/7)+(1===a?1:2)},isExported:!0},Uc={description:r("Date after a number of workdays."),args:_s(`\n start_date (date) ${r("The date from which to begin counting.")}\n num_days (number) ${r("The number of working days to advance from start_date. If negative, counts backwards.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider holidays.")}\n `),returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){return Vc.compute(e,t,1,i)},isExported:!0},Vc={description:r("Date after a number of workdays (specifying weekends)."),args:_s(`\n start_date (date) ${r("The date from which to begin counting.")}\n num_days (number) ${r("The number of working days to advance from start_date. If negative, counts backwards.")}\n weekend (any, default=1) ${r("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider holidays.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i=1,n){let o=Gs(e),s=Math.trunc(Ps(t));"string"==typeof i&&$s((()=>"1111111"!==i),r("The weekend (%s) must be different from '1111111'.",i));const a=Mc(i);let l=new Set;void 0!==n&&Zs([n],(e=>{const t=Gs(e);l.add(t.getTime())}));let c=ae.fromTimestamp(o.getTime()),h=c.getTime();const d=Math.sign(s);let u=Math.abs(s);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),a.includes(c.getDay())||l.has(h)||(u-=1);const g=h-le.getTime();return Math.round(g/ce)},isExported:!0},zc={description:r("Year specified by a given date."),args:_s(`\n date (date) ${r("The date from which to extract the year.")}\n `),returns:["NUMBER"],compute:function(e){return Gs(e).getFullYear()},isExported:!0},Bc={description:r("Exact number of years between two dates."),args:_s(`\n start_date (date) ${r("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.")}\n end_date (date) ${r("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.")}\n day_count_convention (number, default=0) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i=0){let n=Math.trunc(Ps(e)),o=Math.trunc(Ps(t));const s=Math.trunc(Ps(i));return $s((()=>n>=0),r("The start_date (%s) must be positive or null.",n.toString())),$s((()=>o>=0),r("The end_date (%s) must be positive or null.",o.toString())),$s((()=>0<=s&&s<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",s.toString())),Re(n,o,s)}},Hc={description:r("First day of the month preceding a date."),args:_s(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Gs(e),i=t.getFullYear(),n=t.getMonth();return Ce(new ae(i,n,1))}},Wc={description:r("Last day of the month following a date."),args:_s(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){return xc.compute(e,0)}},Gc={description:r("Quarter of the year a specific date falls in"),args:_s(`\n date (date) ${r("The date from which to extract the quarter.")}\n `),returns:["NUMBER"],compute:function(e){return Math.ceil((Gs(e).getMonth()+1)/3)}},qc={description:r("First day of the quarter of the year a specific date falls in."),args:_s(`\n date (date) ${r("The date from which to calculate the start of quarter.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Gc.compute(e),i=zc.compute(e);return Ce(new ae(i,3*(t-1),1))}},Zc={description:r("Last day of the quarter of the year a specific date falls in."),args:_s(`\n date (date) ${r("The date from which to calculate the end of quarter.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Gc.compute(e),i=zc.compute(e);return Ce(new ae(i,3*t,0))}},jc={description:r("First day of the year a specific date falls in."),args:_s(`\n date (date) ${r("The date from which to calculate the start of the year.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=zc.compute(e);return Ce(new ae(t,0,1))}},Yc={description:r("Last day of the year a specific date falls in."),args:_s(`\n date (date) ${r("The date from which to calculate the end of the year.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=zc.compute(e);return Ce(new ae(t+1,0,0))}};var Xc=Object.freeze({__proto__:null,DATE:bc,DATEVALUE:Sc,DAY:Cc,DAYS:Ec,DAYS360:wc,EDATE:yc,EOMONTH:xc,HOUR:Rc,ISOWEEKNUM:Ic,MINUTE:Tc,MONTH:Ac,NETWORKDAYS:Nc,NETWORKDAYS_INTL:Oc,NOW:_c,SECOND:Fc,TIME:Dc,TIMEVALUE:kc,TODAY:$c,WEEKDAY:Lc,WEEKNUM:Pc,WORKDAY:Uc,WORKDAY_INTL:Vc,YEAR:zc,YEARFRAC:Bc,MONTH_START:Hc,MONTH_END:Wc,QUARTER:Gc,QUARTER_START:qc,QUARTER_END:Zc,YEAR_START:jc,YEAR_END:Yc});const Kc={description:r("Compare two numeric values, returning 1 if they're equal."),args:_s(`\n number1 (number) ${r("The first number to compare.")}\n number2 (number, default=0) ${r("The second number to compare.")}\n `),returns:["NUMBER"],compute:function(e,t=0){return Ps(e)===Ps(t)?1:0},isExported:!0};var Qc=Object.freeze({__proto__:null,DELTA:Kc});function Jc(e,t){$s((()=>e<t),r("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function eh(e,t){$s((()=>t<e),r("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function th(e){$s((()=>[1,2,4].includes(e)),r("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function ih(e){$s((()=>0<=e&&e<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function nh(e){$s((()=>e>0),r("The redemption (%s) must be strictly positive.",e.toString()))}function oh(e){$s((()=>e>0),r("The price (%s) must be strictly positive.",e.toString()))}function rh(e){$s((()=>e>0),r("The number_of_periods (%s) must be greater than 0.",e.toString()))}function sh(e){$s((()=>e>0),r("The rate (%s) must be strictly positive.",e.toString()))}function ah(e){$s((()=>e>0),r("The life (%s) must be strictly positive.",e.toString()))}function lh(e){$s((()=>e>=0),r("The cost (%s) must be positive or null.",e.toString()))}function ch(e){$s((()=>e>0),r("The period (%s) must be strictly positive.",e.toString()))}function hh(e){$s((()=>e>=0),r("The salvage (%s) must be positive or null.",e.toString()))}function dh(e){$s((()=>e>0),r("The present value (%s) must be strictly positive.",e.toString()))}function uh(e,t){$s((()=>e<=t),r("The period (%s) must be less than or equal life (%.",e.toString(),t.toString()))}function gh(e){$s((()=>e>0),r("The investment (%s) must be strictly positive.",e.toString()))}function ph(e){$s((()=>e>0),r("The discount (%s) must be strictly positive.",e.toString()))}function mh(e){$s((()=>e<1),r("The discount (%s) must be smaller than 1.",e.toString()))}function fh(e){$s((()=>e>0),r("The depreciation factor (%s) must be strictly positive.",e.toString()))}function vh(e,t){const i=Gs(e),n=Gs(t),o=Gs(e);o.setFullYear(i.getFullYear()+1),$s((()=>n.getTime()<=o.getTime()),r("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function bh(e,t,i){rh(i),$s((()=>e>0),r("The first_period (%s) must be strictly positive.",e.toString())),$s((()=>t>0),r("The last_period (%s) must be strictly positive.",t.toString())),$s((()=>e<=t),r("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),$s((()=>t<=i),r("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),i.toString()))}function Sh(e){$s((()=>e>-1),r("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function Ch(e,t){$s((()=>e.length===t.length&&e[0].length===t[0].length),r("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function Eh(e){$s((()=>e.every((t=>t>=e[0]))),r("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const wh=_s(`\nsettlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\nmaturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\nfrequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\nday_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n`);function yh(e,t,i,n,o=1e-10,s){let a,l,c,h,d=i,u=!1,g=0;do{c=e(d),isNaN(c)?($s((()=>g<n&&void 0!==s),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++,d=s(h),h=d):(a=d-c/t(d),l=Math.abs(a-d),d=a,u=l<o||Math.abs(c)<o,$s((()=>g<n),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const xh={description:r("Accrued interest of security paying at maturity."),args:_s(`\n issue (date) ${r("The date the security was initially issued.")}\n maturity (date) ${r("The maturity date of the security.")}\n rate (number) ${r("The annualized rate of interest.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Ps(e)),s=Math.trunc(Ps(t)),a=Ps(n),l=Ps(i),c=Math.trunc(Ps(o));eh(s,r),ih(c),nh(a),sh(l);return a*l*Bc.compute(r,s,o)},isExported:!0},Rh={description:r("Depreciation for an accounting period."),args:_s(`\n cost (number) ${r("The initial cost of the asset.")}\n purchase_date (date) ${r("The date the asset was purchased.")}\n first_period_end (date) ${r("The date the first period ended.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n rate (number) ${r("The deprecation rate.")}\n day_count_convention (number, optional) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s,a=0){a=a||0;const l=Ps(e),c=Math.trunc(Ps(t)),h=Math.trunc(Ps(i)),d=Ps(n),u=Ps(o),g=Ps(s),p=Math.trunc(Ps(a));!function(e){$s((()=>e>0),r("The cost (%s) must be strictly positive.",e.toString()))}(l),hh(d),function(e,t){$s((()=>e<=t),r("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){$s((()=>e>=0),r("The period (%s) must be positive or null.",e.toString()))}(u),sh(g),ih(p),$s((()=>c<=h),r("The purchase_date (%s) must be before the first_period_end (%s).",c.toString(),h.toString()));const m=u<1&&u>0?1:Math.trunc(u),f=l*g,v=Bc.compute(c,h,p),b=c===h?f:f*v,S=l-b-f*m;return S>=d?0===m?b:f:d-S<f?f-(d-S):0},isExported:!0},Ih={description:r("Days in coupon period containing settlement date."),args:wh,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Ps(e)),r=Math.trunc(Ps(t)),s=Math.trunc(Ps(i)),a=Math.trunc(Ps(n));if(Jc(o,r),th(s),ih(a),1===a){const o=Oh.compute(e,t,i,n);return Nh.compute(e,t,i,n)-o}return(3===a?365:360)/s},isExported:!0},Th={description:r("Days from settlement until next coupon."),args:wh,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Ps(e)),r=Math.trunc(Ps(t)),s=Math.trunc(Ps(i)),a=Math.trunc(Ps(n));Jc(o,r),th(s),ih(a);const l=Oh.compute(o,r,i,n);if([1,2,3].includes(a))return o-l;if(4===a){const e=Re(l,o,a);return Math.round(360*e)}const c=Gs(o),h=Gs(l),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&&we(h)&&we(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&we(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Ah={description:r("Days from settlement until next coupon."),args:wh,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Ps(e)),r=Math.trunc(Ps(t)),s=Math.trunc(Ps(i)),a=Math.trunc(Ps(n));Jc(o,r),th(s),ih(a);const l=Nh.compute(o,r,i,n);if([1,2,3].includes(a))return l-o;if(4===a){const e=Re(o,l,a);return Math.round(360*e)}const c=Th.compute(e,t,i,a);return Ih.compute(e,t,i,a)-c},isExported:!0},Nh={description:r("Next coupon date after the settlement date."),args:wh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Ps(e)),r=Math.trunc(Ps(t)),s=Math.trunc(Ps(i)),a=Math.trunc(Ps(n));Jc(o,r),th(s),ih(a);const l=12/s,c=Mh.compute(e,t,i,n);return Ce(ye(Gs(r),-(c-1)*l,!0))},isExported:!0},Mh={description:r("Number of coupons between settlement and maturity."),args:wh,returns:["NUMBER"],compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Ps(e)),r=Math.trunc(Ps(t)),s=Math.trunc(Ps(i)),a=Math.trunc(Ps(n));Jc(o,r),th(s),ih(a);let l=1,c=r;const h=12/s;for(;c>o;)c=Ce(ye(Gs(c),-h,!1)),l++;return l-1},isExported:!0},Oh={description:r("Last coupon date prior to or on the settlement date."),args:wh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,n=0){n=n||0;const o=Math.trunc(Ps(e)),r=Math.trunc(Ps(t)),s=Math.trunc(Ps(i)),a=Math.trunc(Ps(n));Jc(o,r),th(s),ih(a);const l=12/s,c=Mh.compute(e,t,i,n);return Ce(ye(Gs(r),-c*l,!0))},isExported:!0},_h={description:r("Cumulative interest paid over a set of periods."),args:_s(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n first_period (number) ${r("The number of the payment period to begin the cumulative calculation.")}\n last_period (number) ${r("The number of the payment period to end the cumulative calculation.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,r=0){const s=Ps(n),a=Ps(o),l=Ps(e),c=Ps(i),h=Ps(t);bh(s,a,h),sh(l),dh(c);let d=0;for(let t=s;t<=a;t++){d+=Wh.compute(e,t,h,i,0,r)}return d},isExported:!0},Fh={description:r("Cumulative principal paid over a set of periods."),args:_s(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n first_period (number) ${r("The number of the payment period to begin the cumulative calculation.")}\n last_period (number) ${r("The number of the payment period to end the cumulative calculation.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,r=0){const s=Ps(n),a=Ps(o),l=Ps(e),c=Ps(i),h=Ps(t);bh(s,a,h),sh(l),dh(c);let d=0;for(let t=s;t<=a;t++){d+=ed.compute(e,t,h,i,0,r)}return d},isExported:!0},Dh={description:r("Depreciation via declining balance method."),args:_s(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n month (number, optional) ${r("The number of months in the first year of depreciation.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n,...o){const s=Ps(e),a=Ps(t),l=Ps(i),c=Math.trunc(Ps(n)),h=o.length?Math.trunc(Ps(o[0])):12,d=l+(12===h?0:1);lh(s),hh(a),ch(c),ah(l),$s((()=>1<=h&&h<=12),r("The month (%s) must be between 1 and 12 inclusive.",h.toString())),$s((()=>c<=d),r("The period (%s) must be less than or equal to %s.",c.toString(),d.toString()));const u=h/12;let g=1-Math.pow(a/s,1/l);g=Math.round(1e3*g)/1e3;let p=s,m=s*(1-g*u);for(let e=1;e<c;e++)p=m,m=p*(1-g),e===l&&(m=p*(1-g*(1-u)));return p-m},isExported:!0},kh={description:r("Depreciation via double-declining balance method."),args:_s(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n factor (number, default=2) ${r("The factor by which depreciation decreases.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n,o=2){o=o||0;const r=Ps(e),s=Ps(t),a=Ps(i),l=Ps(n),c=Ps(o);if(lh(r),hh(s),ch(l),ah(a),uh(l,a),fh(c),0===r||s>=r)return 0;const h=c/a;if(h>1)return 1===n?r-s:0;if(l<=1)return r*h;const d=r*Math.pow(1-h,l-1),u=r*Math.pow(1-h,l),g=u<s?d-s:d-u;return Math.max(g,0)},isExported:!0},$h={description:r("Discount rate of a security based on price."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Ps(e)),s=Math.trunc(Ps(t)),a=Ps(i),l=Ps(n),c=Math.trunc(Ps(o));Jc(r,s),ih(c),oh(a),nh(l);return(l-a)/l/Bc.compute(r,s,c)},isExported:!0},Lh={description:r("Convert a decimal fraction to decimal value."),args:_s(`\n fractional_price (number) ${r("The price quotation given using fractional decimal conventions.")}\n unit (number) ${r("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Ps(e),n=Math.trunc(Ps(t));$s((()=>n>0),r("The unit (%s) must be strictly positive.",n.toString()));const o=Math.trunc(i);return o+(i-o)*(10**Math.ceil(Math.log10(n))/n)},isExported:!0},Ph={description:r("Convert a decimal value to decimal fraction."),args:_s(`\n decimal_price (number) ${r("The price quotation given as a decimal value.")}\n unit (number) ${r("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Ps(e),n=Math.trunc(Ps(t));$s((()=>n>0),r("The unit (%s) must be strictly positive.",n.toString()));const o=Math.trunc(i);return o+(i-o)*(n/10**Math.ceil(Math.log10(n)))},isExported:!0},Uh={description:r("Number of periods for an investment to reach a value."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s=0){s=s||0;const a=Math.trunc(Ps(e)),l=Math.trunc(Ps(t)),c=Ps(i),h=Ps(n),d=Math.trunc(Ps(o)),u=Math.trunc(Ps(s));Jc(a,l),th(d),ih(u),$s((()=>c>=0),r("The rate (%s) must be positive or null.",c.toString())),$s((()=>h>=0),r("The yield (%s) must be positive or null.",h.toString()));const g=Bc.compute(a,l,u),p=g-Math.trunc(g)||1/d,m=Math.ceil(g*d),f=c/d,v=h/d;let b=0,S=0;for(let e=1;e<=m;e++){const t=(f+(e===m?1:0))/(1+v)**e;S+=(p+(e-1)/d)*t,b+=t}return 0===b?0:S/b},isExported:!0},Vh={description:r("Annual effective interest rate."),args:_s(`\n nominal_rate (number) ${r("The nominal interest rate per year.")}\n periods_per_year (number) ${r("The number of compounding periods per year.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Ps(e),n=Math.trunc(Ps(t));return $s((()=>i>0),r("The nominal rate (%s) must be strictly greater than 0.",i.toString())),$s((()=>n>0),r("The number of periods by year (%s) must strictly greater than 0.",n.toString())),Math.pow(1+i/n,n)-1},isExported:!0},zh={description:r("Future value of an annuity investment."),args:_s(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_amount (number) ${r("The amount per period to be paid.")}\n present_value (number, default=0) ${r("The current value of the annuity.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n=0,o=0){n=n||0,o=o||0;const r=Ps(e),s=Ps(t),a=Ps(i),l=Ps(n),c=Ws(o)?1:0;return r?-l*(1+r)**s-a*(1+r*c)*((1+r)**s-1)/r:-(l+a*s)},isExported:!0},Bh={description:r("Future value of principal from series of rates."),args:_s(`\n principal (number) ${r("The amount of initial capital or value to compound against.")}\n rate_schedule (number, range<number>) ${r("A series of interest rates to compound against the principal.")}\n `),returns:["NUMBER"],compute:function(e,t){return Xs([t],((e,t)=>e*(1+Ps(t))),Ps(e))},isExported:!0},Hh={description:r("Calculates effective interest rate."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n investment (number) ${r("The amount invested in the security.")}\n redemption (number) ${r("The amount to be received at maturity.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){const r=Math.trunc(Ps(e)),s=Math.trunc(Ps(t)),a=Ps(n),l=Ps(i);Jc(r,s),gh(l),nh(a);return(a-l)/l/Bc.compute(r,s,o)},isExported:!0},Wh={description:r("Payment on the principal of an investment."),args:_s(`\n rate (number) ${r("The annualized rate of interest.")}\n period (number) ${r("The amortization period, in terms of number of periods.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n,o=0,r=0){return Jh.compute(e,i,n,o,r)-ed.compute(e,t,i,n,o,r)},isExported:!0},Gh={description:r("Internal rate of return given periodic cashflows."),args:_s(`\n cashflow_amounts (number, range<number>) ${r("An array or range containing the income or payments associated with the investment.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t=.1){const i=Ps(t);Sh(i);let n=!1,o=!1,s=[];js([e],(e=>{e>0&&(n=!0),e<0&&(o=!0),s.push(e)})),$s((()=>n&&o),r("The cashflow_amounts must include negative and positive values."));const a=s.shift();return yh((function(e){return function(e,t,i){const n=i.length;let o=0;return i.reduce(((t,i)=>(o++,t+i*e**(n-o))),t*e**n)}(e,a,s)}),(function(e){return function(e,t,i){const n=i.length;let o=0;return i.reduce(((t,i)=>(o++,t+i*(n-o)*e**(n-o-1))),t*n*e**(n-1))}(e,a,s)}),i+1,20,1e-5)-1},isExported:!0},qh={description:r("Returns the interest paid at a particular period of an investment."),args:_s(`\n rate (number) ${r("The interest rate.")}\n period (number) ${r("The period for which you want to view the interest payment.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n){const o=Ps(e),s=Ps(t),a=Ps(i),l=Ps(n);$s((()=>0!==a),r("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(s/a))*o},isExported:!0},Zh={description:r("Modified Macaulay duration."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,r=0){return Uh.compute(e,t,i,n,o,r)/(1+Ps(n)/Math.trunc(Ps(o)))},isExported:!0},jh={description:r("Modified internal rate of return."),args:_s(`\n cashflow_amounts (range<number>) ${r("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")}\n financing_rate (number) ${r("The interest rate paid on funds invested.")}\n reinvestment_return_rate (number) ${r("The return (as a percentage) earned on reinvestment of income received from the investment.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Ps(t),o=Ps(i),s=(a=e,a.length?a[0].map(((e,t)=>a.map((e=>e[t])))):a).flat().filter(Xe).map(Ps);var a;const l=s.length;let c=0,h=0;for(const e of $e(0,l)){const t=s[e];t>=0?c+=t*(o+1)**(l-e-1):h+=t/(n+1)**e}$s((()=>0!==h&&0!==c),r("There must be both positive and negative values in cashflow_amounts."));return(-c/h)**(1/(l-1))-1},isExported:!0},Yh={description:r("Annual nominal interest rate."),args:_s(`\n effective_rate (number) ${r("The effective interest rate per year.")}\n periods_per_year (number) ${r("The number of compounding periods per year.")}\n `),returns:["NUMBER"],compute:function(e,t){const i=Ps(e),n=Math.trunc(Ps(t));return $s((()=>i>0),r("The effective rate (%s) must must strictly greater than 0.",i.toString())),$s((()=>n>0),r("The number of periods by year (%s) must strictly greater than 0.",n.toString())),(Math.pow(i+1,1/n)-1)*n},isExported:!0},Xh={description:r("Number of payment periods for an investment."),args:_s(`\n rate (number) ${r("The interest rate.")}\n payment_amount (number) ${r("The amount of each payment made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n=0,o=0){n=n||0,o=o||0;const r=Ps(e),s=Ps(t),a=Ps(i),l=Ps(n),c=Ws(o)?1:0;if(0===r)return-(l+a)/s;const h=s*(1+r*c)/r;return Math.log((h-l)/(a+h))/Math.log(1+r)},isExported:!0};const Kh={description:r("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:_s(`\n discount (number) ${r("The discount rate of the investment over one period.")}\n cashflow1 (number, range<number>) ${r("The first future cash flow.")}\n cashflow2 (number, range<number>, repeating) ${r("Additional future cash flows.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const i=Ps(e);return $s((()=>-1!==i),r("The discount (%s) must be different from -1.",i.toString())),function(e,t,i){let n=0;return Ks(i,((t,i)=>(n++,t+i/(1+e)**n)),t)}(i,0,t)},isExported:!0},Qh={description:r("Computes the number of periods needed for an investment to reach a value."),args:_s(`\n rate (number) ${r("The rate at which the investment grows each period.")}\n present_value (number) ${r("The investment's current value.")}\n future_value (number) ${r("The investment's desired future value.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Ps(e),o=Ps(t),s=Ps(i);return sh(n),$s((()=>o>0),r("The present_value (%s) must be strictly positive.",o.toString())),$s((()=>s>0),r("The future_value (%s) must be strictly positive.",s.toString())),(Math.log(s)-Math.log(o))/Math.log(1+n)},isExported:!0},Jh={description:r("Periodic payment for an annuity investment."),args:_s(`\n rate (number) ${r("The annualized rate of interest.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n=0,o=0){n=n||0,o=o||0;const r=Ps(t),s=Ps(e),a=Ws(o)?1:0;let l=Ps(n),c=Ps(i);if(rh(r),0===s)return-(l+c)/r;let h=-(c*(1+s)**r+l);return h=h*s/((1+s*a)*((1+s)**r-1)),h},isExported:!0},ed={description:r("Payment on the principal of an investment."),args:_s(`\n rate (number) ${r("The annualized rate of interest.")}\n period (number) ${r("The amortization period, in terms of number of periods.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n,o=0,s=0){o=o||0,s=s||0;const a=Ps(i),l=Ps(e),c=Ps(t),h=Ws(s)?1:0,d=Ps(o),u=Ps(n);rh(a),$s((()=>c>0&&c<=a),r("The period must be between 1 and number_of_periods",a.toString()));const g=Jh.compute(l,a,u,d,s);if(1===h&&1===c)return g;return g+-zh.compute(l,0===h?c-1:c-2,g,u+g*h,0)*l},isExported:!0},td={description:r("Present value of an annuity investment."),args:_s(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_amount (number) ${r("The amount per period to be paid.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n=0,o=0){n=n||0,o=o||0;const r=Ps(e),s=Ps(t),a=Ps(i),l=Ps(n),c=Ws(o)?1:0;return r?-(a*(1+r*c)*((1+r)**s-1)/r+l)/(1+r)**s:-(l+a*s)},isExported:!0},id={description:r("Price of a security paying periodic interest."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s,a=0){a=a||0;const l=Math.trunc(Ps(e)),c=Math.trunc(Ps(t)),h=Ps(i),d=Ps(n),u=Ps(o),g=Math.trunc(Ps(s)),p=Math.trunc(Ps(a));Jc(l,c),th(g),ih(p),$s((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),$s((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString())),nh(u);const m=Bc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=1+d/g,S=100*h/g;if(1===f)return(S+u)/(v*d/g+1)-S*(1-v);let C=0;for(let e=1;e<=f;e++)C+=S/b**(e-1+v);return u/b**(f-1+v)+C-S*(1-v)},isExported:!0},nd={description:r("Price of a discount security."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the security at time of purchase.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Ps(e)),s=Math.trunc(Ps(t)),a=Ps(i),l=Ps(n),c=Math.trunc(Ps(o));Jc(r,s),ih(c),ph(a),nh(l);return l-a*l*Bc.compute(r,s,c)},isExported:!0},od={description:r("Calculates the price of a security paying interest at maturity, based on expected yield."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${r("The date the security was initially issued.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s=0){s=s||0;const a=Math.trunc(Ps(e)),l=Math.trunc(Ps(t)),c=Math.trunc(Ps(i)),h=Ps(n),d=Ps(o),u=Math.trunc(Ps(s));eh(a,c),Jc(a,l),ih(u),$s((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),$s((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString()));const g=Bc.compute(a,l,u),p=Bc.compute(a,c,u);return(100+Bc.compute(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},rd=.1,sd={description:r("Interest rate of an annuity investment."),args:_s(`\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_per_period (number) ${r("The amount per period to be paid.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the interest rate will be.")}\n `),returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,i,n=0,o=0,s=.1){n=n||0,o=o||0,s=s||rd;const a=Ps(e),l=Ps(t),c=Ws(o)?1:0,h=Ps(s);let d=Ps(n),u=Ps(i);rh(a),$s((()=>[l,u,d].some((e=>e>0))&&[l,u,d].some((e=>e<0))),r("There must be both positive and negative values in [payment_amount, present_value, future_value].",a.toString())),Sh(h),d-=l*c,u+=l*c;return yh((e=>{const t=Math.pow(1+e,a);return d+u*t+l*((t-1)/e)}),(e=>{const t=Math.pow(1+e,a-1),i=Math.pow(1+e,a);return u*a*t+l*(a*t/e-(i-1)/e/e)}),h,40,1e-5)},isExported:!0},ad={description:r("Amount received at maturity for a security."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n investment (number) ${r("The amount invested (irrespective of face value of each security).")}\n discount (number) ${r("The discount rate of the security invested in.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Ps(e)),s=Math.trunc(Ps(t)),a=Ps(i),l=Ps(n),c=Math.trunc(Ps(o));Jc(r,s),ih(c),gh(a),ph(l);return a/(1-l*Bc.compute(r,s,c))},isExported:!0},ld={description:r("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:_s(`\n number_of_periods (number) ${r("The number of periods.")}\n present_value (number) ${r("The present value of the investment.")}\n future_value (number) ${r("The future value of the investment.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Ps(e),o=Ps(t),r=Ps(i);return rh(n),(r/o)**(1/n)-1},isExported:!0},cd={description:r("Depreciation of an asset using the straight-line method."),args:_s(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i){return(Ps(e)-Ps(t))/Ps(i)},isExported:!0},hd={description:r("Depreciation via sum of years digit method."),args:_s(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,n){const o=Ps(e),r=Ps(t),s=Ps(i),a=Ps(n);ch(a),ah(s),uh(a,s);return(s-a+1)/(s*(s+1)/2)*(o-r)},isExported:!0},dd={description:r("Price of a US Treasury bill."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the bill at time of purchase.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Math.trunc(Ps(e)),o=Math.trunc(Ps(t)),r=Ps(i);Jc(n,o),vh(n,o),ph(r),mh(r);return 100*(1-r*Bc.compute(n,o,2))},isExported:!0},ud={description:r("Equivalent rate of return for a US Treasury bill."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the bill at time of purchase.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Math.trunc(Ps(e)),o=Math.trunc(Ps(t)),r=Ps(i);Jc(n,o),vh(n,o),ph(r),mh(r);const s=Ec.compute(o,n);if(s<=182)return 365*r/(360-r*s);const a=dd.compute(n,o,r)/100,l=s/(366===s?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},gd={description:r("The yield of a US Treasury bill based on price."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Math.trunc(Ps(e)),o=Math.trunc(Ps(t)),r=Ps(i);Jc(n,o),vh(n,o),oh(r);return(100-r)/r*(1/Bc.compute(n,o,2))},isExported:!0},pd={description:r("Variable declining balance. WARNING : does not handle decimal periods."),args:_s(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n start (number) ${r("Starting period to calculate depreciation.")}\n end (number) ${r("Ending period to calculate depreciation.")}\n factor (number, default=2) ${r("The number of months in the first year of depreciation.")}\n no_switch (number, default=false) ${r("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s=2,a=false){s=s||0;const l=Ps(e),c=Ps(t),h=Ps(i),d=Math.trunc(Ps(n)),u=Math.trunc(Ps(o)),g=Ps(s),p=Ws(a);if(lh(l),hh(c),function(e,t,i){ah(i),$s((()=>e>=0),r("The start_period (%s) must be greater or equal than 0.",e.toString())),$s((()=>t>=0),r("The end_period (%s) must be greater or equal than 0.",t.toString())),$s((()=>e<=t),r("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),$s((()=>t<=i),r("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),i.toString()))}(d,u,h),fh(g),0===l)return 0;if(c>=l)return d<1?l-c:0;const m=g/h;if(m>=1)return d<1?l-c:0;let f=l,v=0,b=0,S=!1;for(let e=0;e<u;e++){if(!S||p){const t=f*m,i=(f-c)/(h-e);!p&&i>t?(S=!0,v=i):v=t}const t=Math.max(f-v,c);e>=d&&(b+=f-t),f=t}return b},isExported:!0},md={description:r("Internal rate of return given non-periodic cash flows."),args:_s(`\n cashflow_amounts (range<number>) ${r("An range containing the income or payments associated with the investment.")}\n cashflow_dates (range<number>) ${r("An range with dates corresponding to the cash flows in cashflow_amounts.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],compute:function(e,t,i=.1){const n=Ps(i=i||0),o=e.flat().map(Ps),s=t.flat().map(Ps);var a;Ch(e,t),a=o,$s((()=>a.some((e=>e>0))&&a.some((e=>e<0))),r("There must be both positive and negative values in cashflow_amounts.")),Eh(s),Sh(n);const l=new Map;for(const e of $e(0,s.length)){const t=s[e];l.has(t)?l.set(t,l.get(t)+o[e]):l.set(t,o[e])}const c=Array.from(l.keys()),h=c.map((e=>l.get(e)));return yh((e=>{let t=h[0];for(const i of $e(1,h.length)){const n=(c[0]-c[i])/365;t+=h[i]*(1+e)**n}return t}),(e=>{let t=0;for(const i of $e(1,h.length)){const n=(c[0]-c[i])/365;t+=n*h[i]*(1+e)**(n-1)}return t}),n,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},fd={description:r("Net present value given to non-periodic cash flows.."),args:_s(`\n discount (number) ${r("The discount rate of the investment over one period.")}\n cashflow_amounts (number, range<number>) ${r("An range containing the income or payments associated with the investment.")}\n cashflow_dates (number, range<number>) ${r("An range with dates corresponding to the cash flows in cashflow_amounts.")}\n `),returns:["NUMBER"],compute:function(e,t,i){const n=Ps(e),o=Array.isArray(t)?t.flat().map(Us):[Us(t)],s=Array.isArray(i)?i.flat().map(Us):[Us(i)];if(Array.isArray(i)&&Array.isArray(t)?Ch(t,i):$s((()=>o.length===s.length),r("There must be the same number of values in cashflow_amounts and cashflow_dates.")),Eh(s),sh(n),1===o.length)return o[0];const a=new Map;for(const e of $e(0,s.length)){const t=s[e];a.has(t)?a.set(t,a.get(t)+o[e]):a.set(t,o[e])}const l=Array.from(a.keys()),c=l.map((e=>a.get(e)));let h=c[0];for(const e of $e(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+n)**t}return h},isExported:!0},vd={description:r("Annual yield of a security paying periodic interest."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s,a=0){a=a||0;const l=Math.trunc(Ps(e)),c=Math.trunc(Ps(t)),h=Ps(i),d=Ps(n),u=Ps(o),g=Math.trunc(Ps(s)),p=Math.trunc(Ps(a));Jc(l,c),th(g),ih(p),$s((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),oh(d),nh(u);const m=Bc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=100*h/g;if(1===f){const e=d+b*(1-v);return(u+b-e)*g*(1/v)/e}const S=yh((function(e){return function(e,t,i,n,o,r){let s=r-(e+o*(1-t))*n**(i-1+t);for(let e=1;e<=i;e++)s+=o*n**(e-1);return s}(d,v,f,e,b,u)}),(function(e){return function(e,t,i,n,o){let r=-(e+o*(1-t))*(i-1+t)*n**(i-2+t);for(let e=1;e<=i;e++)r+=o*(e-1)*n**(e-2);return r}(d,v,f,e,b)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},bd={description:r("Annual yield of a discount security."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o=0){o=o||0;const r=Math.trunc(Ps(e)),s=Math.trunc(Ps(t)),a=Ps(i),l=Ps(n),c=Math.trunc(Ps(o));Jc(r,s),ih(c),oh(a),nh(l);return(l/a-1)/Bc.compute(e,t,o)},isExported:!0},Sd={description:r("Annual yield of a security paying interest at maturity."),args:_s(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${r("The date the security was initially issued.")}\n rate (number) ${r("The annualized rate of interest.")}\n price (number) ${r("The price at which the security is bought.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n,o,s=0){s=s||0;const a=Math.trunc(Ps(e)),l=Math.trunc(Ps(t)),c=Math.trunc(Ps(i)),h=Ps(n),d=Ps(o),u=Math.trunc(Ps(s));Jc(a,l),ih(u),$s((()=>a>=c),r("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),$s((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),oh(d);const g=Bc.compute(c,l,u),p=Bc.compute(c,a,u),m=Bc.compute(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var Cd=Object.freeze({__proto__:null,ACCRINTM:xh,AMORLINC:Rh,COUPDAYS:Ih,COUPDAYBS:Th,COUPDAYSNC:Ah,COUPNCD:Nh,COUPNUM:Mh,COUPPCD:Oh,CUMIPMT:_h,CUMPRINC:Fh,DB:Dh,DDB:kh,DISC:$h,DOLLARDE:Lh,DOLLARFR:Ph,DURATION:Uh,EFFECT:Vh,FV:zh,FVSCHEDULE:Bh,INTRATE:Hh,IPMT:Wh,IRR:Gh,ISPMT:qh,MDURATION:Zh,MIRR:jh,NOMINAL:Yh,NPER:Xh,NPV:Kh,PDURATION:Qh,PMT:Jh,PPMT:ed,PV:td,PRICE:id,PRICEDISC:nd,PRICEMAT:od,RATE:sd,RECEIVED:ad,RRI:ld,SLN:cd,SYD:hd,TBILLPRICE:dd,TBILLEQ:ud,TBILLYIELD:gd,VDB:pd,XIRR:md,XNPV:fd,YIELD:vd,YIELDDISC:bd,YIELDMAT:Sd});const Ed={description:r("Whether a value is an error other than #N/A."),args:_s(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)!=a.NotAvailable}},isExported:!0},wd={description:r("Whether a value is an error."),args:_s(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return!0}},isExported:!0},yd={description:r("Whether a value is `true` or `false`."),args:_s(`value (any, lazy) ${r("The value to be verified as a logical TRUE or FALSE.")}`),returns:["BOOLEAN"],compute:function(e){try{return"boolean"==typeof e()}catch(e){return!1}},isExported:!0},xd={description:r("Whether a value is the error #N/A."),args:_s(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)==a.NotAvailable}},isExported:!0},Rd={description:r("Whether a value is non-textual."),args:_s(`value (any, lazy) ${r("The value to be checked.")}`),returns:["BOOLEAN"],compute:function(e){try{return"string"!=typeof e()}catch(e){return!0}},isExported:!0},Id={description:r("Whether a value is a number."),args:_s(`value (any, lazy) ${r("The value to be verified as a number.")}`),returns:["BOOLEAN"],compute:function(e){try{return"number"==typeof e()}catch(e){return!1}},isExported:!0},Td={description:r("Whether a value is text."),args:_s(`value (any, lazy) ${r("The value to be verified as text.")}`),returns:["BOOLEAN"],compute:function(e){try{return"string"==typeof e()}catch(e){return!1}},isExported:!0},Ad={description:r("Whether the referenced cell is empty"),args:_s(`value (any, lazy) ${r("Reference to the cell that will be checked for emptiness.")}`),returns:["BOOLEAN"],compute:function(e){try{return null===e()}catch(e){return!1}},isExported:!0},Nd={description:r("Returns the error value #N/A."),args:_s(""),returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var Md=Object.freeze({__proto__:null,ISERR:Ed,ISERROR:wd,ISLOGICAL:yd,ISNA:xd,ISNONTEXT:Rd,ISNUMBER:Id,ISTEXT:Td,ISBLANK:Ad,NA:Nd});const Od={description:r("Logical `and` operator."),args:_s(`\n logical_expression1 (boolean, range<boolean>) ${r("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.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that represent logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!0;return Js(e,(e=>(t=!0,i=i&&e,i))),$s((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},_d={description:r("Returns value depending on logical expression."),args:_s(`\n logical_expression (boolean) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")}\n value_if_true (any, lazy) ${r("The value the function returns if logical_expression is TRUE.")}\n value_if_false (any, lazy, default=FALSE) ${r("The value the function returns if logical_expression is FALSE.")}\n `),returns:["ANY"],compute:function(e,t,i=(()=>!1)){const n=Ws(e)?t():i();return null==n?"":n},isExported:!0},Fd={description:r("Value if it is not an error, otherwise 2nd argument."),args:_s(`\n value (any, lazy) ${r("The value to return if value itself is not an error.")}\n value_if_error (any, lazy, default=${r("An empty value")}) ${r("The value the function returns if value is an error.")}\n `),returns:["ANY"],computeFormat:(e,t=(()=>({value:""})))=>{var i;try{return e().format}catch(e){return null===(i=t())||void 0===i?void 0:i.format}},compute:function(e,t=(()=>"")){let i;try{i=e()}catch(e){i=t()}return null==i?"":i},isExported:!0},Dd={description:r("Value if it is not an #N/A error, otherwise 2nd argument."),args:_s(`\n value (any, lazy) ${r("The value to return if value itself is not #N/A an error.")}\n value_if_error (any, lazy, default=${r("An empty value")}) ${r("The value the function returns if value is an #N/A error.")}\n `),returns:["ANY"],compute:function(e,t=(()=>"")){let i;try{i=e()}catch(n){i=n.errorType===a.NotAvailable?t():e()}return null==i?"":i},isExported:!0},kd={description:r("Returns a value depending on multiple logical expressions."),args:_s(`\n condition1 (boolean, lazy) ${r("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")}\n value1 (any, lazy) ${r("The returned value if condition1 is TRUE.")}\n condition2 (boolean, lazy, repeating) ${r("Additional conditions to be evaluated if the previous ones are FALSE.")}\n value2 (any, lazy, repeating) ${r("Additional values to be returned if their corresponding conditions are TRUE.")}\n `),returns:["ANY"],compute:function(...e){$s((()=>e.length%2==0),r("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(Ws(e[t]())){const i=e[t+1]();return null!==i?i:""}throw new Error(r("No match."))},isExported:!0},$d={description:r("Returns opposite of provided logical value."),args:_s(`logical_expression (boolean) ${r("An expression or reference to a cell holding an expression that represents some logical value.")}\n `),returns:["BOOLEAN"],compute:function(e){return!Ws(e)},isExported:!0},Ld={description:r("Logical `or` operator."),args:_s(`\n logical_expression1 (boolean, range<boolean>) ${r("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.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return Js(e,(e=>(t=!0,i=i||e,!i))),$s((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Pd={description:r("Logical `xor` operator."),args:_s(`\n logical_expression1 (boolean, range<boolean>) ${r("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.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return Js(e,(e=>(t=!0,i=i?!e:e,!0))),$s((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0};var Ud=Object.freeze({__proto__:null,AND:Od,IF:_d,IFERROR:Fd,IFNA:Dd,IFS:kd,NOT:$d,OR:Ld,XOR:Pd});const Vd={description:r("Column number of a specified cell."),args:_s(`cell_reference (meta, default=${r("The cell in which the formula is entered")}) ${r("The cell whose column number will be returned. Column A corresponds to 1.")}\n `),returns:["NUMBER"],compute:function(e){var t;const i=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this));$s((()=>!!i),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Mi(i).left+1},isExported:!0},zd={description:r("Number of columns in a specified array or range."),args:_s(`range (meta) ${r("The range whose column count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=Mi(e);return t.right-t.left+1},isExported:!0},Bd={description:r("Horizontal lookup"),args:_s(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (range) ${r("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")}\n index (number) ${r("The row index of the value to be returned, where the first row in range is numbered 1.")}\n is_sorted (boolean, default=true) ${r("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.")}\n `),returns:["ANY"],compute:function(e,t,i,n=true){const o=Math.trunc(Ps(i)),s=Bs(e);$s((()=>1<=o&&o<=t[0].length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=Ws(n);let l;return l=a?ra(t,s,"nextSmaller","asc",t.length,oa):sa(t,s,"strict",t.length,oa),$s((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Vs(e))),t[l][o-1]},isExported:!0},Hd={description:r("Returns the content of a cell, specified by row and column offset."),args:_s(`\n reference (any, range) ${r("The range of cells from which the value is returned.")}\n row (number) ${r("The index of the row to be returned from within the reference range of cells.")}\n column (number) ${r("The index of the column to be returned from within the reference range of cells.")}\n`),returns:["ANY"],computeFormat:(e,t,i)=>{var n;const o=Ps(t.value);return null===(n=e[Ps(i.value)-1][o-1])||void 0===n?void 0:n.format},compute:function(e,t,i){const n=(o=e,Array.isArray(o)&&Array.isArray(o[0])?e:[[e]]);var o;const s=Ps(t),a=Ps(i);return $s((()=>a>=0&&a-1<n.length&&s>=0&&s-1<n[0].length),r("Index out of range.")),$s((()=>0!==t&&0!==i),r("This function can only return a single cell value, not an array. Provide valid row and column indices.")),n[a-1][s-1]},isExported:!0},Wd={description:r("Look up a value."),args:_s(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n search_array (range) ${r("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.")}\n result_range (range, optional) ${r("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.")}\n `),returns:["ANY"],compute:function(e,t,i){let n=t.length,o=t[0].length;const s=Bs(e),a=o>=n,l=ra(t,s,"nextSmaller","asc",a?o:n,a?na:oa);return $s((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Vs(e))),void 0===i?a?t[n-1][l]:t[l][o-1]:(n=i.length,o=i[0].length,$s((()=>1===n||1===o),r("The result_range must be a single row or a single column.")),n>1?($s((()=>l<=n-1),r("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),i[l][0]):($s((()=>l<=o-1),r("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),i[0][l]))},isExported:!0},Gd={description:r("Position of item in range that matches value."),args:_s(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${r("The one-dimensional array to be searched.")}\n search_type (number, default=1) ${r("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.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){let n=Ps(i);const o=Bs(e),s=t.length,a=t[0].length;$s((()=>1===s||1===a),r("The range must be a single row or a single column."));let l=-1;const c=1===s?na:oa,h=1===s?t[0].length:t.length;switch(n=Math.sign(n),n){case 1:l=ra(t,o,"nextSmaller","asc",h,c);break;case 0:l=sa(t,o,"strict",h,c);break;case-1:l=ra(t,o,"nextGreater","desc",h,c)}return $s((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Vs(e))),l+1},isExported:!0},qd={description:r("Row number of a specified cell."),args:_s(`cell_reference (meta, default=${r("The cell in which the formula is entered by default")}) ${r("The cell whose row number will be returned.")}`),returns:["NUMBER"],compute:function(e){var t;e=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this)),$s((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Mi(e).top+1},isExported:!0},Zd={description:r("Number of rows in a specified array or range."),args:_s(`range (meta) ${r("The range whose row count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=Mi(e);return t.bottom-t.top+1},isExported:!0},jd={description:r("Vertical lookup."),args:_s(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${r("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")}\n index (number) ${r("The column index of the value to be returned, where the first column in range is numbered 1.")}\n is_sorted (boolean, default=true) ${r("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.")}\n `),returns:["ANY"],compute:function(e,t,i,n=true){const o=Math.trunc(Ps(i)),s=Bs(e);$s((()=>1<=o&&o<=t.length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=Ws(n);let l;return l=a?ra(t,s,"nextSmaller","asc",t[0].length,na):sa(t,s,"strict",t[0].length,na),$s((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Vs(e))),t[o-1][l]},isExported:!0},Yd={description:r("Search a range for a match and return the corresponding item from a second range."),args:_s(`\n search_key (any) ${r("The value to search for.")}\n lookup_range (any, range) ${r("The range to consider for the search. Should be a single column or a single row.")}\n return_range (any, range) ${r("The range containing the return value. Should have the same dimensions as lookup_range.")}\n if_not_found (any, lazy, optional) ${r("If a valid match is not found, return this value.")}\n match_mode (any, default=0) ${r("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match.")}\n search_mode (any, default=1) ${r("(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. ")}\n\n `),returns:["ANY"],compute:function(e,t,i,n,o=0,s=1){const a=Math.trunc(Ps(o)),l=Math.trunc(Ps(s)),c=Bs(e);$s((()=>1===t.length||1===t[0].length),r("lookup_range should be either a single row or single column.")),$s((()=>1===i.length||1===i[0].length),r("return_range should be either a single row or single column.")),$s((()=>i.length===t.length&&i[0].length===t[0].length),r("return_range should have the same dimensions as lookup_range.")),$s((()=>[-1,1,-2,2].includes(l)),r("searchMode should be a value in [-1, 1, -2, 2].")),$s((()=>[-1,0,1].includes(a)),r("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?na:oa,d=1===t.length?t[0].length:t.length,u=0===a?"strict":1===a?"nextGreater":"nextSmaller",g=-1===l;let p;if(2===l||-2===l){p=ra(t,c,u,2===l?"asc":"desc",d,h)}else p=sa(t,c,u,d,h,g);if(-1!==p)return 1===t.length?i[0][p]:i[p][0];const m=null==n?void 0:n();return $s((()=>!!m),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Vs(e))),m},isExported:!0};var Xd=Object.freeze({__proto__:null,COLUMN:Vd,COLUMNS:zd,HLOOKUP:Bd,INDEX:Hd,LOOKUP:Wd,MATCH:Gd,ROW:qd,ROWS:Zd,VLOOKUP:jd,XLOOKUP:Yd});const Kd={description:r("Sum of two numbers."),args:_s(`\n value1 (number) ${r("The first addend.")}\n value2 (number) ${r("The second addend.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Ps(e)+Ps(t)}},Qd={description:r("Concatenation of two values."),args:_s(`\n value1 (string) ${r("The value to which value2 will be appended.")}\n value2 (string) ${r("The value to append to value1.")}\n `),returns:["STRING"],compute:function(e,t){return Vs(e)+Vs(t)},isExported:!0},Jd={description:r("One number divided by another."),args:_s(`\n dividend (number) ${r("The number to be divided.")}\n divisor (number) ${r("The number to divide by.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){const i=Ps(t);return $s((()=>0!==i),r("The divisor must be different from zero.")),Ps(e)/i}};function eu(e){return null==e}const tu={number:0,string:"",boolean:!1},iu={description:r("Equal."),args:_s(`\n value1 (any) ${r("The first value.")}\n value2 (any) ${r("The value to test against value1 for equality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return e=eu(e)?tu[typeof t]:e,t=eu(t)?tu[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function nu(e,t,i){e=eu(e)?tu[typeof t]:e,t=eu(t)?tu[typeof e]:t,"number"!=typeof e&&(e=Vs(e).toUpperCase()),"number"!=typeof t&&(t=Vs(t).toUpperCase());const n=typeof e,o=typeof t;return"string"===n&&"number"===o||("string"!==o||"number"!==n)&&i(e,t)}const ou={description:r("Strictly greater than."),args:_s(`\n value1 (any) ${r("The value to test as being greater than value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return nu(e,t,((e,t)=>e>t))}},ru={description:r("Greater than or equal to."),args:_s(`\n value1 (any) ${r("The value to test as being greater than or equal to value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return nu(e,t,((e,t)=>e>=t))}},su={description:r("Less than."),args:_s(`\n value1 (any) ${r("The value to test as being less than value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!ru.compute(e,t)}},au={description:r("Less than or equal to."),args:_s(`\n value1 (any) ${r("The value to test as being less than or equal to value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!ou.compute(e,t)}},lu={description:r("Difference of two numbers."),args:_s(`\n value1 (number) ${r("The minuend, or number to be subtracted from.")}\n value2 (number) ${r("The subtrahend, or number to subtract from value1.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Ps(e)-Ps(t)}},cu={description:r("Product of two numbers"),args:_s(`\n factor1 (number) ${r("The first multiplicand.")}\n factor2 (number) ${r("The second multiplicand.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Ps(e)*Ps(t)}},hu={description:r("Not equal."),args:_s(`\n value1 (any) ${r("The first value.")}\n value2 (any) ${r("The value to test against value1 for inequality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!iu.compute(e,t)}},du={description:r("A number raised to a power."),args:_s(`\n base (number) ${r("The number to raise to the exponent power.")}\n exponent (number) ${r("The exponent to raise base to.")}\n `),returns:["NUMBER"],compute:function(e,t){return ja.compute(e,t)}},uu={description:r("A number with the sign reversed."),args:_s(`\n value (number) ${r("The number to have its sign reversed. Equivalently, the number to multiply by -1.")}\n `),computeFormat:e=>null==e?void 0:e.format,returns:["NUMBER"],compute:function(e){return-Ps(e)}},gu={description:r("Value interpreted as a percentage."),args:_s(`\n percentage (number) ${r("The value to interpret as a percentage.")}\n `),returns:["NUMBER"],compute:function(e){return Ps(e)/100}},pu={description:r("A specified number, unchanged."),args:_s(`\n value (any) ${r("The number to return.")}\n `),returns:["ANY"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){return null===e?"":e}};var mu=Object.freeze({__proto__:null,ADD:Kd,CONCAT:Qd,DIVIDE:Jd,EQ:iu,GT:ou,GTE:ru,LT:su,LTE:au,MINUS:lu,MULTIPLY:cu,NE:hu,POW:du,UMINUS:uu,UNARY_PERCENT:gu,UPLUS:pu});const fu=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,vu={description:r("Gets character associated with number."),args:_s(`\n table_number (number) ${r("The number of the character to look up from the current Unicode table in decimal format.")}\n `),returns:["STRING"],compute:function(e){const t=Math.trunc(Ps(e));return $s((()=>t>=1),r("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},bu={description:r("Remove non-printable characters from a piece of text."),args:_s(`\n text (string) ${r("The text whose non-printable characters are to be removed.")}\n `),returns:["STRING"],compute:function(e){const t=Vs(e);let i="";for(const e of t)e&&e.charCodeAt(0)>31&&(i+=e);return i},isExported:!0},Su={description:r("Appends strings to one another."),args:_s(`\n string1 (string, range<string>) ${r("The initial string.")}\n string2 (string, range<string>, repeating) ${r("More strings to append in sequence.")}\n `),returns:["STRING"],compute:function(...e){return Xs(e,((e,t)=>e+Vs(t)),"")},isExported:!0},Cu={description:r("Tests whether two strings are identical."),args:_s(`\n string1 (string) ${r("The first string to compare.")}\n string2 (string) ${r("The second string to compare.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return Vs(e)===Vs(t)},isExported:!0},Eu={description:r("First position of string found in text, case-sensitive."),args:_s(`\n search_for (string) ${r("The string to look for within text_to_search.")}\n text_to_search (string) ${r("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${r("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){const n=Vs(e),o=Vs(t),s=Ps(i);$s((()=>""!==o),r("The text_to_search must be non-empty.")),$s((()=>s>=1),r("The starting_at (%s) must be greater than or equal to 1.",s.toString()));const a=o.indexOf(n,s-1);return $s((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",n.toString(),o)),a+1},isExported:!0},wu={description:r("Concatenates elements of arrays with delimiter."),args:_s(`\n delimiter (string) ${r("The character or string to place between each concatenated value.")}\n value_or_array1 (string, range<string>) ${r("The value or values to be appended using delimiter.")}\n value_or_array2 (string, range<string>, repeating) ${r("More values to be appended using delimiter.")}\n `),returns:["STRING"],compute:function(e,...t){const i=Vs(e);return Xs(t,((e,t)=>(e?e+i:"")+Vs(t)),"")}},yu={description:r("Substring from beginning of specified string."),args:_s(`\n text (string) ${r("The string from which the left portion will be returned.")}\n number_of_characters (number, optional) ${r("The number of characters to return from the left side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const i=t.length?Ps(t[0]):1;return $s((()=>i>=0),r("The number_of_characters (%s) must be positive or null.",i.toString())),Vs(e).substring(0,i)},isExported:!0},xu={description:r("Length of a string."),args:_s(`\n text (string) ${r("The string whose length will be returned.")}\n `),returns:["NUMBER"],compute:function(e){return Vs(e).length},isExported:!0},Ru={description:r("Converts a specified string to lowercase."),args:_s(`\n text (string) ${r("The string to convert to lowercase.")}\n `),returns:["STRING"],compute:function(e){return Vs(e).toLowerCase()},isExported:!0},Iu={description:r("A segment of a string."),args:_s(`\n text (string) ${r("The string to extract a segment from.")}\n starting_at (number) ${r("The index from the left of string from which to begin extracting. The first character in string has the index 1.")}\n extract_length (number) ${r("The length of the segment to extract.")}\n `),returns:["STRING"],compute:function(e,t,i){const n=Vs(e),o=Ps(t),s=Ps(i);return $s((()=>o>=1),r("The starting_at argument (%s) must be positive greater than one.",o.toString())),$s((()=>s>=0),r("The extract_length argument (%s) must be positive or null.",s.toString())),n.slice(o-1,o+s-1)},isExported:!0},Tu={description:r("Capitalizes each word in a specified string."),args:_s(`\n text_to_capitalize (string) ${r("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase.")}\n `),returns:["STRING"],compute:function(e){return Vs(e).replace(fu,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},Au={description:r("Replaces part of a text string with different text."),args:_s(`\n text (string) ${r("The text, a part of which will be replaced.")}\n position (number) ${r("The position where the replacement will begin (starting from 1).")}\n length (number) ${r("The number of characters in the text to be replaced.")}\n new_text (string) ${r("The text which will be inserted into the original text.")}\n `),returns:["STRING"],compute:function(e,t,i,n){const o=Ps(t);$s((()=>o>=1),r("The position (%s) must be greater than or equal to 1.",o.toString()));const s=Vs(e),a=Ps(i),l=Vs(n);return s.substring(0,o-1)+l+s.substring(o-1+a)},isExported:!0},Nu={description:r("A substring from the end of a specified string."),args:_s(`\n text (string) ${r("The string from which the right portion will be returned.")}\n number_of_characters (number, optional) ${r("The number of characters to return from the right side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const i=t.length?Ps(t[0]):1;$s((()=>i>=0),r("The number_of_characters (%s) must be positive or null.",i.toString()));const n=Vs(e),o=n.length;return n.substring(o-i,o)},isExported:!0},Mu={description:r("First position of string found in text, ignoring case."),args:_s(`\n search_for (string) ${r("The string to look for within text_to_search.")}\n text_to_search (string) ${r("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${r("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,i=1){const n=Vs(e).toLowerCase(),o=Vs(t).toLowerCase(),s=Ps(i);$s((()=>""!==o),r("The text_to_search must be non-empty.")),$s((()=>s>=1),r("The starting_at (%s) must be greater than or equal to 1.",s.toString()));const a=o.indexOf(n,s-1);return $s((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",n,o)),a+1},isExported:!0},Ou={description:r("Replaces existing text with new text in a string."),args:_s(`\n text_to_search (string) ${r("The text within which to search and replace.")}\n search_for (string) ${r("The string to search for within text_to_search.")}\n replace_with (string) ${r("The string that will replace search_for.")}\n occurrence_number (number, optional) ${r("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.")}\n `),returns:["NUMBER"],compute:function(e,t,i,n){const o=Ps(n);$s((()=>o>=0),r("The occurrenceNumber (%s) must be positive or null.",o.toString()));const s=Vs(e),a=Vs(t);if(""===a)return s;const l=Vs(i),c=new RegExp(Te(a),"g");if(0===o)return s.replace(c,l);let h=0;return s.replace(c,(e=>++h===o?l:e))},isExported:!0},_u={description:r("Combines text from multiple strings and/or arrays."),args:_s(`\n delimiter (string) ${r(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")}\n ignore_empty (boolean) ${r("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")}\n text1 (string, range<string>) ${r("Any text item. This could be a string, or an array of strings in a range.")}\n text2 (string, range<string>, repeating) ${r("Additional text item(s).")}\n `),returns:["STRING"],compute:function(e,t,...i){const n=Vs(e),o=Ws(t);let r=0;return Xs(i,((e,t)=>o&&""===Vs(t)?e:(r++?e+n:"")+Vs(t)),"")},isExported:!0},Fu={description:r("Removes space characters."),args:_s(`\n text (string) ${r("The text or reference to a cell containing text to be trimmed.")}\n `),returns:["STRING"],compute:function(e){return Vs(e).trim()},isExported:!0},Du={description:r("Converts a specified string to uppercase."),args:_s(`\n text (string) ${r("The string to convert to uppercase.")}\n `),returns:["STRING"],compute:function(e){return Vs(e).toUpperCase()},isExported:!0},ku={description:r("Converts a number to text according to a specified format."),args:_s(`\n number (number) ${r("The number, date or time to format.")}\n format (string) ${r("The pattern by which to format the number, enclosed in quotation marks.")}\n `),returns:["STRING"],compute:function(e,t){return Qt(Ps(e),Vs(t))},isExported:!0};const $u={database:vc,date:Xc,financial:Cd,info:Md,lookup:Xd,logical:Ud,math:ul,misc:ca,operators:mu,statistical:ic,text:Object.freeze({__proto__:null,CHAR:vu,CLEAN:bu,CONCATENATE:Su,EXACT:Cu,FIND:Eu,JOIN:wu,LEFT:yu,LEN:xu,LOWER:Ru,MID:Iu,PROPER:Tu,REPLACE:Au,RIGHT:Nu,SEARCH:Mu,SUBSTITUTE:Ou,TEXTJOIN:_u,TRIM:Fu,UPPER:Du,TEXT:ku}),engineering:Qc},Lu=/^[A-Z0-9\_\.]+$/;function Pu(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>Uu(e()):Uu(e)}))}function Uu(e){return Array.isArray(e)?e.map((e=>e.map((e=>null==e?void 0:e.value)))):null==e?void 0:e.value}const Vu=new class extends tn{constructor(){super(...arguments),this.mapping={}}add(e,t){if(!(e=e.toUpperCase()).match(Lu))throw new Error(r("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const i=Ds(t);return function(e){let t=!1,i=!1,n=!1;for(let o of e){if(o.type.includes("META")&&o.type.length>1)throw new Error(r("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&&!o.repeating)throw new Error(r("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=i||t||n,s=!(o.optional||o.repeating||o.default);if(e&&s)throw new Error(r("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=o.repeating,i=o.optional,n=o.default}}(i.args),this.mapping[e]=function(...e){const t=i.compute.bind(this),n=i.computeFormat?i.computeFormat.bind(this):()=>{};return{value:t(...Pu(e)),format:n(...e)}},super.add(e,i),this}};for(let e in $u){const t=$u[e];for(let i in t){const n=t[i];n.category=e,i=i.replace(/_/g,"."),Vu.add(i,{isExported:!1,...n})}}const zu=Vu.content,Bu=["%"],Hu="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(Bu);function Wu(e){const t=e.split(""),i=[];for(;t.length;){let e=tg(t)||Zu(t)||Yu(t)||Ku(t)||Gu(t)||ig(t)||Xu(t)||Ju(t);e||(e={type:"UNKNOWN",value:t.shift()}),i.push(e)}return i}function Gu(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const qu={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function Zu(e){if(e[0]in qu){const t=e.shift();return{type:qu[t],value:t}}return null}function ju(e,t){for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function Yu(e){for(let t of Hu)if(ju(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function Xu(e){const t=et(e).match(pi);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function Ku(e){if('"'===e[0]){const t=e.shift();let i=t;for(;e[0]&&(e[0]!==t||"\\"===i[i.length-1]);)i+=e.shift();return'"'===e[0]&&(i+=e.shift()),{type:"STRING",value:i}}return null}const Qu=/\w|\.|!|\$/;function Ju(e){let t="";if("'"===e[0]){let i=e.shift();for(t+=i;e[0];)if(i=e.shift(),t+=i,"'"===i){if(!e[0]||"'"!==e[0])break;i=e.shift(),t+=i}if("'"!==i)return{type:"UNKNOWN",value:t}}for(;e[0]&&e[0].match(Qu);)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in zu)return{type:"FUNCTION",value:e};return e.match(Mt)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}const eg=/\s/;function tg(e){let t=0;for(;e[0]&&e[0].match(eg);)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function ig(e){return ju(e,X)?(e.splice(0,X.length),{type:"INVALID_REFERENCE",value:X}):null}const ng=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,og=["-","+"],rg=["%"],sg=["*","+","&"],ag={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10},lg=6;function cg(e){switch(e.type){case"NUMBER":case"SYMBOL":case"REFERENCE":return 0;case"COMMA":return 3;case"LEFT_PAREN":case"RIGHT_PAREN":return 5;case"OPERATOR":return ag[e.value]||15}throw new Error(r("Unknown token: %s",e.value))}function hg(e,t,i){if("OPERATOR"===t.type){const n=cg(t);if(rg.includes(t.value))return{type:"UNARY_OPERATION",value:t.value,operand:e,postfix:!0};{const o=dg(i,n);return{type:"BIN_OPERATION",value:t.value,left:e,right:o}}}throw new Error(ne)}function dg(e,t){const i=e.shift();if(!i)throw new Error(ne);let n=function(e,t){var i,n,o,s;switch(e.type){case"DEBUGGER":const a=dg(t,1e3);return a.debug=!0,a;case"NUMBER":return{type:"NUMBER",value:wi(e.value)};case"STRING":return{type:"STRING",value:Ie(e.value)};case"FUNCTION":if("LEFT_PAREN"!==t.shift().type)throw new Error(r("Wrong function call"));{const n=[];if(t[0]&&"RIGHT_PAREN"!==t[0].type)for("COMMA"===t[0].type?n.push({type:"UNKNOWN",value:""}):n.push(dg(t,lg));"COMMA"===(null===(i=t[0])||void 0===i?void 0:i.type);){t.shift();const e=t[0];if("RIGHT_PAREN"===(null==e?void 0:e.type)){n.push({type:"UNKNOWN",value:""});break}"COMMA"===(null==e?void 0:e.type)?n.push({type:"UNKNOWN",value:""}):n.push(dg(t,lg))}const o=t.shift();if(!o||"RIGHT_PAREN"!==o.type)throw new Error(r("Wrong function call"));return{type:"FUNCALL",value:e.value,args:n}}case"INVALID_REFERENCE":throw new u;case"REFERENCE":if(":"===(null===(n=t[0])||void 0===n?void 0:n.value)&&"REFERENCE"===(null===(o=t[1])||void 0===o?void 0:o.type)){t.shift();const i=t.shift();return{type:"REFERENCE",value:`${e.value}:${null==i?void 0:i.value}`}}return{type:"REFERENCE",value:e.value};case"SYMBOL":if(["TRUE","FALSE"].includes(e.value.toUpperCase()))return{type:"BOOLEAN",value:"TRUE"===e.value.toUpperCase()};if(e.value){if(ng.test(e.value)&&"LEFT_PAREN"===(null===(s=t[0])||void 0===s?void 0:s.type))throw new p(e.value);throw new Error(r("Invalid formula"))}return{type:"STRING",value:e.value};case"LEFT_PAREN":const l=dg(t,5);if(!t.length||"RIGHT_PAREN"!==t[0].type)throw new Error(r("Unmatched left parenthesis"));return t.shift(),l;default:if("OPERATOR"===e.type&&og.includes(e.value))return{type:"UNARY_OPERATION",value:e.value,operand:dg(t,ag[e.value])};throw new Error(r("Unexpected token: %s",e.value))}}(i,e);for(;e[0]&&cg(e[0])>t;)n=hg(n,e.shift(),e);return n}function ug(e){return gg(Wu(e))}function gg(e){"OPERATOR"===(e=e.filter((e=>"SPACE"!==e.type)))[0].type&&"="===e[0].value&&e.splice(0,1);const t=dg(e,0);if(e.length)throw new Error(ne);return t}function pg(e,t,i){switch(t===e.type&&(e=i(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>pg(e,t,i)))};case"UNARY_OPERATION":return{...e,operand:pg(e.operand,t,i)};case"BIN_OPERATION":return{...e,right:pg(e.right,t,i),left:pg(e.left,t,i)};default:return e}}function mg(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>mg(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?fg(e)+e.value:e.value+vg(e);case"BIN_OPERATION":return fg(e)+e.value+vg(e)}}function fg(e){const t=e.value,i="left"in e?e.left:e.operand,n=i.value;return"BIN_OPERATION"===i.type&&ag[n]<ag[t]?`(${mg(i)})`:mg(i)}function vg(e){const t=e.value,i="right"in e?e.right:e.operand,n=ag[i.value],o=ag[t];let r=!1;return"BIN_OPERATION"!==i.type?r=!1:n<o?r=!0:n!==o||sg.includes(t)||(r=!0),r?`(${mg(i)})`:mg(i)}var bg;!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"}(bg||(bg={}));const Sg=(e,t=(()=>!0))=>[{goTo:e,guard:t}],Cg=(e,t=(()=>!0))=>({goTo:e,guard:t}),Eg={[bg.LeftRef]:{REFERENCE:Sg(bg.Separator),NUMBER:Sg(bg.FullRowSeparator),SYMBOL:[Cg(bg.FullColumnSeparator,(e=>Ot(e.value))),Cg(bg.FullRowSeparator,(e=>_t(e.value)))]},[bg.FullColumnSeparator]:{SPACE:Sg(bg.FullColumnSeparator),OPERATOR:Sg(bg.RightColumnRef,(e=>":"===e.value))},[bg.FullRowSeparator]:{SPACE:Sg(bg.FullRowSeparator),OPERATOR:Sg(bg.RightRowRef,(e=>":"===e.value))},[bg.Separator]:{SPACE:Sg(bg.Separator),OPERATOR:Sg(bg.RightRef,(e=>":"===e.value))},[bg.RightRef]:{SPACE:Sg(bg.RightRef),NUMBER:Sg(bg.Found),REFERENCE:Sg(bg.Found,(e=>kt(e.value))),SYMBOL:Sg(bg.Found,(e=>Ft(e.value)||Dt(e.value)))},[bg.RightColumnRef]:{SPACE:Sg(bg.RightColumnRef),SYMBOL:Sg(bg.Found,(e=>Ft(e.value))),REFERENCE:Sg(bg.Found,(e=>kt(e.value)))},[bg.RightRowRef]:{SPACE:Sg(bg.RightRowRef),NUMBER:Sg(bg.Found),REFERENCE:Sg(bg.Found,(e=>kt(e.value))),SYMBOL:Sg(bg.Found,(e=>Dt(e.value)))},[bg.Found]:{}};function wg(e){var t;let i=0,n=Eg[bg.LeftRef],o="";for(;void 0!==n;){const r=e[i++];if(!r)return null;const s=null===(t=n[r.type])||void 0===t?void 0:t.find((e=>e.guard(r))),a=s?s.goTo:void 0;switch(a){case void 0:return null;case bg.Found:return o+=r.value,e.splice(0,i),{type:"REFERENCE",value:o};default:n=Eg[a],o+=r.value}}return null}function yg(e){const t=Wu(e),i=[];for(;t.length;)i.push(wg(t)||t.shift());return i}const xg=Vu.content,Rg={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},Ig={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"};function Tg(e){return e.join("\n").split("\n").filter((e=>""!==e.trim()))}const Ag={};function Ng(e){const t=yg(e),{dependencies:i,constantValues:n}=function(e){const t={numbers:[],strings:[]},i=[];for(const n of e)switch(n.type){case"INVALID_REFERENCE":case"REFERENCE":i.push(n.value);break;case"STRING":const e=Ie(n.value);t.strings.includes(e)||t.strings.push(e);break;case"NUMBER":{const e=wi(n.value);t.numbers.includes(e)||t.numbers.push(e);break}}return{dependencies:i,constantValues:t}}(t),o=function(e,t,i){return et(e.map((e=>{switch(e.type){case"STRING":const n=Ie(e.value);return`|S${i.strings.indexOf(n)}|`;case"NUMBER":return`|N${i.numbers.indexOf(wi(e.value))}|`;case"REFERENCE":case"INVALID_REFERENCE":return`|${t.indexOf(e.value)}|`;case"SPACE":return"";default:return e.value}})))}(t,i,n);if(!Ag[o]){const s=gg([...t]);let a=1;if("BIN_OPERATION"===s.type&&":"===s.value)throw new Error(r("Invalid formula"));if("UNKNOWN"===s.type)throw new Error(r("Invalid formula"));const l=u(s),c=Tg([`// ${o}`,l.code,`return ${l.id};`]).join("\n");let h=new Function("deps","ref","range","ctx",c);function d(e){const t=xg[e.value.toUpperCase()],i=e.args,n=i.length;if(n<t.minArgRequired)throw new Error(r("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",e.value.toUpperCase(),t.minArgRequired.toString(),n.toString()));if(n>t.maxArgPossible)throw new Error(r("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",e.value.toUpperCase(),t.maxArgPossible.toString(),n.toString()));const o=t.nbrArgRepeating;if(o>1){const i=t.args.length-o;if((n-i)%o!=0)throw new Error(r("Invalid number of arguments for the %s function. Expected all arguments after position %s to be supplied by groups of %s arguments",e.value.toUpperCase(),i.toString(),o.toString()))}let s=[];for(let o=0;o<n;o++){const n=t.getArgToFocus(o+1)-1;if(0<=n&&n<t.args.length){const a=i[o],l=t.args[n],c=l.type||[],h=c.includes("META"),d=l.lazy,g=c.some((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e)),p=c.every((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e));if(p&&"REFERENCE"!==a.type)throw new Error(r("Function %s expects the parameter %s to be reference to a cell or range, not a %s.",e.value.toUpperCase(),(o+1).toString(),a.type.toLowerCase()));const m=u(a,d,h,g,{functionName:e.value.toUpperCase(),paramIndex:o+1});s.push(m)}}return s}function u(e,t=!1,o=!1,s=!1,l={}){const c=[];let h,g,p;if("REFERENCE"!==e.type&&("BIN_OPERATION"!==e.type||":"!==e.value)&&o)throw new Error(r("Argument must be a reference to a cell or range."));switch(e.debug&&c.push("debugger;"),e.type){case"BOOLEAN":if(!t)return{id:`{ value: ${e.value} }`,code:""};h=a++,p=`{ value: ${e.value} }`;break;case"NUMBER":h=a++,p=`{ value: this.constantValues.numbers[${n.numbers.indexOf(e.value)}] }`;break;case"STRING":h=a++,p=`{ value: this.constantValues.strings[${n.strings.indexOf(e.value)}] }`;break;case"REFERENCE":const r=i.indexOf(e.value);h=a++,p=s?`range(deps[${r}])`:`ref(deps[${r}], ${o?"true":"false"}, "${l.functionName||Rg["="]}", ${l.paramIndex})`;break;case"FUNCALL":h=a++;const m=d(e);c.push(m.map((e=>e.code)).join("\n")),g=e.value.toUpperCase(),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${m.map((e=>e.id))})`;break;case"UNARY_OPERATION":{h=a++,g=Ig[e.value];const t=u(e.operand,!1,!1,!1,{functionName:g});c.push(t.code),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${t.id})`;break}case"BIN_OPERATION":{h=a++,g=Rg[e.value];const t=u(e.left,!1,!1,!1,{functionName:g}),i=u(e.right,!1,!1,!1,{functionName:g});c.push(t.code),c.push(i.code),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${t.id}, ${i.id})`;break}case"UNKNOWN":if(!t)return{id:"undefined",code:""};h=a++,p="undefined"}if(t){return{id:`_${h}`,code:`const _${h} = () => {\n\t${Tg(c).join("\n\t")}\n\treturn ${p};\n}`}}return c.push(`let _${h} = ${p};`),{id:`_${h}`,code:c.join("\n")}}Ag[o]={execute:h}}return{execute:Ag[o].execute,dependencies:i,constantValues:n,tokens:t}}function Mg(e){return function(e){let t=[],i="";return e.map(((e,n)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(i=""),e.type){case"FUNCTION":i=e.value;break;case"LEFT_PAREN":t.push({parent:i,argPosition:0}),i="";break;case"RIGHT_PAREN":t.pop();break;case"COMMA":t.length&&t[t.length-1].argPosition++}if(t.length){const i=t[t.length-1];i.parent&&(e.functionContext=Object.assign({},i))}return e}))}(function(e){let t=1;const i=[];return e.map((e=>("LEFT_PAREN"===e.type?(i.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=i.pop()),e)))}(function(e){let t=0;return e.map((e=>{const i=e.value.toString().length,n=Object.assign({},e,{start:t,end:t+i,length:i});return t=n.end,n}))}(yg(e))))}function Og(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:i}=$t(e.value),[n,o]=t.split(":"),r=i?`${Me(i)}!`:"",s=_g(n),a=o?`:${_g(o)}`:"";return{...e,value:r+s+a}}function _g(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=Fg(e,"colrow");break;case"colrow":e=Fg(e,"row");break;case"row":e=Fg(e,"col");break;case"col":e=Fg(e,"none")}return e}function Fg(e,t){let i;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return i=e.search(/[0-9]/),e.slice(0,i)+"$"+e.slice(i);case"colrow":return i=e.search(/[0-9]/),-1===i||0===i?"$"+e:"$"+(e=e.slice(0,i)+"$"+e.slice(i));case"none":return e}}class Dg{constructor(e,t,i){this.history=Object.assign(Object.create(e),{update:e.addChange.bind(e,this),selectCell:()=>{}}),this.dispatch=t}exportForExcel(e){}allowDispatch(e){return 0}beforeHandle(e){}handle(e){}finalize(){}batchValidations(...e){return t=>e.map((e=>e.call(this,t))).flat()}chainValidations(...e){return t=>{for(const i of e){let e=i.call(this,t);Array.isArray(e)||(e=[e]);const n=e.filter((e=>0!==e));if(n.length)return n}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}Dg.getters=[];class kg extends Dg{constructor(e,t,i,n,o){super(t,i,n),this.getters=e,this.ui=n,this.selection=o}drawGrid(e,t){}}kg.layers=[];const $g=r("The cell you are trying to edit has been deleted.");class Lg extends kg{constructor(){super(...arguments),this.col=0,this.row=0,this.mode="inactive",this.sheetId="",this.currentContent="",this.currentTokens=[],this.selectionStart=0,this.selectionEnd=0,this.selectionInitialStart=0,this.initialContent="",this.previousRef="",this.previousRange=void 0,this.colorIndexByRange={}}allowDispatch(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":return this.validateSelection(this.currentContent.length,e.start,e.end);case"SET_CURRENT_CONTENT":return e.selection?this.validateSelection(e.content.length,e.selection.start,e.selection.end):0;case"START_EDITION":if(e.selection){const t=this.getters.getActiveCell(),i=e.text||(null==t?void 0:t.composerContent)||"";return this.validateSelection(i.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handleEvent(e){if("selecting"===this.mode)if("newAnchor"===e.mode)this.insertSelectedRange(e.anchor.zone);else this.replaceSelectedRanges(e.anchor.zone)}handle(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":this.selectionStart=e.start,this.selectionEnd=e.end;break;case"STOP_COMPOSER_RANGE_SELECTION":this.isSelectingForComposer()&&(this.mode="editing");break;case"START_EDITION":this.startEdition(e.text,e.selection),this.updateRangeColor();break;case"STOP_EDITION":e.cancel?(this.cancelEditionAndActivateSheet(),this.resetContent()):this.stopEdition(),this.colorIndexByRange={};break;case"SET_CURRENT_CONTENT":this.setContent(e.content,e.selection,!0),this.updateRangeColor();break;case"REPLACE_COMPOSER_CURSOR_SELECTION":this.replaceSelection(e.text);break;case"SELECT_FIGURE":this.cancelEditionAndActivateSheet(),this.resetContent();break;case"ADD_COLUMNS_ROWS":this.onAddElements(e);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case"START_CHANGE_HIGHLIGHT":this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=this.getters.getRangeFromRangeData(e.range),i=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:i,sheetName:n}=$t(e.value),o=n||this.getters.getSheetName(this.sheetId),r=this.getters.getActiveSheetId();if(this.getters.getSheetName(r)!==o)return!1;const s=this.getters.getRangeFromSheetXC(r,i);return Ui(this.getters.expandZone(r,s.zone),t.zone)}));this.previousRef=i.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=i.start;break;case"CHANGE_HIGHLIGHT":const n=this.getters.getRangeFromRangeData(e.range),o=this.getRangeReference(n,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(o),this.previousRef=o,this.selectionStart=this.currentContent.length,this.selectionEnd=this.currentContent.length;break;case"ACTIVATE_SHEET":if(this.currentContent.startsWith("=")||(this.cancelEdition(),this.resetContent()),e.sheetIdFrom!==e.sheetIdTo){const{col:t,row:i}=this.getters.getNextVisibleCellPosition(e.sheetIdTo,0,0),n=this.getters.expandZone(e.sheetIdTo,Ki({col:t,row:i}));this.selection.resetAnchor(this,{cell:{col:t,row:i},zone:n})}break;case"DELETE_SHEET":case"UNDO":case"REDO":!!this.getters.tryGetSheet(this.sheetId)||"inactive"===this.mode||(this.sheetId=this.getters.getActiveSheetId(),this.cancelEditionAndActivateSheet(),this.resetContent(),this.ui.notifyUI({type:"ERROR",text:$g}));break;case"CYCLE_EDITION_REFERENCES":this.cycleReferences()}}getEditionMode(){return this.mode}getCurrentContent(){if("inactive"===this.mode){const e=this.getters.getActiveCell();return(null==e?void 0:e.composerContent)||""}return this.currentContent}getEditionSheet(){return this.sheetId}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}isSelectingForComposer(){return"selecting"===this.mode}showSelectionIndicator(){return this.isSelectingForComposer()&&this.canStartComposerRangeSelection()}getCurrentTokens(){return this.currentTokens}getTokenAtCursor(){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((i=>i.start<=e&&i.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const i=e.map(Og).map((e=>e.value)).join(""),n=this.currentContent,o=e[0].start,r=e[e.length-1].end,s=n.slice(0,o)+i+n.slice(r),a=s.length-n.length,l={start:t[0].start,end:t[t.length-1].end+a};1===t.length&&this.selectionStart===this.selectionEnd&&(l.start=l.end),this.dispatch("SET_CURRENT_CONTENT",{content:s,selection:l})}validateSelection(e,t,i){return t>=0&&t<=e&&i>=0&&i<=e?0:46}onColumnsRemoved(e){if(e.elements.includes(this.col)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:$g});const{top:t,left:i}=ki({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=i,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:$g});const{top:t,left:i}=ki({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=i,this.row=t}onAddElements(e){const{top:t,left:i}=Di({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=i,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=Ki({col:this.col,row:this.row});this.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.mode="selecting",this.selectionInitialStart=this.selectionStart}startEdition(e,t){var i;const n=this.getters.getActiveCell();e&&(null===(i=null==n?void 0:n.format)||void 0===i?void 0:i.includes("%"))&&Ci(e)&&(t=t||{start:e.length,end:e.length},e=`${e}%`),this.initialContent=(null==n?void 0:n.composerContent)||"",this.mode="editing";const{col:o,row:r}=this.getters.getPosition();this.col=o,this.row=r,this.sheetId=this.getters.getActiveSheetId(),this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const s=Ki({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:s},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if("inactive"!==this.mode){const e=this.getters.getActiveSheetId();this.cancelEditionAndActivateSheet();const{col:t,row:i}=this.getters.getMainCellPosition(this.sheetId,this.col,this.row);let n=this.currentContent;if(!(this.initialContent!==n))return;if(n){const o=this.getters.getCell(e,t,i);if(n.startsWith("=")){const e=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length,t=this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length,i=e-t;i>0&&(n+=et(new Array(i).fill(")")))}else(null==o?void 0:o.isLink())&&(n=We(n,o.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:t,row:i,content:n})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:t,row:i});this.setContent("")}}cancelEditionAndActivateSheet(){if("inactive"===this.mode)return;this.cancelEdition();this.getters.getActiveSheetId()!==this.sheetId&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,i){e=e.replace(/[\r\n]/g,"");const n=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(n||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?Mg(e):[],this.currentTokens.length>100&&i&&this.ui.notifyUI({type:"ERROR",text:r("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells")})),this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(i,t),this.selectionInitialStart=t):(this.insertText(","+i,t),this.selectionInitialStart=t+1)}replaceSelectedRanges(e){const t=this.getZoneReference(e);this.replaceText(t,this.selectionInitialStart,this.selectionEnd)}getZoneReference(e,t=[{colFixed:!1,rowFixed:!1}]){const i=this.getters.getActiveSheetId();let n=this.getters.zoneToXC(i,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){n=`${Me(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${n}`}return n}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){1===t.length&&Ji(e.zone)>1?t.push({...t[0]}):2===t.length&&1===Ji(e.zone)&&t.pop();const i=e.clone({parts:this.previousRange.parts});return this.getters.getSelectionRangeString(i,this.getters.getEditionSheet())}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,i)}replaceText(e,t,i){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(i,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const i=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),n=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:i,selection:{start:n,end:n}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getEditionSheet(),t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),i={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(i[e]=this.colorIndexByRange[e]);const n=new Set(Object.values(i));let o=0;const r=()=>{for(;n.has(o);)o++;return n.add(o),o};for(const e of t){const t=e in i?i[e]:r();i[e]=t}this.colorIndexByRange=i}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getEditionSheet(),t=e=>{const t=this.colorIndexByRange[e];return ut[t%ut.length]};return this.getReferencedRanges().map((i=>{const n=this.getters.getRangeString(i,e);return{zone:i.zone,color:t(n),sheetId:i.sheetId}}))}getReferencedRanges(){const e=this.getters.getEditionSheet();return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value))).filter((e=>!e.invalidSheetName&&!e.invalidXc))}canStartComposerRangeSelection(){if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let i=t,n=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(n.type)||Bu.includes(n.value);){if("SPACE"!==n.type||i<1)return!1;i--,n=this.currentTokens[i]}for(i=t+1,n=this.currentTokens[i];n&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(n.type);){if("SPACE"!==n.type)return!1;i++,n=this.currentTokens[i]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((i=>i.start<=e&&i.end>=e||i.start>=e&&i.start<t))}}Lg.getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights"];const Pg=Vu.content,Ug=new tn;Ug.add("functions",(()=>Object.keys(Pg).map((e=>({text:e,description:Pg[e].description}))))),Cn`
984
984
  .o-autocomplete-dropdown {
985
985
  pointer-events: auto;
986
986
  background-color: #fff;
@@ -2432,4 +2432,4 @@
2432
2432
  <tableParts count="${e.filterTables.length}">
2433
2433
  ${yf(a)}
2434
2434
  </tableParts>
2435
- `}var mS;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(mS||(mS={}));const fS={},vS={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:M,HEADER_WIDTH:O,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:_,DEFAULT_CELL_HEIGHT:F,SCROLLBAR_WIDTH:D},bS={autofillModifiersRegistry:sn,autofillRulesRegistry:vn,cellMenuRegistry:zo,colMenuRegistry:Bo,linkMenuRegistry:Gn,functionRegistry:Vu,uiPluginRegistry:ob,corePluginRegistry:nb,rowMenuRegistry:Ho,sidePanelRegistry:bs,figureRegistry:Kn,sheetMenuRegistry:Go,chartSidePanelComponentRegistry:cs,chartComponentRegistry:on,chartRegistry:nn,topbarMenuRegistry:Jo,topbarComponentRegistry:Ss,clickableCellRegistry:rb,otRegistry:er,inverseCommandRegistry:Qn,cellRegistry:Yn,cellPopoverRegistry:jn},SS={LinkCell:Ap},CS={args:_s,toBoolean:Ws,toJsDate:Gs,toNumber:Ps,toString:Vs,toXC:Vt,toZone:Mi,toCartesian:Ut,numberToLetters:Lt,createFullMenuItem:Bn,UuidGenerator:Ai,formatValue:Qt,computeTextWidth:_e,isMarkdownLink:He,parseMarkdownLink:Ge,markdownLink:We,createEmptyWorkbookData:Yf,createEmptySheet:jf,createEmptyExcelSheet:Xf,getDefaultChartJsRuntime:Tr,chartFontColor:br,getMenuChildren:Nn,ChartColors:vr,EvaluationError:c,CellErrorLevel:l,getFillingMode:Mr,rgbaToHex:Ct,colorToRGBA:Et,positionToZone:Ki},ES={ChartPanel:hs,ChartFigure:xs,ChartJsComponent:rn,Grid:Ep,GridOverlay:rp,ScorecardChart:Es,LineConfigPanel:rs,LineBarPieDesignPanel:ts,BarConfigPanel:or,LineBarPieConfigPanel:nr,GaugeChartConfigPanel:ns,GaugeChartDesignPanel:os,ScorecardChartConfigPanel:as,ScorecardChartDesignPanel:ls};e.AbstractChart=rr,e.CorePlugin=Kf,e.DATETIME_FORMAT=Y,e.DispatchResult=gn,e.EvaluationError=c,e.Model=class extends Vv{constructor(e={},i={},n=[],o=new Ai,r=!0){super(),this.corePlugins=[],this.uiPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.handlers=[],this.coreHandlers=[],this.dispatch=(e,t)=>{const i={type:e,...t};let n=this.status;if(this.getters.isReadonly()&&(o=i,!hn.has(o.type)))return new gn(67);var o;if(!this.session.canApplyOptimisticUpdate())return new gn(64);switch(n){case 0:const t=this.checkDispatchAllowed(i);if(!t.isSuccessful)return t;this.status=1;const{changes:n,commands:o}=this.state.recordChanges((()=>{un(i)&&this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i),this.finalize()}));this.session.save(o,n),this.status=0,this.trigger("update");break;case 1:if(un(i)){const e=this.checkDispatchAllowed(i);if(!e.isSuccessful)return e;this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i)}else this.dispatchToHandlers(this.handlers,i);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(un(i))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,i)}return gn.Success},this.dispatchFromCorePlugin=(e,t)=>{const i={type:e,...t},n=this.status;this.status=2;const o=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(o,i),this.status=n,gn.Success},n=qf(e,n);const s=Wf(e,r);this.state=new Mb,this.uuidGenerator=o,this.config=this.setupConfig(i),this.session=this.setupSession(s.revisionId),this.config.moveClient=this.session.move.bind(this.session),this.history=new Ib(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new Tb(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getSelectionRangeString=this.range.getSelectionRangeString.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode,canUndo:this.history.canUndo.bind(this.history),canRedo:this.history.canRedo.bind(this.history),getClient:this.session.getClient.bind(this.session),getConnectedClients:this.session.getConnectedClients.bind(this.session),isFullySynchronized:this.session.isFullySynchronized.bind(this.session)},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new Nb(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range);for(let e of nb.getAll())this.setupCorePlugin(e,s);Object.assign(this.getters,this.coreGetters);for(let e of ob.getAll())this.setupUiPlugin(e);this.uuidGenerator.setIsFastStrategy(!1),this.handlers.push(this.history),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.session.loadInitialMessages(n),this.joinSession(),i.snapshotRequested&&this.session.snapshot(this.exportData()),t.markRaw(this)}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.getters,this.state,this.dispatch,this.config,this.selection);for(let i of e.getters){if(!(i in t))throw new Error(`Invalid getter name: ${i} for plugin ${t.constructor}`);if(i in this.getters)throw new Error(`Getter "${i}" is already defined.`);this.getters[i]=t[i].bind(t)}this.uiPlugins.push(t),this.handlers.push(t);const i=e.layers.map((e=>[t,e]));this.renderers.push(...i),this.renderers.sort(((e,t)=>e[1]-t[1]))}setupCorePlugin(e,t){const i=new e(this.coreGetters,this.state,this.range,this.dispatchFromCorePlugin,this.config,this.uuidGenerator);for(let t of e.getters){if(!(t in i))throw new Error(`Invalid getter name: ${t} for plugin ${i.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=i[t].bind(i)}i.import(t),this.corePlugins.push(i),this.coreHandlers.push(i),this.handlers.push(i)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.uiPlugins,t),this.status=e}this.finalize()}setupSession(e){return new Yv(xb(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1)})),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-redone",this,this.finalize),this.session.on("revision-undone",this,this.finalize),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:r("Anonymous").toString()},i=e.transportService||new mb;return{...e,mode:e.mode||"normal",evalContext:e.evalContext||{},transportService:i,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e)}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return t.some((e=>0!==e))?new gn(t.flat()):gn.Success}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){t=Ae(t);for(const i of e)i.beforeHandle(t);for(const i of e)i.handle(t)}drawGrid(e){for(let[t,i]of this.renderers)e.ctx.save(),t.drawGrid(e,i),e.ctx.restore()}exportData(){let e=Yf();for(let t of this.handlers)t instanceof Kf&&t.export(e);return e.revisionId=this.session.getRevisionId()||K,e=Ae(e),e}updateMode(e){"normal"!==e&&this.dispatch("STOP_EDITION",{cancel:!0}),this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...Yf(),sheets:[Xf(Hf,"Sheet1")]};for(let t of this.handlers)t instanceof Dg&&t.exportForExcel(e);return e=Ae(e),gS(e)}},e.Registry=tn,e.Revision=Zv,e.SPREADSHEET_DIMENSIONS=vS,e.Spreadsheet=pb,e.UIPlugin=kg,e.__info__=fS,e.addFunction=function(e,t){Vu.add(e,t)},e.astToFormula=mg,e.cellTypes=SS,e.compile=Ng,e.components=ES,e.convertAstNodes=pg,e.coreTypes=dn,e.findCellInNewZone=Yi,e.functionCache=Ag,e.helpers=CS,e.invalidateEvaluationCommands=ln,e.load=Wf,e.parse=ug,e.readonlyAllowedCommands=hn,e.registries=bS,e.setTranslationMethod=function(e){i=e},e.tokenize=Wu,Object.defineProperty(e,"__esModule",{value:!0}),fS.version="16.0.40",fS.date="2024-04-26T07:39:46.758Z",fS.hash="70a6783"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
2435
+ `}var mS;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(mS||(mS={}));const fS={},vS={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:M,HEADER_WIDTH:O,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:_,DEFAULT_CELL_HEIGHT:F,SCROLLBAR_WIDTH:D},bS={autofillModifiersRegistry:sn,autofillRulesRegistry:vn,cellMenuRegistry:zo,colMenuRegistry:Bo,linkMenuRegistry:Gn,functionRegistry:Vu,uiPluginRegistry:ob,corePluginRegistry:nb,rowMenuRegistry:Ho,sidePanelRegistry:bs,figureRegistry:Kn,sheetMenuRegistry:Go,chartSidePanelComponentRegistry:cs,chartComponentRegistry:on,chartRegistry:nn,topbarMenuRegistry:Jo,topbarComponentRegistry:Ss,clickableCellRegistry:rb,otRegistry:er,inverseCommandRegistry:Qn,cellRegistry:Yn,cellPopoverRegistry:jn},SS={LinkCell:Ap},CS={args:_s,toBoolean:Ws,toJsDate:Gs,toNumber:Ps,toString:Vs,toXC:Vt,toZone:Mi,toCartesian:Ut,numberToLetters:Lt,createFullMenuItem:Bn,UuidGenerator:Ai,formatValue:Qt,computeTextWidth:_e,isMarkdownLink:He,parseMarkdownLink:Ge,markdownLink:We,createEmptyWorkbookData:Yf,createEmptySheet:jf,createEmptyExcelSheet:Xf,getDefaultChartJsRuntime:Tr,chartFontColor:br,getMenuChildren:Nn,ChartColors:vr,EvaluationError:c,CellErrorLevel:l,getFillingMode:Mr,rgbaToHex:Ct,colorToRGBA:Et,positionToZone:Ki},ES={ChartPanel:hs,ChartFigure:xs,ChartJsComponent:rn,Grid:Ep,GridOverlay:rp,ScorecardChart:Es,LineConfigPanel:rs,LineBarPieDesignPanel:ts,BarConfigPanel:or,LineBarPieConfigPanel:nr,GaugeChartConfigPanel:ns,GaugeChartDesignPanel:os,ScorecardChartConfigPanel:as,ScorecardChartDesignPanel:ls};e.AbstractChart=rr,e.CorePlugin=Kf,e.DATETIME_FORMAT=Y,e.DispatchResult=gn,e.EvaluationError=c,e.Model=class extends Vv{constructor(e={},i={},n=[],o=new Ai,r=!0){super(),this.corePlugins=[],this.uiPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.handlers=[],this.coreHandlers=[],this.dispatch=(e,t)=>{const i={type:e,...t};let n=this.status;if(this.getters.isReadonly()&&(o=i,!hn.has(o.type)))return new gn(67);var o;if(!this.session.canApplyOptimisticUpdate())return new gn(64);switch(n){case 0:const t=this.checkDispatchAllowed(i);if(!t.isSuccessful)return t;this.status=1;const{changes:n,commands:o}=this.state.recordChanges((()=>{un(i)&&this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i),this.finalize()}));this.session.save(o,n),this.status=0,this.trigger("update");break;case 1:if(un(i)){const e=this.checkDispatchAllowed(i);if(!e.isSuccessful)return e;this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i)}else this.dispatchToHandlers(this.handlers,i);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(un(i))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,i)}return gn.Success},this.dispatchFromCorePlugin=(e,t)=>{const i={type:e,...t},n=this.status;this.status=2;const o=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(o,i),this.status=n,gn.Success},n=qf(e,n);const s=Wf(e,r);this.state=new Mb,this.uuidGenerator=o,this.config=this.setupConfig(i),this.session=this.setupSession(s.revisionId),this.config.moveClient=this.session.move.bind(this.session),this.history=new Ib(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new Tb(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getSelectionRangeString=this.range.getSelectionRangeString.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode,canUndo:this.history.canUndo.bind(this.history),canRedo:this.history.canRedo.bind(this.history),getClient:this.session.getClient.bind(this.session),getConnectedClients:this.session.getConnectedClients.bind(this.session),isFullySynchronized:this.session.isFullySynchronized.bind(this.session)},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new Nb(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range);for(let e of nb.getAll())this.setupCorePlugin(e,s);Object.assign(this.getters,this.coreGetters);for(let e of ob.getAll())this.setupUiPlugin(e);this.uuidGenerator.setIsFastStrategy(!1),this.handlers.push(this.history),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.session.loadInitialMessages(n),this.joinSession(),i.snapshotRequested&&this.session.snapshot(this.exportData()),t.markRaw(this)}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.getters,this.state,this.dispatch,this.config,this.selection);for(let i of e.getters){if(!(i in t))throw new Error(`Invalid getter name: ${i} for plugin ${t.constructor}`);if(i in this.getters)throw new Error(`Getter "${i}" is already defined.`);this.getters[i]=t[i].bind(t)}this.uiPlugins.push(t),this.handlers.push(t);const i=e.layers.map((e=>[t,e]));this.renderers.push(...i),this.renderers.sort(((e,t)=>e[1]-t[1]))}setupCorePlugin(e,t){const i=new e(this.coreGetters,this.state,this.range,this.dispatchFromCorePlugin,this.config,this.uuidGenerator);for(let t of e.getters){if(!(t in i))throw new Error(`Invalid getter name: ${t} for plugin ${i.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=i[t].bind(i)}i.import(t),this.corePlugins.push(i),this.coreHandlers.push(i),this.handlers.push(i)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.uiPlugins,t),this.status=e}this.finalize()}setupSession(e){return new Yv(xb(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1)})),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-redone",this,this.finalize),this.session.on("revision-undone",this,this.finalize),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:r("Anonymous").toString()},i=e.transportService||new mb;return{...e,mode:e.mode||"normal",evalContext:e.evalContext||{},transportService:i,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e)}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return t.some((e=>0!==e))?new gn(t.flat()):gn.Success}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){t=Ae(t);for(const i of e)i.beforeHandle(t);for(const i of e)i.handle(t)}drawGrid(e){for(let[t,i]of this.renderers)e.ctx.save(),t.drawGrid(e,i),e.ctx.restore()}exportData(){let e=Yf();for(let t of this.handlers)t instanceof Kf&&t.export(e);return e.revisionId=this.session.getRevisionId()||K,e=Ae(e),e}updateMode(e){"normal"!==e&&this.dispatch("STOP_EDITION",{cancel:!0}),this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...Yf(),sheets:[Xf(Hf,"Sheet1")]};for(let t of this.handlers)t instanceof Dg&&t.exportForExcel(e);return e=Ae(e),gS(e)}},e.Registry=tn,e.Revision=Zv,e.SPREADSHEET_DIMENSIONS=vS,e.Spreadsheet=pb,e.UIPlugin=kg,e.__info__=fS,e.addFunction=function(e,t){Vu.add(e,t)},e.astToFormula=mg,e.cellTypes=SS,e.compile=Ng,e.components=ES,e.convertAstNodes=pg,e.coreTypes=dn,e.findCellInNewZone=Yi,e.functionCache=Ag,e.helpers=CS,e.invalidateEvaluationCommands=ln,e.load=Wf,e.parse=ug,e.readonlyAllowedCommands=hn,e.registries=bS,e.setTranslationMethod=function(e){i=e},e.tokenize=Wu,Object.defineProperty(e,"__esModule",{value:!0}),fS.version="16.0.41",fS.date="2024-05-15T09:15:13.021Z",fS.hash="3b3f648"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
@@ -3239,7 +3239,7 @@ https://fontawesome.com/license -->
3239
3239
  </t>
3240
3240
  </odoo>
3241
3241
  <!--
3242
- __info__.version = '16.0.40';
3243
- __info__.date = '2024-04-26T07:40:08.573Z';
3244
- __info__.hash = '70a6783';
3242
+ __info__.version = '16.0.41';
3243
+ __info__.date = '2024-05-15T09:15:35.373Z';
3244
+ __info__.hash = '3b3f648';
3245
3245
  -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odoo/o-spreadsheet",
3
- "version": "16.0.40",
3
+ "version": "16.0.41",
4
4
  "description": "A spreadsheet component",
5
5
  "main": "dist/o-spreadsheet.cjs.js",
6
6
  "browser": "dist/o-spreadsheet.iife.js",