@odoo/o-spreadsheet 18.0.83 → 18.0.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 18.0.83
6
- * @date 2026-10-10T06:31:52.656Z
7
- * @hash 22b9b73
5
+ * @version 18.0.84
6
+ * @date 2026-10-14T06:49:38.664Z
7
+ * @hash 56a1fca
8
8
  */
9
9
 
10
10
  import { Component, markRaw, onMounted, onPatched, onWillPatch, onWillStart, onWillUnmount, onWillUpdateProps, status, toRaw, useChildSubEnv, useComponent, useEffect, useEnv, useExternalListener, useRef, useState, useSubEnv, xml } from "@odoo/owl";
@@ -2211,7 +2211,7 @@ const globalIdCounter = /* @__PURE__ */ new WeakMap();
2211
2211
  function getItemId(item, itemsDic) {
2212
2212
  if (!globalReverseLookup$1.has(itemsDic)) {
2213
2213
  globalReverseLookup$1.set(itemsDic, /* @__PURE__ */ new Map());
2214
- const maxId = Math.max(...Object.keys(itemsDic).map(parseInt), 0);
2214
+ const maxId = Math.max(...Object.keys(itemsDic).map(Number), 0);
2215
2215
  globalIdCounter.set(itemsDic, maxId);
2216
2216
  }
2217
2217
  const reverseLookup = globalReverseLookup$1.get(itemsDic);
@@ -3732,7 +3732,7 @@ function visitMatchingRanges(args, cb, locale, isQuery = false) {
3732
3732
  for (let i = 0; i < countArg - 1; i += 2) {
3733
3733
  const criteriaRange = toMatrix(args[i]);
3734
3734
  if (criteriaRange.length !== dimRow || criteriaRange[0].length !== dimCol) throw new EvaluationError(_t("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));
3735
- const predicate = getPredicate(toString(args[i + 1]), locale);
3735
+ const predicate = getPredicate(toLocaleString(args[i + 1], locale), locale);
3736
3736
  if (isQuery && typeof predicate.operand === "string") predicate.operand += "*";
3737
3737
  predicates.push(predicate);
3738
3738
  }
@@ -40124,7 +40124,7 @@ var PivotSpreadsheetSidePanel = class extends Component {
40124
40124
  return this.pivot.isInvalidRange;
40125
40125
  }
40126
40126
  get ranges() {
40127
- if (this.state.range) return [this.state.range];
40127
+ if (this.state.rangeHasChanged) return this.state.range ? [this.state.range] : [];
40128
40128
  if (this.definition.range) return [this.env.model.getters.getRangeString(this.definition.range, "forceSheetReference")];
40129
40129
  return [];
40130
40130
  }
@@ -40139,25 +40139,23 @@ var PivotSpreadsheetSidePanel = class extends Component {
40139
40139
  }
40140
40140
  onSelectionChanged(ranges) {
40141
40141
  this.state.rangeHasChanged = true;
40142
- if (ranges.length === 0) {
40143
- this.state.range = void 0;
40144
- return;
40145
- }
40146
- const sheetId = this.env.model.getters.getActiveSheetId();
40147
- const range = this.env.model.getters.getRangeFromSheetXC(sheetId, ranges[0]);
40148
- this.state.range = this.env.model.getters.getRangeString(range, "forceSheetReference", { useBoundedReference: true });
40142
+ this.state.range = ranges[0];
40149
40143
  }
40150
40144
  onSelectionConfirmed() {
40151
- if (this.state.range) {
40152
- const range = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.state.range);
40153
- if (range.invalidSheetName || range.invalidXc) return;
40154
- const dataSet = {
40155
- sheetId: range.sheetId,
40156
- zone: range.zone
40157
- };
40158
- this.store.update({ dataSet });
40159
- this.store.applyUpdate();
40145
+ if (!this.state.range) {
40146
+ const pivotRange = this.definition.range;
40147
+ this.state.range = pivotRange ? this.env.model.getters.getRangeString(pivotRange, "forceSheetReference") : void 0;
40148
+ return;
40160
40149
  }
40150
+ const range = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.state.range);
40151
+ if (range.invalidSheetName || range.invalidXc) return;
40152
+ this.state.range = this.env.model.getters.getRangeString(range, "forceSheetReference", { useBoundedReference: true });
40153
+ const dataSet = {
40154
+ sheetId: range.sheetId,
40155
+ zone: range.zone
40156
+ };
40157
+ this.store.update({ dataSet });
40158
+ this.store.applyUpdate();
40161
40159
  }
40162
40160
  flipAxis() {
40163
40161
  const { rows, columns } = this.definition;
@@ -66520,6 +66518,6 @@ const constants = {
66520
66518
  //#endregion
66521
66519
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, PivotRuntimeDefinition, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, SpreadsheetPivotTable, UIPlugin, __info__, addFunction, addRenderingLayer, astToFormula, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, stores, tokenColors, tokenize };
66522
66520
 
66523
- __info__.version = "18.0.83";
66524
- __info__.date = "2026-10-10T06:31:52.656Z";
66525
- __info__.hash = "22b9b73";
66521
+ __info__.version = "18.0.84";
66522
+ __info__.date = "2026-10-14T06:49:38.664Z";
66523
+ __info__.hash = "56a1fca";
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 18.0.83
6
- * @date 2026-10-10T06:31:52.656Z
7
- * @hash 22b9b73
5
+ * @version 18.0.84
6
+ * @date 2026-10-14T06:49:38.664Z
7
+ * @hash 56a1fca
8
8
  */
9
9
 
10
10
  (function(exports, _odoo_owl) {
@@ -2213,7 +2213,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2213
2213
  function getItemId(item, itemsDic) {
2214
2214
  if (!globalReverseLookup$1.has(itemsDic)) {
2215
2215
  globalReverseLookup$1.set(itemsDic, /* @__PURE__ */ new Map());
2216
- const maxId = Math.max(...Object.keys(itemsDic).map(parseInt), 0);
2216
+ const maxId = Math.max(...Object.keys(itemsDic).map(Number), 0);
2217
2217
  globalIdCounter.set(itemsDic, maxId);
2218
2218
  }
2219
2219
  const reverseLookup = globalReverseLookup$1.get(itemsDic);
@@ -3734,7 +3734,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3734
3734
  for (let i = 0; i < countArg - 1; i += 2) {
3735
3735
  const criteriaRange = toMatrix(args[i]);
3736
3736
  if (criteriaRange.length !== dimRow || criteriaRange[0].length !== dimCol) throw new EvaluationError(_t("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));
3737
- const predicate = getPredicate(toString(args[i + 1]), locale);
3737
+ const predicate = getPredicate(toLocaleString(args[i + 1], locale), locale);
3738
3738
  if (isQuery && typeof predicate.operand === "string") predicate.operand += "*";
3739
3739
  predicates.push(predicate);
3740
3740
  }
@@ -40126,7 +40126,7 @@ stores.inject(MyMetaStore, storeInstance);
40126
40126
  return this.pivot.isInvalidRange;
40127
40127
  }
40128
40128
  get ranges() {
40129
- if (this.state.range) return [this.state.range];
40129
+ if (this.state.rangeHasChanged) return this.state.range ? [this.state.range] : [];
40130
40130
  if (this.definition.range) return [this.env.model.getters.getRangeString(this.definition.range, "forceSheetReference")];
40131
40131
  return [];
40132
40132
  }
@@ -40141,25 +40141,23 @@ stores.inject(MyMetaStore, storeInstance);
40141
40141
  }
40142
40142
  onSelectionChanged(ranges) {
40143
40143
  this.state.rangeHasChanged = true;
40144
- if (ranges.length === 0) {
40145
- this.state.range = void 0;
40146
- return;
40147
- }
40148
- const sheetId = this.env.model.getters.getActiveSheetId();
40149
- const range = this.env.model.getters.getRangeFromSheetXC(sheetId, ranges[0]);
40150
- this.state.range = this.env.model.getters.getRangeString(range, "forceSheetReference", { useBoundedReference: true });
40144
+ this.state.range = ranges[0];
40151
40145
  }
40152
40146
  onSelectionConfirmed() {
40153
- if (this.state.range) {
40154
- const range = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.state.range);
40155
- if (range.invalidSheetName || range.invalidXc) return;
40156
- const dataSet = {
40157
- sheetId: range.sheetId,
40158
- zone: range.zone
40159
- };
40160
- this.store.update({ dataSet });
40161
- this.store.applyUpdate();
40147
+ if (!this.state.range) {
40148
+ const pivotRange = this.definition.range;
40149
+ this.state.range = pivotRange ? this.env.model.getters.getRangeString(pivotRange, "forceSheetReference") : void 0;
40150
+ return;
40162
40151
  }
40152
+ const range = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.state.range);
40153
+ if (range.invalidSheetName || range.invalidXc) return;
40154
+ this.state.range = this.env.model.getters.getRangeString(range, "forceSheetReference", { useBoundedReference: true });
40155
+ const dataSet = {
40156
+ sheetId: range.sheetId,
40157
+ zone: range.zone
40158
+ };
40159
+ this.store.update({ dataSet });
40160
+ this.store.applyUpdate();
40163
40161
  }
40164
40162
  flipAxis() {
40165
40163
  const { rows, columns } = this.definition;
@@ -66566,8 +66564,8 @@ exports.stores = stores;
66566
66564
  exports.tokenColors = tokenColors;
66567
66565
  exports.tokenize = tokenize;
66568
66566
 
66569
- __info__.version = "18.0.83";
66570
- __info__.date = "2026-10-10T06:31:52.656Z";
66571
- __info__.hash = "22b9b73";
66567
+ __info__.version = "18.0.84";
66568
+ __info__.date = "2026-10-14T06:49:38.664Z";
66569
+ __info__.hash = "56a1fca";
66572
66570
 
66573
66571
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
@@ -1,7 +1,7 @@
1
1
  (function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),l=(e,t)=>{let n={};for(var i in e)r(n,i,{get:e[i],enumerable:!0});return t||r(n,Symbol.toStringTag,{value:`Module`}),n},u=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;l<u;l++)d=c[l],!s.call(e,d)&&d!==n&&r(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e},d=(e,t,i)=>(i=e==null?{}:n(o(e)),u(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e));function f(e){return e.map(m).sort((e,t)=>e.sequence-t.sequence)}let p=1;function m(e){let t=e.name,n=e.children,r=e.description,i=e.icon,a=e.secondaryIcon;return{id:(e.id||p++).toString(),name:typeof t==`function`?t:()=>t,isVisible:e.isVisible?e.isVisible:()=>!0,isEnabled:e.isEnabled?e.isEnabled:()=>!0,isActive:e.isActive,execute:e.execute,children:n?e=>n.map(t=>typeof t==`function`?t(e):t).flat().map(m).sort((e,t)=>e.sequence-t.sequence):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:typeof i==`function`?i:()=>i||``,iconColor:e.iconColor,secondaryIcon:typeof a==`function`?a:()=>a||``,description:typeof r==`function`?r:()=>r||``,textColor:e.textColor,sequence:e.sequence||0,onStartHover:e.onStartHover,onStopHover:e.onStopHover}}var h=class{content={};add(e,t){return this.content[e]=t,this}get(e){let t=this.content[e];if(!t&&!(e in this.content))throw Error(`Cannot find ${e} in this registry!`);return t}contains(e){return e in this.content}getAll(){return Object.values(this.content)}getKeys(){return Object.keys(this.content)}remove(e){delete this.content[e]}};let g=.5,_=`#37A850`,v=`#f5f5f5`,ee=`#F8F9FA`,te=`#E8EAED`,ne=`#595959`,re=`#666666`,ie=`#c9ccd2`,ae=`#3266ca`,oe=`#FFFFFF`,se=`#CACACA`,ce=11982760,le=`#017E84`,ue=`#188038`,de=`#E0E2E4`,fe=`#4A4F59`,pe=`#999`,me=`#E2E3E3`,he=`#BCBCBC`,ge=`#9B359B`,_e=`#4EA7F2`,ve=`#EA6175`,ye=`#AAAAAA`,be=`#111827`,xe=`#D8DADD`,Se=`#E7E9ED`,Ce=`#F9FAFB`,we=`#374151`,Te=`#374151C2`,Ee=`#111827`,De=`#714B67`,Oe=xe,ke=`#111827`,Ae=`#e6f2f3`,je=`#111827`,Me=`#017E84`,Ne=`#D44C591A`,Pe=`#C34A41`,Fe=`#E6F2F3`,Ie=`#000000.#434343.#666666.#999999.#B7B7B7.#CCCCCC.#D9D9D9.#EFEFEF.#F3F3F3.#FFFFFF.#980000.#FF0000.#FF9900.#FFFF00.#00FF00.#00FFFF.#4A86E8.#0000FF.#9900FF.#FF00FF.#E6B8AF.#F4CCCC.#FCE5CD.#FFF2CC.#D9EAD3.#D0E0E3.#C9DAF8.#CFE2F3.#D9D2E9.#EAD1DC.#DD7E6B.#EA9999.#F9CB9C.#FFE599.#B6D7A8.#A2C4C9.#A4C2F4.#9FC5E8.#B4A7D6.#D5A6BD.#CC4125.#E06666.#F6B26B.#FFD966.#93C47D.#76A5AF.#6D9EEB.#6FA8DC.#8E7CC3.#C27BA0.#A61C00.#CC0000.#E69138.#F1C232.#6AA84F.#45818E.#3C78D8.#3D85C6.#674EA7.#A64D79.#85200C.#990000.#B45F06.#BF9000.#38761D.#134F5C.#1155CC.#0B5394.#351C75.#741B47.#5B0F00.#660000.#783F04.#7F6000.#274E13.#0C343D.#1C4587.#073763.#20124D.#4C1130`.split(`.`),Le={align:`left`,verticalAlign:`bottom`,wrapping:`overflow`,bold:!1,italic:!1,strikethrough:!1,underline:!1,fontSize:10,fillColor:``,textColor:``},Re={...Le,align:`right`},ze=Le.verticalAlign,Be=Le.wrapping,Ve=Le.fontSize,He=`'Roboto', arial, 'Liberation Sans'`,Ue={style:`thin`,color:`#000000`},We=`START_REVISION`,Ge=`difference`,Ke=`#43C5B1`,qe=`#EA6175`,Je=[`'`,`*`,`?`,`/`,`\\`,`[`,`]`],Ye=/'|\*|\?|\/|\\|\[|\]/,Xe=0;function Ze(){return Xe}function Qe(e){Xe=e}let $e=.85,et=[6,7,8,9,10,11,12,14,18,24,36],tt={hasFilters:!1,totalRow:!1,firstColumn:!0,lastColumn:!1,numberOfHeaders:1,bandedRows:!0,bandedColumns:!1,styleId:`TableStyleMedium5`,automaticAutofill:!1},nt={symbol:`$`,position:`before`,decimalPlaces:2,code:``,name:`Dollar`},rt=new RegExp(Ye,`g`);function it(e){return e[0]===`"`&&(e=e.slice(1)),e[e.length-1]===`"`&&e[e.length-2]!==`\\`?e.slice(0,e.length-1):e}function at(e){return`clone`in e&&e.clone instanceof Function}function ot(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function y(e){switch(typeof e){case`object`:{if(e===null)return e;if(at(e))return e.clone();if(!(st(e)||e instanceof Array))throw Error(`Unsupported type: only objects and arrays are supported`);let t=Array.isArray(e)?Array(e.length):{};if(Array.isArray(e))for(let n=0,r=e.length;n<r;n++)n in e&&(t[n]=y(e[n]));else for(let n in e)t[n]=y(e[n]);return t}case`number`:case`string`:case`boolean`:case`function`:case`undefined`:return e;default:throw Error(`Unsupported type: ${typeof e}`)}}function st(e){return typeof e==`object`&&!!e&&(e?.constructor===Object||e?.constructor===void 0)}function ct(e){return lt(e,`'`)}function lt(e,t=`"`){return e.startsWith(t)&&(e=e.slice(1)),e.endsWith(t)&&(e=e.slice(0,-1)),e}function ut(e){return e.match(/\w/g)?.length!==e.length&&(e=`'${e}'`),e}function dt(e,t=` `){return e.replace(rt,t)}function b(e,t,n){return e<t?t:e>n?n:e}function x(e,t,n=1){if(t<=e&&n>0)return[];if(n===0)throw Error(`range() step must not be zero`);let r=Math.ceil(Math.abs((t-e)/n)),i=Array(r);for(let t=0;t<r;t++)i[t]=e+t*n;return i}function ft(e){return e.reduce((e,t,n,r)=>(Math.abs(t-r[n-1])===1?e[e.length-1].push(t):e.push([t]),e),[])}function*pt(e,t){t.next();for(let n of e){let e=t.next();yield{...n,next:e.done?void 0:e.value}}}function mt(e){let t=e.toUpperCase();return t===`TRUE`||t===`FALSE`}let ht=/^\[(.+)\]\((.+)\)$/,gt=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function _t(e){return ht.test(e)}function vt(e){return gt.test(e)}function yt(e,t){return`[${e}](${t})`}function bt(e){let t=e.match(ht)||[],n=t[1],r=t[2];if(!n||!r)throw Error(`Could not parse markdown link ${e}.`);return{label:n,url:r}}let xt=`o-spreadsheet://`;function St(e){return e.startsWith(xt)}function Ct(e){return`${xt}${e}`}function wt(e){if(e.startsWith(xt))return e.substr(16);throw Error(`${e} is not a valid sheet link`)}function S(e){return e!==void 0}function Tt(e){return e!==null}function Et(e){return e===void 0?!0:Object.values(e).every(e=>typeof e==`object`?Et(e):!e)}function Dt(e,t,n){let r,i=function(){let i=this,a=Array.from(arguments);function o(){r=void 0,n||e.apply(i,a)}let s=n&&!r;clearTimeout(r),r=setTimeout(o,t),s&&e.apply(i,a)};return i.isDebouncePending=()=>r!==void 0,i.stopDebounce=()=>{clearTimeout(r)},i}function Ot(e){let t=!1;return async(...n)=>{t||(t=!0,await Promise.resolve(),t=!1,e(...n))}}function kt(e){let t=``;for(let n=0,r=e.length;n<r;n++)t+=e[n];return t}function At(e){let t=!1,n,r=()=>(t||=(n=e instanceof Function?e():e,!0),n);return r.map=e=>At(()=>e(r())),r}function jt(e,t){let n=e.slice(t).find(e=>e);return n||=e.slice(0,t).reverse().find(e=>e),n||``}function Mt(e,t){return e===`after`?t+1:t}function C(e,t){if(e===t)return!0;if(e&&!t||t&&!e||typeof e!=typeof t||typeof e!=`object`)return!1;for(let n in t)if(!(n in e)&&t[n]!==void 0)return!1;for(let n in e){if(typeof e[n]!=typeof t[n])return!1;if(typeof e[n]==`object`){if(!C(e[n],t[n]))return!1}else if(e[n]!==t[n])return!1}return!0}function Nt(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!C(e[n],t[n]))return!1;return!0}function Pt(e,t){if(e.length<t.length)return!1;let n=new Set(e);return t.every(e=>n.has(e))}function Ft(e){if(!e)return e;let t={...e};return Object.keys(t).forEach(e=>!t[e]&&delete t[e]),t}let It=[` `,`\f`,`\v`,`\xA0`,` `,` `,` `,`\u2028`,`\u2029`,` `,` `,` `,``],Lt=new RegExp(It.join(`|`),`g`),Rt=/(\r\n|\r)/g,zt=It.concat([` `]);function Bt(e){return e?e.replace(Rt,`
2
2
  `):``}function Vt(e){let t=Array.from(e).sort((e,t)=>e-t);for(let e=1;e<t.length;e++)if(t[e]-t[e-1]!==1)return!1;return!0}function Ht(e){let t=new Map,n=e.name?e.name+` (memoized)`:`memoized`;return{[n](...n){return t.has(n[0])||t.set(n[0],e(...n)),t.get(n[0])}}[n]}function Ut(e,t){let n=new Set(t),r=[];for(let t=0;t<e.length;t++)n.has(t)||r.push(e[t]);return r}function Wt(e,t,n){return e.slice(0,n).concat(t).concat(e.slice(n))}function Gt(e,t,n){let r=[...e];return r.splice(n,1,t),r}function Kt(e){return e.split(`
3
3
  `).map(e=>e.replace(/\s+/g,` `).trim()).join(`
4
- `)}function qt(e,t,n){return t>n?qt(e,n,t):e>=t&&e<=n}function Jt(e,t){let n=ot(e),r=t.matchCase?``:`i`;return t.exactMatch&&(n=`^${n}$`),RegExp(n,r)}function Yt(e){let t=e.length;if(t<1e5)return Math.max(...e);let n=-1/0;for(;t--;)n=e[t]>n?e[t]:n;return n}function Xt(e){let t=e.length;if(t<1e5)return Math.min(...e);let n=1/0;for(;t--;)n=e[t]<n?e[t]:n;return n}var Zt=class{text;currentIndex=0;current;constructor(e){this.text=e,this.current=e[0]}shift(){let e=this.current,t=this.text[++this.currentIndex];return this.current=t,e}advanceBy(e){this.currentIndex+=e,this.current=this.text[this.currentIndex]}isOver(){return this.currentIndex>=this.text.length}remaining(){return this.text.substring(this.currentIndex)}currentStartsWith(e){if(this.current!==e[0])return!1;for(let t=1;t<e.length;t++)if(this.text[this.currentIndex+t]!==e[t])return!1;return!0}};function Qt(e,t=e=>e){let n=new Set;return e.filter(e=>{let r=t(e);return n.has(r)?!1:(n.add(r),!0)})}function $t(e){let t={};for(let n in e)for(let r in e[n])t[r]||(t[r]={}),t[r][n]=e[n][r];return t}let en=/rgba?\(|\s+|\)/gi,tn=/^#([A-F\d]{2}){3,4}$/,nn=[`#eb6d00`,`#0074d9`,`#ad8e00`,`#169ed4`,`#b10dc9`,`#00a82d`,`#00a3a3`,`#f012be`,`#3d9970`,`#111111`,`#62A300`,`#ff4136`,`#949494`,`#85144b`,`#001f3f`];function rn(e){return an(e.toString(16).padStart(6,`0`))}function an(e){let t=e;if(e.startsWith(`rgb`)?t=dn(e):(t=e.replace(`#`,``).toUpperCase(),(t.length===3||t.length===4)&&(t=t.split(``).reduce((e,t)=>e+t+t,``)),t=`#${t}`),!tn.test(t))throw Error(`invalid color input: ${e}`);return t}function on(e){try{return an(e),!0}catch{return!1}}function sn(e){try{return gn(e),!0}catch{return!1}}let cn=e=>e>=0&&e<=255;function ln(e,t,n,r=1){if(!cn(e)||!cn(t)||!cn(n)||r<0||r>1)throw Error(`Invalid RGBA values ${[e,t,n,r]}`);return{a:r,b:n,g:t,r:e}}function un(e){let{r:t,g:n,b:r}=pn(e);t/=255,n/=255,r/=255;let i=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4,a=i(t),o=i(n),s=i(r);return .2126*a+.7152*o+.0722*s}function dn(e){let t=e.replace(en,``).split(`,`),n=255;if(t.length!==3&&t.length!==4)throw Error(`invalid color`);if(t.length===4){let e=parseFloat(t.pop()||`1`);if(isNaN(e))throw Error(`invalid alpha value`);n=Math.round(e*255)}let r=t.map(e=>parseInt(e,10));return n!==255&&r.push(n),`#`+kt(r.map(e=>e.toString(16).padStart(2,`0`))).toUpperCase()}function fn(e){let t=e.r.toString(16),n=e.g.toString(16),r=e.b.toString(16),i=Math.round(e.a*255).toString(16);return t.length===1&&(t=`0`+t),n.length===1&&(n=`0`+n),r.length===1&&(r=`0`+r),i.length===1&&(i=`0`+i),i===`ff`&&(i=``),(`#`+t+n+r+i).toUpperCase()}function pn(e){e=an(e);let t,n,r,i;if(e.length===7)t=parseInt(e[1]+e[2],16),n=parseInt(e[3]+e[4],16),r=parseInt(e[5]+e[6],16),i=255;else if(e.length===9)t=parseInt(e[1]+e[2],16),n=parseInt(e[3]+e[4],16),r=parseInt(e[5]+e[6],16),i=parseInt(e[7]+e[8],16);else throw Error(`Invalid color`);return i=+(i/255).toFixed(3),{a:i,r:t,g:n,b:r}}function mn(e){e={...e},e.s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,n=t*(1-Math.abs(e.h/60%2-1)),r=e.l-t/2,i=0,a=0,o=0;return 0<=e.h&&e.h<60?(i=t,a=n,o=0):60<=e.h&&e.h<120?(i=n,a=t,o=0):120<=e.h&&e.h<180?(i=0,a=t,o=n):180<=e.h&&e.h<240?(i=0,a=n,o=t):240<=e.h&&e.h<300?(i=n,a=0,o=t):300<=e.h&&e.h<360&&(i=t,a=0,o=n),i=Math.round((i+r)*255),a=Math.round((a+r)*255),o=Math.round((o+r)*255),{a:e.a,r:i,g:a,b:o}}function hn(e){let t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=a-i,s=0,c=0,l=0;return s=o===0?0:a===t?(n-r)/o%6:a===n?(r-t)/o+2:(t-n)/o+4,s=Math.round(s*60),s<0&&(s+=360),l=(a+i)/2,c=o===0?0:o/(1-Math.abs(2*l-1)),c=+(c*100).toFixed(1),l=+(l*100).toFixed(1),{a:e.a,h:s,s:c,l}}function gn(e){return fn(mn(e))}function _n(e){return hn(pn(e))}function vn(e,t,n=0){if(!(on(e)&&on(t)))return!1;let r=pn(e),i=pn(t);return r.a===i.a?Math.sqrt(((r.r-i.r)/255)**2+((r.g-i.g)/255)**2+((r.b-i.b)/255)**2)<=n:!1}function yn(e,t){return t===1?an(e).slice(0,7):fn({...pn(e),a:t})}function bn(e,t){let n=_n(e);return t===1?`#fff`:(n.l=t*(100-n.l)+n.l,gn(n))}function xn(e,t){let n=_n(e);return t===1?`#000`:(n.l-=t*n.l,gn(n))}let Sn=[`#4EA7F2`,`#EA6175`,`#43C5B1`,`#F4A261`,`#8481DD`,`#FFD86D`],Cn=[`#4EA7F2`,`#3188E6`,`#43C5B1`,`#00A78D`,`#EA6175`,`#CE4257`,`#F4A261`,`#F48935`,`#8481DD`,`#5752D1`,`#FFD86D`,`#FFBC2C`],wn=[`#4EA7F2`,`#3188E6`,`#056BD9`,`#A76DBC`,`#7F4295`,`#6D2387`,`#EA6175`,`#CE4257`,`#982738`,`#43C5B1`,`#00A78D`,`#0E8270`,`#F4A261`,`#F48935`,`#BE5D10`,`#8481DD`,`#5752D1`,`#3A3580`,`#A4A8B6`,`#7E8290`,`#545B70`,`#FFD86D`,`#FFBC2C`,`#C08A16`],Tn=`#4EA7F2.#3188E6.#056BD9.#155193.#A76DBC.#7F4295.#6D2387.#4F1565.#EA6175.#CE4257.#982738.#791B29.#43C5B1.#00A78D.#0E8270.#105F53.#F4A261.#F48935.#BE5D10.#7D380D.#8481DD.#5752D1.#3A3580.#26235F.#A4A8B6.#7E8290.#545B70.#3F4250.#FFD86D.#FFBC2C.#C08A16.#936A12`.split(`.`);function En(e,t){return t[e%t.length]}function Dn(e){return e<=6?Sn:e<=12?Cn:e<=24?wn:Tn}var On=class{preferredColors;currentColorIndex=0;palette;constructor(e,t=[]){this.preferredColors=t,this.palette=Dn(e).filter(e=>!t.includes(e))}next(){return this.preferredColors?.[this.currentColorIndex]?this.preferredColors[this.currentColorIndex++]:En(this.currentColorIndex++,this.palette)}};function kn(e){if(e<0)throw Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):kn(Math.floor(e/26)-1)+kn(e%26)}function An(e){let t=0,n=e.length;for(let r=0;r<n;r++){let n=jn(e[r]);t=t*26+n}return t-1}function jn(e){let t=e.charCodeAt(0);return t>=65&&t<=90?t-64:t-96}function Mn(e){return e>=`A`&&e<=`Z`||e>=`a`&&e<=`z`}function Nn(e){return e>=`0`&&e<=`9`}let Pn=An(`ZZZ`),Fn=9999998;function In(e){for(;e.current===` `;)e.advanceBy(1)}function Ln(e){if(e.current===`$`&&e.advanceBy(1),!e.current||!Mn(e.current))return-1;let t=0;for(;e.current&&Mn(e.current);)t=t*26+jn(e.shift());return t}function Rn(e){if(e.current===`$`&&e.advanceBy(1),!e.current||!Nn(e.current))return-1;let t=0;for(;e.current&&Nn(e.current);)t=t*10+Number(e.shift());return t}function zn(e){let t=new Zt(e);In(t);let n=Ln(t);if(n===-1||!t.current)throw Error(`Invalid cell description: ${e}`);let r=Rn(t);In(t);let i=n-1,a=r-1;if(!t.isOver()||i>Pn||a>Fn)throw Error(`Invalid cell description: ${e}`);return{col:i,row:a}}function w(e,t,n={colFixed:!1,rowFixed:!1}){return(n.colFixed?`$`:``)+kn(e)+(n.rowFixed?`$`:``)+String(t+1)}function T(e,t=[]){if(e.length<=1&&t.length===0)return e;let n=[0],r=new Map([[0,[]]]);return Bn(n,r,e,!1),Bn(n,r,t,!0),Wn(n,r)}function Bn(e,t,n,r=!1){for(let i of n){let n=i.left,a=i.right===void 0?void 0:i.right+1,o=Vn(e,t,n,!0,0),s=Vn(e,t,a,!1,o);for(let n=o;n<=s;n++)Hn(t.get(e[n]),i,r);Un(e,t,o,s)}}function Vn(e,t,n,r,i){if(n===void 0)return e.length-1;let a=Gn(e,n,i);return n===e[a]?r?a:a-1:(e.splice(a+1,0,n),t.set(n,[...t.get(e[a])]),r?a+1:a)}function Hn(e,t,n=!1){let r=t.top,i=t.bottom===void 0?void 0:t.bottom+1,a=[],o=Gn(e,r,0,!1);if((o%2!=0&&!n||o%2==0&&n)&&a.push(r),i===void 0){e.splice(o+1),e.push(...a);return}let s=Kn(e,i,0,!1);(s%2==0&&!n||s%2!=0&&n)&&a.push(i),e.splice(o+1,s-o-1,...a)}function Un(e,t,n,r){let i=n-1==-1?0:n-1,a=r===e.length-1?r:r+1;for(let n=a;n>i;n--)Nt(t.get(e[n]),t.get(e[n-1]))&&(t.delete(e[n]),e.splice(n,1))}function Wn(e,t){let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=t.get(a);if(!o||o.length===0){n.push(...r),r=[];continue}let s=e[i+1];s!==void 0&&s--;let c=[];for(let e=0;e<o.length;e+=2){let t=o[e],n=o[e+1];n!==void 0&&n--;let i={top:t,left:a,bottom:n,right:s,hasHeader:n===void 0&&t!==0||s===void 0&&a!==0},l=!1;for(let e=r.length-1;e>=0;e--){let t=r[e];if(t.top===i.top&&t.bottom===i.bottom){t.right=i.right,r.splice(e,1),c.push(t),l=!0;break}}l||c.push(i)}n.push(...r),r=c}return n.push(...r),n}function Gn(e,t,n=0,r=!0){let i=e.length-1,a=-1;for(;n<=i;){let o=Math.floor((n+i)/2);if(e[o]===t&&r)return o;e[o]<t?(a=o,n=o+1):i=o-1}return a}function Kn(e,t,n=0,r=!0){let i=e.length-1,a=e.length;for(;n<=i;){let o=Math.floor((n+i)/2);if(e[o]===t&&r)return o;e[o]>t?(a=o,i=o-1):n=o+1}return a}let qn=e=>e,Jn=()=>!1,Yn=qn,Xn=Jn;function Zn(e,...t){if(t.length===1&&typeof t[0]==`object`&&!(t[0]instanceof String)){let n=t[0];e=e.replace(/\%\(([^\)]+)\)s/g,(e,t)=>n[t])}else t.length>0&&(e=e.replace(/\%s/g,()=>t.shift()));return e}function Qn(e,t=()=>!0){Yn=e,Xn=t}function $n(){Yn===qn&&Xn===Jn&&(Xn=()=>!0)}let E=function(e,...t){return Xn()?Zn(Yn(e),...t):new er(e,t)};var er=class extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){let e=super.valueOf();return Xn()?Zn(Yn(e),...this.values):Zn(e,...this.values)}toString(){return this.valueOf()}};function tr(e){let t=new Zt(e);In(t);let n=e.indexOf(`!`);n!==-1&&t.advanceBy(n+1);let r=Ln(t),i=Rn(t),a,o,s,c,l=!1,u=!1,d=!1;if(i===-1?(s=c=r-1,a=o=0,l=!0):r===-1?(a=o=i-1,s=c=0,u=!0):(s=c=r-1,a=o=i-1,d=!0),In(t),t.current===`:`){t.advanceBy(1),In(t);let e=Ln(t),n=Rn(t);n===-1?(c=e-1,l=!0):e===-1?(o=n-1,u=!0):(c=e-1,o=n-1,a=l?o:a,s=u?c:s,d=!0)}let f={top:a,left:s,bottom:l?void 0:o,right:u?void 0:c};return d&&=u||l,d&&(f.hasHeader=d),f}function nr(e){let t=Cr(tr(e)),n=t.bottom,r=t.right;if(n!==void 0&&n>Fn||r!==void 0&&r>Pn)throw Error(`Range string out of bounds: ${e}`);if(n===void 0&&r===void 0)throw Error(`Wrong zone xc. The zone cannot be at the same time a full column and a full row`);return t}function rr(e){let t=nr(e);if(t.bottom===void 0||t.right===void 0)throw Error(`This does not support unbounded ranges`);return t}function ir(e){let{bottom:t,top:n,left:r,right:i}=e;return t!==void 0&&isNaN(t)||isNaN(n)||isNaN(r)||i!==void 0&&isNaN(i)?!1:ar(e)&&e.top>=0&&e.left>=0}function ar(e){return(e.bottom===void 0||e.bottom>=e.top&&e.bottom>=0)&&(e.right===void 0||e.right>=e.left&&e.right>=0)}function or(e){let{top:t,bottom:n,left:r,right:i}=e,a=`hasHeader`in e?e.hasHeader:!1,o=t===n&&r===i;if(n===void 0&&i!==void 0)return t===0&&!a?`${kn(r)}:${kn(i)}`:`${w(r,t)}:${kn(i)}`;if(i===void 0&&n!==void 0)return r===0&&!a?`${t+1}:${n+1}`:`${w(r,t)}:${n+1}`;if(n!==void 0&&i!==void 0)return o?w(r,t):`${w(r,t)}:${w(i,n)}`;throw Error(E(`Bad zone format`))}function sr(e,t,n,r,i){let a=t===`left`?`columns`:`rows`,o=r===`before`?n-1:n,s=e[t===`left`?`right`:`bottom`];return e[t]<=o&&s&&s>o?wr(e,a,`RESIZE`,i):o<e[t]?wr(e,a,`MOVE`,i):{...e}}function cr(e,t,n,r,i){let a=t===`left`?`columns`:`rows`,o=r===`before`?n-1:n,s=t===`left`?`right`:`bottom`;return e[t]<=o&&e[s]>o?wr(e,a,`RESIZE`,i):o<e[t]?wr(e,a,`MOVE`,i):{...e}}function lr(e,t,n){let r=t===`left`?`right`:`bottom`,i=e[t],a=e[r];for(let o of n.sort((e,t)=>t-e))e[t]>o&&(i--,a--),e[t]<o&&e[r]>=o&&a--;return{...e,[t]:i,[r]:a}}function ur(e,t,n){let r=t===`left`?`right`:`bottom`,i=e[t],a=e[r],o=e[r];for(let r of n.sort((e,t)=>t-e))e[t]>r&&(i--,a!==void 0&&a--),o!==void 0&&a!==void 0&&e[t]<=r&&o>=r&&a--;if(!(a!==void 0&&i>a))return{...e,[t]:i,[r]:a}}function dr(...e){return{top:Math.min(...e.map(e=>e.top)),left:Math.min(...e.map(e=>e.left)),bottom:Math.max(...e.map(e=>e.bottom)),right:Math.max(...e.map(e=>e.right))}}function fr(...e){return{top:Math.min(...e.map(e=>e.top)),left:Math.min(...e.map(e=>e.left)),bottom:e.some(e=>e.bottom===void 0)?void 0:Math.max(...e.map(e=>e.bottom)),right:e.some(e=>e.right===void 0)?void 0:Math.max(...e.map(e=>e.right))}}function pr(e,t){if(hr(e,t))return{top:Math.max(e.top,t.top),left:Math.max(e.left,t.left),bottom:Math.min(e.bottom,t.bottom),right:Math.min(e.right,t.right)}}function mr(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function hr(e,t){return!(e.bottom<t.top||t.bottom<e.top||e.right<t.left||t.right<e.left)}function gr(e,t,n){let{left:r,right:i,top:a,bottom:o}=n;return e>=r&&e<=i&&t>=a&&t<=o}function _r(e,t){return mr(dr(t,e),t)}function vr(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function yr(e){let{numberOfCols:t,numberOfRows:n}=vr(e);return t===1||n===1}function br(e){let{top:t,left:n,bottom:r,right:i}=e;if(jr(e)===1)return[];let a={top:t+1,bottom:r,left:n,right:n};if(i===n)return[a];let o={top:t,bottom:r,left:n+1,right:i};return t===r?[o]:[a,o]}function xr(e){let t={};for(let n of e)t[n.sheetId]??=[],t[n.sheetId].push(D(n));for(let e in t)t[e]=T(t[e]);return t}function Sr(e){let t=[],{left:n,right:r,top:i,bottom:a}=Cr(e);for(let e of x(n,r+1))for(let n of x(i,a+1))t.push({col:e,row:n});return t}function Cr(e){return e.right!==void 0&&e.left>e.right&&(e={...e,left:e.right,right:e.left}),e.bottom!==void 0&&e.top>e.bottom&&(e={...e,top:e.bottom,bottom:e.top}),e}function wr(e,t,n,r){let i=t===`both`?r[0]:t===`columns`?r:0,a=t===`both`?r[1]:t===`rows`?r:0,o=`hasHeader`in e?e.hasHeader:!1,s;s=Ar(e)&&!o?t!==`rows`:kr(e)&&!o?t!==`columns`:!0;let c={...e};return s&&n===`MOVE`&&(c.left+=i,c.top+=a),c.right!==void 0&&(c.right+=i),c.bottom!==void 0&&(c.bottom+=a),c}function Tr(e){return e.reverse().filter((e,t,n)=>t===n.findIndex(t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)).reverse()}function Er(e){return e.reduce((e,t)=>{let n=e.length;for(let r=0;r<n;r++)if(hr(e[r],t))return e[r]=dr(e[r],t),e;return e[n]=t,e},[])}function Dr(e,t){let n,r,{left:i,right:a,top:o,bottom:s}=e,{left:c,right:l,top:u,bottom:d}=t;return n=c===i?l===a?c:l:c,r=u===o?d===s?u:d:u,{col:n,row:r}}function D(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function Or(e){return{...e,right:e.left,bottom:e.top}}function kr(e){return e.right===void 0}function Ar(e){return e.bottom===void 0}function jr(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function Mr(e){return e.length<2?!0:T(e).length===1}function Nr(e){let t=new Set;for(let n of T(e))for(let e of x(n.left,n.right+1))t.add(e);return t}function Pr(e){let t=new Set;for(let n of T(e))for(let e of x(n.top,n.bottom+1))t.add(e);return t}function Fr(e,t){return e.right+1===t.left||e.left===t.right+1?e.top<=t.bottom&&e.top>=t.top||t.top<=e.bottom&&t.top>=e.top:e.bottom+1===t.top||e.top===t.bottom+1?e.left<=t.right&&e.left>=t.left||t.left<=e.right&&t.left>=e.left:!1}function Ir(e){let t=[...e],n=!0;for(;n;){n=!1;for(let e=0;e<t.length;e++){let r=t[e],i=t.findIndex((t,n)=>e!==n&&(Fr(t,r)||hr(t,r)));if(i!==-1){t[e]=dr(t[i],r),t.splice(i,1),n=!0;break}}}return t}let Lr=new WeakMap,Rr=new WeakMap;function zr(e,t){if(!Lr.has(t)){Lr.set(t,new Map);let e=Math.max(...Object.keys(t).map(parseInt),0);Rr.set(t,e)}let n=Lr.get(t),r=Vr(e);if(n.has(r)){let i=n.get(r);return t[i]=e,i}let i=Rr.get(t)+1;return n.set(r,i),Rr.set(t,i),t[i]=e,i}function Br(e){let t={};for(let n in e){let r=T(e[n].map(D));for(let e of r)t[or(e)]=Number(n)}return t}function Vr(e){if(e===null)return`null`;if(e===void 0)return`undefined`;if(typeof e!=`object`)return String(e);if(Array.isArray(e)){let t=e.length,n=`[`;for(let r=0;r<t;r++)r>0&&(n+=`,`),n+=Vr(e[r]);return n+`]`}let t=Object.keys(e).sort(),n=`{`;for(let r of t)e[r]!==void 0&&(n+=`"${r}":${Vr(e[r])},`);return n+=`}`,n}function Hr(e,t,n,r){let i=e.sheets.find(e=>e.id===n.sheetId);if(!i)throw Error(`Sheet with id ${n.sheetId} not found`);let a=zr(r,e[t]),o=i[t],s=D(n),c=Object.keys(o).find(e=>_r(s,rr(e)));if(!c){o[or(s)]=a;return}let l=o[c],u=T([rr(c)],[s]);delete o[c];for(let e of u)o[or(e)]=l;o[or(s)]=a}var O=class e{jsDate;constructor(e,t,n,r=0,i=0,a=0){this.jsDate=new Date(Date.UTC(e,t,n,r,i,a,0))}static fromTimestamp(t){let n=new Date(t);return new e(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds())}static now(){let t=new Date;return new e(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())}toString(){return this.jsDate.toString()}toLocaleDateString(){return this.jsDate.toLocaleDateString()}getTime(){return this.jsDate.getTime()}getFullYear(){return this.jsDate.getUTCFullYear()}getMonth(){return this.jsDate.getUTCMonth()}getQuarter(){return Math.floor(this.getMonth()/3)+1}getDate(){return this.jsDate.getUTCDate()}getDay(){return this.jsDate.getUTCDay()}getHours(){return this.jsDate.getUTCHours()}getMinutes(){return this.jsDate.getUTCMinutes()}getSeconds(){return this.jsDate.getUTCSeconds()}getIsoWeek(){let e=new Date(this.jsDate.getTime()),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let n=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-n.getTime())/864e5+1)/7)}setFullYear(e){return this.jsDate.setUTCFullYear(e)}setMonth(e){return this.jsDate.setUTCMonth(e)}setDate(e){return this.jsDate.setUTCDate(e)}setHours(e){return this.jsDate.setUTCHours(e)}setMinutes(e){return this.jsDate.setUTCMinutes(e)}setSeconds(e){return this.jsDate.setUTCSeconds(e)}};let Ur=new O(1899,11,30),Wr=1440*60*1e3,Gr=2e3,Kr=O.now().getFullYear(),qr=O.now().getMonth(),Jr=O.fromTimestamp(0).getTime()-Ur.getTime(),Yr=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,Xr=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,Zr=zt.join(``),Qr=RegExp(`\/|-|${zt.join(`|`)}`),$r=RegExp(`^(\\d{1,4})[\/${Zr}\-](\\d{1,4})([\/${Zr}\-](\\d{1,4}))?$`),ei=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function ti(e,t){switch(typeof e){case`number`:return e;case`string`:return ni(e,t)?ii(e,t)?.value:!e||isNaN(Number(e))?void 0:Number(e);default:return}}function ni(e,t){return ii(e,t)!==null}let ri=new Map;function ii(e,t){return ri.has(t)||ri.set(t,new Map),ri.get(t).has(e)||ri.get(t).set(e,ai(e,t)),ri.get(t).get(e)}function ai(e,t){e=e.trim();let n=null,r=e.match(ei);if(r){if(n=pi(r[0]),n===null)return null;e=e.replace(r[0],``).trim()}let i=null,a=oi(e,t);if(a){let t=a.dateString.match(Qr)[0];if(i=ci(a,t),i===null)return null;e=e.replace(a.dateString,``).trim()}return e!==``||!(i||n)?null:i&&i.jsDate&&n&&n.jsDate?{value:i.value+n.value,format:i.format+` `+(n.format===`hhhh:mm:ss`?`hh:mm:ss`:n.format),jsDate:new O(i.jsDate.getFullYear()+n.jsDate.getFullYear()-1899,i.jsDate.getMonth()+n.jsDate.getMonth()-11,i.jsDate.getDate()+n.jsDate.getDate()-30,i.jsDate.getHours()+n.jsDate.getHours(),i.jsDate.getMinutes()+n.jsDate.getMinutes(),i.jsDate.getSeconds()+n.jsDate.getSeconds())}:i||n}function oi(e,t){let n=e.match($r);if(!n)return null;let[,r,i,,a]=n;if(r.length>2&&a&&a.length>2)return null;if(r.length>2)return{year:r,month:i,day:a,dateString:e,type:`ymd`};let o=si(t);return a?a.length>2?o===`mdy`?{month:r,day:i,year:a,dateString:e,type:`mdy`}:{day:r,month:i,year:a,dateString:e,type:`dmy`}:o===`mdy`?{month:r,day:i,year:a,dateString:e,type:`mdy`}:o===`ymd`?{year:r,month:i,day:a,dateString:e,type:`ymd`}:o===`dmy`?{day:r,month:i,year:a,dateString:e,type:`dmy`}:null:i.length>2?{month:r,year:i,day:void 0,dateString:e,type:o}:o===`dmy`?{day:r,month:i,year:a,dateString:e,type:`dmy`}:{month:r,day:i,year:a,dateString:e,type:`mdy`}}function si(e){switch(e.dateFormat[0]){case`d`:return`dmy`;case`m`:return`mdy`;case`y`:return`ymd`}throw Error(`Invalid date format in locale`)}function ci(e,t){let{year:n,month:r,day:i}=e,a=di(r),o=fi(i),s=ui(n);if(s===null||a===null||o===null)return null;let c=r?.length===2&&a+1<10||i?.length===2&&o<10,l=n?.length!==2,u=new O(s,a,o);if(u.getMonth()!==a||u.getDate()!==o)return null;let d=u.getTime()-Ur.getTime(),f=li(e,t,c,l);return{value:Math.round(d/Wr),format:f,jsDate:u}}function li(e,t,n,r){let i=e.year?r?`yyyy`:`yy`:void 0,a=e.month?n?`mm`:`m`:void 0,o=e.day?n?`dd`:`d`:void 0;switch(e.type){case`mdy`:return[a,o,i].filter(S).join(t);case`ymd`:return[i,a,o].filter(S).join(t);case`dmy`:return[o,a,i].filter(S).join(t)}}function ui(e){if(!e)return Kr;let t=Number(e);switch(e.length){case 1:return Gr+t;case 2:return Gr+(Gr+t>Kr+10?-100:0)+t;case 3:case 4:return t}return null}function di(e){if(!e)return qr;let t=Number(e);return t>=1&&t<=12?t-1:null}function fi(e){if(!e)return 1;let t=Number(e);return t>=0&&t<=31?t:null}function pi(e){if(e=e.trim(),ei.test(e)){let t=/AM/i.test(e),n=/PM/i.test(e),r=(t||n?e.substring(0,e.length-2).trim():e).split(/:/),i=r.length>=2,a=r.length===3,o=Number(r[0]),s=i?Number(r[1]):0,c=a?Number(r[2]):0,l=a?`hh:mm:ss`:`hh:mm`;if(t||n)l+=` a`;else if(!i)return null;o>=12&&t?o-=12:o<12&&n&&(o+=12),s+=Math.floor(c/60),c%=60,o+=Math.floor(s/60),s%=60,o>=24&&(l=`hhhh:mm:ss`);let u=new O(1899,11,30,o,s,c);return{value:o/24+s/1440+c/86400,format:l,jsDate:u}}return null}function mi(e){let t=Math.trunc(e),n=O.fromTimestamp(t*Wr-Jr),r=e-t;r=r<0?1+r:r;let i=Math.round(r*24),a=Math.round((r-i/24)*24*60),o=Math.round((r-i/24-a/24/60)*24*60*60);return n.setHours(i),n.setMinutes(a),n.setSeconds(o),n}function hi(e){return Math.round(gi(e))}function gi(e){return(e.getTime()-Ur.getTime())/Wr}function _i(e){return new O(e.getFullYear(),e.getMonth()+1,0).getDate()}function vi(e){return _i(e)===e.getDate()}function yi(e,t,n){let r=e.getFullYear(),i=e.getMonth(),a=e.getDate(),o=new O(r,i+t,1);return n&&a===_i(e)||a>_i(o)?o.setDate(_i(o)):o.setDate(a),o}function bi(e){let t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function xi(e,t,n){if(e===t)return 0;if(e>t){let n=t;t=e,e=n}let r=mi(e),i=mi(t),a=r.getDate(),o=i.getDate(),s=r.getMonth(),c=i.getMonth(),l=r.getFullYear(),u=i.getFullYear(),d=0,f=0;switch(n){case 0:a===31&&(a=30),a===30&&o===31&&(o=30),s===1&&a===(bi(l)?29:28)&&(a=30,c===1&&o===(bi(u)?29:28)&&(o=30)),d=l+(s*30+a)/360,f=u+(c*30+o)/360;break;case 1:let n=365,r=l===u,i=l+1===u;if(!r&&!i||!r&&s<c||!r&&s===c&&a<o){let e=0,t=0;for(let n=l;n<=u;n++)e++,t+=bi(n)?366:365;n=t/e}else r?bi(l)&&(n=366):(bi(l)&&s<2&&(n=366),bi(u)&&(c>1||c===1&&o===29)&&(n=366));d=e/n,f=t/n;break;case 2:d=e/360,f=t/360;break;case 3:d=e/365,f=t/365;break;case 4:a===31&&(a=30),o===31&&(o=30),d=l+(s*30+a)/360,f=u+(c*30+o)/360;break}return f-d}function Si(e,t){let n=(t.getFullYear()-e.getFullYear())*12+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?n-1:n}function Ci(e,t){let n=e.getTime(),r=t.getTime();return Math.floor((r-n)/Wr)}function wi(e,t){let n=t.getFullYear()-e.getFullYear(),r=e.getMonth(),i=t.getMonth(),a=e.getDate(),o=t.getDate();return i>r||i===r&&o>=a?n:n-1}function Ti(e,t){return xi(e,t,1)<1}function Ei(e,t){return Math.trunc(e)===Math.trunc(t)}function Di(e,t,n){return t>n?Di(e,n,t):(e=Math.trunc(e),t=Math.trunc(t),n=Math.trunc(n),e>=t&&e<=n)}function Oi(e,t){return Math.trunc(e)<Math.trunc(t)}function ki(e,t){return Math.trunc(e)<=Math.trunc(t)}function Ai(e,t){return Math.trunc(e)>Math.trunc(t)}function ji(e,t){return Math.trunc(e)>=Math.trunc(t)}let Mi=Ht(function(e){return e=ot(e),RegExp(`(?:^-?\\d+(?:${e}?\\d*(?:e(\\+|-)?\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)}),Ni=Ht(function(e){let t=ot(e.decimalSeparator),n=`(?:\\d+(?:${ot(e.thousandsSeparator||``)}\\d{3,})*(?:${t}\\d*)?)`,r=`(?:${t}\\d+)`,i=`(?:\\s*`+n+`|`+r+`)(?:e(?:\\+|-)?\\d+)?(?:\\s*%)?`,a=`^(?:(?:`+[`(?:\\s*-)?(?:\\s*[\\$€])?`+i,`(?:\\s*-)?`+i+`(?:\\s*[\\$€])?`,`(?:\\s*[\\$€])?(?:\\s*-)?`+i].join(`)|(?:`)+`))$`;return new RegExp(a,`i`)});function Pi(e,t){return e?Ni(t).test(e.trim()):!1}let Fi=Ht(function(e){return RegExp(`[\$€${ot(e.thousandsSeparator||``)}]`,`g`)});function Ii(e,t){e=e.replace(Fi(t),``),t.decimalSeparator!==`.`&&(e=e.replace(t.decimalSeparator,`.`));let n=Number(e);return isNaN(n)&&e.includes(`%`)&&(n=Number(e.split(`%`)[0]),!isNaN(n))?n/100:n}function Li(e,t,n){let r=[...e].sort((e,t)=>e-t),i=(r.length+(n?-1:1))*t;if(n||i--,Number.isInteger(i))return r[i];let a=Math.ceil(i),o=Math.floor(i);return r[a]*(i-o)+r[o]*(a-i)}function Ri(e){return`sheetId`in e}function zi(e){return`dimension`in e&&`sheetId`in e&&`elements`in e}function Bi(e){return`target`in e&&`sheetId`in e}function Vi(e){return`ranges`in e}function Hi(e){return`col`in e&&`row`in e&&`sheetId`in e}function Ui(e){return`sheetId`in e&&`zone`in e}let Wi=new Set([`RENAME_SHEET`,`DELETE_SHEET`,`CREATE_SHEET`,`DUPLICATE_SHEET`,`ADD_COLUMNS_ROWS`,`REMOVE_COLUMNS_ROWS`,`UNDO`,`REDO`,`ADD_MERGE`,`REMOVE_MERGE`,`UPDATE_LOCALE`,`ADD_PIVOT`,`UPDATE_PIVOT`,`INSERT_PIVOT`,`RENAME_PIVOT`,`REMOVE_PIVOT`,`DUPLICATE_PIVOT`]),Gi=new Set([`EVALUATE_CELLS`,`UPDATE_CELL`,`UNHIDE_COLUMNS_ROWS`,`HIDE_COLUMNS_ROWS`,`GROUP_HEADERS`,`UNGROUP_HEADERS`,`FOLD_ALL_HEADER_GROUPS`,`FOLD_HEADER_GROUP`,`FOLD_HEADER_GROUPS_IN_ZONE`,`UNFOLD_ALL_HEADER_GROUPS`,`UNFOLD_HEADER_GROUP`,`UNFOLD_HEADER_GROUPS_IN_ZONE`,`UPDATE_TABLE`,`UPDATE_FILTER`,`UNDO`,`REDO`]),Ki=new Set([`MOVE_RANGES`]),qi=new Set([`EVALUATE_CELLS`,`ADD_CONDITIONAL_FORMAT`,`REMOVE_CONDITIONAL_FORMAT`,`CHANGE_CONDITIONAL_FORMAT_PRIORITY`]),Ji=new Set([`AUTOFILL_CELL`,`SET_BORDER`,`SET_ZONE_BORDERS`,`SET_BORDERS_ON_TARGET`]),Yi=new Set([`START`,`ACTIVATE_SHEET`,`COPY`,`RESIZE_SHEETVIEW`,`SET_VIEWPORT_OFFSET`,`EVALUATE_CELLS`,`SET_FORMULA_VISIBILITY`,`UPDATE_FILTER`]),Xi=new Set(`UPDATE_CELL.UPDATE_CELL_POSITION.CLEAR_CELL.CLEAR_CELLS.DELETE_CONTENT.ADD_COLUMNS_ROWS.REMOVE_COLUMNS_ROWS.RESIZE_COLUMNS_ROWS.HIDE_COLUMNS_ROWS.UNHIDE_COLUMNS_ROWS.SET_GRID_LINES_VISIBILITY.UNFREEZE_COLUMNS.UNFREEZE_ROWS.FREEZE_COLUMNS.FREEZE_ROWS.UNFREEZE_COLUMNS_ROWS.ADD_MERGE.REMOVE_MERGE.CREATE_SHEET.DELETE_SHEET.DUPLICATE_SHEET.MOVE_SHEET.RENAME_SHEET.COLOR_SHEET.HIDE_SHEET.SHOW_SHEET.MOVE_RANGES.ADD_CONDITIONAL_FORMAT.REMOVE_CONDITIONAL_FORMAT.CHANGE_CONDITIONAL_FORMAT_PRIORITY.CREATE_FIGURE.DELETE_FIGURE.UPDATE_FIGURE.SET_FORMATTING.CLEAR_FORMATTING.SET_BORDER.SET_ZONE_BORDERS.SET_BORDERS_ON_TARGET.CREATE_CHART.UPDATE_CHART.CREATE_TABLE.REMOVE_TABLE.UPDATE_TABLE.CREATE_TABLE_STYLE.REMOVE_TABLE_STYLE.CREATE_IMAGE.GROUP_HEADERS.UNGROUP_HEADERS.UNFOLD_HEADER_GROUP.FOLD_HEADER_GROUP.FOLD_ALL_HEADER_GROUPS.UNFOLD_ALL_HEADER_GROUPS.UNFOLD_HEADER_GROUPS_IN_ZONE.FOLD_HEADER_GROUPS_IN_ZONE.ADD_DATA_VALIDATION_RULE.REMOVE_DATA_VALIDATION_RULE.UPDATE_LOCALE.ADD_PIVOT.UPDATE_PIVOT.INSERT_PIVOT.RENAME_PIVOT.REMOVE_PIVOT.DUPLICATE_PIVOT`.split(`.`));function Zi(e){return Xi.has(e.type)}function Qi(e){return Yi.has(e.type)}var $i=class{reasons;constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter(e=>e!==`Success`)}static get Success(){return ea}get isSuccessful(){return this.reasons.length===0}isCancelledBecause(e){return this.reasons.includes(e)}};let ea=new $i,ta=function(e){return e.Success=`Success`,e.CancelledForUnknownReason=`CancelledForUnknownReason`,e.WillRemoveExistingMerge=`WillRemoveExistingMerge`,e.CannotMoveTableHeader=`CannotMoveTableHeader`,e.MergeIsDestructive=`MergeIsDestructive`,e.CellIsMerged=`CellIsMerged`,e.InvalidTarget=`InvalidTarget`,e.EmptyUndoStack=`EmptyUndoStack`,e.EmptyRedoStack=`EmptyRedoStack`,e.NotEnoughElements=`NotEnoughElements`,e.NotEnoughSheets=`NotEnoughSheets`,e.MissingSheetName=`MissingSheetName`,e.UnchangedSheetName=`UnchangedSheetName`,e.DuplicatedSheetName=`DuplicatedSheetName`,e.DuplicatedSheetId=`DuplicatedSheetId`,e.ForbiddenCharactersInSheetName=`ForbiddenCharactersInSheetName`,e.WrongSheetMove=`WrongSheetMove`,e.WrongSheetPosition=`WrongSheetPosition`,e.InvalidAnchorZone=`InvalidAnchorZone`,e.SelectionOutOfBound=`SelectionOutOfBound`,e.TargetOutOfSheet=`TargetOutOfSheet`,e.WrongCutSelection=`WrongCutSelection`,e.WrongPasteSelection=`WrongPasteSelection`,e.WrongPasteOption=`WrongPasteOption`,e.WrongFigurePasteOption=`WrongFigurePasteOption`,e.EmptyClipboard=`EmptyClipboard`,e.EmptyRange=`EmptyRange`,e.InvalidRange=`InvalidRange`,e.InvalidZones=`InvalidZones`,e.InvalidSheetId=`InvalidSheetId`,e.InvalidCellId=`InvalidCellId`,e.InvalidFigureId=`InvalidFigureId`,e.InputAlreadyFocused=`InputAlreadyFocused`,e.MaximumRangesReached=`MaximumRangesReached`,e.MinimumRangesReached=`MinimumRangesReached`,e.InvalidChartDefinition=`InvalidChartDefinition`,e.InvalidDataSet=`InvalidDataSet`,e.InvalidLabelRange=`InvalidLabelRange`,e.InvalidScorecardKeyValue=`InvalidScorecardKeyValue`,e.InvalidScorecardBaseline=`InvalidScorecardBaseline`,e.InvalidGaugeDataRange=`InvalidGaugeDataRange`,e.EmptyGaugeRangeMin=`EmptyGaugeRangeMin`,e.GaugeRangeMinNaN=`GaugeRangeMinNaN`,e.EmptyGaugeRangeMax=`EmptyGaugeRangeMax`,e.GaugeRangeMaxNaN=`GaugeRangeMaxNaN`,e.GaugeRangeMinBiggerThanRangeMax=`GaugeRangeMinBiggerThanRangeMax`,e.GaugeLowerInflectionPointNaN=`GaugeLowerInflectionPointNaN`,e.GaugeUpperInflectionPointNaN=`GaugeUpperInflectionPointNaN`,e.GaugeLowerBiggerThanUpper=`GaugeLowerBiggerThanUpper`,e.InvalidAutofillSelection=`InvalidAutofillSelection`,e.MinBiggerThanMax=`MinBiggerThanMax`,e.LowerBiggerThanUpper=`LowerBiggerThanUpper`,e.MidBiggerThanMax=`MidBiggerThanMax`,e.MinBiggerThanMid=`MinBiggerThanMid`,e.FirstArgMissing=`FirstArgMissing`,e.SecondArgMissing=`SecondArgMissing`,e.MinNaN=`MinNaN`,e.MidNaN=`MidNaN`,e.MaxNaN=`MaxNaN`,e.ValueUpperInflectionNaN=`ValueUpperInflectionNaN`,e.ValueLowerInflectionNaN=`ValueLowerInflectionNaN`,e.MinInvalidFormula=`MinInvalidFormula`,e.MidInvalidFormula=`MidInvalidFormula`,e.MaxInvalidFormula=`MaxInvalidFormula`,e.ValueUpperInvalidFormula=`ValueUpperInvalidFormula`,e.ValueLowerInvalidFormula=`ValueLowerInvalidFormula`,e.InvalidSortZone=`InvalidSortZone`,e.WaitingSessionConfirmation=`WaitingSessionConfirmation`,e.MergeOverlap=`MergeOverlap`,e.TooManyHiddenElements=`TooManyHiddenElements`,e.Readonly=`Readonly`,e.InvalidViewportSize=`InvalidViewportSize`,e.InvalidScrollingDirection=`InvalidScrollingDirection`,e.ViewportScrollLimitsReached=`ViewportScrollLimitsReached`,e.FigureDoesNotExist=`FigureDoesNotExist`,e.InvalidConditionalFormatId=`InvalidConditionalFormatId`,e.InvalidConditionalFormatType=`InvalidConditionalFormatType`,e.InvalidCellPopover=`InvalidCellPopover`,e.EmptyTarget=`EmptyTarget`,e.InvalidFreezeQuantity=`InvalidFreezeQuantity`,e.FrozenPaneOverlap=`FrozenPaneOverlap`,e.ValuesNotChanged=`ValuesNotChanged`,e.InvalidFilterZone=`InvalidFilterZone`,e.TableNotFound=`TableNotFound`,e.TableOverlap=`TableOverlap`,e.InvalidTableConfig=`InvalidTableConfig`,e.InvalidTableStyle=`InvalidTableStyle`,e.FilterNotFound=`FilterNotFound`,e.MergeInTable=`MergeInTable`,e.NonContinuousTargets=`NonContinuousTargets`,e.DuplicatedFigureId=`DuplicatedFigureId`,e.InvalidSelectionStep=`InvalidSelectionStep`,e.DuplicatedChartId=`DuplicatedChartId`,e.ChartDoesNotExist=`ChartDoesNotExist`,e.InvalidHeaderIndex=`InvalidHeaderIndex`,e.InvalidQuantity=`InvalidQuantity`,e.MoreThanOneColumnSelected=`MoreThanOneColumnSelected`,e.EmptySplitSeparator=`EmptySplitSeparator`,e.SplitWillOverwriteContent=`SplitWillOverwriteContent`,e.NoSplitSeparatorInSelection=`NoSplitSeparatorInSelection`,e.NoActiveSheet=`NoActiveSheet`,e.InvalidLocale=`InvalidLocale`,e.MoreThanOneRangeSelected=`MoreThanOneRangeSelected`,e.NoColumnsProvided=`NoColumnsProvided`,e.ColumnsNotIncludedInZone=`ColumnsNotIncludedInZone`,e.DuplicatesColumnsSelected=`DuplicatesColumnsSelected`,e.InvalidHeaderGroupStartEnd=`InvalidHeaderGroupStartEnd`,e.HeaderGroupAlreadyExists=`HeaderGroupAlreadyExists`,e.UnknownHeaderGroup=`UnknownHeaderGroup`,e.UnknownDataValidationRule=`UnknownDataValidationRule`,e.UnknownDataValidationCriterionType=`UnknownDataValidationCriterionType`,e.InvalidDataValidationCriterionValue=`InvalidDataValidationCriterionValue`,e.InvalidNumberOfCriterionValues=`InvalidNumberOfCriterionValues`,e.InvalidCopyPasteSelection=`InvalidCopyPasteSelection`,e.NoChanges=`NoChanges`,e.InvalidInputId=`InvalidInputId`,e.SheetIsHidden=`SheetIsHidden`,e.InvalidTableResize=`InvalidTableResize`,e.PivotIdNotFound=`PivotIdNotFound`,e.PivotInError=`PivotInError`,e.EmptyName=`EmptyName`,e.ValueCellIsInvalidFormula=`ValueCellIsInvalidFormula`,e.InvalidDefinition=`InvalidDefinition`,e.InvalidColor=`InvalidColor`,e.InvalidPivotDataSet=`InvalidPivotDataSet`,e}({}),na=[{name:`English (US)`,code:`en_US`,thousandsSeparator:`,`,decimalSeparator:`.`,weekStart:7,dateFormat:`m/d/yyyy`,timeFormat:`hh:mm:ss a`,formulaArgSeparator:`,`},{name:`French`,code:`fr_FR`,thousandsSeparator:` `,decimalSeparator:`,`,weekStart:1,dateFormat:`dd/mm/yyyy`,timeFormat:`hh:mm:ss`,formulaArgSeparator:`;`}],k=na[0],ra=[`thin`,`medium`,`thick`,`dashed`,`dotted`];function A(e){return Array.isArray(e)&&Array.isArray(e[0])}let ia={Background:0,Highlights:1,Clipboard:2,Chart:4,Autofill:5,Selection:6,Headers:100},aa=Ht(()=>Object.keys(ia).sort((e,t)=>ia[e]-ia[t]));function oa(e,t){if(ia[e])throw Error(`Layer ${e} already exists`);ia[e]=t}let j={NotAvailable:`#N/A`,InvalidReference:`#REF`,BadExpression:`#BAD_EXPR`,CircularDependency:`#CYCLE`,UnknownFunction:`#NAME?`,DivisionByZero:`#DIV/0!`,SpilledBlocked:`#SPILL!`,GenericError:`#ERROR`,NullError:`#NULL!`},sa=new Set(Object.values(j));var M=class{message;value;constructor(e=E(`Error`),t=j.GenericError){this.message=e,this.value=t,this.message=e.toString()}},ca=class extends M{constructor(e=E(`Invalid expression`)){super(e,j.BadExpression)}},la=class extends M{constructor(e=E(`Circular reference`)){super(e,j.CircularDependency)}},ua=class extends M{constructor(e=E(`Invalid reference`)){super(e,j.InvalidReference)}},da=class extends M{constructor(e=E(`Data not available`)){super(e,j.NotAvailable)}},fa=class extends M{constructor(e=E(`Unknown function`)){super(e,j.UnknownFunction)}},pa=class extends M{constructor(e=E(`Spill range is not empty`)){super(e,j.SpilledBlocked)}};let ma=[`number`,`string`,`boolean`,`undefined`];function N(e,t,n){if(!e())throw new M(t,n)}function ha(e){if(e!==void 0)return A(e)?e[0][0]?.format:e.format}function P(e){return typeof e==`string`&&sa.has(e)}let ga=e=>E(`The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.`,e),_a=(e,t,n)=>E(`The function [[FUNCTION_NAME]] expects a number value between %s and %s inclusive, but receives %s.`,e.toString(),t.toString(),n.toString()),va=(e,t)=>E(`The function [[FUNCTION_NAME]] has an argument with value '%s'. It should be one of: %s.`,t,e.map(e=>`'${e}'`).join(`, `));function F(e,t){let n=ka(e);switch(typeof n){case`number`:return n;case`boolean`:return+!!n;case`string`:if(Pi(n,t)||n===``)return Ii(n,t);let e=ii(n,t);if(e)return e.value;throw new M(ga(n));default:return 0}}function ya(e,t){try{return F(e,t)}catch{return}}function ba(e,t){return B(e).map(e=>e.map(e=>{if(typeof e.value!=`number`){let n=``;throw typeof e==`object`?n=E(`Function [[FUNCTION_NAME]] expects number values for %s, but got an empty value.`,t):typeof e==`string`?n=E(`Function [[FUNCTION_NAME]] expects number values for %s, but got a string.`,t):typeof e==`boolean`&&(n=E(`Function [[FUNCTION_NAME]] expects number values for %s, but got a boolean.`,t)),new M(n)}return e.value}))}function xa(e,t){let n=ka(e);if(n===``)throw new M(ga(n));return F(n,t)}function Sa(e,t){return Math.trunc(F(e,t))}function Ca(e,t){return Math.trunc(xa(e,t))}function wa(e){N(()=>e>=1,E(`The function [[FUNCTION_NAME]] expects a number value to be greater than or equal to 1, but receives %s.`,e.toString()))}function Ta(e){N(()=>e!==0,E(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`),j.DivisionByZero)}function I(e){let t=ka(e);switch(typeof t){case`string`:return t;case`number`:return t.toString();case`boolean`:return t?`TRUE`:`FALSE`;default:return``}}function L(e,t){let n=ka(e);switch(typeof n){case`string`:return n;case`number`:return n.toString().replace(`.`,t.decimalSeparator);case`boolean`:return n?`TRUE`:`FALSE`;default:return``}}let Ea=Ht(function(e){return e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``)}),Da=e=>E(`The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a boolean.`,e);function R(e){let t=ka(e);switch(typeof t){case`boolean`:return t;case`string`:if(t){let e=t.toUpperCase();if(e===`TRUE`)return!0;if(e===`FALSE`)return!1;throw new M(Da(t))}else return!1;case`number`:return!!t;default:return!1}}function Oa(e){let t=ka(e);if(t===``)throw new M(Da(t));return R(t)}function z(e,t){return mi(F(ka(e),t))}function ka(e){if(typeof e==`object`&&e&&`value`in e){if(P(e.value))throw e;return e.value}if(P(e))throw new M(``,e);return e}function Aa(e,t,n){for(let r of e)if(A(r)){let e=r.length,n=r[0].length;for(let i=0;i<n;i++)for(let n=0;n<e;n++)t(r[n][i])}else n(r)}function ja(e,t){Aa(e,e=>{if(P(e.value))throw e;t(e)},e=>{if(P(e?.value))throw e;t(e)})}function Ma(e,t,n){Aa(e,e=>{if(typeof e?.value==`number`&&t(e),P(e?.value))throw e},e=>{t({value:xa(e,n),format:e?.format})})}function Na(e,t,n,r,i=`rowFirst`){let a=r;for(let r of e)if(A(r)){let e=r.length,n=r[0].length;if(i===`rowFirst`)for(let i=0;i<n;i++)for(let n=0;n<e;n++)a=t(a,r[n][i]);else for(let i=0;i<e;i++)for(let e=0;e<n;e++)a=t(a,r[i][e])}else a=n(a,r);return a}function Pa(e,t,n,r=`rowFirst`){return Na(e,t,t,n,r)}function Fa(e,t,n,r){return Na(e,(e,n)=>{let r=n?.value;if(typeof r==`number`)return t(e,r);if(P(r))throw n;return e},(e,n)=>t(e,xa(n,r)),n)}function Ia(e,t,n,r){return Na(e,(e,n)=>{let i=n?.value;if(i!=null){if(typeof i==`number`)return t(e,i);if(typeof i==`boolean`)return t(e,F(i,r));if(P(i))throw n;return t(e,0)}return e},(e,n)=>t(e,F(n,r)),n)}function La(e,t,n){let r=Array(e);for(let i=0;i<e;i++){r[i]=Array(t);for(let e=0;e<t;e++)r[i][e]=n(i,e)}return r}function Ra(e,t){return e.length===0?[]:La(e.length,e[0].length,(n,r)=>t(e[n][r]))}function za(e,t){let n=e.length,r=e[0]?.length??0;for(let i=0;i<n;i++)for(let n=0;n<r;n++)t(e[i][n])}function Ba(e){return e.length?La(e[0].length,e.length,(t,n)=>e[n][t]):[]}function Va(e,t,n=void 0){let r=1,i=1,a=1/0,o=1/0,s;for(let e=0;e<t.length;e++){let c=t[e];if(A(c)&&(n===void 0||n[e])){let n=c.length,l=c[0].length;n!==1||l!==1?(s??=Array(t.length),n!==1&&l!==1?(s[e]=`matrix`,r=Math.max(r,n),i=Math.max(i,l),a=Math.min(a,n),o=Math.min(o,l)):n===1?l!==1&&(s[e]=`vertical`,i=Math.max(i,l),o=Math.min(o,l)):(s[e]=`horizontal`,r=Math.max(r,n),a=Math.min(a,n))):t[e]=c[0][0]}}if(r===1&&i===1)return e(...t);let c=Array(t.length),l=[],u=[];for(let e=0;e<t.length;e++){let n=t[e];switch(s?.[e]){case`matrix`:l.push((e,t)=>n[e][t]),u.push(e);break;case`horizontal`:l.push(e=>n[e][0]),u.push(e);break;case`vertical`:l.push((e,t)=>n[0][t]),u.push(e);break;case void 0:c[e]=n;break}}let d=u.length,f;switch(c.length){case 1:f=()=>e(c[0]);break;case 2:f=()=>e(c[0],c[1]);break;case 3:f=()=>e(c[0],c[1],c[2]);break;default:f=()=>e(...c)}let p=Array(r);for(let e=0;e<r;e++){let t=Array(i);p[e]=t;for(let n=0;n<i;n++){if(e>a-1||n>o-1){t[n]=new da(E(`Array arguments to [[FUNCTION_NAME]] are of different size.`));continue}for(let t=0;t<d;t++)c[u[t]]=l[t](e,n);let r=f();t[n]=A(r)?r[0][0]:r}}return p}function Ha(e,t,n){for(let r of e)if(A(r)){let e=r.length,n=r[0].length;for(let i=0;i<n;i++)for(let n=0;n<e;n++)if(!t(r[n][i]??void 0))return}else if(!n(r))return}function Ua(e,t){return Ha(e,e=>{let n=e?.value;if(typeof n==`boolean`)return t(n);if(typeof n==`number`)return t(!!n);if(P(n))throw e;return!0},e=>e!==void 0&&e.value!==null?t(Oa(e)):!0)}function Wa(e,t){let n,r,i=e.substring(0,2);return i===`<=`||i===`>=`||i===`<>`?(n=i,r=e.substring(2)):(i=e.substring(0,1),i===`<`||i===`>`||i===`=`?(n=i,r=e.substring(1)):(n=`=`,r=e)),Pi(r,t)||ni(r,t)?r=F(r,t):(r===`TRUE`||r===`FALSE`)&&(r=R(r)),{operator:n,operand:r}}let Ga=Ht(function(e){if(e===`*`)return/.+/;let t=``,n=``;for(let r of e)r===`?`&&n!==`~`?t+=`.`:r===`*`&&n!==`~`?t+=`.*`:((r===`*`||r===`?`)&&(t=t.slice(0,-1)),[`^`,`.`,`[`,`]`,`$`,`(`,`)`,`*`,`+`,`?`,`|`,`{`,`}`,`\\`].includes(r)&&(t+=`\\`),t+=r),n=r;return RegExp(`^`+t+`$`,`i`)});function Ka(e=``,t,n){let{operator:r,operand:i}=t;if(i===void 0||e===null||i===null)return!1;if(typeof i==`number`&&r===`=`)return typeof e==`string`&&(Pi(e,n)||ni(e,n))?F(e,n)===i:e===i;if(r===`<>`||r===`=`){let t;return t=typeof e==typeof i?typeof e==`string`&&typeof i==`string`?Ga(i).test(e):e===i:!1,r===`=`?t:!t}if(typeof e==typeof i)switch(r){case`<`:return e<i;case`>`:return e>i;case`<=`:return e<=i;case`>=`:return e>=i}return!1}function qa(e,t,n,r=!1){let i=e.length;if(i%2==1)throw new M(E(`Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs.`));let a=B(e[0]),o=a.length,s=a[0].length,c=[];for(let t=0;t<i-1;t+=2){let i=B(e[t]);if(i.length!==o||i[0].length!==s)throw new M(E(`Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension`));let a=Wa(I(e[t+1]),n);r&&typeof a.operand==`string`&&(a.operand+=`*`),c.push(a)}for(let r=0;r<o;r++)for(let a=0;a<s;a++){let o=!0;for(let t=0;t<i-1;t+=2){let i=B(e[t])[r][a].value,s=c[t/2];if(o=Ka(i??void 0,s,n),!o)break}o&&t(r,a)}}function Ja(e,t,n,r,i,a){if(t===void 0||t.value===null)return-1;if(P(t.value))throw t;let o=Za(t.value),s=typeof o,c,l,u=0,d=i-1,f,p,m,h,g=r===`desc`?t=>Za(a(e,i-t-1)):t=>Za(a(e,t));for(;d-u>=0;){for(f=Math.floor((u+d)/2),p=f,m=g(p),h=typeof m;u<p&&s!==h;)p--,m=g(p),h=typeof m;if(h!==s||m==null){u=f+1;continue}n===`strict`&&m===o?(c=m,l=p):n===`nextSmaller`&&m<=o?(c==null||c<m||c===m&&l<p)&&(c=m,l=p):n===`nextGreater`&&m>=o&&(c===void 0||c>m||c===m&&l<p)&&(c=m,l=p),m>o||n===`strict`&&m===o?d=p-1:u=f+1}return l===void 0?-1:r===`desc`?i-l-1:l}function Ya(e,t,n,r,i,a,o=!1){if(t===void 0||t.value===null)return-1;if(P(t.value))throw t;let s=Za(t.value),c=o?(e,t)=>Za(i(e,r-t-1)):(e,t)=>Za(i(e,t)),l=n!==`wildcard`||typeof s!=`string`||!(s.includes(`*`)||s.includes(`?`));if(a&&l){let t=o?`reverseSearch`:`forwardSearch`,i=a[t].get(e);if(i===void 0){i=new Map;for(let t=0;t<r;t++){let n=c(e,t)??null;i.has(n)||i.set(n,t)}a[t].set(e,i)}if(i.has(s)){let e=i.get(s);return o?r-e-1:e}if(n===`strict`)return-1}let u=Xa(e,s,n,r,c);return o&&u!==-1?r-u-1:u}function Xa(e,t,n,r,i){let a=n=>i(e,n)===t;if(n===`wildcard`&&typeof t==`string`&&(t.includes(`*`)||t.includes(`?`))){let n=Ga(t);a=t=>{let r=i(e,t);return typeof r==`string`?n.test(r):!1}}let o,s=-1;n===`nextSmaller`&&(a=n=>{let r=i(e,n);return(!o&&Qa(t,r)>=0||Qa(t,r)>=0&&Qa(r,o)>0)&&(o=r,s=n),r===t}),n===`nextGreater`&&(a=n=>{let r=i(e,n);return(!o&&Qa(t,r)<=0||Qa(t,r)<=0&&Qa(r,o)<0)&&(o=r,s=n),r===t});for(let e=0;e<r;e++)if(a(e))return e;return s}function Za(e){return typeof e==`string`?Ea(e):e}function Qa(e,t){let n=ma.indexOf(typeof e)-ma.indexOf(typeof t);return n===0&&(typeof e==`string`&&typeof t==`string`?n=e.localeCompare(t):typeof e==`number`&&typeof t==`number`?n=e-t:typeof e==`boolean`&&typeof t==`boolean`&&(n=Number(e)-Number(t))),n}function B(e){return e===void 0?[[]]:A(e)?e:[[e]]}function $a(e,t){return Pa(e,(e,n)=>(e.push(t(n)),e),[],`rowFirst`)}function eo(e){if(e===void 0)return!1;let{value:t}=e;return!(t===null||t===``)}function to(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}let no=new h;function ro(e,t){return e=to(e),{url:e,label:t||e,isExternal:!0,isUrlEditable:!0}}no.add(`sheet_URL`,{match:e=>St(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){let n=wt(e);return t.tryGetSheetName(n)||E(`Invalid sheet`)},open(e,t){let n=wt(e);t.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:n}).isCancelledBecause(`SheetIsHidden`)&&t.notifyUser({type:`warning`,sticky:!1,text:E(`Cannot open the link because the linked sheet is hidden.`)})},sequence:0});let io={createLink:ro,match:e=>vt(e),open:e=>window.open(e,`_blank`),urlRepresentation:e=>e,sequence:0};function ao(e){return no.getAll().sort((e,t)=>e.sequence-t.sequence).find(t=>t.match(e))||io}function oo(e,t){return ao(e.url).urlRepresentation(e.url,t)}function so(e,t){ao(e.url).open(e.url,t)}function co(e){if(typeof e==`string`){if(_t(e)){let{label:t,url:n}=bt(e);return ao(n).createLink(n,t)}else if(vt(e))return ro(e)}}function lo(e){e=e.replace(/\s/g,` `);let t=new Zt(e),n=[],r=[];for(n.push(r);!t.isOver();){if(t.current===`;`){r=[],n.push(r),t.shift();continue}let e=vo(t)||uo(t)||po(t)||mo(t)||go(t)||_o(t)||bo(t)||ho(t)||xo(t);if(!e)throw Error(`Unknown token at `+t.remaining());r.push(e)}return n}function uo(e){let t;if(e.current===`"`?(e.shift(),t=`"`):e.currentStartsWith(`[$`)&&(e.advanceBy(2),t=`]`),!t)return null;let n=``;for(;e.current&&e.current!==t;)n+=e.shift();if(e.current===t)e.shift();else throw Error(`Unterminated string in format`);return{type:`STRING`,value:n}}let fo=new Set(`$+-/():!^&~{}<>= `);function po(e){if(e.current===`\\`){e.shift();let t=e.shift();if(!t)throw Error(`Unexpected end of format string`);return{type:`CHAR`,value:t}}return fo.has(e.current)?{type:`CHAR`,value:e.shift()}:null}function mo(e){return e.current===`,`?(e.shift(),{type:`THOUSANDS_SEPARATOR`,value:`,`}):null}function ho(e){return e.current===`@`?(e.shift(),{type:`TEXT_PLACEHOLDER`,value:`@`}):null}function go(e){return e.current===`.`?(e.shift(),{type:`DECIMAL_POINT`,value:`.`}):null}function _o(e){return e.current===`%`?(e.shift(),{type:`PERCENT`,value:`%`}):null}function vo(e){if(e.current===`0`||e.current===`#`){let t=e.current;return e.shift(),{type:`DIGIT`,value:t}}return null}let yo=new Set(`dmqyhsa`);function bo(e){if(!yo.has(e.current))return null;let t=e.current,n=``;for(;e.current===t;)n+=e.shift();return{type:`DATE_PART`,value:n}}function xo(e){if(e.current!==`*`)return null;e.shift();let t=e.shift();if(!t)throw Error(`Unexpected end of format string`);return{type:`REPEATED_CHAR`,value:t}}let So={};function Co(e){let t=So[e];return t===void 0&&(t=wo(e),So[e]=t),t}function wo(e){let t=lo(e);for(let e of t){let t=e.filter(e=>e.type===`REPEATED_CHAR`);for(let e of t.slice(1))e.type=`CHAR`}let n=ko(t[0])||Oo(t[0])||Ao(t[0]);if(!n)throw Error(`Invalid first format part of: `+e);if(t.length>1&&n.type===`text`)throw Error(`The first format in a multi-part format must be a number format: `+e);let r=ko(t[1])||Oo(t[1]);if(t[1]?.length&&!r)throw Error(`Invalid second format part of: `+e);let i=ko(t[2])||Oo(t[2]);if(t[2]?.length&&!i)throw Error(`Invalid third format part of: `+e);let a=Ao(t[3]);if(t[3]?.length&&!a)throw Error(`Invalid fourth format part of: `+e);return{positive:n,negative:r,zero:i,text:a}}function To(e){return e.every(e=>e.type===`DATE_PART`||e.type===`DECIMAL_POINT`||e.type===`THOUSANDS_SEPARATOR`||e.type===`STRING`||e.type===`CHAR`||e.type===`REPEATED_CHAR`)}function Eo(e){return e.every(e=>e.type===`DIGIT`||e.type===`DECIMAL_POINT`||e.type===`THOUSANDS_SEPARATOR`||e.type===`PERCENT`||e.type===`STRING`||e.type===`CHAR`||e.type===`REPEATED_CHAR`)}function Do(e){return e.every(e=>e.type===`STRING`||e.type===`TEXT_PLACEHOLDER`||e.type===`CHAR`||e.type===`REPEATED_CHAR`)}function Oo(e){if(!e||!Eo(e))return;let t=[],n,r=t,i=0,a=0,o=e.findLastIndex(e=>e.type===`DIGIT`),s=!1,c=0;for(let l=0;l<e.length;l++){let u=e[l];switch(u.type){case`DIGIT`:r===t?r.push(u):c<20&&(r.push(u),c++);break;case`DECIMAL_POINT`:if(r===t)n=[],r=n;else throw Error(`Multiple decimal points in a number format`);break;case`REPEATED_CHAR`:case`CHAR`:case`STRING`:r.push(u);break;case`PERCENT`:i++,r.push(u);break;case`THOUSANDS_SEPARATOR`:l-1===o?(a+=1,o++,r.push(u)):e[l+1]?.type===`DIGIT`&&e[l-1]?.type===`DIGIT`?(r===t&&(s=!0),r.push(u)):r.push({type:`CHAR`,value:`,`});break}}return{type:`number`,integerPart:t,decimalPart:n,percentSymbols:i,thousandsSeparator:s,magnitude:a}}function ko(e){let t=e&&To(e)?{type:`date`,tokens:e}:void 0;if(t){if(t.tokens.length&&t.tokens.every(e=>e.type===`DATE_PART`&&e.value===`a`))throw Error(`Invalid date format`);return{type:`date`,tokens:jo(t.tokens.map(e=>e.type===`THOUSANDS_SEPARATOR`||e.type===`DECIMAL_POINT`?{type:`CHAR`,value:e.value}:e))}}}function Ao(e){return e&&Do(e)?{type:`text`,tokens:e}:void 0}function jo(e){let t=e.filter(e=>e.type===`DATE_PART`);for(let e=0;e<t.length;e++)!t[e].value.startsWith(`m`)||t[e].value.length>2||(t[e-1]?.value.startsWith(`h`)||t[e+1]?.value.startsWith(`s`))&&(t[e].value=t[e].value.replaceAll(`m`,`M`));return e}function Mo(e){return[No(e.positive),No(e.negative),No(e.zero),No(e.text)].filter(S).join(`;`)}function No(e){if(!e)return;let t=``,n=e.type===`number`?Po(e):e.tokens;for(let e of n)switch(e.type){case`STRING`:t+=`[$${e.value}]`;break;case`CHAR`:t+=Fo(e.value)?`\\${e.value}`:e.value;break;case`REPEATED_CHAR`:t+=`*`+e.value;break;case`DATE_PART`:t+=e.value===`MM`?`mm`:e.value;break;default:t+=e.value}return t}function Po(e){let t=[...e.integerPart];return e.decimalPart&&(t.push({type:`DECIMAL_POINT`,value:`.`}),t.push(...e.decimalPart)),t}function Fo(e){return!fo.has(e)}let Io=`REPEATED_CHAR_PLACEHOLDER_`,Lo={0:E(`January`),1:E(`February`),2:E(`March`),3:E(`April`),4:E(`May`),5:E(`June`),6:E(`July`),7:E(`August`),8:E(`September`),9:E(`October`),10:E(`November`),11:E(`December`)},Ro={0:E(`Sunday`),1:E(`Monday`),2:E(`Tuesday`),3:E(`Wednesday`),4:E(`Thursday`),5:E(`Friday`),6:E(`Saturday`)};function V(e,{format:t,locale:n,formatWidth:r}){switch(typeof e==`boolean`&&(e=e?`TRUE`:`FALSE`),typeof e){case`string`:{if(e.includes(`\\"`)&&(e=e.replaceAll(/\\"/g,`"`)),!t)return e;let n=Co(t),i=n.text||n.positive;return!i||i.type!==`text`?e:zo(e,i,r)}case`number`:t||=ts(e);let i=Co(t);if(i.positive.type===`text`)return zo(e.toString(),i.positive,r);let a=i.positive;if(e<0&&i.negative?(a=i.negative,e=-e):e===0&&i.zero&&(a=i.zero),a.type===`date`)return Bo(Qo(e,a),r);let o=e<0,s=Bo(Vo(Math.abs(e),a,n),r);return o?`-`+s:s;case`object`:return``}}function zo(e,t,n){let r=``;for(let n of t.tokens)switch(n.type){case`TEXT_PLACEHOLDER`:r+=e;break;case`CHAR`:case`STRING`:r+=n.value;break;case`REPEATED_CHAR`:r+=Io+n.value;break}return Bo(r,n)}function Bo(e,t){let n=e.indexOf(Io);if(n===-1)return e;let r=e.slice(0,n),i=e.slice(n+26+1),a=e[n+26];function o(){if(!t)return{timesToRepeat:0,padding:``};let e=t.measureText(r+i),n=t.measureText(a),o=t.availableWidth-e;if(o<=0)return{timesToRepeat:0,padding:``};let s=Math.floor(o/n),c=o-s*n,l=t.measureText(` `);return{timesToRepeat:s,padding:` `.repeat(Math.floor(c/l))}}let{timesToRepeat:s,padding:c}=o();return r+a.repeat(s)+c+i}function Vo(e,t,n){if(e===1/0)return`∞`+(t.percentSymbols?`%`:``);let r=t.percentSymbols*2-t.magnitude*3;e*=10**r;let i=0;t.decimalPart!==void 0&&(i=t.decimalPart.filter(e=>e.type===`DIGIT`).length);let{integerDigits:a,decimalDigits:o}=Go(Math.abs(e),i),s=Ho(a,t,t.thousandsSeparator?n.thousandsSeparator:void 0);return t.decimalPart!==void 0&&(s+=n.decimalSeparator+Uo(o||``,t)),s}function Ho(e,t,n){let r=t.integerPart;r.some(e=>e.type===`DIGIT`)||(r=[...r,{type:`DIGIT`,value:`#`}]),e===`0`&&(e=``);let i=``,a=r.findIndex(e=>e.type===`DIGIT`),o=e.length-1;function s(t,r){if(r===`0`&&(t||=`0`),!t)return;let a=e.length-1-o;i=n&&a>0&&a%3==0?t+n+i:t+i}for(let t=r.length-1;t>=0;t--){let n=r[t];switch(n.type){case`DIGIT`:let r=e[o];if(s(r,n.value),o--,a===t)for(;o>=0;)s(e[o],`0`),o--;break;case`THOUSANDS_SEPARATOR`:break;case`REPEATED_CHAR`:i=Io+n.value+i;break;default:i=n.value+i;break}}return i}function Uo(e,t){if(!t.decimalPart)return``;let n=``,r=0;for(let i of t.decimalPart)switch(i.type){case`DIGIT`:let t=i.value===`#`?e[r]||``:e[r]||`0`;n+=t,r++;break;case`THOUSANDS_SEPARATOR`:break;case`REPEATED_CHAR`:n+=Io+i.value;break;default:n+=i.value;break}return n}let Wo=[];function Go(e,t=20){let n=e.toString();if(n.includes(`e`))return Yo(e,t);if(Number.isInteger(e))return{integerDigits:n,decimalDigits:void 0};let r=n.indexOf(`.`),i=n.substring(0,r),a=n.substring(r+1);if(t===0)return Number(a[0])>=5&&(i=(Number(i)+1).toString()),{integerDigits:i,decimalDigits:void 0};if(a.length>t){let{integerDigits:e,decimalDigits:n}=Jo(a,t);a=n,e!==`0`&&(i=(Number(i)+Number(e)).toString())}return{integerDigits:i,decimalDigits:Ko(a||``)}}function Ko(e){let t=e.length-1;for(;t>=0&&e[t]===`0`;)t--;return e.slice(0,t+1)||void 0}let qo=/^0+/;function Jo(e,t){let n=`0`,r=e,i=e.slice(0,t);if(Number(e[t])<5)return{integerDigits:n,decimalDigits:i};let a=i.match(qo)?.[0]||``,o=(Number(i)+1).toString(),s=i.slice(a.length),c=o.length>s.length;return c&&!a?(n=`1`,r=void 0):r=c?a.slice(0,-1)+o:a+o,{integerDigits:n,decimalDigits:r}}function Yo(e,t=20){let n=Wo[t];n||(n=new Intl.NumberFormat(`en-US`,{maximumFractionDigits:t,useGrouping:!1}),Wo[t]=n);let[r,i]=n.format(e).split(`.`);return{integerDigits:r,decimalDigits:i}}function Xo(e,t){let{integerDigits:n,decimalDigits:r}=Go(e,20);return r?n+t+r:n}let Zo=Ht(function(e){if(!e)return!1;try{return Co(e).positive.type===`date`}catch{return!1}});function Qo(e,t){let n=mi(e);if(isNaN(n.getTime()))return e.toString();let r=t.tokens.some(e=>e.type===`DATE_PART`&&e.value===`a`),i=``;for(let e of t.tokens)switch(e.type){case`DATE_PART`:i+=$o(n,e.value,r);break;case`REPEATED_CHAR`:i+=Io+e.value;break;default:i+=e.value;break}return i}function $o(e,t,n){switch(t){case`d`:return e.getDate();case`dd`:return e.getDate().toString().padStart(2,`0`);case`ddd`:return Ro[e.getDay()].slice(0,3);case`dddd`:return Ro[e.getDay()].toString();case`m`:return e.getMonth()+1;case`mm`:return String(e.getMonth()+1).padStart(2,`0`);case`mmm`:return Lo[e.getMonth()].slice(0,3);case`mmmm`:return Lo[e.getMonth()].toString();case`mmmmm`:return Lo[e.getMonth()].slice(0,1);case`qq`:return E(`Q%(quarter)s`,{quarter:e.getQuarter()}).toString();case`qqqq`:return E(`Quarter %(quarter)s`,{quarter:e.getQuarter()}).toString();case`yy`:let r=String(e.getFullYear()).replace(`-`,``).padStart(2,`0`);return r.slice(r.length-2);case`yyyy`:return String(e.getFullYear()).replace(`-`,``).padStart(4,`0`);case`hhhh`:return Math.floor((e.getTime()-Ur.getTime())/(3600*1e3)).toString();case`hh`:let i=e.getHours();return n&&(i=i===0?12:i>12?i-12:i),i.toString().padStart(2,`0`);case`MM`:return e.getMinutes().toString().padStart(2,`0`);case`ss`:return e.getSeconds().toString().padStart(2,`0`);case`a`:return e.getHours()>=12?`PM`:`AM`;default:throw Error(`invalid date format token: ${t}`)}}let es=Ht(function(e){return RegExp(`[0-9]+${ot(e.decimalSeparator)}[0-9]`)});function ts(e){let{integerDigits:t,decimalDigits:n}=Go(e);if(!n)return`0`;let r=t.replace(`-`,``).length;if(r+2>11)return`0`;let i=11-r-1;return{decimalDigits:n}=Go(e,Math.min(i,n.length)),n?`0.`+`0`.repeat(n.length):`0`}function ns(e,t){if(ni(e,t))return ii(e,t).format}function rs(e){let t=e.includes(`.`)?`0.00`:`0`,n=e.match(/[\$€]/);if(n){let r=e.match(/[\d]/),i=`[$`+n.values().next().value+`]`;return r.index<n.index?`#,##`+t+i:i+`#,##`+t}if(e.includes(`%`))return t+`%`}function is(e){let t=e.decimalPlaces??2,n=e.position??`before`,r=e.code??``,i=e.symbol??``,a=`#,##0`+(t?`.`+`0`.repeat(t):``),o=`${r} ${i}`.trim();return n===`after`&&r&&(o=` `+o),ss(o,n,a)}function as(e){let t=e.decimalPlaces??2,n=e.position??`before`,r=e.code??``,i=e.symbol??``,a=`#,##0`+(t?`.`+`0`.repeat(t):``),o=`${r} ${i}`.trim();return n===`after`&&r&&(o=` `+o),[os(o,n,` ${a} `),os(o,n,`(${a})`),os(o,n,` - `)].join(`;`)}function os(e,t,n){let r=`[$${e}]`;return t===`before`?r+`* `+n:n+`* `+r}function ss(e,t,n){let r=`[$${e}]`;return t===`before`?r+n:n+r}function cs(e){let t=Co(e);return Mo({positive:ls(t.positive),negative:t.negative?ls(t.negative):void 0,zero:t.zero?ls(t.zero):void 0,text:t.text})}function ls(e){if(e.type!==`number`||!e.decimalPart)return e;let t=e.decimalPart.filter(e=>e.type!==`DIGIT`);return{...e,decimalPart:void 0,integerPart:[...e.integerPart,...t]}}function us({value:e,format:t},n){return V(e,{format:ds({value:e,format:t},void 0,n),locale:n})}function ds(e,t,n){let r=0;try{r=Math.abs(F(e?.value,n))}catch{return``}let i=e?.format;if(t!==void 0)switch(t?.value){case`k`:return fs(i,1,`k`,n);case`m`:return fs(i,2,`m`,n);case`b`:return fs(i,3,`b`,n);default:throw new M(E(`The formatting unit should be 'k', 'm' or 'b'.`))}return r<1e5?fs(i,0,``,n):r<1e8?fs(i,1,`k`,n):r<1e11?fs(i,2,`m`,n):fs(i,3,`b`,n)}function fs(e,t,n,r){let i=Co(e||`#,##0`);return Mo({positive:ps(i.positive,t,n),negative:i.negative?ps(i.negative,t,n):void 0,zero:i.zero?ps(i.zero,t,n):void 0,text:i.text})}function ps(e,t,n){if(e.type!==`number`)return e;let r=ls(e),i={type:`STRING`,value:n},a=[...r.integerPart],o=a.findLastIndex(e=>e.type===`DIGIT`);if(o===-1)throw Error(`Cannot create a large number format from a format with no digit.`);for(;a[o+1]?.type===`THOUSANDS_SEPARATOR`;)a=Ut(a,[o+1]);let s=a[o+1];a=s?.type===`STRING`&&[`m`,`k`,`b`].includes(s.value)?Gt(a,i,o+1):Wt(a,[i],o+1),t>0&&(a=Wt(a,Array(t).fill({type:`THOUSANDS_SEPARATOR`,value:`,`}),o+1));let c=r.percentSymbols-a.filter(e=>e.type===`PERCENT`).length;return a.push(...Array(c).fill({type:`PERCENT`,value:`%`})),{...r,integerPart:a,magnitude:t}}function ms(e,t){let n=Co(e);return Mo(Co(Mo({positive:hs(n.positive,t),negative:n.negative?hs(n.negative,t):void 0,zero:n.zero?hs(n.zero,t):void 0,text:n.text})))}function hs(e,t){return e.type===`number`?t>0?_s(e,t):gs(e,Math.abs(t)):e}function gs(e,t){let n=e.decimalPart;if(!n)return e;let r=[],i=0;for(let e=n.length-1;e>=0&&!(i>=Math.abs(t));e--)n[e].type===`DIGIT`&&(i++,r.push(e));return n=Ut(n,r),n.some(e=>e.type===`DIGIT`)?{...e,decimalPart:n}:{...e,decimalPart:void 0,integerPart:[...e.integerPart,...n]}}function _s(e,t){let n=e.integerPart,r=e.decimalPart;if(!r){let e=n.findLastIndex(e=>e.type===`DIGIT`);r=n.slice(e+1),n=n.slice(0,e+1)}let i=x(0,t).map(()=>({type:`DIGIT`,value:`0`})),a=r.findLastIndex(e=>e.type===`DIGIT`);return r=a===-1?[...i,...r]:Wt(r,i,a+1),{...e,decimalPart:r,integerPart:n}}function vs(e){let t=Co(e);for(let e of[t.positive,t.negative,t.zero])if(e&&e.type===`date`&&e.tokens.some(e=>e.type===`DATE_PART`&&e.value.includes(`q`)))return!1;return!0}function ys(e){if(!e)return!1;try{return Co(e).positive.type===`text`}catch{return!1}}function bs(e,t){return Ss({value:ys(t.format)&&e.parsedValue!==null?e.content:e.parsedValue,format:t.format},t.locale)}function xs(e,t){if(e.startsWith(`=`))throw Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);if(e===``)return null;if(Pi(e,k))return Ii(e,k);let n=ii(e,t);return n?n.value:mt(e)?e.toUpperCase()===`TRUE`:e}function Ss(e,t=k,n){let r=co(e.value);if(!r)return Cs(e,t,n);let i=xs(r.label,t);return{...Cs({value:i,format:e.format||(typeof i==`number`?ns(r.label,t)||rs(r.label):void 0)},t,n),link:r}}function Cs(e,t,n){let{value:r,format:i,message:a}=e;i=n?.format||i;let o=V(r,{format:i,locale:t});return P(r)?ks(r,a):r===null?Es(i):ys(i)?ws(I(r),i,o):typeof r==`number`?Zo(i||``)?Ds(r,i,o):Ts(r,i,o):typeof r==`boolean`?Os(r,i,o):ws(r,i,o)}function ws(e,t,n){return{value:e,format:t,formattedValue:n,type:`text`,isAutoSummable:!0,defaultAlign:`left`}}function Ts(e,t,n){return{value:e||0,format:t,formattedValue:n,type:`number`,isAutoSummable:!0,defaultAlign:`right`}}let Es=Ht(function(e){return{value:null,format:e,formattedValue:``,type:`empty`,isAutoSummable:!0,defaultAlign:`left`}});function Ds(e,t,n){return{value:e,format:t,formattedValue:n,type:`number`,isAutoSummable:!1,defaultAlign:`right`}}function Os(e,t,n){return{value:e,format:t,formattedValue:n,type:`boolean`,isAutoSummable:!1,defaultAlign:`center`}}function ks(e,t){return{value:e,formattedValue:e,message:t,type:`error`,isAutoSummable:!1,defaultAlign:`center`}}function As(e){let t=O.now();switch(e){case`today`:return Math.floor(gi(t));case`yesterday`:return t.setDate(t.getDate()-1),Math.floor(gi(t));case`tomorrow`:return t.setDate(t.getDate()+1),Math.floor(gi(t));case`lastWeek`:return t.setDate(t.getDate()-6),Math.floor(gi(t));case`lastMonth`:{let e=t.getMonth()===0?11:t.getMonth()-1,n=new O(t.getFullYear(),e,1);return t.getDate()>_i(n)?t.setDate(1):(t.setDate(t.getDate()+1),t.setMonth(t.getMonth()-1)),Math.floor(gi(t))}case`lastYear`:return t.getMonth()===1&&t.getDate()===29?(t.setDate(28),t.setFullYear(t.getFullYear()-1)):(t.setDate(t.getDate()+1),t.setFullYear(t.getFullYear()-1)),Math.floor(gi(t))}}function js(e,t){return`dateValue`in e&&e.dateValue!==`exactDate`?[As(e.dateValue)]:e.values.map(e=>ti(e,t))}function Ms(e,t){return e.values.map(e=>ya(e,t))}function Ns(e,t){return e.map(e=>{if(e.startsWith(`=`))return e;let n=xs(e,t);return typeof n==`number`?V(n,{format:t.dateFormat,locale:t}):``})}function Ps(e){return 20+120*Math.exp(-.035*(e-1))}let Fs=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,`i`),Is=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,`i`),Ls=new RegExp(/^\$?([A-Z]{1,3})+$/,`i`),Rs=new RegExp(/^\$?([0-9]{1,7})+$/,`i`),zs=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,`i`),Bs=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,`i`),Vs=RegExp(`^\\s*('.+'!|[^']+!)?(`+[Fs.source,`(\\$?[A-Z]{1,3})?\\$?[0-9]{1,7}\\s*:\\s*(\\$?[A-Z]{1,3})?\\$?[0-9]{1,7}\\s*`,`\\$?[A-Z]{1,3}(\\$?[0-9]{1,7})?\\s*:\\s*\\$?[A-Z]{1,3}(\\$?[0-9]{1,7})?\\s*`].join(`|`)+`)$`,`i`);function Hs(e){return zs.test(e)}function Us(e){return Bs.test(e)}function Ws(e){return Ls.test(e)}function Gs(e){return Rs.test(e)}function Ks(e){return Is.test(e)}function qs(e){if(!e.includes(`!`))return{xc:e};let t=e.split(`!`),n=t.pop();return{sheetName:ct(t.join(`!`))||void 0,xc:n}}function Js(e,t){return e===void 0?t:`${ut(e)}!${t}`}var Ys=class e{getSheetSize;_zone;parts;invalidXc;prefixSheet=!1;sheetId;invalidSheetName;constructor(e,t){this.getSheetSize=t,this._zone=e.zone,this.prefixSheet=e.prefixSheet,this.invalidXc=e.invalidXc,this.sheetId=e.sheetId,this.invalidSheetName=e.invalidSheetName;let n=[...e.parts];e.parts.length===1&&jr(this.zone)>1?n.push({...e.parts[0]}):e.parts.length===2&&jr(this.zone)===1&&n.pop(),this.parts=n}static fromRange(t,n){return t instanceof e?t:new e(t,n.getSheetSize)}get unboundedZone(){return this._zone}get zone(){let{left:e,top:t,bottom:n,right:r}=this._zone;if(r!==void 0&&n!==void 0)return this._zone;if(n===void 0&&r!==void 0)return{right:r,top:t,left:e,bottom:this.getSheetSize(this.sheetId).numberOfRows-1};if(r===void 0&&n!==void 0)return{bottom:n,left:e,top:t,right:this.getSheetSize(this.sheetId).numberOfCols-1};throw Error(E(`Bad zone format`))}static getRangeParts(e,t){let n=e.split(`:`).map(e=>{let t=Us(e);return{colFixed:t?!1:e.startsWith(`$`),rowFixed:t?e.startsWith(`$`):e.includes(`$`,1)}}),r=t.bottom===void 0,i=t.right===void 0;return r&&(n[0].rowFixed=n[0].rowFixed||n[1].rowFixed,n[1].rowFixed=n[0].rowFixed||n[1].rowFixed),i&&(n[0].colFixed=n[0].colFixed||n[1].colFixed,n[1].colFixed=n[0].colFixed||n[1].colFixed),n}get isFullCol(){return this._zone.bottom===void 0}get isFullRow(){return this._zone.right===void 0}get rangeData(){return{_zone:this._zone,_sheetId:this.sheetId}}orderZone(){if(ar(this._zone))return this;let e={...this._zone},t=this.parts;if(e.right!==void 0&&e.right<e.left){let n=e.right;e.right=e.left,e.left=n,t=[{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1},{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1}]}if(e.bottom!==void 0&&e.bottom<e.top){let n=e.bottom;e.bottom=e.top,e.top=n,t=[{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1},{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1}]}return this.clone({zone:e,parts:t})}clone(t){return new e({zone:t?.zone?t.zone:{...this._zone},sheetId:t?.sheetId?t.sheetId:this.sheetId,invalidSheetName:t&&`invalidSheetName`in t?t.invalidSheetName:this.invalidSheetName,invalidXc:t&&`invalidXc`in t?t.invalidXc:this.invalidXc,parts:t?.parts?t.parts:this.parts.map(e=>({rowFixed:e.rowFixed,colFixed:e.colFixed})),prefixSheet:t?.prefixSheet===void 0?this.prefixSheet:t.prefixSheet},this.getSheetSize)}};function Xs(e,t,n){let r=n.sheetId===e?t:n.sheetId;return n.clone({sheetId:r})}function Zs(e,t,n){if(!n)return;let r=e.getRangeFromSheetXC(t,n);return r.invalidSheetName||r.invalidXc?void 0:r}function Qs(e,t){let n=[];for(let r of t){let t=r.dataRange;if(!e.isRangeValid(t)){n.push(r);continue}let{sheetName:i}=qs(t),a=i?`${i}!`:``,o=nr(t);if(o.bottom!==o.top&&o.left!==o.right)if(o.right)for(let e=o.left;e<=o.right;++e){let t=e===o.left?r:{yAxisId:r.yAxisId};n.push({...t,dataRange:`${a}${or({left:e,right:e,top:o.top,bottom:o.bottom})}`})}else for(let e=o.top;e<=o.bottom;++e){let t=e===o.top?r:{yAxisId:r.yAxisId};n.push({...t,dataRange:`${a}${or({left:o.left,right:o.right,top:e,bottom:e})}`})}else n.push(r)}return n}function $s(e){let t=[];for(let n of e)for(let e of Sr(n.zone))t.push({...e,sheetId:n.sheetId});return t}function ec(e,t){e=e.toLocaleLowerCase(),t=t.toLocaleLowerCase();let n=0,r=0,i=t.length,a=0;for(let o=0;o<i;o++)t[o]===e[a]?(a++,r+=100+r-o/200):r=0,n+=r;return a===e.length?n:0}function tc(e,t,n){let r=[];return t.forEach(t=>{let i=ec(e,n(t));i>0&&r.push({score:i,elem:t})}),r.sort((e,t)=>t.score-e.score),r.map(e=>e.elem)}function nc(e){let t=[];for(let n=0;n<e;n++)t.push({cells:{}});return t}function rc(e,t,n){return n.map(n=>n>=e?n+t:n)}function ic(e,t){return e=[...e].sort((e,t)=>t-e),t.map(t=>{for(let n of e)if(t>n)t--;else if(t===n)return;return t}).filter(S)}function ac(e,t=`Sheet`){let n=1,r=`${t}${n}`;for(;e.includes(r);)r=`${t}${n}`,n++;return r}function oc(e,t){let n=1,r=E(`Copy of %s`,e),i=r.toString();for(;t.includes(i);)i=`${r} (${n})`,n++;return i}function sc(e,t){return e===void 0||t===void 0?!1:ct(e.trim().toUpperCase())===ct(t.trim().toUpperCase())}function cc(e,t=1){return t*(e+4)-4}function lc(e,t,n,r){if(!t||!t.isFormula&&!t.content)return 23;let i=``;try{if(!t.isFormula){let e={format:t.format,locale:n};i=V(xs(t.content,n),e)}}catch{i=j.GenericError}return uc(e,i,t.style,r)}function uc(e,t,n,r){let i=Sc(e,t,n,n?.wrapping===`wrap`?r-8:void 0).length;return cc(bc(n),i)+6}function dc(e,t=!1,n=!1){return`${n?`italic`:``} ${t?`bold`:``} ${e}px ${He}`}let fc={};function pc(e,t,n,r=`pt`){let i=yc(n,r);e.save(),e.font=i;let a=mc(e,t);return e.restore(),a}function mc(e,t){let n=e.font;if(fc[n]||(fc[n]={}),fc[n][t]===void 0){let r=e.measureText(t).width;fc[n][t]=r}return fc[n][t]}let hc={};function gc(e,t,n,r=`pt`){let i=yc(n,r);e.save(),e.font=i;let a=_c(e,t);return e.restore(),a}function _c(e,t){let n=e.font;if(hc[n]||(hc[n]={}),hc[n][t]===void 0){let r=e.measureText(t),i=r.width,a=r.fontBoundingBoxAscent+r.fontBoundingBoxDescent;hc[n][t]={width:i,height:a}}return hc[n][t]}function vc(e){return Math.round(e*96/72)}function yc(e,t=`pt`){return`${e.italic?`italic `:``}${e.bold?`bold`:`400`} ${(t===`pt`?bc(e):e.fontSize)??Ve}px ${He}`}function bc(e){return vc(e?.fontSize||Ve)}function xc(e,t,n,r){if(pc(e,t,r)<=n)return[t];let i=[],a=``;for(let o of t)pc(e,a+o,r)>n?(i.push(a),a=o):a+=o;return i.push(a),i}function Sc(e,t,n,r){n||={},_t(t)&&(t=bt(t).label);let i=[],a=t.includes(`
4
+ `)}function qt(e,t,n){return t>n?qt(e,n,t):e>=t&&e<=n}function Jt(e,t){let n=ot(e),r=t.matchCase?``:`i`;return t.exactMatch&&(n=`^${n}$`),RegExp(n,r)}function Yt(e){let t=e.length;if(t<1e5)return Math.max(...e);let n=-1/0;for(;t--;)n=e[t]>n?e[t]:n;return n}function Xt(e){let t=e.length;if(t<1e5)return Math.min(...e);let n=1/0;for(;t--;)n=e[t]<n?e[t]:n;return n}var Zt=class{text;currentIndex=0;current;constructor(e){this.text=e,this.current=e[0]}shift(){let e=this.current,t=this.text[++this.currentIndex];return this.current=t,e}advanceBy(e){this.currentIndex+=e,this.current=this.text[this.currentIndex]}isOver(){return this.currentIndex>=this.text.length}remaining(){return this.text.substring(this.currentIndex)}currentStartsWith(e){if(this.current!==e[0])return!1;for(let t=1;t<e.length;t++)if(this.text[this.currentIndex+t]!==e[t])return!1;return!0}};function Qt(e,t=e=>e){let n=new Set;return e.filter(e=>{let r=t(e);return n.has(r)?!1:(n.add(r),!0)})}function $t(e){let t={};for(let n in e)for(let r in e[n])t[r]||(t[r]={}),t[r][n]=e[n][r];return t}let en=/rgba?\(|\s+|\)/gi,tn=/^#([A-F\d]{2}){3,4}$/,nn=[`#eb6d00`,`#0074d9`,`#ad8e00`,`#169ed4`,`#b10dc9`,`#00a82d`,`#00a3a3`,`#f012be`,`#3d9970`,`#111111`,`#62A300`,`#ff4136`,`#949494`,`#85144b`,`#001f3f`];function rn(e){return an(e.toString(16).padStart(6,`0`))}function an(e){let t=e;if(e.startsWith(`rgb`)?t=dn(e):(t=e.replace(`#`,``).toUpperCase(),(t.length===3||t.length===4)&&(t=t.split(``).reduce((e,t)=>e+t+t,``)),t=`#${t}`),!tn.test(t))throw Error(`invalid color input: ${e}`);return t}function on(e){try{return an(e),!0}catch{return!1}}function sn(e){try{return gn(e),!0}catch{return!1}}let cn=e=>e>=0&&e<=255;function ln(e,t,n,r=1){if(!cn(e)||!cn(t)||!cn(n)||r<0||r>1)throw Error(`Invalid RGBA values ${[e,t,n,r]}`);return{a:r,b:n,g:t,r:e}}function un(e){let{r:t,g:n,b:r}=pn(e);t/=255,n/=255,r/=255;let i=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4,a=i(t),o=i(n),s=i(r);return .2126*a+.7152*o+.0722*s}function dn(e){let t=e.replace(en,``).split(`,`),n=255;if(t.length!==3&&t.length!==4)throw Error(`invalid color`);if(t.length===4){let e=parseFloat(t.pop()||`1`);if(isNaN(e))throw Error(`invalid alpha value`);n=Math.round(e*255)}let r=t.map(e=>parseInt(e,10));return n!==255&&r.push(n),`#`+kt(r.map(e=>e.toString(16).padStart(2,`0`))).toUpperCase()}function fn(e){let t=e.r.toString(16),n=e.g.toString(16),r=e.b.toString(16),i=Math.round(e.a*255).toString(16);return t.length===1&&(t=`0`+t),n.length===1&&(n=`0`+n),r.length===1&&(r=`0`+r),i.length===1&&(i=`0`+i),i===`ff`&&(i=``),(`#`+t+n+r+i).toUpperCase()}function pn(e){e=an(e);let t,n,r,i;if(e.length===7)t=parseInt(e[1]+e[2],16),n=parseInt(e[3]+e[4],16),r=parseInt(e[5]+e[6],16),i=255;else if(e.length===9)t=parseInt(e[1]+e[2],16),n=parseInt(e[3]+e[4],16),r=parseInt(e[5]+e[6],16),i=parseInt(e[7]+e[8],16);else throw Error(`Invalid color`);return i=+(i/255).toFixed(3),{a:i,r:t,g:n,b:r}}function mn(e){e={...e},e.s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,n=t*(1-Math.abs(e.h/60%2-1)),r=e.l-t/2,i=0,a=0,o=0;return 0<=e.h&&e.h<60?(i=t,a=n,o=0):60<=e.h&&e.h<120?(i=n,a=t,o=0):120<=e.h&&e.h<180?(i=0,a=t,o=n):180<=e.h&&e.h<240?(i=0,a=n,o=t):240<=e.h&&e.h<300?(i=n,a=0,o=t):300<=e.h&&e.h<360&&(i=t,a=0,o=n),i=Math.round((i+r)*255),a=Math.round((a+r)*255),o=Math.round((o+r)*255),{a:e.a,r:i,g:a,b:o}}function hn(e){let t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=a-i,s=0,c=0,l=0;return s=o===0?0:a===t?(n-r)/o%6:a===n?(r-t)/o+2:(t-n)/o+4,s=Math.round(s*60),s<0&&(s+=360),l=(a+i)/2,c=o===0?0:o/(1-Math.abs(2*l-1)),c=+(c*100).toFixed(1),l=+(l*100).toFixed(1),{a:e.a,h:s,s:c,l}}function gn(e){return fn(mn(e))}function _n(e){return hn(pn(e))}function vn(e,t,n=0){if(!(on(e)&&on(t)))return!1;let r=pn(e),i=pn(t);return r.a===i.a?Math.sqrt(((r.r-i.r)/255)**2+((r.g-i.g)/255)**2+((r.b-i.b)/255)**2)<=n:!1}function yn(e,t){return t===1?an(e).slice(0,7):fn({...pn(e),a:t})}function bn(e,t){let n=_n(e);return t===1?`#fff`:(n.l=t*(100-n.l)+n.l,gn(n))}function xn(e,t){let n=_n(e);return t===1?`#000`:(n.l-=t*n.l,gn(n))}let Sn=[`#4EA7F2`,`#EA6175`,`#43C5B1`,`#F4A261`,`#8481DD`,`#FFD86D`],Cn=[`#4EA7F2`,`#3188E6`,`#43C5B1`,`#00A78D`,`#EA6175`,`#CE4257`,`#F4A261`,`#F48935`,`#8481DD`,`#5752D1`,`#FFD86D`,`#FFBC2C`],wn=[`#4EA7F2`,`#3188E6`,`#056BD9`,`#A76DBC`,`#7F4295`,`#6D2387`,`#EA6175`,`#CE4257`,`#982738`,`#43C5B1`,`#00A78D`,`#0E8270`,`#F4A261`,`#F48935`,`#BE5D10`,`#8481DD`,`#5752D1`,`#3A3580`,`#A4A8B6`,`#7E8290`,`#545B70`,`#FFD86D`,`#FFBC2C`,`#C08A16`],Tn=`#4EA7F2.#3188E6.#056BD9.#155193.#A76DBC.#7F4295.#6D2387.#4F1565.#EA6175.#CE4257.#982738.#791B29.#43C5B1.#00A78D.#0E8270.#105F53.#F4A261.#F48935.#BE5D10.#7D380D.#8481DD.#5752D1.#3A3580.#26235F.#A4A8B6.#7E8290.#545B70.#3F4250.#FFD86D.#FFBC2C.#C08A16.#936A12`.split(`.`);function En(e,t){return t[e%t.length]}function Dn(e){return e<=6?Sn:e<=12?Cn:e<=24?wn:Tn}var On=class{preferredColors;currentColorIndex=0;palette;constructor(e,t=[]){this.preferredColors=t,this.palette=Dn(e).filter(e=>!t.includes(e))}next(){return this.preferredColors?.[this.currentColorIndex]?this.preferredColors[this.currentColorIndex++]:En(this.currentColorIndex++,this.palette)}};function kn(e){if(e<0)throw Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):kn(Math.floor(e/26)-1)+kn(e%26)}function An(e){let t=0,n=e.length;for(let r=0;r<n;r++){let n=jn(e[r]);t=t*26+n}return t-1}function jn(e){let t=e.charCodeAt(0);return t>=65&&t<=90?t-64:t-96}function Mn(e){return e>=`A`&&e<=`Z`||e>=`a`&&e<=`z`}function Nn(e){return e>=`0`&&e<=`9`}let Pn=An(`ZZZ`),Fn=9999998;function In(e){for(;e.current===` `;)e.advanceBy(1)}function Ln(e){if(e.current===`$`&&e.advanceBy(1),!e.current||!Mn(e.current))return-1;let t=0;for(;e.current&&Mn(e.current);)t=t*26+jn(e.shift());return t}function Rn(e){if(e.current===`$`&&e.advanceBy(1),!e.current||!Nn(e.current))return-1;let t=0;for(;e.current&&Nn(e.current);)t=t*10+Number(e.shift());return t}function zn(e){let t=new Zt(e);In(t);let n=Ln(t);if(n===-1||!t.current)throw Error(`Invalid cell description: ${e}`);let r=Rn(t);In(t);let i=n-1,a=r-1;if(!t.isOver()||i>Pn||a>Fn)throw Error(`Invalid cell description: ${e}`);return{col:i,row:a}}function w(e,t,n={colFixed:!1,rowFixed:!1}){return(n.colFixed?`$`:``)+kn(e)+(n.rowFixed?`$`:``)+String(t+1)}function T(e,t=[]){if(e.length<=1&&t.length===0)return e;let n=[0],r=new Map([[0,[]]]);return Bn(n,r,e,!1),Bn(n,r,t,!0),Wn(n,r)}function Bn(e,t,n,r=!1){for(let i of n){let n=i.left,a=i.right===void 0?void 0:i.right+1,o=Vn(e,t,n,!0,0),s=Vn(e,t,a,!1,o);for(let n=o;n<=s;n++)Hn(t.get(e[n]),i,r);Un(e,t,o,s)}}function Vn(e,t,n,r,i){if(n===void 0)return e.length-1;let a=Gn(e,n,i);return n===e[a]?r?a:a-1:(e.splice(a+1,0,n),t.set(n,[...t.get(e[a])]),r?a+1:a)}function Hn(e,t,n=!1){let r=t.top,i=t.bottom===void 0?void 0:t.bottom+1,a=[],o=Gn(e,r,0,!1);if((o%2!=0&&!n||o%2==0&&n)&&a.push(r),i===void 0){e.splice(o+1),e.push(...a);return}let s=Kn(e,i,0,!1);(s%2==0&&!n||s%2!=0&&n)&&a.push(i),e.splice(o+1,s-o-1,...a)}function Un(e,t,n,r){let i=n-1==-1?0:n-1,a=r===e.length-1?r:r+1;for(let n=a;n>i;n--)Nt(t.get(e[n]),t.get(e[n-1]))&&(t.delete(e[n]),e.splice(n,1))}function Wn(e,t){let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=t.get(a);if(!o||o.length===0){n.push(...r),r=[];continue}let s=e[i+1];s!==void 0&&s--;let c=[];for(let e=0;e<o.length;e+=2){let t=o[e],n=o[e+1];n!==void 0&&n--;let i={top:t,left:a,bottom:n,right:s,hasHeader:n===void 0&&t!==0||s===void 0&&a!==0},l=!1;for(let e=r.length-1;e>=0;e--){let t=r[e];if(t.top===i.top&&t.bottom===i.bottom){t.right=i.right,r.splice(e,1),c.push(t),l=!0;break}}l||c.push(i)}n.push(...r),r=c}return n.push(...r),n}function Gn(e,t,n=0,r=!0){let i=e.length-1,a=-1;for(;n<=i;){let o=Math.floor((n+i)/2);if(e[o]===t&&r)return o;e[o]<t?(a=o,n=o+1):i=o-1}return a}function Kn(e,t,n=0,r=!0){let i=e.length-1,a=e.length;for(;n<=i;){let o=Math.floor((n+i)/2);if(e[o]===t&&r)return o;e[o]>t?(a=o,i=o-1):n=o+1}return a}let qn=e=>e,Jn=()=>!1,Yn=qn,Xn=Jn;function Zn(e,...t){if(t.length===1&&typeof t[0]==`object`&&!(t[0]instanceof String)){let n=t[0];e=e.replace(/\%\(([^\)]+)\)s/g,(e,t)=>n[t])}else t.length>0&&(e=e.replace(/\%s/g,()=>t.shift()));return e}function Qn(e,t=()=>!0){Yn=e,Xn=t}function $n(){Yn===qn&&Xn===Jn&&(Xn=()=>!0)}let E=function(e,...t){return Xn()?Zn(Yn(e),...t):new er(e,t)};var er=class extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){let e=super.valueOf();return Xn()?Zn(Yn(e),...this.values):Zn(e,...this.values)}toString(){return this.valueOf()}};function tr(e){let t=new Zt(e);In(t);let n=e.indexOf(`!`);n!==-1&&t.advanceBy(n+1);let r=Ln(t),i=Rn(t),a,o,s,c,l=!1,u=!1,d=!1;if(i===-1?(s=c=r-1,a=o=0,l=!0):r===-1?(a=o=i-1,s=c=0,u=!0):(s=c=r-1,a=o=i-1,d=!0),In(t),t.current===`:`){t.advanceBy(1),In(t);let e=Ln(t),n=Rn(t);n===-1?(c=e-1,l=!0):e===-1?(o=n-1,u=!0):(c=e-1,o=n-1,a=l?o:a,s=u?c:s,d=!0)}let f={top:a,left:s,bottom:l?void 0:o,right:u?void 0:c};return d&&=u||l,d&&(f.hasHeader=d),f}function nr(e){let t=Cr(tr(e)),n=t.bottom,r=t.right;if(n!==void 0&&n>Fn||r!==void 0&&r>Pn)throw Error(`Range string out of bounds: ${e}`);if(n===void 0&&r===void 0)throw Error(`Wrong zone xc. The zone cannot be at the same time a full column and a full row`);return t}function rr(e){let t=nr(e);if(t.bottom===void 0||t.right===void 0)throw Error(`This does not support unbounded ranges`);return t}function ir(e){let{bottom:t,top:n,left:r,right:i}=e;return t!==void 0&&isNaN(t)||isNaN(n)||isNaN(r)||i!==void 0&&isNaN(i)?!1:ar(e)&&e.top>=0&&e.left>=0}function ar(e){return(e.bottom===void 0||e.bottom>=e.top&&e.bottom>=0)&&(e.right===void 0||e.right>=e.left&&e.right>=0)}function or(e){let{top:t,bottom:n,left:r,right:i}=e,a=`hasHeader`in e?e.hasHeader:!1,o=t===n&&r===i;if(n===void 0&&i!==void 0)return t===0&&!a?`${kn(r)}:${kn(i)}`:`${w(r,t)}:${kn(i)}`;if(i===void 0&&n!==void 0)return r===0&&!a?`${t+1}:${n+1}`:`${w(r,t)}:${n+1}`;if(n!==void 0&&i!==void 0)return o?w(r,t):`${w(r,t)}:${w(i,n)}`;throw Error(E(`Bad zone format`))}function sr(e,t,n,r,i){let a=t===`left`?`columns`:`rows`,o=r===`before`?n-1:n,s=e[t===`left`?`right`:`bottom`];return e[t]<=o&&s&&s>o?wr(e,a,`RESIZE`,i):o<e[t]?wr(e,a,`MOVE`,i):{...e}}function cr(e,t,n,r,i){let a=t===`left`?`columns`:`rows`,o=r===`before`?n-1:n,s=t===`left`?`right`:`bottom`;return e[t]<=o&&e[s]>o?wr(e,a,`RESIZE`,i):o<e[t]?wr(e,a,`MOVE`,i):{...e}}function lr(e,t,n){let r=t===`left`?`right`:`bottom`,i=e[t],a=e[r];for(let o of n.sort((e,t)=>t-e))e[t]>o&&(i--,a--),e[t]<o&&e[r]>=o&&a--;return{...e,[t]:i,[r]:a}}function ur(e,t,n){let r=t===`left`?`right`:`bottom`,i=e[t],a=e[r],o=e[r];for(let r of n.sort((e,t)=>t-e))e[t]>r&&(i--,a!==void 0&&a--),o!==void 0&&a!==void 0&&e[t]<=r&&o>=r&&a--;if(!(a!==void 0&&i>a))return{...e,[t]:i,[r]:a}}function dr(...e){return{top:Math.min(...e.map(e=>e.top)),left:Math.min(...e.map(e=>e.left)),bottom:Math.max(...e.map(e=>e.bottom)),right:Math.max(...e.map(e=>e.right))}}function fr(...e){return{top:Math.min(...e.map(e=>e.top)),left:Math.min(...e.map(e=>e.left)),bottom:e.some(e=>e.bottom===void 0)?void 0:Math.max(...e.map(e=>e.bottom)),right:e.some(e=>e.right===void 0)?void 0:Math.max(...e.map(e=>e.right))}}function pr(e,t){if(hr(e,t))return{top:Math.max(e.top,t.top),left:Math.max(e.left,t.left),bottom:Math.min(e.bottom,t.bottom),right:Math.min(e.right,t.right)}}function mr(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function hr(e,t){return!(e.bottom<t.top||t.bottom<e.top||e.right<t.left||t.right<e.left)}function gr(e,t,n){let{left:r,right:i,top:a,bottom:o}=n;return e>=r&&e<=i&&t>=a&&t<=o}function _r(e,t){return mr(dr(t,e),t)}function vr(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function yr(e){let{numberOfCols:t,numberOfRows:n}=vr(e);return t===1||n===1}function br(e){let{top:t,left:n,bottom:r,right:i}=e;if(jr(e)===1)return[];let a={top:t+1,bottom:r,left:n,right:n};if(i===n)return[a];let o={top:t,bottom:r,left:n+1,right:i};return t===r?[o]:[a,o]}function xr(e){let t={};for(let n of e)t[n.sheetId]??=[],t[n.sheetId].push(D(n));for(let e in t)t[e]=T(t[e]);return t}function Sr(e){let t=[],{left:n,right:r,top:i,bottom:a}=Cr(e);for(let e of x(n,r+1))for(let n of x(i,a+1))t.push({col:e,row:n});return t}function Cr(e){return e.right!==void 0&&e.left>e.right&&(e={...e,left:e.right,right:e.left}),e.bottom!==void 0&&e.top>e.bottom&&(e={...e,top:e.bottom,bottom:e.top}),e}function wr(e,t,n,r){let i=t===`both`?r[0]:t===`columns`?r:0,a=t===`both`?r[1]:t===`rows`?r:0,o=`hasHeader`in e?e.hasHeader:!1,s;s=Ar(e)&&!o?t!==`rows`:kr(e)&&!o?t!==`columns`:!0;let c={...e};return s&&n===`MOVE`&&(c.left+=i,c.top+=a),c.right!==void 0&&(c.right+=i),c.bottom!==void 0&&(c.bottom+=a),c}function Tr(e){return e.reverse().filter((e,t,n)=>t===n.findIndex(t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)).reverse()}function Er(e){return e.reduce((e,t)=>{let n=e.length;for(let r=0;r<n;r++)if(hr(e[r],t))return e[r]=dr(e[r],t),e;return e[n]=t,e},[])}function Dr(e,t){let n,r,{left:i,right:a,top:o,bottom:s}=e,{left:c,right:l,top:u,bottom:d}=t;return n=c===i?l===a?c:l:c,r=u===o?d===s?u:d:u,{col:n,row:r}}function D(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function Or(e){return{...e,right:e.left,bottom:e.top}}function kr(e){return e.right===void 0}function Ar(e){return e.bottom===void 0}function jr(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function Mr(e){return e.length<2?!0:T(e).length===1}function Nr(e){let t=new Set;for(let n of T(e))for(let e of x(n.left,n.right+1))t.add(e);return t}function Pr(e){let t=new Set;for(let n of T(e))for(let e of x(n.top,n.bottom+1))t.add(e);return t}function Fr(e,t){return e.right+1===t.left||e.left===t.right+1?e.top<=t.bottom&&e.top>=t.top||t.top<=e.bottom&&t.top>=e.top:e.bottom+1===t.top||e.top===t.bottom+1?e.left<=t.right&&e.left>=t.left||t.left<=e.right&&t.left>=e.left:!1}function Ir(e){let t=[...e],n=!0;for(;n;){n=!1;for(let e=0;e<t.length;e++){let r=t[e],i=t.findIndex((t,n)=>e!==n&&(Fr(t,r)||hr(t,r)));if(i!==-1){t[e]=dr(t[i],r),t.splice(i,1),n=!0;break}}}return t}let Lr=new WeakMap,Rr=new WeakMap;function zr(e,t){if(!Lr.has(t)){Lr.set(t,new Map);let e=Math.max(...Object.keys(t).map(Number),0);Rr.set(t,e)}let n=Lr.get(t),r=Vr(e);if(n.has(r)){let i=n.get(r);return t[i]=e,i}let i=Rr.get(t)+1;return n.set(r,i),Rr.set(t,i),t[i]=e,i}function Br(e){let t={};for(let n in e){let r=T(e[n].map(D));for(let e of r)t[or(e)]=Number(n)}return t}function Vr(e){if(e===null)return`null`;if(e===void 0)return`undefined`;if(typeof e!=`object`)return String(e);if(Array.isArray(e)){let t=e.length,n=`[`;for(let r=0;r<t;r++)r>0&&(n+=`,`),n+=Vr(e[r]);return n+`]`}let t=Object.keys(e).sort(),n=`{`;for(let r of t)e[r]!==void 0&&(n+=`"${r}":${Vr(e[r])},`);return n+=`}`,n}function Hr(e,t,n,r){let i=e.sheets.find(e=>e.id===n.sheetId);if(!i)throw Error(`Sheet with id ${n.sheetId} not found`);let a=zr(r,e[t]),o=i[t],s=D(n),c=Object.keys(o).find(e=>_r(s,rr(e)));if(!c){o[or(s)]=a;return}let l=o[c],u=T([rr(c)],[s]);delete o[c];for(let e of u)o[or(e)]=l;o[or(s)]=a}var O=class e{jsDate;constructor(e,t,n,r=0,i=0,a=0){this.jsDate=new Date(Date.UTC(e,t,n,r,i,a,0))}static fromTimestamp(t){let n=new Date(t);return new e(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds())}static now(){let t=new Date;return new e(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())}toString(){return this.jsDate.toString()}toLocaleDateString(){return this.jsDate.toLocaleDateString()}getTime(){return this.jsDate.getTime()}getFullYear(){return this.jsDate.getUTCFullYear()}getMonth(){return this.jsDate.getUTCMonth()}getQuarter(){return Math.floor(this.getMonth()/3)+1}getDate(){return this.jsDate.getUTCDate()}getDay(){return this.jsDate.getUTCDay()}getHours(){return this.jsDate.getUTCHours()}getMinutes(){return this.jsDate.getUTCMinutes()}getSeconds(){return this.jsDate.getUTCSeconds()}getIsoWeek(){let e=new Date(this.jsDate.getTime()),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let n=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-n.getTime())/864e5+1)/7)}setFullYear(e){return this.jsDate.setUTCFullYear(e)}setMonth(e){return this.jsDate.setUTCMonth(e)}setDate(e){return this.jsDate.setUTCDate(e)}setHours(e){return this.jsDate.setUTCHours(e)}setMinutes(e){return this.jsDate.setUTCMinutes(e)}setSeconds(e){return this.jsDate.setUTCSeconds(e)}};let Ur=new O(1899,11,30),Wr=1440*60*1e3,Gr=2e3,Kr=O.now().getFullYear(),qr=O.now().getMonth(),Jr=O.fromTimestamp(0).getTime()-Ur.getTime(),Yr=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,Xr=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,Zr=zt.join(``),Qr=RegExp(`\/|-|${zt.join(`|`)}`),$r=RegExp(`^(\\d{1,4})[\/${Zr}\-](\\d{1,4})([\/${Zr}\-](\\d{1,4}))?$`),ei=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function ti(e,t){switch(typeof e){case`number`:return e;case`string`:return ni(e,t)?ii(e,t)?.value:!e||isNaN(Number(e))?void 0:Number(e);default:return}}function ni(e,t){return ii(e,t)!==null}let ri=new Map;function ii(e,t){return ri.has(t)||ri.set(t,new Map),ri.get(t).has(e)||ri.get(t).set(e,ai(e,t)),ri.get(t).get(e)}function ai(e,t){e=e.trim();let n=null,r=e.match(ei);if(r){if(n=pi(r[0]),n===null)return null;e=e.replace(r[0],``).trim()}let i=null,a=oi(e,t);if(a){let t=a.dateString.match(Qr)[0];if(i=ci(a,t),i===null)return null;e=e.replace(a.dateString,``).trim()}return e!==``||!(i||n)?null:i&&i.jsDate&&n&&n.jsDate?{value:i.value+n.value,format:i.format+` `+(n.format===`hhhh:mm:ss`?`hh:mm:ss`:n.format),jsDate:new O(i.jsDate.getFullYear()+n.jsDate.getFullYear()-1899,i.jsDate.getMonth()+n.jsDate.getMonth()-11,i.jsDate.getDate()+n.jsDate.getDate()-30,i.jsDate.getHours()+n.jsDate.getHours(),i.jsDate.getMinutes()+n.jsDate.getMinutes(),i.jsDate.getSeconds()+n.jsDate.getSeconds())}:i||n}function oi(e,t){let n=e.match($r);if(!n)return null;let[,r,i,,a]=n;if(r.length>2&&a&&a.length>2)return null;if(r.length>2)return{year:r,month:i,day:a,dateString:e,type:`ymd`};let o=si(t);return a?a.length>2?o===`mdy`?{month:r,day:i,year:a,dateString:e,type:`mdy`}:{day:r,month:i,year:a,dateString:e,type:`dmy`}:o===`mdy`?{month:r,day:i,year:a,dateString:e,type:`mdy`}:o===`ymd`?{year:r,month:i,day:a,dateString:e,type:`ymd`}:o===`dmy`?{day:r,month:i,year:a,dateString:e,type:`dmy`}:null:i.length>2?{month:r,year:i,day:void 0,dateString:e,type:o}:o===`dmy`?{day:r,month:i,year:a,dateString:e,type:`dmy`}:{month:r,day:i,year:a,dateString:e,type:`mdy`}}function si(e){switch(e.dateFormat[0]){case`d`:return`dmy`;case`m`:return`mdy`;case`y`:return`ymd`}throw Error(`Invalid date format in locale`)}function ci(e,t){let{year:n,month:r,day:i}=e,a=di(r),o=fi(i),s=ui(n);if(s===null||a===null||o===null)return null;let c=r?.length===2&&a+1<10||i?.length===2&&o<10,l=n?.length!==2,u=new O(s,a,o);if(u.getMonth()!==a||u.getDate()!==o)return null;let d=u.getTime()-Ur.getTime(),f=li(e,t,c,l);return{value:Math.round(d/Wr),format:f,jsDate:u}}function li(e,t,n,r){let i=e.year?r?`yyyy`:`yy`:void 0,a=e.month?n?`mm`:`m`:void 0,o=e.day?n?`dd`:`d`:void 0;switch(e.type){case`mdy`:return[a,o,i].filter(S).join(t);case`ymd`:return[i,a,o].filter(S).join(t);case`dmy`:return[o,a,i].filter(S).join(t)}}function ui(e){if(!e)return Kr;let t=Number(e);switch(e.length){case 1:return Gr+t;case 2:return Gr+(Gr+t>Kr+10?-100:0)+t;case 3:case 4:return t}return null}function di(e){if(!e)return qr;let t=Number(e);return t>=1&&t<=12?t-1:null}function fi(e){if(!e)return 1;let t=Number(e);return t>=0&&t<=31?t:null}function pi(e){if(e=e.trim(),ei.test(e)){let t=/AM/i.test(e),n=/PM/i.test(e),r=(t||n?e.substring(0,e.length-2).trim():e).split(/:/),i=r.length>=2,a=r.length===3,o=Number(r[0]),s=i?Number(r[1]):0,c=a?Number(r[2]):0,l=a?`hh:mm:ss`:`hh:mm`;if(t||n)l+=` a`;else if(!i)return null;o>=12&&t?o-=12:o<12&&n&&(o+=12),s+=Math.floor(c/60),c%=60,o+=Math.floor(s/60),s%=60,o>=24&&(l=`hhhh:mm:ss`);let u=new O(1899,11,30,o,s,c);return{value:o/24+s/1440+c/86400,format:l,jsDate:u}}return null}function mi(e){let t=Math.trunc(e),n=O.fromTimestamp(t*Wr-Jr),r=e-t;r=r<0?1+r:r;let i=Math.round(r*24),a=Math.round((r-i/24)*24*60),o=Math.round((r-i/24-a/24/60)*24*60*60);return n.setHours(i),n.setMinutes(a),n.setSeconds(o),n}function hi(e){return Math.round(gi(e))}function gi(e){return(e.getTime()-Ur.getTime())/Wr}function _i(e){return new O(e.getFullYear(),e.getMonth()+1,0).getDate()}function vi(e){return _i(e)===e.getDate()}function yi(e,t,n){let r=e.getFullYear(),i=e.getMonth(),a=e.getDate(),o=new O(r,i+t,1);return n&&a===_i(e)||a>_i(o)?o.setDate(_i(o)):o.setDate(a),o}function bi(e){let t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function xi(e,t,n){if(e===t)return 0;if(e>t){let n=t;t=e,e=n}let r=mi(e),i=mi(t),a=r.getDate(),o=i.getDate(),s=r.getMonth(),c=i.getMonth(),l=r.getFullYear(),u=i.getFullYear(),d=0,f=0;switch(n){case 0:a===31&&(a=30),a===30&&o===31&&(o=30),s===1&&a===(bi(l)?29:28)&&(a=30,c===1&&o===(bi(u)?29:28)&&(o=30)),d=l+(s*30+a)/360,f=u+(c*30+o)/360;break;case 1:let n=365,r=l===u,i=l+1===u;if(!r&&!i||!r&&s<c||!r&&s===c&&a<o){let e=0,t=0;for(let n=l;n<=u;n++)e++,t+=bi(n)?366:365;n=t/e}else r?bi(l)&&(n=366):(bi(l)&&s<2&&(n=366),bi(u)&&(c>1||c===1&&o===29)&&(n=366));d=e/n,f=t/n;break;case 2:d=e/360,f=t/360;break;case 3:d=e/365,f=t/365;break;case 4:a===31&&(a=30),o===31&&(o=30),d=l+(s*30+a)/360,f=u+(c*30+o)/360;break}return f-d}function Si(e,t){let n=(t.getFullYear()-e.getFullYear())*12+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?n-1:n}function Ci(e,t){let n=e.getTime(),r=t.getTime();return Math.floor((r-n)/Wr)}function wi(e,t){let n=t.getFullYear()-e.getFullYear(),r=e.getMonth(),i=t.getMonth(),a=e.getDate(),o=t.getDate();return i>r||i===r&&o>=a?n:n-1}function Ti(e,t){return xi(e,t,1)<1}function Ei(e,t){return Math.trunc(e)===Math.trunc(t)}function Di(e,t,n){return t>n?Di(e,n,t):(e=Math.trunc(e),t=Math.trunc(t),n=Math.trunc(n),e>=t&&e<=n)}function Oi(e,t){return Math.trunc(e)<Math.trunc(t)}function ki(e,t){return Math.trunc(e)<=Math.trunc(t)}function Ai(e,t){return Math.trunc(e)>Math.trunc(t)}function ji(e,t){return Math.trunc(e)>=Math.trunc(t)}let Mi=Ht(function(e){return e=ot(e),RegExp(`(?:^-?\\d+(?:${e}?\\d*(?:e(\\+|-)?\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)}),Ni=Ht(function(e){let t=ot(e.decimalSeparator),n=`(?:\\d+(?:${ot(e.thousandsSeparator||``)}\\d{3,})*(?:${t}\\d*)?)`,r=`(?:${t}\\d+)`,i=`(?:\\s*`+n+`|`+r+`)(?:e(?:\\+|-)?\\d+)?(?:\\s*%)?`,a=`^(?:(?:`+[`(?:\\s*-)?(?:\\s*[\\$€])?`+i,`(?:\\s*-)?`+i+`(?:\\s*[\\$€])?`,`(?:\\s*[\\$€])?(?:\\s*-)?`+i].join(`)|(?:`)+`))$`;return new RegExp(a,`i`)});function Pi(e,t){return e?Ni(t).test(e.trim()):!1}let Fi=Ht(function(e){return RegExp(`[\$€${ot(e.thousandsSeparator||``)}]`,`g`)});function Ii(e,t){e=e.replace(Fi(t),``),t.decimalSeparator!==`.`&&(e=e.replace(t.decimalSeparator,`.`));let n=Number(e);return isNaN(n)&&e.includes(`%`)&&(n=Number(e.split(`%`)[0]),!isNaN(n))?n/100:n}function Li(e,t,n){let r=[...e].sort((e,t)=>e-t),i=(r.length+(n?-1:1))*t;if(n||i--,Number.isInteger(i))return r[i];let a=Math.ceil(i),o=Math.floor(i);return r[a]*(i-o)+r[o]*(a-i)}function Ri(e){return`sheetId`in e}function zi(e){return`dimension`in e&&`sheetId`in e&&`elements`in e}function Bi(e){return`target`in e&&`sheetId`in e}function Vi(e){return`ranges`in e}function Hi(e){return`col`in e&&`row`in e&&`sheetId`in e}function Ui(e){return`sheetId`in e&&`zone`in e}let Wi=new Set([`RENAME_SHEET`,`DELETE_SHEET`,`CREATE_SHEET`,`DUPLICATE_SHEET`,`ADD_COLUMNS_ROWS`,`REMOVE_COLUMNS_ROWS`,`UNDO`,`REDO`,`ADD_MERGE`,`REMOVE_MERGE`,`UPDATE_LOCALE`,`ADD_PIVOT`,`UPDATE_PIVOT`,`INSERT_PIVOT`,`RENAME_PIVOT`,`REMOVE_PIVOT`,`DUPLICATE_PIVOT`]),Gi=new Set([`EVALUATE_CELLS`,`UPDATE_CELL`,`UNHIDE_COLUMNS_ROWS`,`HIDE_COLUMNS_ROWS`,`GROUP_HEADERS`,`UNGROUP_HEADERS`,`FOLD_ALL_HEADER_GROUPS`,`FOLD_HEADER_GROUP`,`FOLD_HEADER_GROUPS_IN_ZONE`,`UNFOLD_ALL_HEADER_GROUPS`,`UNFOLD_HEADER_GROUP`,`UNFOLD_HEADER_GROUPS_IN_ZONE`,`UPDATE_TABLE`,`UPDATE_FILTER`,`UNDO`,`REDO`]),Ki=new Set([`MOVE_RANGES`]),qi=new Set([`EVALUATE_CELLS`,`ADD_CONDITIONAL_FORMAT`,`REMOVE_CONDITIONAL_FORMAT`,`CHANGE_CONDITIONAL_FORMAT_PRIORITY`]),Ji=new Set([`AUTOFILL_CELL`,`SET_BORDER`,`SET_ZONE_BORDERS`,`SET_BORDERS_ON_TARGET`]),Yi=new Set([`START`,`ACTIVATE_SHEET`,`COPY`,`RESIZE_SHEETVIEW`,`SET_VIEWPORT_OFFSET`,`EVALUATE_CELLS`,`SET_FORMULA_VISIBILITY`,`UPDATE_FILTER`]),Xi=new Set(`UPDATE_CELL.UPDATE_CELL_POSITION.CLEAR_CELL.CLEAR_CELLS.DELETE_CONTENT.ADD_COLUMNS_ROWS.REMOVE_COLUMNS_ROWS.RESIZE_COLUMNS_ROWS.HIDE_COLUMNS_ROWS.UNHIDE_COLUMNS_ROWS.SET_GRID_LINES_VISIBILITY.UNFREEZE_COLUMNS.UNFREEZE_ROWS.FREEZE_COLUMNS.FREEZE_ROWS.UNFREEZE_COLUMNS_ROWS.ADD_MERGE.REMOVE_MERGE.CREATE_SHEET.DELETE_SHEET.DUPLICATE_SHEET.MOVE_SHEET.RENAME_SHEET.COLOR_SHEET.HIDE_SHEET.SHOW_SHEET.MOVE_RANGES.ADD_CONDITIONAL_FORMAT.REMOVE_CONDITIONAL_FORMAT.CHANGE_CONDITIONAL_FORMAT_PRIORITY.CREATE_FIGURE.DELETE_FIGURE.UPDATE_FIGURE.SET_FORMATTING.CLEAR_FORMATTING.SET_BORDER.SET_ZONE_BORDERS.SET_BORDERS_ON_TARGET.CREATE_CHART.UPDATE_CHART.CREATE_TABLE.REMOVE_TABLE.UPDATE_TABLE.CREATE_TABLE_STYLE.REMOVE_TABLE_STYLE.CREATE_IMAGE.GROUP_HEADERS.UNGROUP_HEADERS.UNFOLD_HEADER_GROUP.FOLD_HEADER_GROUP.FOLD_ALL_HEADER_GROUPS.UNFOLD_ALL_HEADER_GROUPS.UNFOLD_HEADER_GROUPS_IN_ZONE.FOLD_HEADER_GROUPS_IN_ZONE.ADD_DATA_VALIDATION_RULE.REMOVE_DATA_VALIDATION_RULE.UPDATE_LOCALE.ADD_PIVOT.UPDATE_PIVOT.INSERT_PIVOT.RENAME_PIVOT.REMOVE_PIVOT.DUPLICATE_PIVOT`.split(`.`));function Zi(e){return Xi.has(e.type)}function Qi(e){return Yi.has(e.type)}var $i=class{reasons;constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter(e=>e!==`Success`)}static get Success(){return ea}get isSuccessful(){return this.reasons.length===0}isCancelledBecause(e){return this.reasons.includes(e)}};let ea=new $i,ta=function(e){return e.Success=`Success`,e.CancelledForUnknownReason=`CancelledForUnknownReason`,e.WillRemoveExistingMerge=`WillRemoveExistingMerge`,e.CannotMoveTableHeader=`CannotMoveTableHeader`,e.MergeIsDestructive=`MergeIsDestructive`,e.CellIsMerged=`CellIsMerged`,e.InvalidTarget=`InvalidTarget`,e.EmptyUndoStack=`EmptyUndoStack`,e.EmptyRedoStack=`EmptyRedoStack`,e.NotEnoughElements=`NotEnoughElements`,e.NotEnoughSheets=`NotEnoughSheets`,e.MissingSheetName=`MissingSheetName`,e.UnchangedSheetName=`UnchangedSheetName`,e.DuplicatedSheetName=`DuplicatedSheetName`,e.DuplicatedSheetId=`DuplicatedSheetId`,e.ForbiddenCharactersInSheetName=`ForbiddenCharactersInSheetName`,e.WrongSheetMove=`WrongSheetMove`,e.WrongSheetPosition=`WrongSheetPosition`,e.InvalidAnchorZone=`InvalidAnchorZone`,e.SelectionOutOfBound=`SelectionOutOfBound`,e.TargetOutOfSheet=`TargetOutOfSheet`,e.WrongCutSelection=`WrongCutSelection`,e.WrongPasteSelection=`WrongPasteSelection`,e.WrongPasteOption=`WrongPasteOption`,e.WrongFigurePasteOption=`WrongFigurePasteOption`,e.EmptyClipboard=`EmptyClipboard`,e.EmptyRange=`EmptyRange`,e.InvalidRange=`InvalidRange`,e.InvalidZones=`InvalidZones`,e.InvalidSheetId=`InvalidSheetId`,e.InvalidCellId=`InvalidCellId`,e.InvalidFigureId=`InvalidFigureId`,e.InputAlreadyFocused=`InputAlreadyFocused`,e.MaximumRangesReached=`MaximumRangesReached`,e.MinimumRangesReached=`MinimumRangesReached`,e.InvalidChartDefinition=`InvalidChartDefinition`,e.InvalidDataSet=`InvalidDataSet`,e.InvalidLabelRange=`InvalidLabelRange`,e.InvalidScorecardKeyValue=`InvalidScorecardKeyValue`,e.InvalidScorecardBaseline=`InvalidScorecardBaseline`,e.InvalidGaugeDataRange=`InvalidGaugeDataRange`,e.EmptyGaugeRangeMin=`EmptyGaugeRangeMin`,e.GaugeRangeMinNaN=`GaugeRangeMinNaN`,e.EmptyGaugeRangeMax=`EmptyGaugeRangeMax`,e.GaugeRangeMaxNaN=`GaugeRangeMaxNaN`,e.GaugeRangeMinBiggerThanRangeMax=`GaugeRangeMinBiggerThanRangeMax`,e.GaugeLowerInflectionPointNaN=`GaugeLowerInflectionPointNaN`,e.GaugeUpperInflectionPointNaN=`GaugeUpperInflectionPointNaN`,e.GaugeLowerBiggerThanUpper=`GaugeLowerBiggerThanUpper`,e.InvalidAutofillSelection=`InvalidAutofillSelection`,e.MinBiggerThanMax=`MinBiggerThanMax`,e.LowerBiggerThanUpper=`LowerBiggerThanUpper`,e.MidBiggerThanMax=`MidBiggerThanMax`,e.MinBiggerThanMid=`MinBiggerThanMid`,e.FirstArgMissing=`FirstArgMissing`,e.SecondArgMissing=`SecondArgMissing`,e.MinNaN=`MinNaN`,e.MidNaN=`MidNaN`,e.MaxNaN=`MaxNaN`,e.ValueUpperInflectionNaN=`ValueUpperInflectionNaN`,e.ValueLowerInflectionNaN=`ValueLowerInflectionNaN`,e.MinInvalidFormula=`MinInvalidFormula`,e.MidInvalidFormula=`MidInvalidFormula`,e.MaxInvalidFormula=`MaxInvalidFormula`,e.ValueUpperInvalidFormula=`ValueUpperInvalidFormula`,e.ValueLowerInvalidFormula=`ValueLowerInvalidFormula`,e.InvalidSortZone=`InvalidSortZone`,e.WaitingSessionConfirmation=`WaitingSessionConfirmation`,e.MergeOverlap=`MergeOverlap`,e.TooManyHiddenElements=`TooManyHiddenElements`,e.Readonly=`Readonly`,e.InvalidViewportSize=`InvalidViewportSize`,e.InvalidScrollingDirection=`InvalidScrollingDirection`,e.ViewportScrollLimitsReached=`ViewportScrollLimitsReached`,e.FigureDoesNotExist=`FigureDoesNotExist`,e.InvalidConditionalFormatId=`InvalidConditionalFormatId`,e.InvalidConditionalFormatType=`InvalidConditionalFormatType`,e.InvalidCellPopover=`InvalidCellPopover`,e.EmptyTarget=`EmptyTarget`,e.InvalidFreezeQuantity=`InvalidFreezeQuantity`,e.FrozenPaneOverlap=`FrozenPaneOverlap`,e.ValuesNotChanged=`ValuesNotChanged`,e.InvalidFilterZone=`InvalidFilterZone`,e.TableNotFound=`TableNotFound`,e.TableOverlap=`TableOverlap`,e.InvalidTableConfig=`InvalidTableConfig`,e.InvalidTableStyle=`InvalidTableStyle`,e.FilterNotFound=`FilterNotFound`,e.MergeInTable=`MergeInTable`,e.NonContinuousTargets=`NonContinuousTargets`,e.DuplicatedFigureId=`DuplicatedFigureId`,e.InvalidSelectionStep=`InvalidSelectionStep`,e.DuplicatedChartId=`DuplicatedChartId`,e.ChartDoesNotExist=`ChartDoesNotExist`,e.InvalidHeaderIndex=`InvalidHeaderIndex`,e.InvalidQuantity=`InvalidQuantity`,e.MoreThanOneColumnSelected=`MoreThanOneColumnSelected`,e.EmptySplitSeparator=`EmptySplitSeparator`,e.SplitWillOverwriteContent=`SplitWillOverwriteContent`,e.NoSplitSeparatorInSelection=`NoSplitSeparatorInSelection`,e.NoActiveSheet=`NoActiveSheet`,e.InvalidLocale=`InvalidLocale`,e.MoreThanOneRangeSelected=`MoreThanOneRangeSelected`,e.NoColumnsProvided=`NoColumnsProvided`,e.ColumnsNotIncludedInZone=`ColumnsNotIncludedInZone`,e.DuplicatesColumnsSelected=`DuplicatesColumnsSelected`,e.InvalidHeaderGroupStartEnd=`InvalidHeaderGroupStartEnd`,e.HeaderGroupAlreadyExists=`HeaderGroupAlreadyExists`,e.UnknownHeaderGroup=`UnknownHeaderGroup`,e.UnknownDataValidationRule=`UnknownDataValidationRule`,e.UnknownDataValidationCriterionType=`UnknownDataValidationCriterionType`,e.InvalidDataValidationCriterionValue=`InvalidDataValidationCriterionValue`,e.InvalidNumberOfCriterionValues=`InvalidNumberOfCriterionValues`,e.InvalidCopyPasteSelection=`InvalidCopyPasteSelection`,e.NoChanges=`NoChanges`,e.InvalidInputId=`InvalidInputId`,e.SheetIsHidden=`SheetIsHidden`,e.InvalidTableResize=`InvalidTableResize`,e.PivotIdNotFound=`PivotIdNotFound`,e.PivotInError=`PivotInError`,e.EmptyName=`EmptyName`,e.ValueCellIsInvalidFormula=`ValueCellIsInvalidFormula`,e.InvalidDefinition=`InvalidDefinition`,e.InvalidColor=`InvalidColor`,e.InvalidPivotDataSet=`InvalidPivotDataSet`,e}({}),na=[{name:`English (US)`,code:`en_US`,thousandsSeparator:`,`,decimalSeparator:`.`,weekStart:7,dateFormat:`m/d/yyyy`,timeFormat:`hh:mm:ss a`,formulaArgSeparator:`,`},{name:`French`,code:`fr_FR`,thousandsSeparator:` `,decimalSeparator:`,`,weekStart:1,dateFormat:`dd/mm/yyyy`,timeFormat:`hh:mm:ss`,formulaArgSeparator:`;`}],k=na[0],ra=[`thin`,`medium`,`thick`,`dashed`,`dotted`];function A(e){return Array.isArray(e)&&Array.isArray(e[0])}let ia={Background:0,Highlights:1,Clipboard:2,Chart:4,Autofill:5,Selection:6,Headers:100},aa=Ht(()=>Object.keys(ia).sort((e,t)=>ia[e]-ia[t]));function oa(e,t){if(ia[e])throw Error(`Layer ${e} already exists`);ia[e]=t}let j={NotAvailable:`#N/A`,InvalidReference:`#REF`,BadExpression:`#BAD_EXPR`,CircularDependency:`#CYCLE`,UnknownFunction:`#NAME?`,DivisionByZero:`#DIV/0!`,SpilledBlocked:`#SPILL!`,GenericError:`#ERROR`,NullError:`#NULL!`},sa=new Set(Object.values(j));var M=class{message;value;constructor(e=E(`Error`),t=j.GenericError){this.message=e,this.value=t,this.message=e.toString()}},ca=class extends M{constructor(e=E(`Invalid expression`)){super(e,j.BadExpression)}},la=class extends M{constructor(e=E(`Circular reference`)){super(e,j.CircularDependency)}},ua=class extends M{constructor(e=E(`Invalid reference`)){super(e,j.InvalidReference)}},da=class extends M{constructor(e=E(`Data not available`)){super(e,j.NotAvailable)}},fa=class extends M{constructor(e=E(`Unknown function`)){super(e,j.UnknownFunction)}},pa=class extends M{constructor(e=E(`Spill range is not empty`)){super(e,j.SpilledBlocked)}};let ma=[`number`,`string`,`boolean`,`undefined`];function N(e,t,n){if(!e())throw new M(t,n)}function ha(e){if(e!==void 0)return A(e)?e[0][0]?.format:e.format}function P(e){return typeof e==`string`&&sa.has(e)}let ga=e=>E(`The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.`,e),_a=(e,t,n)=>E(`The function [[FUNCTION_NAME]] expects a number value between %s and %s inclusive, but receives %s.`,e.toString(),t.toString(),n.toString()),va=(e,t)=>E(`The function [[FUNCTION_NAME]] has an argument with value '%s'. It should be one of: %s.`,t,e.map(e=>`'${e}'`).join(`, `));function F(e,t){let n=ka(e);switch(typeof n){case`number`:return n;case`boolean`:return+!!n;case`string`:if(Pi(n,t)||n===``)return Ii(n,t);let e=ii(n,t);if(e)return e.value;throw new M(ga(n));default:return 0}}function ya(e,t){try{return F(e,t)}catch{return}}function ba(e,t){return B(e).map(e=>e.map(e=>{if(typeof e.value!=`number`){let n=``;throw typeof e==`object`?n=E(`Function [[FUNCTION_NAME]] expects number values for %s, but got an empty value.`,t):typeof e==`string`?n=E(`Function [[FUNCTION_NAME]] expects number values for %s, but got a string.`,t):typeof e==`boolean`&&(n=E(`Function [[FUNCTION_NAME]] expects number values for %s, but got a boolean.`,t)),new M(n)}return e.value}))}function xa(e,t){let n=ka(e);if(n===``)throw new M(ga(n));return F(n,t)}function Sa(e,t){return Math.trunc(F(e,t))}function Ca(e,t){return Math.trunc(xa(e,t))}function wa(e){N(()=>e>=1,E(`The function [[FUNCTION_NAME]] expects a number value to be greater than or equal to 1, but receives %s.`,e.toString()))}function Ta(e){N(()=>e!==0,E(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`),j.DivisionByZero)}function I(e){let t=ka(e);switch(typeof t){case`string`:return t;case`number`:return t.toString();case`boolean`:return t?`TRUE`:`FALSE`;default:return``}}function L(e,t){let n=ka(e);switch(typeof n){case`string`:return n;case`number`:return n.toString().replace(`.`,t.decimalSeparator);case`boolean`:return n?`TRUE`:`FALSE`;default:return``}}let Ea=Ht(function(e){return e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``)}),Da=e=>E(`The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a boolean.`,e);function R(e){let t=ka(e);switch(typeof t){case`boolean`:return t;case`string`:if(t){let e=t.toUpperCase();if(e===`TRUE`)return!0;if(e===`FALSE`)return!1;throw new M(Da(t))}else return!1;case`number`:return!!t;default:return!1}}function Oa(e){let t=ka(e);if(t===``)throw new M(Da(t));return R(t)}function z(e,t){return mi(F(ka(e),t))}function ka(e){if(typeof e==`object`&&e&&`value`in e){if(P(e.value))throw e;return e.value}if(P(e))throw new M(``,e);return e}function Aa(e,t,n){for(let r of e)if(A(r)){let e=r.length,n=r[0].length;for(let i=0;i<n;i++)for(let n=0;n<e;n++)t(r[n][i])}else n(r)}function ja(e,t){Aa(e,e=>{if(P(e.value))throw e;t(e)},e=>{if(P(e?.value))throw e;t(e)})}function Ma(e,t,n){Aa(e,e=>{if(typeof e?.value==`number`&&t(e),P(e?.value))throw e},e=>{t({value:xa(e,n),format:e?.format})})}function Na(e,t,n,r,i=`rowFirst`){let a=r;for(let r of e)if(A(r)){let e=r.length,n=r[0].length;if(i===`rowFirst`)for(let i=0;i<n;i++)for(let n=0;n<e;n++)a=t(a,r[n][i]);else for(let i=0;i<e;i++)for(let e=0;e<n;e++)a=t(a,r[i][e])}else a=n(a,r);return a}function Pa(e,t,n,r=`rowFirst`){return Na(e,t,t,n,r)}function Fa(e,t,n,r){return Na(e,(e,n)=>{let r=n?.value;if(typeof r==`number`)return t(e,r);if(P(r))throw n;return e},(e,n)=>t(e,xa(n,r)),n)}function Ia(e,t,n,r){return Na(e,(e,n)=>{let i=n?.value;if(i!=null){if(typeof i==`number`)return t(e,i);if(typeof i==`boolean`)return t(e,F(i,r));if(P(i))throw n;return t(e,0)}return e},(e,n)=>t(e,F(n,r)),n)}function La(e,t,n){let r=Array(e);for(let i=0;i<e;i++){r[i]=Array(t);for(let e=0;e<t;e++)r[i][e]=n(i,e)}return r}function Ra(e,t){return e.length===0?[]:La(e.length,e[0].length,(n,r)=>t(e[n][r]))}function za(e,t){let n=e.length,r=e[0]?.length??0;for(let i=0;i<n;i++)for(let n=0;n<r;n++)t(e[i][n])}function Ba(e){return e.length?La(e[0].length,e.length,(t,n)=>e[n][t]):[]}function Va(e,t,n=void 0){let r=1,i=1,a=1/0,o=1/0,s;for(let e=0;e<t.length;e++){let c=t[e];if(A(c)&&(n===void 0||n[e])){let n=c.length,l=c[0].length;n!==1||l!==1?(s??=Array(t.length),n!==1&&l!==1?(s[e]=`matrix`,r=Math.max(r,n),i=Math.max(i,l),a=Math.min(a,n),o=Math.min(o,l)):n===1?l!==1&&(s[e]=`vertical`,i=Math.max(i,l),o=Math.min(o,l)):(s[e]=`horizontal`,r=Math.max(r,n),a=Math.min(a,n))):t[e]=c[0][0]}}if(r===1&&i===1)return e(...t);let c=Array(t.length),l=[],u=[];for(let e=0;e<t.length;e++){let n=t[e];switch(s?.[e]){case`matrix`:l.push((e,t)=>n[e][t]),u.push(e);break;case`horizontal`:l.push(e=>n[e][0]),u.push(e);break;case`vertical`:l.push((e,t)=>n[0][t]),u.push(e);break;case void 0:c[e]=n;break}}let d=u.length,f;switch(c.length){case 1:f=()=>e(c[0]);break;case 2:f=()=>e(c[0],c[1]);break;case 3:f=()=>e(c[0],c[1],c[2]);break;default:f=()=>e(...c)}let p=Array(r);for(let e=0;e<r;e++){let t=Array(i);p[e]=t;for(let n=0;n<i;n++){if(e>a-1||n>o-1){t[n]=new da(E(`Array arguments to [[FUNCTION_NAME]] are of different size.`));continue}for(let t=0;t<d;t++)c[u[t]]=l[t](e,n);let r=f();t[n]=A(r)?r[0][0]:r}}return p}function Ha(e,t,n){for(let r of e)if(A(r)){let e=r.length,n=r[0].length;for(let i=0;i<n;i++)for(let n=0;n<e;n++)if(!t(r[n][i]??void 0))return}else if(!n(r))return}function Ua(e,t){return Ha(e,e=>{let n=e?.value;if(typeof n==`boolean`)return t(n);if(typeof n==`number`)return t(!!n);if(P(n))throw e;return!0},e=>e!==void 0&&e.value!==null?t(Oa(e)):!0)}function Wa(e,t){let n,r,i=e.substring(0,2);return i===`<=`||i===`>=`||i===`<>`?(n=i,r=e.substring(2)):(i=e.substring(0,1),i===`<`||i===`>`||i===`=`?(n=i,r=e.substring(1)):(n=`=`,r=e)),Pi(r,t)||ni(r,t)?r=F(r,t):(r===`TRUE`||r===`FALSE`)&&(r=R(r)),{operator:n,operand:r}}let Ga=Ht(function(e){if(e===`*`)return/.+/;let t=``,n=``;for(let r of e)r===`?`&&n!==`~`?t+=`.`:r===`*`&&n!==`~`?t+=`.*`:((r===`*`||r===`?`)&&(t=t.slice(0,-1)),[`^`,`.`,`[`,`]`,`$`,`(`,`)`,`*`,`+`,`?`,`|`,`{`,`}`,`\\`].includes(r)&&(t+=`\\`),t+=r),n=r;return RegExp(`^`+t+`$`,`i`)});function Ka(e=``,t,n){let{operator:r,operand:i}=t;if(i===void 0||e===null||i===null)return!1;if(typeof i==`number`&&r===`=`)return typeof e==`string`&&(Pi(e,n)||ni(e,n))?F(e,n)===i:e===i;if(r===`<>`||r===`=`){let t;return t=typeof e==typeof i?typeof e==`string`&&typeof i==`string`?Ga(i).test(e):e===i:!1,r===`=`?t:!t}if(typeof e==typeof i)switch(r){case`<`:return e<i;case`>`:return e>i;case`<=`:return e<=i;case`>=`:return e>=i}return!1}function qa(e,t,n,r=!1){let i=e.length;if(i%2==1)throw new M(E(`Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs.`));let a=B(e[0]),o=a.length,s=a[0].length,c=[];for(let t=0;t<i-1;t+=2){let i=B(e[t]);if(i.length!==o||i[0].length!==s)throw new M(E(`Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension`));let a=Wa(L(e[t+1],n),n);r&&typeof a.operand==`string`&&(a.operand+=`*`),c.push(a)}for(let r=0;r<o;r++)for(let a=0;a<s;a++){let o=!0;for(let t=0;t<i-1;t+=2){let i=B(e[t])[r][a].value,s=c[t/2];if(o=Ka(i??void 0,s,n),!o)break}o&&t(r,a)}}function Ja(e,t,n,r,i,a){if(t===void 0||t.value===null)return-1;if(P(t.value))throw t;let o=Za(t.value),s=typeof o,c,l,u=0,d=i-1,f,p,m,h,g=r===`desc`?t=>Za(a(e,i-t-1)):t=>Za(a(e,t));for(;d-u>=0;){for(f=Math.floor((u+d)/2),p=f,m=g(p),h=typeof m;u<p&&s!==h;)p--,m=g(p),h=typeof m;if(h!==s||m==null){u=f+1;continue}n===`strict`&&m===o?(c=m,l=p):n===`nextSmaller`&&m<=o?(c==null||c<m||c===m&&l<p)&&(c=m,l=p):n===`nextGreater`&&m>=o&&(c===void 0||c>m||c===m&&l<p)&&(c=m,l=p),m>o||n===`strict`&&m===o?d=p-1:u=f+1}return l===void 0?-1:r===`desc`?i-l-1:l}function Ya(e,t,n,r,i,a,o=!1){if(t===void 0||t.value===null)return-1;if(P(t.value))throw t;let s=Za(t.value),c=o?(e,t)=>Za(i(e,r-t-1)):(e,t)=>Za(i(e,t)),l=n!==`wildcard`||typeof s!=`string`||!(s.includes(`*`)||s.includes(`?`));if(a&&l){let t=o?`reverseSearch`:`forwardSearch`,i=a[t].get(e);if(i===void 0){i=new Map;for(let t=0;t<r;t++){let n=c(e,t)??null;i.has(n)||i.set(n,t)}a[t].set(e,i)}if(i.has(s)){let e=i.get(s);return o?r-e-1:e}if(n===`strict`)return-1}let u=Xa(e,s,n,r,c);return o&&u!==-1?r-u-1:u}function Xa(e,t,n,r,i){let a=n=>i(e,n)===t;if(n===`wildcard`&&typeof t==`string`&&(t.includes(`*`)||t.includes(`?`))){let n=Ga(t);a=t=>{let r=i(e,t);return typeof r==`string`?n.test(r):!1}}let o,s=-1;n===`nextSmaller`&&(a=n=>{let r=i(e,n);return(!o&&Qa(t,r)>=0||Qa(t,r)>=0&&Qa(r,o)>0)&&(o=r,s=n),r===t}),n===`nextGreater`&&(a=n=>{let r=i(e,n);return(!o&&Qa(t,r)<=0||Qa(t,r)<=0&&Qa(r,o)<0)&&(o=r,s=n),r===t});for(let e=0;e<r;e++)if(a(e))return e;return s}function Za(e){return typeof e==`string`?Ea(e):e}function Qa(e,t){let n=ma.indexOf(typeof e)-ma.indexOf(typeof t);return n===0&&(typeof e==`string`&&typeof t==`string`?n=e.localeCompare(t):typeof e==`number`&&typeof t==`number`?n=e-t:typeof e==`boolean`&&typeof t==`boolean`&&(n=Number(e)-Number(t))),n}function B(e){return e===void 0?[[]]:A(e)?e:[[e]]}function $a(e,t){return Pa(e,(e,n)=>(e.push(t(n)),e),[],`rowFirst`)}function eo(e){if(e===void 0)return!1;let{value:t}=e;return!(t===null||t===``)}function to(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}let no=new h;function ro(e,t){return e=to(e),{url:e,label:t||e,isExternal:!0,isUrlEditable:!0}}no.add(`sheet_URL`,{match:e=>St(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){let n=wt(e);return t.tryGetSheetName(n)||E(`Invalid sheet`)},open(e,t){let n=wt(e);t.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:n}).isCancelledBecause(`SheetIsHidden`)&&t.notifyUser({type:`warning`,sticky:!1,text:E(`Cannot open the link because the linked sheet is hidden.`)})},sequence:0});let io={createLink:ro,match:e=>vt(e),open:e=>window.open(e,`_blank`),urlRepresentation:e=>e,sequence:0};function ao(e){return no.getAll().sort((e,t)=>e.sequence-t.sequence).find(t=>t.match(e))||io}function oo(e,t){return ao(e.url).urlRepresentation(e.url,t)}function so(e,t){ao(e.url).open(e.url,t)}function co(e){if(typeof e==`string`){if(_t(e)){let{label:t,url:n}=bt(e);return ao(n).createLink(n,t)}else if(vt(e))return ro(e)}}function lo(e){e=e.replace(/\s/g,` `);let t=new Zt(e),n=[],r=[];for(n.push(r);!t.isOver();){if(t.current===`;`){r=[],n.push(r),t.shift();continue}let e=vo(t)||uo(t)||po(t)||mo(t)||go(t)||_o(t)||bo(t)||ho(t)||xo(t);if(!e)throw Error(`Unknown token at `+t.remaining());r.push(e)}return n}function uo(e){let t;if(e.current===`"`?(e.shift(),t=`"`):e.currentStartsWith(`[$`)&&(e.advanceBy(2),t=`]`),!t)return null;let n=``;for(;e.current&&e.current!==t;)n+=e.shift();if(e.current===t)e.shift();else throw Error(`Unterminated string in format`);return{type:`STRING`,value:n}}let fo=new Set(`$+-/():!^&~{}<>= `);function po(e){if(e.current===`\\`){e.shift();let t=e.shift();if(!t)throw Error(`Unexpected end of format string`);return{type:`CHAR`,value:t}}return fo.has(e.current)?{type:`CHAR`,value:e.shift()}:null}function mo(e){return e.current===`,`?(e.shift(),{type:`THOUSANDS_SEPARATOR`,value:`,`}):null}function ho(e){return e.current===`@`?(e.shift(),{type:`TEXT_PLACEHOLDER`,value:`@`}):null}function go(e){return e.current===`.`?(e.shift(),{type:`DECIMAL_POINT`,value:`.`}):null}function _o(e){return e.current===`%`?(e.shift(),{type:`PERCENT`,value:`%`}):null}function vo(e){if(e.current===`0`||e.current===`#`){let t=e.current;return e.shift(),{type:`DIGIT`,value:t}}return null}let yo=new Set(`dmqyhsa`);function bo(e){if(!yo.has(e.current))return null;let t=e.current,n=``;for(;e.current===t;)n+=e.shift();return{type:`DATE_PART`,value:n}}function xo(e){if(e.current!==`*`)return null;e.shift();let t=e.shift();if(!t)throw Error(`Unexpected end of format string`);return{type:`REPEATED_CHAR`,value:t}}let So={};function Co(e){let t=So[e];return t===void 0&&(t=wo(e),So[e]=t),t}function wo(e){let t=lo(e);for(let e of t){let t=e.filter(e=>e.type===`REPEATED_CHAR`);for(let e of t.slice(1))e.type=`CHAR`}let n=ko(t[0])||Oo(t[0])||Ao(t[0]);if(!n)throw Error(`Invalid first format part of: `+e);if(t.length>1&&n.type===`text`)throw Error(`The first format in a multi-part format must be a number format: `+e);let r=ko(t[1])||Oo(t[1]);if(t[1]?.length&&!r)throw Error(`Invalid second format part of: `+e);let i=ko(t[2])||Oo(t[2]);if(t[2]?.length&&!i)throw Error(`Invalid third format part of: `+e);let a=Ao(t[3]);if(t[3]?.length&&!a)throw Error(`Invalid fourth format part of: `+e);return{positive:n,negative:r,zero:i,text:a}}function To(e){return e.every(e=>e.type===`DATE_PART`||e.type===`DECIMAL_POINT`||e.type===`THOUSANDS_SEPARATOR`||e.type===`STRING`||e.type===`CHAR`||e.type===`REPEATED_CHAR`)}function Eo(e){return e.every(e=>e.type===`DIGIT`||e.type===`DECIMAL_POINT`||e.type===`THOUSANDS_SEPARATOR`||e.type===`PERCENT`||e.type===`STRING`||e.type===`CHAR`||e.type===`REPEATED_CHAR`)}function Do(e){return e.every(e=>e.type===`STRING`||e.type===`TEXT_PLACEHOLDER`||e.type===`CHAR`||e.type===`REPEATED_CHAR`)}function Oo(e){if(!e||!Eo(e))return;let t=[],n,r=t,i=0,a=0,o=e.findLastIndex(e=>e.type===`DIGIT`),s=!1,c=0;for(let l=0;l<e.length;l++){let u=e[l];switch(u.type){case`DIGIT`:r===t?r.push(u):c<20&&(r.push(u),c++);break;case`DECIMAL_POINT`:if(r===t)n=[],r=n;else throw Error(`Multiple decimal points in a number format`);break;case`REPEATED_CHAR`:case`CHAR`:case`STRING`:r.push(u);break;case`PERCENT`:i++,r.push(u);break;case`THOUSANDS_SEPARATOR`:l-1===o?(a+=1,o++,r.push(u)):e[l+1]?.type===`DIGIT`&&e[l-1]?.type===`DIGIT`?(r===t&&(s=!0),r.push(u)):r.push({type:`CHAR`,value:`,`});break}}return{type:`number`,integerPart:t,decimalPart:n,percentSymbols:i,thousandsSeparator:s,magnitude:a}}function ko(e){let t=e&&To(e)?{type:`date`,tokens:e}:void 0;if(t){if(t.tokens.length&&t.tokens.every(e=>e.type===`DATE_PART`&&e.value===`a`))throw Error(`Invalid date format`);return{type:`date`,tokens:jo(t.tokens.map(e=>e.type===`THOUSANDS_SEPARATOR`||e.type===`DECIMAL_POINT`?{type:`CHAR`,value:e.value}:e))}}}function Ao(e){return e&&Do(e)?{type:`text`,tokens:e}:void 0}function jo(e){let t=e.filter(e=>e.type===`DATE_PART`);for(let e=0;e<t.length;e++)!t[e].value.startsWith(`m`)||t[e].value.length>2||(t[e-1]?.value.startsWith(`h`)||t[e+1]?.value.startsWith(`s`))&&(t[e].value=t[e].value.replaceAll(`m`,`M`));return e}function Mo(e){return[No(e.positive),No(e.negative),No(e.zero),No(e.text)].filter(S).join(`;`)}function No(e){if(!e)return;let t=``,n=e.type===`number`?Po(e):e.tokens;for(let e of n)switch(e.type){case`STRING`:t+=`[$${e.value}]`;break;case`CHAR`:t+=Fo(e.value)?`\\${e.value}`:e.value;break;case`REPEATED_CHAR`:t+=`*`+e.value;break;case`DATE_PART`:t+=e.value===`MM`?`mm`:e.value;break;default:t+=e.value}return t}function Po(e){let t=[...e.integerPart];return e.decimalPart&&(t.push({type:`DECIMAL_POINT`,value:`.`}),t.push(...e.decimalPart)),t}function Fo(e){return!fo.has(e)}let Io=`REPEATED_CHAR_PLACEHOLDER_`,Lo={0:E(`January`),1:E(`February`),2:E(`March`),3:E(`April`),4:E(`May`),5:E(`June`),6:E(`July`),7:E(`August`),8:E(`September`),9:E(`October`),10:E(`November`),11:E(`December`)},Ro={0:E(`Sunday`),1:E(`Monday`),2:E(`Tuesday`),3:E(`Wednesday`),4:E(`Thursday`),5:E(`Friday`),6:E(`Saturday`)};function V(e,{format:t,locale:n,formatWidth:r}){switch(typeof e==`boolean`&&(e=e?`TRUE`:`FALSE`),typeof e){case`string`:{if(e.includes(`\\"`)&&(e=e.replaceAll(/\\"/g,`"`)),!t)return e;let n=Co(t),i=n.text||n.positive;return!i||i.type!==`text`?e:zo(e,i,r)}case`number`:t||=ts(e);let i=Co(t);if(i.positive.type===`text`)return zo(e.toString(),i.positive,r);let a=i.positive;if(e<0&&i.negative?(a=i.negative,e=-e):e===0&&i.zero&&(a=i.zero),a.type===`date`)return Bo(Qo(e,a),r);let o=e<0,s=Bo(Vo(Math.abs(e),a,n),r);return o?`-`+s:s;case`object`:return``}}function zo(e,t,n){let r=``;for(let n of t.tokens)switch(n.type){case`TEXT_PLACEHOLDER`:r+=e;break;case`CHAR`:case`STRING`:r+=n.value;break;case`REPEATED_CHAR`:r+=Io+n.value;break}return Bo(r,n)}function Bo(e,t){let n=e.indexOf(Io);if(n===-1)return e;let r=e.slice(0,n),i=e.slice(n+26+1),a=e[n+26];function o(){if(!t)return{timesToRepeat:0,padding:``};let e=t.measureText(r+i),n=t.measureText(a),o=t.availableWidth-e;if(o<=0)return{timesToRepeat:0,padding:``};let s=Math.floor(o/n),c=o-s*n,l=t.measureText(` `);return{timesToRepeat:s,padding:` `.repeat(Math.floor(c/l))}}let{timesToRepeat:s,padding:c}=o();return r+a.repeat(s)+c+i}function Vo(e,t,n){if(e===1/0)return`∞`+(t.percentSymbols?`%`:``);let r=t.percentSymbols*2-t.magnitude*3;e*=10**r;let i=0;t.decimalPart!==void 0&&(i=t.decimalPart.filter(e=>e.type===`DIGIT`).length);let{integerDigits:a,decimalDigits:o}=Go(Math.abs(e),i),s=Ho(a,t,t.thousandsSeparator?n.thousandsSeparator:void 0);return t.decimalPart!==void 0&&(s+=n.decimalSeparator+Uo(o||``,t)),s}function Ho(e,t,n){let r=t.integerPart;r.some(e=>e.type===`DIGIT`)||(r=[...r,{type:`DIGIT`,value:`#`}]),e===`0`&&(e=``);let i=``,a=r.findIndex(e=>e.type===`DIGIT`),o=e.length-1;function s(t,r){if(r===`0`&&(t||=`0`),!t)return;let a=e.length-1-o;i=n&&a>0&&a%3==0?t+n+i:t+i}for(let t=r.length-1;t>=0;t--){let n=r[t];switch(n.type){case`DIGIT`:let r=e[o];if(s(r,n.value),o--,a===t)for(;o>=0;)s(e[o],`0`),o--;break;case`THOUSANDS_SEPARATOR`:break;case`REPEATED_CHAR`:i=Io+n.value+i;break;default:i=n.value+i;break}}return i}function Uo(e,t){if(!t.decimalPart)return``;let n=``,r=0;for(let i of t.decimalPart)switch(i.type){case`DIGIT`:let t=i.value===`#`?e[r]||``:e[r]||`0`;n+=t,r++;break;case`THOUSANDS_SEPARATOR`:break;case`REPEATED_CHAR`:n+=Io+i.value;break;default:n+=i.value;break}return n}let Wo=[];function Go(e,t=20){let n=e.toString();if(n.includes(`e`))return Yo(e,t);if(Number.isInteger(e))return{integerDigits:n,decimalDigits:void 0};let r=n.indexOf(`.`),i=n.substring(0,r),a=n.substring(r+1);if(t===0)return Number(a[0])>=5&&(i=(Number(i)+1).toString()),{integerDigits:i,decimalDigits:void 0};if(a.length>t){let{integerDigits:e,decimalDigits:n}=Jo(a,t);a=n,e!==`0`&&(i=(Number(i)+Number(e)).toString())}return{integerDigits:i,decimalDigits:Ko(a||``)}}function Ko(e){let t=e.length-1;for(;t>=0&&e[t]===`0`;)t--;return e.slice(0,t+1)||void 0}let qo=/^0+/;function Jo(e,t){let n=`0`,r=e,i=e.slice(0,t);if(Number(e[t])<5)return{integerDigits:n,decimalDigits:i};let a=i.match(qo)?.[0]||``,o=(Number(i)+1).toString(),s=i.slice(a.length),c=o.length>s.length;return c&&!a?(n=`1`,r=void 0):r=c?a.slice(0,-1)+o:a+o,{integerDigits:n,decimalDigits:r}}function Yo(e,t=20){let n=Wo[t];n||(n=new Intl.NumberFormat(`en-US`,{maximumFractionDigits:t,useGrouping:!1}),Wo[t]=n);let[r,i]=n.format(e).split(`.`);return{integerDigits:r,decimalDigits:i}}function Xo(e,t){let{integerDigits:n,decimalDigits:r}=Go(e,20);return r?n+t+r:n}let Zo=Ht(function(e){if(!e)return!1;try{return Co(e).positive.type===`date`}catch{return!1}});function Qo(e,t){let n=mi(e);if(isNaN(n.getTime()))return e.toString();let r=t.tokens.some(e=>e.type===`DATE_PART`&&e.value===`a`),i=``;for(let e of t.tokens)switch(e.type){case`DATE_PART`:i+=$o(n,e.value,r);break;case`REPEATED_CHAR`:i+=Io+e.value;break;default:i+=e.value;break}return i}function $o(e,t,n){switch(t){case`d`:return e.getDate();case`dd`:return e.getDate().toString().padStart(2,`0`);case`ddd`:return Ro[e.getDay()].slice(0,3);case`dddd`:return Ro[e.getDay()].toString();case`m`:return e.getMonth()+1;case`mm`:return String(e.getMonth()+1).padStart(2,`0`);case`mmm`:return Lo[e.getMonth()].slice(0,3);case`mmmm`:return Lo[e.getMonth()].toString();case`mmmmm`:return Lo[e.getMonth()].slice(0,1);case`qq`:return E(`Q%(quarter)s`,{quarter:e.getQuarter()}).toString();case`qqqq`:return E(`Quarter %(quarter)s`,{quarter:e.getQuarter()}).toString();case`yy`:let r=String(e.getFullYear()).replace(`-`,``).padStart(2,`0`);return r.slice(r.length-2);case`yyyy`:return String(e.getFullYear()).replace(`-`,``).padStart(4,`0`);case`hhhh`:return Math.floor((e.getTime()-Ur.getTime())/(3600*1e3)).toString();case`hh`:let i=e.getHours();return n&&(i=i===0?12:i>12?i-12:i),i.toString().padStart(2,`0`);case`MM`:return e.getMinutes().toString().padStart(2,`0`);case`ss`:return e.getSeconds().toString().padStart(2,`0`);case`a`:return e.getHours()>=12?`PM`:`AM`;default:throw Error(`invalid date format token: ${t}`)}}let es=Ht(function(e){return RegExp(`[0-9]+${ot(e.decimalSeparator)}[0-9]`)});function ts(e){let{integerDigits:t,decimalDigits:n}=Go(e);if(!n)return`0`;let r=t.replace(`-`,``).length;if(r+2>11)return`0`;let i=11-r-1;return{decimalDigits:n}=Go(e,Math.min(i,n.length)),n?`0.`+`0`.repeat(n.length):`0`}function ns(e,t){if(ni(e,t))return ii(e,t).format}function rs(e){let t=e.includes(`.`)?`0.00`:`0`,n=e.match(/[\$€]/);if(n){let r=e.match(/[\d]/),i=`[$`+n.values().next().value+`]`;return r.index<n.index?`#,##`+t+i:i+`#,##`+t}if(e.includes(`%`))return t+`%`}function is(e){let t=e.decimalPlaces??2,n=e.position??`before`,r=e.code??``,i=e.symbol??``,a=`#,##0`+(t?`.`+`0`.repeat(t):``),o=`${r} ${i}`.trim();return n===`after`&&r&&(o=` `+o),ss(o,n,a)}function as(e){let t=e.decimalPlaces??2,n=e.position??`before`,r=e.code??``,i=e.symbol??``,a=`#,##0`+(t?`.`+`0`.repeat(t):``),o=`${r} ${i}`.trim();return n===`after`&&r&&(o=` `+o),[os(o,n,` ${a} `),os(o,n,`(${a})`),os(o,n,` - `)].join(`;`)}function os(e,t,n){let r=`[$${e}]`;return t===`before`?r+`* `+n:n+`* `+r}function ss(e,t,n){let r=`[$${e}]`;return t===`before`?r+n:n+r}function cs(e){let t=Co(e);return Mo({positive:ls(t.positive),negative:t.negative?ls(t.negative):void 0,zero:t.zero?ls(t.zero):void 0,text:t.text})}function ls(e){if(e.type!==`number`||!e.decimalPart)return e;let t=e.decimalPart.filter(e=>e.type!==`DIGIT`);return{...e,decimalPart:void 0,integerPart:[...e.integerPart,...t]}}function us({value:e,format:t},n){return V(e,{format:ds({value:e,format:t},void 0,n),locale:n})}function ds(e,t,n){let r=0;try{r=Math.abs(F(e?.value,n))}catch{return``}let i=e?.format;if(t!==void 0)switch(t?.value){case`k`:return fs(i,1,`k`,n);case`m`:return fs(i,2,`m`,n);case`b`:return fs(i,3,`b`,n);default:throw new M(E(`The formatting unit should be 'k', 'm' or 'b'.`))}return r<1e5?fs(i,0,``,n):r<1e8?fs(i,1,`k`,n):r<1e11?fs(i,2,`m`,n):fs(i,3,`b`,n)}function fs(e,t,n,r){let i=Co(e||`#,##0`);return Mo({positive:ps(i.positive,t,n),negative:i.negative?ps(i.negative,t,n):void 0,zero:i.zero?ps(i.zero,t,n):void 0,text:i.text})}function ps(e,t,n){if(e.type!==`number`)return e;let r=ls(e),i={type:`STRING`,value:n},a=[...r.integerPart],o=a.findLastIndex(e=>e.type===`DIGIT`);if(o===-1)throw Error(`Cannot create a large number format from a format with no digit.`);for(;a[o+1]?.type===`THOUSANDS_SEPARATOR`;)a=Ut(a,[o+1]);let s=a[o+1];a=s?.type===`STRING`&&[`m`,`k`,`b`].includes(s.value)?Gt(a,i,o+1):Wt(a,[i],o+1),t>0&&(a=Wt(a,Array(t).fill({type:`THOUSANDS_SEPARATOR`,value:`,`}),o+1));let c=r.percentSymbols-a.filter(e=>e.type===`PERCENT`).length;return a.push(...Array(c).fill({type:`PERCENT`,value:`%`})),{...r,integerPart:a,magnitude:t}}function ms(e,t){let n=Co(e);return Mo(Co(Mo({positive:hs(n.positive,t),negative:n.negative?hs(n.negative,t):void 0,zero:n.zero?hs(n.zero,t):void 0,text:n.text})))}function hs(e,t){return e.type===`number`?t>0?_s(e,t):gs(e,Math.abs(t)):e}function gs(e,t){let n=e.decimalPart;if(!n)return e;let r=[],i=0;for(let e=n.length-1;e>=0&&!(i>=Math.abs(t));e--)n[e].type===`DIGIT`&&(i++,r.push(e));return n=Ut(n,r),n.some(e=>e.type===`DIGIT`)?{...e,decimalPart:n}:{...e,decimalPart:void 0,integerPart:[...e.integerPart,...n]}}function _s(e,t){let n=e.integerPart,r=e.decimalPart;if(!r){let e=n.findLastIndex(e=>e.type===`DIGIT`);r=n.slice(e+1),n=n.slice(0,e+1)}let i=x(0,t).map(()=>({type:`DIGIT`,value:`0`})),a=r.findLastIndex(e=>e.type===`DIGIT`);return r=a===-1?[...i,...r]:Wt(r,i,a+1),{...e,decimalPart:r,integerPart:n}}function vs(e){let t=Co(e);for(let e of[t.positive,t.negative,t.zero])if(e&&e.type===`date`&&e.tokens.some(e=>e.type===`DATE_PART`&&e.value.includes(`q`)))return!1;return!0}function ys(e){if(!e)return!1;try{return Co(e).positive.type===`text`}catch{return!1}}function bs(e,t){return Ss({value:ys(t.format)&&e.parsedValue!==null?e.content:e.parsedValue,format:t.format},t.locale)}function xs(e,t){if(e.startsWith(`=`))throw Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);if(e===``)return null;if(Pi(e,k))return Ii(e,k);let n=ii(e,t);return n?n.value:mt(e)?e.toUpperCase()===`TRUE`:e}function Ss(e,t=k,n){let r=co(e.value);if(!r)return Cs(e,t,n);let i=xs(r.label,t);return{...Cs({value:i,format:e.format||(typeof i==`number`?ns(r.label,t)||rs(r.label):void 0)},t,n),link:r}}function Cs(e,t,n){let{value:r,format:i,message:a}=e;i=n?.format||i;let o=V(r,{format:i,locale:t});return P(r)?ks(r,a):r===null?Es(i):ys(i)?ws(I(r),i,o):typeof r==`number`?Zo(i||``)?Ds(r,i,o):Ts(r,i,o):typeof r==`boolean`?Os(r,i,o):ws(r,i,o)}function ws(e,t,n){return{value:e,format:t,formattedValue:n,type:`text`,isAutoSummable:!0,defaultAlign:`left`}}function Ts(e,t,n){return{value:e||0,format:t,formattedValue:n,type:`number`,isAutoSummable:!0,defaultAlign:`right`}}let Es=Ht(function(e){return{value:null,format:e,formattedValue:``,type:`empty`,isAutoSummable:!0,defaultAlign:`left`}});function Ds(e,t,n){return{value:e,format:t,formattedValue:n,type:`number`,isAutoSummable:!1,defaultAlign:`right`}}function Os(e,t,n){return{value:e,format:t,formattedValue:n,type:`boolean`,isAutoSummable:!1,defaultAlign:`center`}}function ks(e,t){return{value:e,formattedValue:e,message:t,type:`error`,isAutoSummable:!1,defaultAlign:`center`}}function As(e){let t=O.now();switch(e){case`today`:return Math.floor(gi(t));case`yesterday`:return t.setDate(t.getDate()-1),Math.floor(gi(t));case`tomorrow`:return t.setDate(t.getDate()+1),Math.floor(gi(t));case`lastWeek`:return t.setDate(t.getDate()-6),Math.floor(gi(t));case`lastMonth`:{let e=t.getMonth()===0?11:t.getMonth()-1,n=new O(t.getFullYear(),e,1);return t.getDate()>_i(n)?t.setDate(1):(t.setDate(t.getDate()+1),t.setMonth(t.getMonth()-1)),Math.floor(gi(t))}case`lastYear`:return t.getMonth()===1&&t.getDate()===29?(t.setDate(28),t.setFullYear(t.getFullYear()-1)):(t.setDate(t.getDate()+1),t.setFullYear(t.getFullYear()-1)),Math.floor(gi(t))}}function js(e,t){return`dateValue`in e&&e.dateValue!==`exactDate`?[As(e.dateValue)]:e.values.map(e=>ti(e,t))}function Ms(e,t){return e.values.map(e=>ya(e,t))}function Ns(e,t){return e.map(e=>{if(e.startsWith(`=`))return e;let n=xs(e,t);return typeof n==`number`?V(n,{format:t.dateFormat,locale:t}):``})}function Ps(e){return 20+120*Math.exp(-.035*(e-1))}let Fs=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,`i`),Is=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,`i`),Ls=new RegExp(/^\$?([A-Z]{1,3})+$/,`i`),Rs=new RegExp(/^\$?([0-9]{1,7})+$/,`i`),zs=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,`i`),Bs=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,`i`),Vs=RegExp(`^\\s*('.+'!|[^']+!)?(`+[Fs.source,`(\\$?[A-Z]{1,3})?\\$?[0-9]{1,7}\\s*:\\s*(\\$?[A-Z]{1,3})?\\$?[0-9]{1,7}\\s*`,`\\$?[A-Z]{1,3}(\\$?[0-9]{1,7})?\\s*:\\s*\\$?[A-Z]{1,3}(\\$?[0-9]{1,7})?\\s*`].join(`|`)+`)$`,`i`);function Hs(e){return zs.test(e)}function Us(e){return Bs.test(e)}function Ws(e){return Ls.test(e)}function Gs(e){return Rs.test(e)}function Ks(e){return Is.test(e)}function qs(e){if(!e.includes(`!`))return{xc:e};let t=e.split(`!`),n=t.pop();return{sheetName:ct(t.join(`!`))||void 0,xc:n}}function Js(e,t){return e===void 0?t:`${ut(e)}!${t}`}var Ys=class e{getSheetSize;_zone;parts;invalidXc;prefixSheet=!1;sheetId;invalidSheetName;constructor(e,t){this.getSheetSize=t,this._zone=e.zone,this.prefixSheet=e.prefixSheet,this.invalidXc=e.invalidXc,this.sheetId=e.sheetId,this.invalidSheetName=e.invalidSheetName;let n=[...e.parts];e.parts.length===1&&jr(this.zone)>1?n.push({...e.parts[0]}):e.parts.length===2&&jr(this.zone)===1&&n.pop(),this.parts=n}static fromRange(t,n){return t instanceof e?t:new e(t,n.getSheetSize)}get unboundedZone(){return this._zone}get zone(){let{left:e,top:t,bottom:n,right:r}=this._zone;if(r!==void 0&&n!==void 0)return this._zone;if(n===void 0&&r!==void 0)return{right:r,top:t,left:e,bottom:this.getSheetSize(this.sheetId).numberOfRows-1};if(r===void 0&&n!==void 0)return{bottom:n,left:e,top:t,right:this.getSheetSize(this.sheetId).numberOfCols-1};throw Error(E(`Bad zone format`))}static getRangeParts(e,t){let n=e.split(`:`).map(e=>{let t=Us(e);return{colFixed:t?!1:e.startsWith(`$`),rowFixed:t?e.startsWith(`$`):e.includes(`$`,1)}}),r=t.bottom===void 0,i=t.right===void 0;return r&&(n[0].rowFixed=n[0].rowFixed||n[1].rowFixed,n[1].rowFixed=n[0].rowFixed||n[1].rowFixed),i&&(n[0].colFixed=n[0].colFixed||n[1].colFixed,n[1].colFixed=n[0].colFixed||n[1].colFixed),n}get isFullCol(){return this._zone.bottom===void 0}get isFullRow(){return this._zone.right===void 0}get rangeData(){return{_zone:this._zone,_sheetId:this.sheetId}}orderZone(){if(ar(this._zone))return this;let e={...this._zone},t=this.parts;if(e.right!==void 0&&e.right<e.left){let n=e.right;e.right=e.left,e.left=n,t=[{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1},{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1}]}if(e.bottom!==void 0&&e.bottom<e.top){let n=e.bottom;e.bottom=e.top,e.top=n,t=[{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1},{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1}]}return this.clone({zone:e,parts:t})}clone(t){return new e({zone:t?.zone?t.zone:{...this._zone},sheetId:t?.sheetId?t.sheetId:this.sheetId,invalidSheetName:t&&`invalidSheetName`in t?t.invalidSheetName:this.invalidSheetName,invalidXc:t&&`invalidXc`in t?t.invalidXc:this.invalidXc,parts:t?.parts?t.parts:this.parts.map(e=>({rowFixed:e.rowFixed,colFixed:e.colFixed})),prefixSheet:t?.prefixSheet===void 0?this.prefixSheet:t.prefixSheet},this.getSheetSize)}};function Xs(e,t,n){let r=n.sheetId===e?t:n.sheetId;return n.clone({sheetId:r})}function Zs(e,t,n){if(!n)return;let r=e.getRangeFromSheetXC(t,n);return r.invalidSheetName||r.invalidXc?void 0:r}function Qs(e,t){let n=[];for(let r of t){let t=r.dataRange;if(!e.isRangeValid(t)){n.push(r);continue}let{sheetName:i}=qs(t),a=i?`${i}!`:``,o=nr(t);if(o.bottom!==o.top&&o.left!==o.right)if(o.right)for(let e=o.left;e<=o.right;++e){let t=e===o.left?r:{yAxisId:r.yAxisId};n.push({...t,dataRange:`${a}${or({left:e,right:e,top:o.top,bottom:o.bottom})}`})}else for(let e=o.top;e<=o.bottom;++e){let t=e===o.top?r:{yAxisId:r.yAxisId};n.push({...t,dataRange:`${a}${or({left:o.left,right:o.right,top:e,bottom:e})}`})}else n.push(r)}return n}function $s(e){let t=[];for(let n of e)for(let e of Sr(n.zone))t.push({...e,sheetId:n.sheetId});return t}function ec(e,t){e=e.toLocaleLowerCase(),t=t.toLocaleLowerCase();let n=0,r=0,i=t.length,a=0;for(let o=0;o<i;o++)t[o]===e[a]?(a++,r+=100+r-o/200):r=0,n+=r;return a===e.length?n:0}function tc(e,t,n){let r=[];return t.forEach(t=>{let i=ec(e,n(t));i>0&&r.push({score:i,elem:t})}),r.sort((e,t)=>t.score-e.score),r.map(e=>e.elem)}function nc(e){let t=[];for(let n=0;n<e;n++)t.push({cells:{}});return t}function rc(e,t,n){return n.map(n=>n>=e?n+t:n)}function ic(e,t){return e=[...e].sort((e,t)=>t-e),t.map(t=>{for(let n of e)if(t>n)t--;else if(t===n)return;return t}).filter(S)}function ac(e,t=`Sheet`){let n=1,r=`${t}${n}`;for(;e.includes(r);)r=`${t}${n}`,n++;return r}function oc(e,t){let n=1,r=E(`Copy of %s`,e),i=r.toString();for(;t.includes(i);)i=`${r} (${n})`,n++;return i}function sc(e,t){return e===void 0||t===void 0?!1:ct(e.trim().toUpperCase())===ct(t.trim().toUpperCase())}function cc(e,t=1){return t*(e+4)-4}function lc(e,t,n,r){if(!t||!t.isFormula&&!t.content)return 23;let i=``;try{if(!t.isFormula){let e={format:t.format,locale:n};i=V(xs(t.content,n),e)}}catch{i=j.GenericError}return uc(e,i,t.style,r)}function uc(e,t,n,r){let i=Sc(e,t,n,n?.wrapping===`wrap`?r-8:void 0).length;return cc(bc(n),i)+6}function dc(e,t=!1,n=!1){return`${n?`italic`:``} ${t?`bold`:``} ${e}px ${He}`}let fc={};function pc(e,t,n,r=`pt`){let i=yc(n,r);e.save(),e.font=i;let a=mc(e,t);return e.restore(),a}function mc(e,t){let n=e.font;if(fc[n]||(fc[n]={}),fc[n][t]===void 0){let r=e.measureText(t).width;fc[n][t]=r}return fc[n][t]}let hc={};function gc(e,t,n,r=`pt`){let i=yc(n,r);e.save(),e.font=i;let a=_c(e,t);return e.restore(),a}function _c(e,t){let n=e.font;if(hc[n]||(hc[n]={}),hc[n][t]===void 0){let r=e.measureText(t),i=r.width,a=r.fontBoundingBoxAscent+r.fontBoundingBoxDescent;hc[n][t]={width:i,height:a}}return hc[n][t]}function vc(e){return Math.round(e*96/72)}function yc(e,t=`pt`){return`${e.italic?`italic `:``}${e.bold?`bold`:`400`} ${(t===`pt`?bc(e):e.fontSize)??Ve}px ${He}`}function bc(e){return vc(e?.fontSize||Ve)}function xc(e,t,n,r){if(pc(e,t,r)<=n)return[t];let i=[],a=``;for(let o of t)pc(e,a+o,r)>n?(i.push(a),a=o):a+=o;return i.push(a),i}function Sc(e,t,n,r){n||={},_t(t)&&(t=bt(t).label);let i=[],a=t.includes(`
5
5
  `)?t.split(`
6
6
  `):[t];for(let t of a){let a=t.includes(` `)?t.split(` `):[t];if(!r){i.push(t);continue}let o=``,s=r;for(let t of a){let a=xc(e,t,r,n),c=a.pop(),l=pc(e,c,n);if(a.length)o!==``&&(i.push(o),o=``,s=r),a.forEach(e=>{i.push(e)}),o=c,s=r-l;else{let t=o===``?c:` `+c,a=pc(e,t,n);a<=s?(o+=t,s-=a):(i.push(o),o=c,s=r-l)}}o!==``&&i.push(o)}return i}function Cc(e,t,n,r=.25){let i=1;if(n(i)>e)return i;if(n(t)<e)return t;let a=(i+t)/2,o=n(a),s=0;for(;Math.abs(o-e)>r&&s<20;)o>=e?t=(i+t)/2:i=(i+t)/2,a=(i+t)/2,o=n(a),s++;return a}function wc(e){return bc(e)+8}function Tc(e){return e?e.toLowerCase():``}let Ec=/([0-9\.]*)px/;function Dc(e){return Number(e.match(Ec)?.[1])}function Oc(e,t,n){let r=mc(e,t);if(r<=n)return t;let i=mc(e,`…`);if(r<=i)return t;let a=t.length;for(;r>=n-i&&a-->0;)t=t.substring(0,a),r=mc(e,t);return t+`…`}function kc(e,t,n,r=!1,i=!1,a=Dc(e.font)/10){if(e.fillText(t,n.x,n.y),!r&&!i)return;let o=e.measureText(t),s=o.width,c=o.actualBoundingBoxAscent+o.actualBoundingBoxDescent,l=o.fontBoundingBoxAscent+o.fontBoundingBoxDescent,{x:u,y:d}=n,f=d,p=d;switch(e.textAlign){case`center`:u-=s/2;break;case`right`:u-=s;break}switch(e.textBaseline){case`top`:p+=l-2*a,f+=l/2-a;break;case`middle`:p+=l/2-a;break;case`alphabetic`:p+=2*a,f-=3*a;break;case`bottom`:p=d,f-=c/2-a/2;break}r&&(e.lineWidth=a,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(u,p),e.lineTo(u+s,p),e.stroke()),i&&(e.lineWidth=a,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(u,f),e.lineTo(u+s,f),e.stroke())}var Ac=class{isFastIdStrategy=!1;fastIdStart=0;setIsFastStrategy(e){this.isFastIdStrategy=e}smallUuid(){return this.isFastIdStrategy?(this.fastIdStart++,String(this.fastIdStart)):window.crypto?`10000000-1000`.replace(/[01]/g,e=>{let t=Number(e);return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)}):`xxxxxxxx-xxxx`.replace(/[xy]/g,function(e){var t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}uuidv4(){return this.isFastIdStrategy?(this.fastIdStart++,String(this.fastIdStart)):window.crypto?`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>{let t=Number(e);return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)}):`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,function(e){var t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}};function jc(e,t){let n=new Set(t.map(e=>e.left)),r=new Set(t.map(e=>e.right)),i=new Set(t.map(e=>e.top)),a=new Set(t.map(e=>e.bottom)),o=i.size===1&&a.size===1||n.size===1&&r.size===1?Er(t):[t[t.length-1]],s=o.map(e=>Sr(e)).flat();return{sheetId:e,zones:t,clippedZones:o,columnsIndexes:[...new Set(s.map(e=>e.col))].sort((e,t)=>e-t),rowsIndexes:[...new Set(s.map(e=>e.row))].sort((e,t)=>e-t)}}function Mc(e,t,n){let r=Math.max(e.right-t+1,e.left),i=Math.max(e.bottom-n+1,e.top),a=[];for(let o=e.left;o<=r;o+=t)for(let r=e.top;r<=i;r+=n)a.push({left:o,top:r,bottom:r+n-1,right:o+t-1});return a}function Nc(e,t){if(!t.length||!t[0].length)return e;let n=t[0].length,r=t.length;return e.map(e=>Mc(e,n,r)).flat()}function Pc(e){if(!e[`text/html`])return{text:e[`text/plain`]};let t=new DOMParser().parseFromString(e[`text/html`],`text/html`);return{text:e[`text/plain`],data:Fc(t)}}function Fc(e){if([...e.documentElement.attributes].some(e=>e.value.includes(`microsoft`)))return;let t=e.querySelector(`div`)?.getAttribute(`data-osheet-clipboard`);return t&&JSON.parse(t)}let Ic=(e,t,n,r)=>{e.forEach(({handlerName:e,handler:i})=>{let a=t[e];a&&i.paste(n,a,r)})};function Lc(e,t,n,r,i){let a,o=[],s={sheetId:e,zones:t};for(let{handlerName:c,handler:l}of r){let r=n[c];if(!r)continue;let u=l.getPasteTarget(e,t,r,i);u.figureId&&(s.figureId=u.figureId);for(let e of u.zones){if(o.push(e),a===void 0){a=e;continue}a=dr(a,e)}}return{target:s,zone:a,selectedZones:o}}let Rc=(e,t,n)=>{let r={col:t[0].left,row:t[0].top};e.getBackToDefault(),e.selectZone({cell:r,zone:dr(...n)},{scrollIntoView:!1})};var zc=class{getters;dispatch;constructor(e,t){this.getters=e,this.dispatch=t}copy(e,t=`copyPaste`){}paste(e,t,n){}isPasteAllowed(e,t,n,r){return`Success`}isCutAllowed(e){return`Success`}getPasteTarget(e,t,n,r){return{zones:[],sheetId:e}}convertTextToClipboardData(e){}},Bc=class extends zc{copy(e,t=`copyPaste`){}pasteFromCopy(e,t,n,r){if(t.length===1)for(let i of Nc(t,n))this.pasteZone(e,i.left,i.top,n,r);else for(let i of T(t))for(let t=i.left;t<=i.right;t++)for(let a=i.top;a<=i.bottom;a++)this.pasteZone(e,t,a,n,r)}pasteZone(e,t,n,r,i){}},Vc=class extends Bc{queuedBordersToAdd={};copy(e){let t=e.sheetId;if(e.zones.length===0)return;let{rowsIndexes:n,columnsIndexes:r}=e,i=[];for(let e of n){let n=[];for(let i of r){let r={col:i,row:e,sheetId:t};n.push(this.getters.getCellBorder(r))}i.push(n)}return{borders:i}}paste(e,t,n){let r=e.sheetId;if(n.pasteOption===`asValue`)return;let i=e.zones;if(!n.isCutOperation)this.pasteFromCopy(r,i,t.borders);else{let{left:e,top:n}=i[0];this.pasteZone(r,e,n,t.borders)}this.executeQueuedChanges(r)}pasteZone(e,t,n,r){for(let[i,a]of r.entries())for(let[r,o]of a.entries()){let a={col:t+r,row:n+i,sheetId:e};this.pasteBorder(o,a)}}pasteBorder(e,t){let n={...this.getters.getCellBorder(t),...e},r=JSON.stringify(n);this.queuedBordersToAdd[r]||(this.queuedBordersToAdd[r]=[]),this.queuedBordersToAdd[r].push(D(t))}executeQueuedChanges(e){for(let t in this.queuedBordersToAdd){let n=this.queuedBordersToAdd[t],r=JSON.parse(t),i=T(n,[]);this.dispatch(`SET_BORDERS_ON_TARGET`,{sheetId:e,target:i,border:r})}this.queuedBordersToAdd={}}};let Hc=[`%`],Uc=`+,-,*,/,:,=,<>,>=,>,<=,<,^,&`.split(`,`).concat(Hc);function Wc(e,t=k){e=Bt(e);let n=new Zt(e),r=[],i=Lt.test(e)?nl:rl;for(;!n.isOver();){let e=il(n)||i(n)||Jc(n,t)||qc(n)||Yc(n)||Qc(n)||Gc(n)||al(n)||Zc(n,t)||tl(n);e||={type:`UNKNOWN`,value:n.shift()},r.push(e)}return r}function Gc(e){return e.current===`?`?(e.shift(),{type:`DEBUGGER`,value:`?`}):null}let Kc={"(":{type:`LEFT_PAREN`,value:`(`},")":{type:`RIGHT_PAREN`,value:`)`}};function qc(e){return e.current===`(`||e.current===`)`?Kc[e.shift()]:null}function Jc(e,t){return e.current===t.formulaArgSeparator?{type:`ARG_SEPARATOR`,value:e.shift()}:null}function Yc(e){for(let t of Uc)if(e.currentStartsWith(t))return e.advanceBy(t.length),{type:`OPERATOR`,value:t};return null}let Xc=new Set(`0123456789`);function Zc(e,t){if(!Xc.has(e.current)&&e.current!==t.decimalSeparator)return null;let n=e.remaining().match(Mi(t.decimalSeparator));return n?(e.advanceBy(n[0].length),{type:`NUMBER`,value:n[0]}):null}function Qc(e){if(e.current===`"`){let t=e.shift(),n=t;for(;e.current&&(e.current!==t||n[n.length-1]===`\\`);)n+=e.shift();return e.current===`"`&&(n+=e.shift()),{type:`STRING`,value:n}}return null}let $c=/\p{L}|\p{N}|_|\.|!|\$/u,el=new Set(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.!$`);function tl(e){let t=``;if(e.current===`'`){let n=e.shift();for(t+=n;e.current;)if(n=e.shift(),t+=n,n===`'`)if(e.current&&e.current===`'`)n=e.shift(),t+=n;else break;if(n!==`'`)return{type:`UNKNOWN`,value:t}}for(;e.current&&(el.has(e.current)||e.current.match($c));)t+=e.shift();if(t.length){let e=t;return Vs.test(e)?{type:`REFERENCE`,value:e}:{type:`SYMBOL`,value:e}}return null}function nl(e){let t=``;for(;e.current===` `||e.current&&e.current.match(Lt);)t+=e.shift();return t?{type:`SPACE`,value:t}:null}function rl(e){let t=``;for(;e.current===` `;)t+=e.shift();return t?{type:`SPACE`,value:t}:null}function il(e){let t=0;for(;e.current===`
7
7
  `;)t++,e.shift();return t?{type:`SPACE`,value:`
@@ -1306,7 +1306,7 @@ stores.inject(MyMetaStore, storeInstance);
1306
1306
  .add-calculated-measure {
1307
1307
  cursor: pointer;
1308
1308
  }
1309
- `;var vF=class extends t.Component{static template=`o-spreadsheet-PivotLayoutConfigurator`;static components={AddDimensionButton:uF,PivotDimension:pF,PivotDimensionOrder:hF,PivotDimensionGranularity:mF,PivotMeasureEditor:_F};static props={definition:Object,onDimensionsUpdated:Function,unusedGroupableFields:Array,measureFields:Array,unusedGranularities:Object,dateGranularities:Array,datetimeGranularities:Array,getScrollableContainerEl:{type:Function,optional:!0},pivotId:String};dimensionsRef=(0,t.useRef)(`pivot-dimensions`);dragAndDrop=xP();AGGREGATORS=Nu;composerFocus;isDateOrDatetimeField=zu;setup(){this.composerFocus=H(wd)}startDragAndDrop(e,t){if(t.button!==0||t.target.tagName===`SELECT`)return;let n=this.getDimensionElementsRects(),{columns:r,rows:i}=this.props.definition,a=[...r.map(e=>e.nameWithGranularity),`__rows_title__`,...i.map(e=>e.nameWithGranularity)],o=r.concat(i),s=a.map((e,t)=>({id:e,size:n[t+1].height,position:n[t+1].y}));this.dragAndDrop.start(`vertical`,{draggedItemId:e.nameWithGranularity,initialMousePosition:t.clientY,items:s,scrollableContainerEl:this.props.getScrollableContainerEl?.()||this.dimensionsRef.el,onDragEnd:(e,t)=>{let n=a.findIndex(t=>t===e);if(n===t)return;let r=[...a];r.splice(n,1),r.splice(t,0,e);let i=r.slice(0,r.indexOf(`__rows_title__`)),s=r.slice(r.indexOf(`__rows_title__`)+1);this.props.onDimensionsUpdated({columns:i.map(e=>o.find(t=>t.nameWithGranularity===e)).filter(S),rows:s.map(e=>o.find(t=>t.nameWithGranularity===e)).filter(S)})}})}getGranularitiesFor(e){return zu(e)?e.type===`date`?this.props.dateGranularities:this.props.datetimeGranularities:[]}startDragAndDropMeasures(e,t){if(t.button!==0||t.target.tagName===`SELECT`||t.target.tagName===`INPUT`||this.composerFocus.focusMode!==`inactive`)return;let n=this.getDimensionElementsRects(),{measures:r,columns:i,rows:a}=this.props.definition,o=r.map(e=>e.id),s=3+i.length+a.length,c=o.map((e,t)=>({id:e,size:n[t+s].height,position:n[t+s].y}));this.dragAndDrop.start(`vertical`,{draggedItemId:e.id,initialMousePosition:t.clientY,items:c,scrollableContainerEl:this.props.getScrollableContainerEl?.()||this.dimensionsRef.el,onDragEnd:(e,t)=>{let n=o.findIndex(t=>t===e);if(n===t)return;let i=[...o];i.splice(n,1),i.splice(t,0,e),this.props.onDimensionsUpdated({measures:i.map(e=>r.find(t=>t.id===e)).filter(S)})}})}getDimensionElementsRects(){return Array.from(this.dimensionsRef.el.children).map(e=>{let t=getComputedStyle(e),n=e.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width+parseInt(t.marginLeft||`0`)+parseInt(t.marginRight||`0`),height:n.height+parseInt(t.marginTop||`0`)+parseInt(t.marginBottom||`0`)}})}removeDimension(e){let{columns:t,rows:n}=this.props.definition;this.props.onDimensionsUpdated({columns:t.filter(t=>t.nameWithGranularity!==e.nameWithGranularity),rows:n.filter(t=>t.nameWithGranularity!==e.nameWithGranularity)})}removeMeasureDimension(e){let{measures:t}=this.props.definition;this.props.onDimensionsUpdated({measures:t.filter(t=>t.id!==e.id)})}addColumnDimension(e){let{columns:t}=this.props.definition;this.props.onDimensionsUpdated({columns:t.concat([{fieldName:e,order:`asc`}])})}addRowDimension(e){let{rows:t}=this.props.definition;this.props.onDimensionsUpdated({rows:t.concat([{fieldName:e,order:`asc`}])})}addMeasureDimension(e){let{measures:t}=this.props.definition,n=this.getDefaultMeasureAggregator(e);this.props.onDimensionsUpdated({measures:t.concat([{id:this.getMeasureId(e,n),fieldName:e,aggregator:n}])})}updateMeasure(e,t){let{measures:n}=this.props.definition;this.props.onDimensionsUpdated({measures:n.map(n=>n.id===e.id?t:n)})}getMeasureId(e,t){let n=e.replaceAll(`'`,``)+(t?`:${t}`:``),r=n,i=2;for(;this.props.definition.measures.some(e=>e.id===r);)r=`${n}:${i}`,i++;return r}getDefaultMeasureAggregator(e){let t=this.props.measureFields.find(t=>t.name===e);return t?.aggregator?t.aggregator:`count`}addCalculatedMeasure(){let{measures:e}=this.props.definition,t=this.env.model.getters.generateNewCalculatedMeasureName(e);this.props.onDimensionsUpdated({measures:e.concat([{id:this.getMeasureId(t,`sum`),fieldName:t,aggregator:`sum`,computedBy:{sheetId:this.env.model.getters.getActiveSheetId(),formula:`=0`}}])})}updateOrder(e,t){let{rows:n,columns:r}=this.props.definition;this.props.onDimensionsUpdated({rows:n.map(n=>n.nameWithGranularity===e.nameWithGranularity?{...n,order:t||void 0}:n),columns:r.map(n=>n.nameWithGranularity===e.nameWithGranularity?{...n,order:t||void 0}:n)})}updateGranularity(e,t){let{rows:n,columns:r}=this.props.definition;this.props.onDimensionsUpdated({rows:n.map(n=>n.nameWithGranularity===e.nameWithGranularity?{...n,granularity:t}:n),columns:r.map(n=>n.nameWithGranularity===e.nameWithGranularity?{...n,granularity:t}:n)})}getMeasureDescription(e){let t=e.display;if(!t||t.type===`no_calculations`)return``;let n=this.env.model.getters.getPivot(this.props.pivotId),r=[...n.definition.columns,...n.definition.rows].find(e=>e.nameWithGranularity===t.fieldNameWithGranularity),i=r?Yu(r):``;return xg.descriptions[t.type](i)}},yF=class extends t.Component{static template=`o-spreadsheet-PivotTitleSection`;static components={CogWheelMenu:fF,Section:PN,TextInput:dF};static props={pivotId:String,flipAxis:Function};get cogWheelMenuItems(){return[{name:E(`Flip axes`),icon:`o-spreadsheet-Icon.EXCHANGE`,execute:this.props.flipAxis},{name:E(`Duplicate`),icon:`o-spreadsheet-Icon.COPY`,execute:()=>this.duplicatePivot()},{name:E(`Delete`),icon:`o-spreadsheet-Icon.TRASH`,execute:()=>this.delete()}]}get name(){return this.env.model.getters.getPivotName(this.props.pivotId)}get displayName(){return this.env.model.getters.getPivotDisplayName(this.props.pivotId)}duplicatePivot(){let e=this.env.model.uuidGenerator.smallUuid(),t=this.env.model.uuidGenerator.smallUuid(),n=this.env.model.dispatch(`DUPLICATE_PIVOT_IN_NEW_SHEET`,{pivotId:this.props.pivotId,newPivotId:e,newSheetId:t}),r;r=n.isSuccessful?E(`Pivot duplicated.`):n.isCancelledBecause(`PivotInError`)?E(`Cannot duplicate a pivot in error.`):E(`Pivot duplication failed.`);let i=n.isSuccessful?`success`:`danger`;this.env.notifyUser({text:r,sticky:!1,type:i}),n.isSuccessful&&this.env.openSidePanel(`PivotSidePanel`,{pivotId:e})}delete(){this.env.askConfirmation(E(`Are you sure you want to delete this pivot?`),()=>{this.env.model.dispatch(`REMOVE_PIVOT`,{pivotId:this.props.pivotId})})}onNameChanged(e){let t=this.env.model.getters.getPivotCoreDefinition(this.props.pivotId);this.env.model.dispatch(`UPDATE_PIVOT`,{pivotId:this.props.pivotId,pivot:{...t,name:e}})}},bF=class{measures;columns;rows;constructor(e,t){this.measures=e.measures.map(e=>xF(t,e)),this.columns=e.columns.map(e=>this.createPivotDimension(t,e)),this.rows=e.rows.map(e=>this.createPivotDimension(t,e))}getDimension(e){let t=this.columns.find(t=>t.nameWithGranularity===e)||this.rows.find(t=>t.nameWithGranularity===e);if(!t)throw new M(E(`Dimension %s does not exist`,e));return t}getMeasure(e){let t=this.measures.find(t=>t.id===e);if(!t)throw new M(E(`Field %s is not a measure`,e));return t}createPivotDimension(e,t){let n=e[t.fieldName],r=n?.type??`integer`,i=n&&zu(n)?t.granularity:void 0;return{displayName:n?.string??t.fieldName,nameWithGranularity:t.fieldName+(i?`:${i}`:``),fieldName:t.fieldName,granularity:i,type:r,order:t.order,isValid:!!n}}};function xF(e,t){let n=t.fieldName,r=n===`__count`?{name:`__count`,string:E(`Count`),type:`integer`,aggregator:`sum`}:e[n],i=t.aggregator;return{id:t.id,get displayName(){return t.userDefinedName??r?.string??t.fieldName},userDefinedName:t.userDefinedName,fieldName:n,aggregator:i,type:n===`__count`?`integer`:r?.type??`integer`,isValid:!!(r||t.computedBy),isHidden:t.isHidden,format:t.format,computedBy:t.computedBy,display:t.display}}var SF=class extends bF{range;constructor(e,t,n){if(super(e,t),e.dataSet){let{sheetId:t,zone:r}=e.dataSet;this.range=n.getRangeFromZone(t,r)}}},CF=class{columns;rows;measures;fieldsType;maxIndent;pivotCells={};rowTree;colTree;constructor(e,t,n,r){this.columns=e.map(e=>{let t=1;return e.map(e=>(e={...e,offset:t},t+=e.width,e))}),this.rows=t,this.measures=n,this.fieldsType=r,this.maxIndent=Math.max(...this.rows.map(e=>e.indent)),this.rowTree=At(()=>this.buildRowsTree()),this.colTree=At(()=>this.buildColumnsTree())}getNumberOfDataColumns(){return this.columns.at(-1)?.length||0}getPivotCells(e=!0,t=!0){let n=JSON.stringify({includeTotal:e,includeColumnHeaders:t});if(!this.pivotCells[n]){let r=this.rows.length,i=this.getNumberOfDataColumns(),a=this.columns.length+r,o=1+i;!e&&r!==1&&--a,!e&&i!==this.measures.length&&(o-=this.measures.length);let s=[],c=t?0:this.columns.length;for(let t=0;t<o;t++){s.push([]);for(let n=c;n<a;n++)!e&&n===a||s[t].push(this.getPivotCell(t,n,e))}this.pivotCells[n]=s}return this.pivotCells[n]}getRowTree(){return this.rowTree()}getColTree(){return this.colTree()}isTotalRow(e){return this.rows[e].indent!==this.maxIndent}getPivotCell(e,t,n=!0){let r=this.columns.length;if(e>0&&t===r-1){let n=this.getColHeaderDomain(e,t);if(!n)return wF;let r=n.at(-1)?.value?.toString()||``;return{type:`MEASURE_HEADER`,domain:n.slice(0,-1),measure:r}}else if(t<=r-1){let n=this.getColHeaderDomain(e,t);return n?{type:`HEADER`,domain:n}:wF}else if(e===0){let e=t-r;return{type:`HEADER`,domain:this.getRowDomain(e)}}else{let i=t-r;return!n&&this.isTotalRow(i)?wF:{type:`VALUE`,domain:[...this.getRowDomain(i),...this.getColDomain(e)],measure:this.getColMeasure(e)}}}getColHeaderDomain(e,t){if(e===0)return;let n=[],r=this.columns[t].find(t=>t.offset===e);if(r){for(let e=0;e<r.fields.length;e++){let t=r.fields[e];if(t===`measure`)n.push({type:`char`,field:t,value:Uu({displayName:`measure`,type:`char`},r.values[e])});else{let{fieldName:i,granularity:a}=Ru(t),o=this.fieldsType[i]||`char`;n.push({type:o,field:t,value:Uu({displayName:i,type:o,granularity:a},r.values[e])})}}return n}}getColDomain(e){let t=this.getColHeaderDomain(e,this.columns.length-1);return t?t.slice(0,-1):[]}getColMeasure(e){let t=this.getColHeaderDomain(e,this.columns.length-1)?.at(-1)?.value;if(t==null)throw Error(`Measure is missing`);return t.toString()}getRowDomain(e){let t=[];for(let n=0;n<this.rows[e].fields.length;n++){let r=this.rows[e].fields[n],{fieldName:i,granularity:a}=Ru(r),o=this.fieldsType[i]||`char`;t.push({type:o,field:r,value:Uu({displayName:i,type:o,granularity:a},this.rows[e].values[n])})}return t}buildRowsTree(){let e=[],t=0,n={};n[0]=e;for(let r of this.rows){if(r.fields.length===0||r.values.length===0)return e;let i=r.fields.length-1,a=r.fields[i],{fieldName:o,granularity:s}=Ru(a),c=Uu({displayName:o,type:this.fieldsType[o]??`char`,granularity:s},r.values[i]);if(i>t){t=i,n[t]=[];let e=n[t-1].at(-1);e&&(e.children=n[t])}t=i;let l={value:c,field:r.fields[i],children:[],width:0};n[t].push(l)}return e}buildColumnsTree(){let e=[],t=this.columns.at(-2)||[],n={};n[0]=e;for(let e of t)for(let t=0;t<e.fields.length;t++){let r=e.fields[t],{fieldName:i,granularity:a}=Ru(r),o=Uu({displayName:i,type:this.fieldsType[i]??`char`,granularity:a},e.values[t]),s={value:o,field:e.fields[t],children:[],width:e.width};n[t]?.at(-1)?.value!==o&&(n[t+1]=[],s.children=n[t+1],n[t].push(s))}return e}export(){return{cols:this.columns,rows:this.rows,measures:this.measures,fieldsType:this.fieldsType}}};let wF={type:`EMPTY`};function TF(e,t){let n=t.measures.filter(e=>!e.isHidden).map(e=>e.id),r=DF(e,t.columns,0);OF(r,n.length);let i=kF(r,t),a=EF(e,0,t.rows,[],[]);a.push({fields:[],values:[],indent:0});let o={};for(let e of t.columns)o[e.fieldName]=e.type;for(let e of t.rows)o[e.fieldName]=e.type;return new CF(i,a,n,o)}function EF(e,t,n,r,i){if(t>=n.length)return[];let a=n[t],o=a.nameWithGranularity,s=AF(e,a),c=MF(s,a),l=[],u=r.concat(o);for(let e of c){let r=i.concat(e);l.push({fields:u,values:r,indent:t});let a=s[e];a&&l.push(...EF(a,t+1,n,u,r))}return l}function DF(e,t,n){if(n>=t.length)return[];let r=t[n],i=t[n].nameWithGranularity,a=AF(e,r);return MF(a,t[n]).map(e=>({value:a[e]?.[0]?.[r.nameWithGranularity]?.value??null,field:i,children:DF(a[e]||[],t,n+1),width:0}))}function OF(e,t){for(let n in e){let r=e[n];r.children.length===0?r.width=t:(OF(r.children,t),r.width=r.children.reduce((e,t)=>e+t.width,0))}}function kF(e,t){let n=t.columns.map(e=>e.nameWithGranularity),r=n.length,i=t.measures.filter(e=>!e.isHidden),a=i.length,o=Array(r).fill(0).map(()=>[]);function s(e,t,i){let a=o[t];for(let o of e){let e=i.concat([o.value]),c={fields:n.slice(0,t+1),values:e,width:o.width,offset:0};a.push(c),t<=r-1&&s(o.children,t+1,e)}}s(e,0,[]);let c=n.length>0,l=[];return c&&o[o.length-1].forEach(e=>{i.forEach(t=>{let n={fields:[...e.fields,`measure`],values:[...e.values,t.id],width:1,offset:0};l.push(n)})}),i.forEach(e=>{let t={fields:[`measure`],values:[e.id],width:1,offset:0};l.push(t)}),o.push(l),o.length===1&&o.unshift([]),o[o.length-2].push({fields:[],values:[],width:a,offset:0}),o}function AF(e,t){return Object.groupBy(e,jF(t))}function jF(e){let t=e.nameWithGranularity;return e=>`${e[t]?.value??null}`}function MF(e,t){return t.order?Object.keys(e).sort((e,n)=>NF(t,e,n)):Object.keys(e)}function NF(e,t,n){return t===`null`?e.order===`asc`?1:-1:n===`null`?e.order===`asc`?-1:1:e.type===`integer`||e.type===`datetime`?e.order===`asc`?F(t,k)-F(n,k):F(n,k)-F(t,k):e.order===`asc`?t.localeCompare(n):n.localeCompare(t)}let PF=Symbol(`NULL`);function FF(e,t,n){let r=e.granularity||`month`;if(!(r in IF))throw Error(`Unknown date granularity: ${r}`);let i=typeof t==`number`||typeof t==`string`?t:PF;if(!IF[r].set.has(t)){IF[r].set.add(t);let a=null;if(typeof t==`number`||typeof t==`string`){let e=z(t,n);switch(r){case`year`:a=e.getFullYear();break;case`quarter_number`:a=Math.floor(e.getMonth()/3)+1;break;case`month_number`:a=e.getMonth()+1;break;case`month`:a=Math.floor(F(t,n));break;case`iso_week_number`:a=e.getIsoWeek();break;case`day_of_month`:a=e.getDate();break;case`day`:a=Math.floor(F(t,n));break;case`day_of_week`:a=(e.getDay()+7-n.weekStart)%7+1;break;case`hour_number`:a=e.getHours();break;case`minute_number`:a=e.getMinutes();break;case`second_number`:a=e.getSeconds();break}}IF[r].values[i]=Uu(e,a)}return IF[r].values[i]}let IF={year:{set:new Set,values:{}},quarter_number:{set:new Set,values:{}},month_number:{set:new Set,values:{}},month:{set:new Set,values:{}},iso_week_number:{set:new Set,values:{}},day_of_month:{set:new Set,values:{}},day:{set:new Set,values:{}},day_of_week:{set:new Set,values:{}},hour_number:{set:new Set,values:{}},minute_number:{set:new Set,values:{}},second_number:{set:new Set,values:{}}};function LF(){for(let e in IF)IF[e].set.clear(),IF[e].values={}}var RF=class{type=`SPREADSHEET`;getters;_definition;coreDefinition;metaData={fields:{},fieldKeys:[]};dataEntries=[];table;invalidRangeError;needsReevaluation=!0;constructor(e,t){this.getters=t.getters,this.coreDefinition=t.definition}init(e={}){(!this._definition||e.reload)&&(this.reload(4),this.needsReevaluation=!1)}reload(e){e===4&&(this.metaData=this.loadMetaData()),e>=3&&(this._definition=this.loadRuntimeDefinition()),e>=2&&(this.dataEntries=this.loadData()),e>=1&&(this.table=void 0)}onDefinitionChange(e){let t=this.coreDefinition;if(this.coreDefinition=e,this._definition){let n=Math.max(this.computeShouldReload(t,e),0);this.reload(n)}}computeShouldReload(e,t){return C(e.dataSet,t.dataSet)?3:4}get isInvalidRange(){return!!this.invalidRangeError}get invalidRangeMessage(){return this.invalidRangeError?.message}get definition(){if(this._definition||this.init(),!this._definition)throw Error(`Pivot definition should be defined at this point.`);return this._definition}isValid(){if(this.invalidRangeError||!this.definition)return!1;for(let e of this.definition.measures)if(!e.isValid)return!1;for(let e of this.definition.columns)if(!e.isValid)return!1;for(let e of this.definition.rows)if(!e.isValid)return!1;return!0}assertIsValid({throwOnError:e}){if(!this.isValid()){if(e)throw this.invalidRangeError?this.invalidRangeError:new M(E(`At least one measure and/or dimension is not correct.`));return{value:j.GenericError,message:this.invalidRangeError?.message??E(`At least one measure and/or dimension is not correct.`)}}}areDomainArgsFieldsValid(e){let t=e.filter((e,t)=>t%2==0).map(I);return t.length&&t.at(-1)===`measure`&&(t=t.slice(0,-1)),Vu(t,this.definition)}parseArgsToPivotDomain(e){let t=[];for(let n=0;n<e.length-1;n+=2){let r=I(e[n]),i=this.getTypeOfDimension(r),a=r===`measure`?I(e[n+1]):Uu(this.getDimension(r),e[n+1]);t.push({field:r,value:a,type:i})}return t}markAsDirtyForEvaluation(){this.needsReevaluation=!0}getMeasure(e){return this.definition.getMeasure(e)}getPivotMeasureValue(e){return{value:this.getMeasure(e).displayName}}getPivotHeaderValueAndFormat(e){let t=e.at(-1);if(!t)return{value:E(`Total`)};let n=this.getDimension(t.field),r=this.filterDataEntriesFromDomain(this.dataEntries,e)[0]?.[n.nameWithGranularity];return n.type===`datetime`?_u(n.granularity||`month`).toValueAndFormat(t.value,this.getters.getLocale()):r?r.value===null?{value:E(`(Undefined)`)}:r:{value:``}}getPivotCellValueAndFormat(e,t){let n=this.filterDataEntriesFromDomain(this.dataEntries,t);if(n.length===0)return{value:``};let r=this.getMeasure(e),i=n.map(e=>e[r.fieldName]).filter(S),a=i.filter(e=>e.type!==`empty`),o=r.aggregator,s=Pu[o];if(!s)throw Error(`Aggregator ${o} does not exist`);try{let e=s([i],this.getters.getLocale());return a.length===0?{...e,value:``}:e}catch(e){return JT(e,o.toUpperCase())}}getPossibleFieldValues(e){let t=[],n=AF(this.dataEntries,e),r=MF(n,e);for(let i of r)t.push({value:n[i]?.[0]?.[e.nameWithGranularity]?.value??``,label:n[i]?.[0]?.[e.nameWithGranularity]?.formattedValue||``});return t}getTableStructure(){if(!this.isValid())throw Error(`Pivot is not valid !`);return this.table||=TF(this.dataEntries,this.definition),this.table}getFields(){return this.metaData.fields}get fields(){return this.getFields()}loadMetaData(){if(this.invalidRangeError=void 0,this.coreDefinition.dataSet){let{zone:e,sheetId:t}=this.coreDefinition.dataSet,n=this.getters.getRangeFromZone(t,e);try{return this.extractFieldsFromRange(n)}catch(e){return this.invalidRangeError=e,{fields:{},fieldKeys:[]}}}else return this.invalidRangeError=new M(E(`The pivot cannot be created because the dataset is missing.`)),{fields:{},fieldKeys:[]}}loadRuntimeDefinition(){return new SF(this.coreDefinition,this.fields,this.getters)}loadData(){let e=this._definition?.range;return this.isValid()&&e?this.extractDataEntriesFromRange(e):[]}getTypeOfDimension(e){if(e===`measure`)return`char`;let{fieldName:t}=Ru(e),n=this.fields[t]?.type;if(!n)throw Error(`Field ${t} does not exist`);return n}filterDataEntriesFromDomain(e,t){return t.reduce((e,t)=>this.filterDataEntriesFromDomainNode(e,t),e)}filterDataEntriesFromDomainNode(e,t){let{field:n,value:r,type:i}=t,{nameWithGranularity:a}=this.getDimension(n);return e.filter(e=>{let t=e[a]?.value;return i===`char`?String(t)===String(r):t===r})}getDimension(e){return this.definition.getDimension(e)}getTypeFromZone(e,t){let n=this.getters.getEvaluatedCellsInZone(e,t).filter(e=>!(e.type===`empty`||e.value===``));return n.length===0?`integer`:n.every(e=>e.type===`number`&&e.format&&Zo(e.format))?`datetime`:n.every(e=>e.type===`boolean`)?`boolean`:n.every(e=>e.type===`number`)?`integer`:`char`}assertCellIsValidField(e,t,n){if(n.type===`error`)throw new M(E(`The pivot cannot be created because cell %s contains an error`,w(e,t)));if(n.type===`empty`||n.value===``)throw new M(E(`The pivot cannot be created because cell %s is empty`,w(e,t)));if(n.value===`__count`)throw new M(E(`The pivot cannot be created because cell %s contains a reserved value`,w(e,t)))}extractFieldsFromRange(e){let t={},n=[],r=e.sheetId,i=e.zone.top;for(let a=e.zone.left;a<=e.zone.right;a++){let o=this.getters.getEvaluatedCell({sheetId:r,col:a,row:i});this.assertCellIsValidField(a,i,o);let s=o.value?.toString();if(s){let i=this.getTypeFromZone(r,{top:e.zone.top+1,left:a,bottom:e.zone.bottom,right:a}),o=this.findName(s,t);t[o]={name:o,type:i,string:o,aggregator:i===`integer`?`sum`:`count`},n.push(o)}}return{fields:t,fieldKeys:n}}findName(e,t){let n=1,r=e;for(;e in t;)e=`${r}${++n}`;return e}extractDataEntriesFromRange(e){let t=[];for(let n=e.zone.top+1;n<=e.zone.bottom;n++){let r={top:n,bottom:n,left:e.zone.left,right:e.zone.right},i=this.getters.getEvaluatedCellsInZone(e.sheetId,r),a={};for(let e in i){let t=i[e],n=this.fields[this.metaData.fieldKeys[e]];if(!n)throw Error(`Field ${this.metaData.fieldKeys[e]} does not exist`);t.value===``?a[n.name]={value:null,type:`empty`,formattedValue:``}:a[n.name]=t}a.__count={value:1,type:`number`,formattedValue:`1`},t.push(a)}let n=this.definition.columns.concat(this.definition.rows).filter(e=>e.type===`datetime`);if(n.length){let e=this.getters.getLocale();for(let r of t)for(let t of n){let n=FF(t,r[t.fieldName]?.value||null,this.getters.getLocale()),{format:i,value:a}=_u(t.granularity||`month`).toValueAndFormat(n,e);r[t.nameWithGranularity]={value:n,type:r[t.fieldName]?.type||`empty`,format:r[t.fieldName]?.format,formattedValue:V(a,{locale:e,format:i})}}}return t}};let zF=new h,BF=[`year`,`quarter_number`,`month_number`,`month`,`iso_week_number`,`day_of_month`,`day`,`day_of_week`],VF=[...BF,`hour_number`,`minute_number`,`second_number`];zF.add(`SPREADSHEET`,{ui:RF,definition:SF,dateGranularities:[...BF],datetimeGranularities:[...VF],isMeasureCandidate:e=>![`datetime`,`boolean`].includes(e.type),isGroupable:()=>!0,adaptRanges:(e,t,n)=>{if(t.type!==`SPREADSHEET`||!t.dataSet)return t;let{sheetId:r,zone:i}=t.dataSet,a=e.getRangeFromZone(r,i),o=HF(a,n);if(o===a)return t;let s=o&&{sheetId:o.sheetId,zone:o.zone};return{...t,dataSet:s}}});function HF(e,t){if(!e)return;let n=t(e);switch(n.changeType){case`NONE`:return e;case`REMOVE`:return;default:return n.range}}var UF=class extends Sd{pivotId;mutators=[`reset`,`deferUpdates`,`applyUpdate`,`discardPendingUpdate`,`update`];updatesAreDeferred=!1;draft=null;notification=this.get(gP);alreadyNotified=!1;constructor(e,t){super(e),this.pivotId=t}handle(e){switch(e.type){case`UPDATE_PIVOT`:e.pivotId===this.pivotId&&this.getters.getPivot(this.pivotId).init()}}get fields(){return this.pivot.getFields()}get pivot(){return this.getters.getPivot(this.pivotId)}get definition(){let e=zF.get(this.pivot.type).definition;return this.draft?new e(this.draft,this.fields,this.getters):this.pivot.definition}get isDirty(){return!!this.draft}get measureFields(){let e=[{name:`__count`,string:E(`Count`),type:`integer`,aggregator:`sum`}],t=this.fields;for(let n in t){let r=t[n];r&&zF.get(this.pivot.type).isMeasureCandidate(r)&&e.push(r)}return e.sort((e,t)=>e.string.localeCompare(t.string))}get unusedGroupableFields(){let e=[],t=this.fields;for(let n in t){let r=t[n];r&&zF.get(this.pivot.type).isGroupable(r)&&e.push(r)}let{columns:n,rows:r,measures:i}=this.definition,a=i.concat(r).concat(n).map(e=>e.fieldName),o=this.unusedGranularities;return e.filter(e=>zu(e)?!a.includes(e.name)||o[e.name].size>0:!a.includes(e.name)).sort((e,t)=>e.string.localeCompare(t.string))}get datetimeGranularities(){return zF.get(this.pivot.type).datetimeGranularities}get dateGranularities(){return zF.get(this.pivot.type).dateGranularities}get unusedGranularities(){return this.getUnusedGranularities(this.fields,this.draft??this.getters.getPivotCoreDefinition(this.pivotId))}reset(e){this.pivotId=e,this.updatesAreDeferred=!0,this.draft=null}deferUpdates(e){this.updatesAreDeferred=e,e===!1&&this.draft&&this.applyUpdate()}applyUpdate(){if(this.draft&&(this.model.dispatch(`UPDATE_PIVOT`,{pivotId:this.pivotId,pivot:this.draft}),this.draft=null,!this.alreadyNotified&&this.isUpdatedPivotVisibleInViewportOnlyAsStaticPivot())){let e=`=PIVOT(${this.getters.getPivotFormulaId(this.pivotId)})`;this.alreadyNotified=!0,this.notification.notifyUser({type:`info`,text:E(`Pivot updates only work with dynamic pivot tables. Use %s or re-insert the static pivot from the Data menu.`,e),sticky:!0})}}discardPendingUpdate(){this.draft=null}update(e){let t=this.getters.getPivotCoreDefinition(this.pivotId),n={...t,...this.draft,...e},r={...n,columns:n.columns.map(e=>({fieldName:e.fieldName,order:e.order,granularity:e.granularity})),rows:n.rows.map(e=>({fieldName:e.fieldName,order:e.order,granularity:e.granularity})),measures:n.measures.map(e=>({id:e.id,fieldName:e.fieldName,aggregator:e.aggregator,userDefinedName:e.userDefinedName,computedBy:e.computedBy,isHidden:e.isHidden,format:e.format,display:e.display}))};if(!this.draft&&C(t,r))return;let i=this.addDefaultDateTimeGranularity(this.fields,r);this.draft=i,this.updatesAreDeferred||this.applyUpdate()}isUpdatedPivotVisibleInViewportOnlyAsStaticPivot(){let e=0,t=this.getters.getPivotFormulaId(this.pivotId);for(let n of this.getters.getVisibleCellPositions()){let r=this.getters.getCell(n);if(r?.isFormula){let n=$E(r.compiledFormula.tokens),i=n?.args[0]?.value;if(n&&t===i.toString()){if(n.functionName===`PIVOT`)return!1;e++}}}return e>0}addDefaultDateTimeGranularity(e,t){let{columns:n,rows:r}=t,i=y(n),a=y(r),o=this.getUnusedGranularities(e,t);for(let t of i.concat(a)){let n=e[t.fieldName]?.type;if((n===`date`||n===`datetime`)&&!t.granularity){let e=o[t.fieldName]?.values().next().value;o[t.fieldName]?.delete(e),t.granularity=e}}return{...t,columns:i,rows:a}}getUnusedGranularities(e,t){let{columns:n,rows:r}=t,i=n.concat(r).filter(t=>{let n=e[t.fieldName]?.type;return n===`date`||n===`datetime`}),a={};for(let t of i)a[t.fieldName]=new Set(e[t.fieldName]?.type===`date`?this.dateGranularities:this.datetimeGranularities);for(let e of i)a[e.fieldName].delete(e.granularity);return a}},WF=class extends t.Component{static template=`o-spreadsheet-PivotSpreadsheetSidePanel`;static props={pivotId:String,onCloseSidePanel:Function};static components={PivotLayoutConfigurator:vF,Section:PN,SelectionInput:LN,Checkbox:NN,PivotDeferUpdate:cF,PivotTitleSection:yF};store;state;pivotSidePanelRef=(0,t.useRef)(`pivotSidePanel`);setup(){this.store=gd(UF,this.props.pivotId),this.state=(0,t.useState)({range:void 0,rangeHasChanged:!1})}get shouldDisplayInvalidRangeError(){return this.store.isDirty&&this.state.rangeHasChanged?!1:this.pivot.isInvalidRange}get ranges(){return this.state.range?[this.state.range]:this.definition.range?[this.env.model.getters.getRangeString(this.definition.range,`forceSheetReference`)]:[]}get pivot(){return this.store.pivot}get definition(){return this.store.definition}getScrollableContainerEl(){return this.pivotSidePanelRef.el}onSelectionChanged(e){if(this.state.rangeHasChanged=!0,e.length===0){this.state.range=void 0;return}let t=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getRangeFromSheetXC(t,e[0]);this.state.range=this.env.model.getters.getRangeString(n,`forceSheetReference`,{useBoundedReference:!0})}onSelectionConfirmed(){if(this.state.range){let e=this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(),this.state.range);if(e.invalidSheetName||e.invalidXc)return;let t={sheetId:e.sheetId,zone:e.zone};this.store.update({dataSet:t}),this.store.applyUpdate()}}flipAxis(){let{rows:e,columns:t}=this.definition;this.onDimensionsUpdated({rows:t,columns:e})}onDimensionsUpdated(e){this.store.update(e)}};let GF=new h;GF.add(`SPREADSHEET`,{editor:WF});var KF=class extends t.Component{static template=`o-spreadsheet-PivotSidePanel`;static props={pivotId:String,onCloseSidePanel:Function};static components={PivotLayoutConfigurator:vF,Section:PN};get sidePanelEditor(){let e=this.env.model.getters.getPivotCoreDefinition(this.props.pivotId);if(!e)throw Error(`pivotId does not correspond to a pivot.`);return GF.get(e.type).editor}};U`
1309
+ `;var vF=class extends t.Component{static template=`o-spreadsheet-PivotLayoutConfigurator`;static components={AddDimensionButton:uF,PivotDimension:pF,PivotDimensionOrder:hF,PivotDimensionGranularity:mF,PivotMeasureEditor:_F};static props={definition:Object,onDimensionsUpdated:Function,unusedGroupableFields:Array,measureFields:Array,unusedGranularities:Object,dateGranularities:Array,datetimeGranularities:Array,getScrollableContainerEl:{type:Function,optional:!0},pivotId:String};dimensionsRef=(0,t.useRef)(`pivot-dimensions`);dragAndDrop=xP();AGGREGATORS=Nu;composerFocus;isDateOrDatetimeField=zu;setup(){this.composerFocus=H(wd)}startDragAndDrop(e,t){if(t.button!==0||t.target.tagName===`SELECT`)return;let n=this.getDimensionElementsRects(),{columns:r,rows:i}=this.props.definition,a=[...r.map(e=>e.nameWithGranularity),`__rows_title__`,...i.map(e=>e.nameWithGranularity)],o=r.concat(i),s=a.map((e,t)=>({id:e,size:n[t+1].height,position:n[t+1].y}));this.dragAndDrop.start(`vertical`,{draggedItemId:e.nameWithGranularity,initialMousePosition:t.clientY,items:s,scrollableContainerEl:this.props.getScrollableContainerEl?.()||this.dimensionsRef.el,onDragEnd:(e,t)=>{let n=a.findIndex(t=>t===e);if(n===t)return;let r=[...a];r.splice(n,1),r.splice(t,0,e);let i=r.slice(0,r.indexOf(`__rows_title__`)),s=r.slice(r.indexOf(`__rows_title__`)+1);this.props.onDimensionsUpdated({columns:i.map(e=>o.find(t=>t.nameWithGranularity===e)).filter(S),rows:s.map(e=>o.find(t=>t.nameWithGranularity===e)).filter(S)})}})}getGranularitiesFor(e){return zu(e)?e.type===`date`?this.props.dateGranularities:this.props.datetimeGranularities:[]}startDragAndDropMeasures(e,t){if(t.button!==0||t.target.tagName===`SELECT`||t.target.tagName===`INPUT`||this.composerFocus.focusMode!==`inactive`)return;let n=this.getDimensionElementsRects(),{measures:r,columns:i,rows:a}=this.props.definition,o=r.map(e=>e.id),s=3+i.length+a.length,c=o.map((e,t)=>({id:e,size:n[t+s].height,position:n[t+s].y}));this.dragAndDrop.start(`vertical`,{draggedItemId:e.id,initialMousePosition:t.clientY,items:c,scrollableContainerEl:this.props.getScrollableContainerEl?.()||this.dimensionsRef.el,onDragEnd:(e,t)=>{let n=o.findIndex(t=>t===e);if(n===t)return;let i=[...o];i.splice(n,1),i.splice(t,0,e),this.props.onDimensionsUpdated({measures:i.map(e=>r.find(t=>t.id===e)).filter(S)})}})}getDimensionElementsRects(){return Array.from(this.dimensionsRef.el.children).map(e=>{let t=getComputedStyle(e),n=e.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width+parseInt(t.marginLeft||`0`)+parseInt(t.marginRight||`0`),height:n.height+parseInt(t.marginTop||`0`)+parseInt(t.marginBottom||`0`)}})}removeDimension(e){let{columns:t,rows:n}=this.props.definition;this.props.onDimensionsUpdated({columns:t.filter(t=>t.nameWithGranularity!==e.nameWithGranularity),rows:n.filter(t=>t.nameWithGranularity!==e.nameWithGranularity)})}removeMeasureDimension(e){let{measures:t}=this.props.definition;this.props.onDimensionsUpdated({measures:t.filter(t=>t.id!==e.id)})}addColumnDimension(e){let{columns:t}=this.props.definition;this.props.onDimensionsUpdated({columns:t.concat([{fieldName:e,order:`asc`}])})}addRowDimension(e){let{rows:t}=this.props.definition;this.props.onDimensionsUpdated({rows:t.concat([{fieldName:e,order:`asc`}])})}addMeasureDimension(e){let{measures:t}=this.props.definition,n=this.getDefaultMeasureAggregator(e);this.props.onDimensionsUpdated({measures:t.concat([{id:this.getMeasureId(e,n),fieldName:e,aggregator:n}])})}updateMeasure(e,t){let{measures:n}=this.props.definition;this.props.onDimensionsUpdated({measures:n.map(n=>n.id===e.id?t:n)})}getMeasureId(e,t){let n=e.replaceAll(`'`,``)+(t?`:${t}`:``),r=n,i=2;for(;this.props.definition.measures.some(e=>e.id===r);)r=`${n}:${i}`,i++;return r}getDefaultMeasureAggregator(e){let t=this.props.measureFields.find(t=>t.name===e);return t?.aggregator?t.aggregator:`count`}addCalculatedMeasure(){let{measures:e}=this.props.definition,t=this.env.model.getters.generateNewCalculatedMeasureName(e);this.props.onDimensionsUpdated({measures:e.concat([{id:this.getMeasureId(t,`sum`),fieldName:t,aggregator:`sum`,computedBy:{sheetId:this.env.model.getters.getActiveSheetId(),formula:`=0`}}])})}updateOrder(e,t){let{rows:n,columns:r}=this.props.definition;this.props.onDimensionsUpdated({rows:n.map(n=>n.nameWithGranularity===e.nameWithGranularity?{...n,order:t||void 0}:n),columns:r.map(n=>n.nameWithGranularity===e.nameWithGranularity?{...n,order:t||void 0}:n)})}updateGranularity(e,t){let{rows:n,columns:r}=this.props.definition;this.props.onDimensionsUpdated({rows:n.map(n=>n.nameWithGranularity===e.nameWithGranularity?{...n,granularity:t}:n),columns:r.map(n=>n.nameWithGranularity===e.nameWithGranularity?{...n,granularity:t}:n)})}getMeasureDescription(e){let t=e.display;if(!t||t.type===`no_calculations`)return``;let n=this.env.model.getters.getPivot(this.props.pivotId),r=[...n.definition.columns,...n.definition.rows].find(e=>e.nameWithGranularity===t.fieldNameWithGranularity),i=r?Yu(r):``;return xg.descriptions[t.type](i)}},yF=class extends t.Component{static template=`o-spreadsheet-PivotTitleSection`;static components={CogWheelMenu:fF,Section:PN,TextInput:dF};static props={pivotId:String,flipAxis:Function};get cogWheelMenuItems(){return[{name:E(`Flip axes`),icon:`o-spreadsheet-Icon.EXCHANGE`,execute:this.props.flipAxis},{name:E(`Duplicate`),icon:`o-spreadsheet-Icon.COPY`,execute:()=>this.duplicatePivot()},{name:E(`Delete`),icon:`o-spreadsheet-Icon.TRASH`,execute:()=>this.delete()}]}get name(){return this.env.model.getters.getPivotName(this.props.pivotId)}get displayName(){return this.env.model.getters.getPivotDisplayName(this.props.pivotId)}duplicatePivot(){let e=this.env.model.uuidGenerator.smallUuid(),t=this.env.model.uuidGenerator.smallUuid(),n=this.env.model.dispatch(`DUPLICATE_PIVOT_IN_NEW_SHEET`,{pivotId:this.props.pivotId,newPivotId:e,newSheetId:t}),r;r=n.isSuccessful?E(`Pivot duplicated.`):n.isCancelledBecause(`PivotInError`)?E(`Cannot duplicate a pivot in error.`):E(`Pivot duplication failed.`);let i=n.isSuccessful?`success`:`danger`;this.env.notifyUser({text:r,sticky:!1,type:i}),n.isSuccessful&&this.env.openSidePanel(`PivotSidePanel`,{pivotId:e})}delete(){this.env.askConfirmation(E(`Are you sure you want to delete this pivot?`),()=>{this.env.model.dispatch(`REMOVE_PIVOT`,{pivotId:this.props.pivotId})})}onNameChanged(e){let t=this.env.model.getters.getPivotCoreDefinition(this.props.pivotId);this.env.model.dispatch(`UPDATE_PIVOT`,{pivotId:this.props.pivotId,pivot:{...t,name:e}})}},bF=class{measures;columns;rows;constructor(e,t){this.measures=e.measures.map(e=>xF(t,e)),this.columns=e.columns.map(e=>this.createPivotDimension(t,e)),this.rows=e.rows.map(e=>this.createPivotDimension(t,e))}getDimension(e){let t=this.columns.find(t=>t.nameWithGranularity===e)||this.rows.find(t=>t.nameWithGranularity===e);if(!t)throw new M(E(`Dimension %s does not exist`,e));return t}getMeasure(e){let t=this.measures.find(t=>t.id===e);if(!t)throw new M(E(`Field %s is not a measure`,e));return t}createPivotDimension(e,t){let n=e[t.fieldName],r=n?.type??`integer`,i=n&&zu(n)?t.granularity:void 0;return{displayName:n?.string??t.fieldName,nameWithGranularity:t.fieldName+(i?`:${i}`:``),fieldName:t.fieldName,granularity:i,type:r,order:t.order,isValid:!!n}}};function xF(e,t){let n=t.fieldName,r=n===`__count`?{name:`__count`,string:E(`Count`),type:`integer`,aggregator:`sum`}:e[n],i=t.aggregator;return{id:t.id,get displayName(){return t.userDefinedName??r?.string??t.fieldName},userDefinedName:t.userDefinedName,fieldName:n,aggregator:i,type:n===`__count`?`integer`:r?.type??`integer`,isValid:!!(r||t.computedBy),isHidden:t.isHidden,format:t.format,computedBy:t.computedBy,display:t.display}}var SF=class extends bF{range;constructor(e,t,n){if(super(e,t),e.dataSet){let{sheetId:t,zone:r}=e.dataSet;this.range=n.getRangeFromZone(t,r)}}},CF=class{columns;rows;measures;fieldsType;maxIndent;pivotCells={};rowTree;colTree;constructor(e,t,n,r){this.columns=e.map(e=>{let t=1;return e.map(e=>(e={...e,offset:t},t+=e.width,e))}),this.rows=t,this.measures=n,this.fieldsType=r,this.maxIndent=Math.max(...this.rows.map(e=>e.indent)),this.rowTree=At(()=>this.buildRowsTree()),this.colTree=At(()=>this.buildColumnsTree())}getNumberOfDataColumns(){return this.columns.at(-1)?.length||0}getPivotCells(e=!0,t=!0){let n=JSON.stringify({includeTotal:e,includeColumnHeaders:t});if(!this.pivotCells[n]){let r=this.rows.length,i=this.getNumberOfDataColumns(),a=this.columns.length+r,o=1+i;!e&&r!==1&&--a,!e&&i!==this.measures.length&&(o-=this.measures.length);let s=[],c=t?0:this.columns.length;for(let t=0;t<o;t++){s.push([]);for(let n=c;n<a;n++)!e&&n===a||s[t].push(this.getPivotCell(t,n,e))}this.pivotCells[n]=s}return this.pivotCells[n]}getRowTree(){return this.rowTree()}getColTree(){return this.colTree()}isTotalRow(e){return this.rows[e].indent!==this.maxIndent}getPivotCell(e,t,n=!0){let r=this.columns.length;if(e>0&&t===r-1){let n=this.getColHeaderDomain(e,t);if(!n)return wF;let r=n.at(-1)?.value?.toString()||``;return{type:`MEASURE_HEADER`,domain:n.slice(0,-1),measure:r}}else if(t<=r-1){let n=this.getColHeaderDomain(e,t);return n?{type:`HEADER`,domain:n}:wF}else if(e===0){let e=t-r;return{type:`HEADER`,domain:this.getRowDomain(e)}}else{let i=t-r;return!n&&this.isTotalRow(i)?wF:{type:`VALUE`,domain:[...this.getRowDomain(i),...this.getColDomain(e)],measure:this.getColMeasure(e)}}}getColHeaderDomain(e,t){if(e===0)return;let n=[],r=this.columns[t].find(t=>t.offset===e);if(r){for(let e=0;e<r.fields.length;e++){let t=r.fields[e];if(t===`measure`)n.push({type:`char`,field:t,value:Uu({displayName:`measure`,type:`char`},r.values[e])});else{let{fieldName:i,granularity:a}=Ru(t),o=this.fieldsType[i]||`char`;n.push({type:o,field:t,value:Uu({displayName:i,type:o,granularity:a},r.values[e])})}}return n}}getColDomain(e){let t=this.getColHeaderDomain(e,this.columns.length-1);return t?t.slice(0,-1):[]}getColMeasure(e){let t=this.getColHeaderDomain(e,this.columns.length-1)?.at(-1)?.value;if(t==null)throw Error(`Measure is missing`);return t.toString()}getRowDomain(e){let t=[];for(let n=0;n<this.rows[e].fields.length;n++){let r=this.rows[e].fields[n],{fieldName:i,granularity:a}=Ru(r),o=this.fieldsType[i]||`char`;t.push({type:o,field:r,value:Uu({displayName:i,type:o,granularity:a},this.rows[e].values[n])})}return t}buildRowsTree(){let e=[],t=0,n={};n[0]=e;for(let r of this.rows){if(r.fields.length===0||r.values.length===0)return e;let i=r.fields.length-1,a=r.fields[i],{fieldName:o,granularity:s}=Ru(a),c=Uu({displayName:o,type:this.fieldsType[o]??`char`,granularity:s},r.values[i]);if(i>t){t=i,n[t]=[];let e=n[t-1].at(-1);e&&(e.children=n[t])}t=i;let l={value:c,field:r.fields[i],children:[],width:0};n[t].push(l)}return e}buildColumnsTree(){let e=[],t=this.columns.at(-2)||[],n={};n[0]=e;for(let e of t)for(let t=0;t<e.fields.length;t++){let r=e.fields[t],{fieldName:i,granularity:a}=Ru(r),o=Uu({displayName:i,type:this.fieldsType[i]??`char`,granularity:a},e.values[t]),s={value:o,field:e.fields[t],children:[],width:e.width};n[t]?.at(-1)?.value!==o&&(n[t+1]=[],s.children=n[t+1],n[t].push(s))}return e}export(){return{cols:this.columns,rows:this.rows,measures:this.measures,fieldsType:this.fieldsType}}};let wF={type:`EMPTY`};function TF(e,t){let n=t.measures.filter(e=>!e.isHidden).map(e=>e.id),r=DF(e,t.columns,0);OF(r,n.length);let i=kF(r,t),a=EF(e,0,t.rows,[],[]);a.push({fields:[],values:[],indent:0});let o={};for(let e of t.columns)o[e.fieldName]=e.type;for(let e of t.rows)o[e.fieldName]=e.type;return new CF(i,a,n,o)}function EF(e,t,n,r,i){if(t>=n.length)return[];let a=n[t],o=a.nameWithGranularity,s=AF(e,a),c=MF(s,a),l=[],u=r.concat(o);for(let e of c){let r=i.concat(e);l.push({fields:u,values:r,indent:t});let a=s[e];a&&l.push(...EF(a,t+1,n,u,r))}return l}function DF(e,t,n){if(n>=t.length)return[];let r=t[n],i=t[n].nameWithGranularity,a=AF(e,r);return MF(a,t[n]).map(e=>({value:a[e]?.[0]?.[r.nameWithGranularity]?.value??null,field:i,children:DF(a[e]||[],t,n+1),width:0}))}function OF(e,t){for(let n in e){let r=e[n];r.children.length===0?r.width=t:(OF(r.children,t),r.width=r.children.reduce((e,t)=>e+t.width,0))}}function kF(e,t){let n=t.columns.map(e=>e.nameWithGranularity),r=n.length,i=t.measures.filter(e=>!e.isHidden),a=i.length,o=Array(r).fill(0).map(()=>[]);function s(e,t,i){let a=o[t];for(let o of e){let e=i.concat([o.value]),c={fields:n.slice(0,t+1),values:e,width:o.width,offset:0};a.push(c),t<=r-1&&s(o.children,t+1,e)}}s(e,0,[]);let c=n.length>0,l=[];return c&&o[o.length-1].forEach(e=>{i.forEach(t=>{let n={fields:[...e.fields,`measure`],values:[...e.values,t.id],width:1,offset:0};l.push(n)})}),i.forEach(e=>{let t={fields:[`measure`],values:[e.id],width:1,offset:0};l.push(t)}),o.push(l),o.length===1&&o.unshift([]),o[o.length-2].push({fields:[],values:[],width:a,offset:0}),o}function AF(e,t){return Object.groupBy(e,jF(t))}function jF(e){let t=e.nameWithGranularity;return e=>`${e[t]?.value??null}`}function MF(e,t){return t.order?Object.keys(e).sort((e,n)=>NF(t,e,n)):Object.keys(e)}function NF(e,t,n){return t===`null`?e.order===`asc`?1:-1:n===`null`?e.order===`asc`?-1:1:e.type===`integer`||e.type===`datetime`?e.order===`asc`?F(t,k)-F(n,k):F(n,k)-F(t,k):e.order===`asc`?t.localeCompare(n):n.localeCompare(t)}let PF=Symbol(`NULL`);function FF(e,t,n){let r=e.granularity||`month`;if(!(r in IF))throw Error(`Unknown date granularity: ${r}`);let i=typeof t==`number`||typeof t==`string`?t:PF;if(!IF[r].set.has(t)){IF[r].set.add(t);let a=null;if(typeof t==`number`||typeof t==`string`){let e=z(t,n);switch(r){case`year`:a=e.getFullYear();break;case`quarter_number`:a=Math.floor(e.getMonth()/3)+1;break;case`month_number`:a=e.getMonth()+1;break;case`month`:a=Math.floor(F(t,n));break;case`iso_week_number`:a=e.getIsoWeek();break;case`day_of_month`:a=e.getDate();break;case`day`:a=Math.floor(F(t,n));break;case`day_of_week`:a=(e.getDay()+7-n.weekStart)%7+1;break;case`hour_number`:a=e.getHours();break;case`minute_number`:a=e.getMinutes();break;case`second_number`:a=e.getSeconds();break}}IF[r].values[i]=Uu(e,a)}return IF[r].values[i]}let IF={year:{set:new Set,values:{}},quarter_number:{set:new Set,values:{}},month_number:{set:new Set,values:{}},month:{set:new Set,values:{}},iso_week_number:{set:new Set,values:{}},day_of_month:{set:new Set,values:{}},day:{set:new Set,values:{}},day_of_week:{set:new Set,values:{}},hour_number:{set:new Set,values:{}},minute_number:{set:new Set,values:{}},second_number:{set:new Set,values:{}}};function LF(){for(let e in IF)IF[e].set.clear(),IF[e].values={}}var RF=class{type=`SPREADSHEET`;getters;_definition;coreDefinition;metaData={fields:{},fieldKeys:[]};dataEntries=[];table;invalidRangeError;needsReevaluation=!0;constructor(e,t){this.getters=t.getters,this.coreDefinition=t.definition}init(e={}){(!this._definition||e.reload)&&(this.reload(4),this.needsReevaluation=!1)}reload(e){e===4&&(this.metaData=this.loadMetaData()),e>=3&&(this._definition=this.loadRuntimeDefinition()),e>=2&&(this.dataEntries=this.loadData()),e>=1&&(this.table=void 0)}onDefinitionChange(e){let t=this.coreDefinition;if(this.coreDefinition=e,this._definition){let n=Math.max(this.computeShouldReload(t,e),0);this.reload(n)}}computeShouldReload(e,t){return C(e.dataSet,t.dataSet)?3:4}get isInvalidRange(){return!!this.invalidRangeError}get invalidRangeMessage(){return this.invalidRangeError?.message}get definition(){if(this._definition||this.init(),!this._definition)throw Error(`Pivot definition should be defined at this point.`);return this._definition}isValid(){if(this.invalidRangeError||!this.definition)return!1;for(let e of this.definition.measures)if(!e.isValid)return!1;for(let e of this.definition.columns)if(!e.isValid)return!1;for(let e of this.definition.rows)if(!e.isValid)return!1;return!0}assertIsValid({throwOnError:e}){if(!this.isValid()){if(e)throw this.invalidRangeError?this.invalidRangeError:new M(E(`At least one measure and/or dimension is not correct.`));return{value:j.GenericError,message:this.invalidRangeError?.message??E(`At least one measure and/or dimension is not correct.`)}}}areDomainArgsFieldsValid(e){let t=e.filter((e,t)=>t%2==0).map(I);return t.length&&t.at(-1)===`measure`&&(t=t.slice(0,-1)),Vu(t,this.definition)}parseArgsToPivotDomain(e){let t=[];for(let n=0;n<e.length-1;n+=2){let r=I(e[n]),i=this.getTypeOfDimension(r),a=r===`measure`?I(e[n+1]):Uu(this.getDimension(r),e[n+1]);t.push({field:r,value:a,type:i})}return t}markAsDirtyForEvaluation(){this.needsReevaluation=!0}getMeasure(e){return this.definition.getMeasure(e)}getPivotMeasureValue(e){return{value:this.getMeasure(e).displayName}}getPivotHeaderValueAndFormat(e){let t=e.at(-1);if(!t)return{value:E(`Total`)};let n=this.getDimension(t.field),r=this.filterDataEntriesFromDomain(this.dataEntries,e)[0]?.[n.nameWithGranularity];return n.type===`datetime`?_u(n.granularity||`month`).toValueAndFormat(t.value,this.getters.getLocale()):r?r.value===null?{value:E(`(Undefined)`)}:r:{value:``}}getPivotCellValueAndFormat(e,t){let n=this.filterDataEntriesFromDomain(this.dataEntries,t);if(n.length===0)return{value:``};let r=this.getMeasure(e),i=n.map(e=>e[r.fieldName]).filter(S),a=i.filter(e=>e.type!==`empty`),o=r.aggregator,s=Pu[o];if(!s)throw Error(`Aggregator ${o} does not exist`);try{let e=s([i],this.getters.getLocale());return a.length===0?{...e,value:``}:e}catch(e){return JT(e,o.toUpperCase())}}getPossibleFieldValues(e){let t=[],n=AF(this.dataEntries,e),r=MF(n,e);for(let i of r)t.push({value:n[i]?.[0]?.[e.nameWithGranularity]?.value??``,label:n[i]?.[0]?.[e.nameWithGranularity]?.formattedValue||``});return t}getTableStructure(){if(!this.isValid())throw Error(`Pivot is not valid !`);return this.table||=TF(this.dataEntries,this.definition),this.table}getFields(){return this.metaData.fields}get fields(){return this.getFields()}loadMetaData(){if(this.invalidRangeError=void 0,this.coreDefinition.dataSet){let{zone:e,sheetId:t}=this.coreDefinition.dataSet,n=this.getters.getRangeFromZone(t,e);try{return this.extractFieldsFromRange(n)}catch(e){return this.invalidRangeError=e,{fields:{},fieldKeys:[]}}}else return this.invalidRangeError=new M(E(`The pivot cannot be created because the dataset is missing.`)),{fields:{},fieldKeys:[]}}loadRuntimeDefinition(){return new SF(this.coreDefinition,this.fields,this.getters)}loadData(){let e=this._definition?.range;return this.isValid()&&e?this.extractDataEntriesFromRange(e):[]}getTypeOfDimension(e){if(e===`measure`)return`char`;let{fieldName:t}=Ru(e),n=this.fields[t]?.type;if(!n)throw Error(`Field ${t} does not exist`);return n}filterDataEntriesFromDomain(e,t){return t.reduce((e,t)=>this.filterDataEntriesFromDomainNode(e,t),e)}filterDataEntriesFromDomainNode(e,t){let{field:n,value:r,type:i}=t,{nameWithGranularity:a}=this.getDimension(n);return e.filter(e=>{let t=e[a]?.value;return i===`char`?String(t)===String(r):t===r})}getDimension(e){return this.definition.getDimension(e)}getTypeFromZone(e,t){let n=this.getters.getEvaluatedCellsInZone(e,t).filter(e=>!(e.type===`empty`||e.value===``));return n.length===0?`integer`:n.every(e=>e.type===`number`&&e.format&&Zo(e.format))?`datetime`:n.every(e=>e.type===`boolean`)?`boolean`:n.every(e=>e.type===`number`)?`integer`:`char`}assertCellIsValidField(e,t,n){if(n.type===`error`)throw new M(E(`The pivot cannot be created because cell %s contains an error`,w(e,t)));if(n.type===`empty`||n.value===``)throw new M(E(`The pivot cannot be created because cell %s is empty`,w(e,t)));if(n.value===`__count`)throw new M(E(`The pivot cannot be created because cell %s contains a reserved value`,w(e,t)))}extractFieldsFromRange(e){let t={},n=[],r=e.sheetId,i=e.zone.top;for(let a=e.zone.left;a<=e.zone.right;a++){let o=this.getters.getEvaluatedCell({sheetId:r,col:a,row:i});this.assertCellIsValidField(a,i,o);let s=o.value?.toString();if(s){let i=this.getTypeFromZone(r,{top:e.zone.top+1,left:a,bottom:e.zone.bottom,right:a}),o=this.findName(s,t);t[o]={name:o,type:i,string:o,aggregator:i===`integer`?`sum`:`count`},n.push(o)}}return{fields:t,fieldKeys:n}}findName(e,t){let n=1,r=e;for(;e in t;)e=`${r}${++n}`;return e}extractDataEntriesFromRange(e){let t=[];for(let n=e.zone.top+1;n<=e.zone.bottom;n++){let r={top:n,bottom:n,left:e.zone.left,right:e.zone.right},i=this.getters.getEvaluatedCellsInZone(e.sheetId,r),a={};for(let e in i){let t=i[e],n=this.fields[this.metaData.fieldKeys[e]];if(!n)throw Error(`Field ${this.metaData.fieldKeys[e]} does not exist`);t.value===``?a[n.name]={value:null,type:`empty`,formattedValue:``}:a[n.name]=t}a.__count={value:1,type:`number`,formattedValue:`1`},t.push(a)}let n=this.definition.columns.concat(this.definition.rows).filter(e=>e.type===`datetime`);if(n.length){let e=this.getters.getLocale();for(let r of t)for(let t of n){let n=FF(t,r[t.fieldName]?.value||null,this.getters.getLocale()),{format:i,value:a}=_u(t.granularity||`month`).toValueAndFormat(n,e);r[t.nameWithGranularity]={value:n,type:r[t.fieldName]?.type||`empty`,format:r[t.fieldName]?.format,formattedValue:V(a,{locale:e,format:i})}}}return t}};let zF=new h,BF=[`year`,`quarter_number`,`month_number`,`month`,`iso_week_number`,`day_of_month`,`day`,`day_of_week`],VF=[...BF,`hour_number`,`minute_number`,`second_number`];zF.add(`SPREADSHEET`,{ui:RF,definition:SF,dateGranularities:[...BF],datetimeGranularities:[...VF],isMeasureCandidate:e=>![`datetime`,`boolean`].includes(e.type),isGroupable:()=>!0,adaptRanges:(e,t,n)=>{if(t.type!==`SPREADSHEET`||!t.dataSet)return t;let{sheetId:r,zone:i}=t.dataSet,a=e.getRangeFromZone(r,i),o=HF(a,n);if(o===a)return t;let s=o&&{sheetId:o.sheetId,zone:o.zone};return{...t,dataSet:s}}});function HF(e,t){if(!e)return;let n=t(e);switch(n.changeType){case`NONE`:return e;case`REMOVE`:return;default:return n.range}}var UF=class extends Sd{pivotId;mutators=[`reset`,`deferUpdates`,`applyUpdate`,`discardPendingUpdate`,`update`];updatesAreDeferred=!1;draft=null;notification=this.get(gP);alreadyNotified=!1;constructor(e,t){super(e),this.pivotId=t}handle(e){switch(e.type){case`UPDATE_PIVOT`:e.pivotId===this.pivotId&&this.getters.getPivot(this.pivotId).init()}}get fields(){return this.pivot.getFields()}get pivot(){return this.getters.getPivot(this.pivotId)}get definition(){let e=zF.get(this.pivot.type).definition;return this.draft?new e(this.draft,this.fields,this.getters):this.pivot.definition}get isDirty(){return!!this.draft}get measureFields(){let e=[{name:`__count`,string:E(`Count`),type:`integer`,aggregator:`sum`}],t=this.fields;for(let n in t){let r=t[n];r&&zF.get(this.pivot.type).isMeasureCandidate(r)&&e.push(r)}return e.sort((e,t)=>e.string.localeCompare(t.string))}get unusedGroupableFields(){let e=[],t=this.fields;for(let n in t){let r=t[n];r&&zF.get(this.pivot.type).isGroupable(r)&&e.push(r)}let{columns:n,rows:r,measures:i}=this.definition,a=i.concat(r).concat(n).map(e=>e.fieldName),o=this.unusedGranularities;return e.filter(e=>zu(e)?!a.includes(e.name)||o[e.name].size>0:!a.includes(e.name)).sort((e,t)=>e.string.localeCompare(t.string))}get datetimeGranularities(){return zF.get(this.pivot.type).datetimeGranularities}get dateGranularities(){return zF.get(this.pivot.type).dateGranularities}get unusedGranularities(){return this.getUnusedGranularities(this.fields,this.draft??this.getters.getPivotCoreDefinition(this.pivotId))}reset(e){this.pivotId=e,this.updatesAreDeferred=!0,this.draft=null}deferUpdates(e){this.updatesAreDeferred=e,e===!1&&this.draft&&this.applyUpdate()}applyUpdate(){if(this.draft&&(this.model.dispatch(`UPDATE_PIVOT`,{pivotId:this.pivotId,pivot:this.draft}),this.draft=null,!this.alreadyNotified&&this.isUpdatedPivotVisibleInViewportOnlyAsStaticPivot())){let e=`=PIVOT(${this.getters.getPivotFormulaId(this.pivotId)})`;this.alreadyNotified=!0,this.notification.notifyUser({type:`info`,text:E(`Pivot updates only work with dynamic pivot tables. Use %s or re-insert the static pivot from the Data menu.`,e),sticky:!0})}}discardPendingUpdate(){this.draft=null}update(e){let t=this.getters.getPivotCoreDefinition(this.pivotId),n={...t,...this.draft,...e},r={...n,columns:n.columns.map(e=>({fieldName:e.fieldName,order:e.order,granularity:e.granularity})),rows:n.rows.map(e=>({fieldName:e.fieldName,order:e.order,granularity:e.granularity})),measures:n.measures.map(e=>({id:e.id,fieldName:e.fieldName,aggregator:e.aggregator,userDefinedName:e.userDefinedName,computedBy:e.computedBy,isHidden:e.isHidden,format:e.format,display:e.display}))};if(!this.draft&&C(t,r))return;let i=this.addDefaultDateTimeGranularity(this.fields,r);this.draft=i,this.updatesAreDeferred||this.applyUpdate()}isUpdatedPivotVisibleInViewportOnlyAsStaticPivot(){let e=0,t=this.getters.getPivotFormulaId(this.pivotId);for(let n of this.getters.getVisibleCellPositions()){let r=this.getters.getCell(n);if(r?.isFormula){let n=$E(r.compiledFormula.tokens),i=n?.args[0]?.value;if(n&&t===i.toString()){if(n.functionName===`PIVOT`)return!1;e++}}}return e>0}addDefaultDateTimeGranularity(e,t){let{columns:n,rows:r}=t,i=y(n),a=y(r),o=this.getUnusedGranularities(e,t);for(let t of i.concat(a)){let n=e[t.fieldName]?.type;if((n===`date`||n===`datetime`)&&!t.granularity){let e=o[t.fieldName]?.values().next().value;o[t.fieldName]?.delete(e),t.granularity=e}}return{...t,columns:i,rows:a}}getUnusedGranularities(e,t){let{columns:n,rows:r}=t,i=n.concat(r).filter(t=>{let n=e[t.fieldName]?.type;return n===`date`||n===`datetime`}),a={};for(let t of i)a[t.fieldName]=new Set(e[t.fieldName]?.type===`date`?this.dateGranularities:this.datetimeGranularities);for(let e of i)a[e.fieldName].delete(e.granularity);return a}},WF=class extends t.Component{static template=`o-spreadsheet-PivotSpreadsheetSidePanel`;static props={pivotId:String,onCloseSidePanel:Function};static components={PivotLayoutConfigurator:vF,Section:PN,SelectionInput:LN,Checkbox:NN,PivotDeferUpdate:cF,PivotTitleSection:yF};store;state;pivotSidePanelRef=(0,t.useRef)(`pivotSidePanel`);setup(){this.store=gd(UF,this.props.pivotId),this.state=(0,t.useState)({range:void 0,rangeHasChanged:!1})}get shouldDisplayInvalidRangeError(){return this.store.isDirty&&this.state.rangeHasChanged?!1:this.pivot.isInvalidRange}get ranges(){return this.state.rangeHasChanged?this.state.range?[this.state.range]:[]:this.definition.range?[this.env.model.getters.getRangeString(this.definition.range,`forceSheetReference`)]:[]}get pivot(){return this.store.pivot}get definition(){return this.store.definition}getScrollableContainerEl(){return this.pivotSidePanelRef.el}onSelectionChanged(e){this.state.rangeHasChanged=!0,this.state.range=e[0]}onSelectionConfirmed(){if(!this.state.range){let e=this.definition.range;this.state.range=e?this.env.model.getters.getRangeString(e,`forceSheetReference`):void 0;return}let e=this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(),this.state.range);if(e.invalidSheetName||e.invalidXc)return;this.state.range=this.env.model.getters.getRangeString(e,`forceSheetReference`,{useBoundedReference:!0});let t={sheetId:e.sheetId,zone:e.zone};this.store.update({dataSet:t}),this.store.applyUpdate()}flipAxis(){let{rows:e,columns:t}=this.definition;this.onDimensionsUpdated({rows:t,columns:e})}onDimensionsUpdated(e){this.store.update(e)}};let GF=new h;GF.add(`SPREADSHEET`,{editor:WF});var KF=class extends t.Component{static template=`o-spreadsheet-PivotSidePanel`;static props={pivotId:String,onCloseSidePanel:Function};static components={PivotLayoutConfigurator:vF,Section:PN};get sidePanelEditor(){let e=this.env.model.getters.getPivotCoreDefinition(this.props.pivotId);if(!e)throw Error(`pivotId does not correspond to a pivot.`);return GF.get(e.type).editor}};U`
1310
1310
  .o-checkbox-selection {
1311
1311
  max-height: 300px;
1312
1312
  }
@@ -3312,4 +3312,4 @@ stores.inject(MyMetaStore, storeInstance);
3312
3312
  <Relationships xmlns="${cf.Relationships}">
3313
3313
  <Relationship ${q(e)} />
3314
3314
  </Relationships>
3315
- `),`_rels/.rels`)}function VH(e){let t={},n=new Set;for(let r of e.sheets){let e=r.name.slice(0,31),i=1;for(;n.has(e);)e=e.slice(0,31-String(i).length)+i++;n.add(e),e!==r.name&&(t[r.name]=e,r.name=e)}if(!Object.keys(t).length)return e;let r=Object.keys(t).sort((e,t)=>t.length-e.length),i=JSON.stringify(e);for(let e of r){let n=RegExp(`'?${ot(e)}'?!`,`g`);i=i.replaceAll(n,n=>{let r=t[e];return n.replace(e,r)})}return JSON.parse(i)}function HH(e){for(let t of e.sheets)t.tables=t.tables.filter(e=>vr(rr(e.range)).numberOfRows>1);return e}var UH=class extends ud{corePlugins=[];featurePlugins=[];statefulUIPlugins=[];coreViewsPlugins=[];range;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},n={},r=[],i=new Ac,a=!1){let o=performance.now();console.debug(`##### Model creation #####`),super(),$n(),r=Qh(e,r);let s=Kh(e,a);this.state=new uV,this.uuidGenerator=i,this.config=this.setupConfig(n),this.session=this.setupSession(s.revisionId),this.coreGetters={},this.range=new QL(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.coreGetters.recomputeRanges=this.range.recomputeRanges.bind(this.range),this.coreGetters.isRangeValid=this.range.isRangeValid.bind(this.range),this.coreGetters.extendRange=this.range.extendRange.bind(this.range),this.coreGetters.getRangesUnion=this.range.getRangesUnion.bind(this.range),this.coreGetters.removeRangesSheetPrefix=this.range.removeRangesSheetPrefix.bind(this.range),this.getters={isReadonly:()=>this.config.mode===`readonly`||this.config.mode===`dashboard`,isDashboard:()=>this.config.mode===`dashboard`},this.selection=new cV(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of gB.getAll())this.setupCorePlugin(e,s);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(r);for(let e of yB.getAll()){let t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of vB.getAll()){let t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of _B.getAll()){let t=this.setupUiPlugin(e);this.featurePlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}if(this.uuidGenerator.setIsFastStrategy(!1),this.dispatch(`START`),this.selection.observe(this,{handleEvent:()=>this.trigger(`update`)}),this.setupSessionEvents(),this.joinSession(),n.snapshotRequested||e[`[Content_Types].xml`]&&!this.getters.isReadonly()){let e=performance.now();console.debug(`Snapshot requested`),this.session.snapshot(this.exportData()),this.garbageCollectExternalResources(),console.debug(`Snapshot taken in`,performance.now()-e,`ms`)}(0,t.markRaw)(this),console.debug(`Model created in`,performance.now()-o,`ms`),console.debug(`######`)}joinSession(){this.session.join(this.config.client)}async leaveSession(){let e=this.getters.isReadonly()?void 0:At(()=>this.exportData());await this.session.leave(e)}setupUiPlugin(e){let t=new e(this.uiPluginConfig);for(let n of e.getters){if(!(n in t))throw Error(`Invalid getter name: ${n} for plugin ${t.constructor}`);if(n in this.getters)throw Error(`Getter "${n}" is already defined.`);this.getters[n]=t[n].bind(t)}for(let n of e.layers)this.renderers[n]||(this.renderers[n]=[]),this.renderers[n].push(t);return t}setupCorePlugin(e,t){let n=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in n))throw Error(`Invalid getter name: ${t} for plugin ${n.constructor}`);if(t in this.coreGetters)throw Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=n[t].bind(n)}n.import(t),this.corePlugins.push(n),this.coreHandlers.push(n),this.handlers.push(n)}onRemoteRevisionReceived({commands:e}){for(let t of e){let e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new _z(iV({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{if(!this.checkDispatchAllowed(e).isSuccessful){this.dispatchToHandlers(this.coreHandlers,{type:`UNDO`,commands:[e]});return}this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1}}),this.config.transportService,e)}setupSessionEvents(){this.session.on(`remote-revision-received`,this,this.onRemoteRevisionReceived),this.session.on(`revision-undone`,this,({commands:e})=>{this.dispatchFromCorePlugin(`UNDO`,{commands:e}),this.finalize()}),this.session.on(`revision-redone`,this,({commands:e})=>{this.dispatchFromCorePlugin(`REDO`,{commands:e}),this.finalize()}),this.session.on(`unexpected-revision-id`,this,()=>this.trigger(`unexpected-revision-id`)),this.session.on(`collaborative-event-received`,this,()=>{this.trigger(`update`)})}setupConfig(e){let t=e.client||{id:this.uuidGenerator.smallUuid(),name:E(`Anonymous`).toString()},n=e.transportService||new XB;return{...e,mode:e.mode||`normal`,custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:n,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger(`notify-ui`,e),raiseBlockingErrorUI:e=>this.trigger(`raise-error-ui`,{text:e}),customColors:e.customColors||[]}}setupExternalConfig(e){let t=e.loadLocales||(()=>Promise.resolve(na));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,canDispatch:this.canDispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[]}}checkDispatchAllowed(e){let t=Zi(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some(e=>e!==`Success`)?new $i(t.flat()):$i.Success}checkDispatchAllowedCoreCommand(e){let t=this.corePlugins.map(t=>t.allowDispatch(e));return t.push(this.range.allowDispatch(e)),t}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map(t=>t.allowDispatch(e))}finalize(){this.status=3;for(let e of this.handlers)e.finalize();this.status=0,this.trigger(`command-finalized`)}canDispatch=(e,t)=>this.checkDispatchAllowed(WH(e,t));dispatch=(e,t)=>{let n=WH(e,t),r=this.status;if(this.getters.isReadonly()&&!Qi(n))return new $i(`Readonly`);if(!this.session.canApplyOptimisticUpdate())return new $i(`WaitingSessionConfirmation`);switch(r){case 0:let t=this.checkDispatchAllowed(n);if(!t.isSuccessful)return this.trigger(`update`),t;this.status=1;let{changes:r,commands:i}=this.state.recordChanges(()=>{let t=performance.now();Zi(n)&&this.state.addCommand(n),this.dispatchToHandlers(this.handlers,n),this.finalize();let r=performance.now()-t;r>5&&console.debug(e,r,`ms`)});this.session.save(n,i,r),this.status=0,this.trigger(`update`);break;case 1:if(Zi(n)){let e=this.checkDispatchAllowed(n);if(!e.isSuccessful)return e;this.state.addCommand(n)}this.dispatchToHandlers(this.handlers,n);break;case 3:throw Error(`Cannot dispatch commands in the finalize state`);case 2:if(Zi(n))throw Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,n)}return $i.Success};dispatchFromCorePlugin=(e,t)=>{let n=WH(e,t),r=this.status;this.status=2;let i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,n),this.status=r,$i.Success};dispatchToHandlers(e,t){let n=Zi(t);for(let r of e)!n&&r instanceof FL||r.beforeHandle(t);for(let r of e)!n&&r instanceof FL||r.handle(t);this.trigger(`command-dispatched`,t)}drawLayer(e,t){let n=this.renderers[t];if(n)for(let r of n)e.ctx.save(),r.drawLayer(e,t),e.ctx.restore()}exportData(){let e=ig();for(let t of this.handlers)t instanceof FL&&t.export(e);return e.revisionId=this.session.getRevisionId()||We,e=y(e),e}updateMode(e){this.config.mode=e,this.trigger(`update`)}exportXLSX(){this.dispatch(`EVALUATE_CELLS`);let e=og();for(let t of this.handlers)t instanceof PL&&t.exportForExcel(e);return e=y(e),MH(e)}garbageCollectExternalResources(){for(let e of this.corePlugins)e.garbageCollectExternalResources()}};function WH(e,t={}){let n=y(t);return n.type=e,n}let GH={},KH={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:26,HEADER_WIDTH:48,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:96,DEFAULT_CELL_HEIGHT:23,SCROLLBAR_WIDTH:15},qH={autoCompleteProviders:g_,autofillModifiersRegistry:sD,autofillRulesRegistry:cD,cellMenuRegistry:Dj,colMenuRegistry:yN,errorTypes:sa,linkMenuRegistry:uk,functionRegistry:KT,featurePluginRegistry:_B,iconsOnCellRegistry:xf,statefulUIPluginRegistry:vB,coreViewsPluginRegistry:yB,corePluginRegistry:gB,rowMenuRegistry:wN,sidePanelRegistry:xI,figureRegistry:xO,chartSidePanelComponentRegistry:fP,chartComponentRegistry:pO,chartRegistry:fO,chartSubtypeRegistry:hO,topbarMenuRegistry:AN,topbarComponentRegistry:MN,clickableCellRegistry:bB,otRegistry:jN,inverseCommandRegistry:DO,urlRegistry:no,cellPopoverRegistry:vD,numberFormatMenuRegistry:bN,repeatLocalCommandTransformRegistry:Qz,repeatCommandTransformRegistry:Zz,clipboardHandlersRegistries:sd,pivotRegistry:zF,pivotTimeAdapterRegistry:gu,pivotSidePanelRegistry:GF,pivotNormalizationValueRegistry:qu,supportedPivotPositionalFormulaRegistry:nD,pivotToFunctionValueRegistry:Ju,migrationStepRegistry:Uh},JH={arg:X,isEvaluationError:P,toBoolean:R,toJsDate:z,toNumber:F,toString:I,toNormalizedPivotValue:Uu,toXC:w,toZone:rr,toUnboundedZone:nr,toCartesian:zn,numberToLetters:kn,lettersToNumber:An,UuidGenerator:Ac,formatValue:V,createCurrencyFormat:is,ColorGenerator:On,computeTextWidth:pc,createEmptyWorkbookData:ig,createEmptySheet:rg,createEmptyExcelSheet:ag,getDefaultChartJsRuntime:i_,chartFontColor:Pd,getChartAxisTitleRuntime:zd,getChartAxisType:MD,getTrendDatasetForBarChart:Hd,getTrendDatasetForLineChart:zD,getFillingMode:l_,rgbaToHex:fn,colorToRGBA:pn,positionToZone:D,isDefined:S,isMatrix:A,lazy:At,genericRepeat:$z,createAction:m,createActions:f,transformRangeData:ld,deepEquals:C,overlap:hr,union:dr,isInside:gr,addStyleToWorkbookData:Hr,deepCopy:y,expandZoneOnInsertion:sr,reduceZoneOnDeletion:ur,unquote:lt,getMaxObjectId:Fu,getFunctionsFromTokens:GE,getFirstPivotFunction:$E,getNumberOfPivotFunctions:tD,parseDimension:Ru,isDateOrDatetimeField:zu,makeFieldProposal:JE,insertTokenAfterArgSeparator:XE,insertTokenAfterLeftParenthesis:ZE,mergeContiguousZones:Ir,getPivotHighlights:EN,pivotTimeAdapter:_u,UNDO_REDO_PIVOT_COMMANDS:RR,createPivotFormula:Hu,areDomainArgsFieldsValid:Vu,splitReference:qs,formatTickValue:Kd,sanitizeSheetName:dt,isNumber:Pi,isDateTime:ni},YH={isMarkdownLink:_t,parseMarkdownLink:bt,markdownLink:yt,openLink:so,urlRepresentation:oo},XH={Checkbox:NN,Section:PN,RoundColorPicker:ZN,ChartDataSeries:RN,ChartErrorSection:BN,ChartLabelRange:VN,ChartTitle:$N,ChartPanel:hP,ChartFigure:_O,ChartJsComponent:m_,Grid:jL,GridOverlay:cL,ScorecardChart:h_,LineConfigPanel:oP,BarConfigPanel:UN,PieChartDesignPanel:sP,GenericChartConfigPanel:HN,ChartWithAxisDesignPanel:nP,GaugeChartConfigPanel:iP,GaugeChartDesignPanel:aP,ScorecardChartConfigPanel:lP,ScorecardChartDesignPanel:uP,ChartTypePicker:pP,FigureComponent:SI,Menu:xk,Popover:_k,SelectionInput:LN,ValidationMessages:zN,AddDimensionButton:uF,PivotDimensionGranularity:mF,PivotDimensionOrder:hF,PivotDimension:pF,PivotLayoutConfigurator:vF,PivotHTMLRenderer:NL,EditableName:ML,PivotDeferUpdate:cF,PivotTitleSection:yF,CogWheelMenu:fF,TextInput:dF,SidePanelCollapsible:GN},ZH={useDragAndDropListItems:xP,useHighlights:kP,useHighlightsOnHover:OP},QH={useStoreProvider:hd,DependencyContainer:dd,CellPopoverStore:$O,ComposerFocusStore:wd,CellComposerStore:PI,FindAndReplaceStore:nF,HighlightStore:kN,HoveredCellStore:QO,ModelStore:bd,NotificationStore:gP,RendererStore:xd,SelectionInputStore:IN,SpreadsheetStore:Sd,useStore:H,useLocalStore:gd,SidePanelStore:DL,PivotSidePanelStore:UF,PivotMeasureDisplayPanelStore:oF};function $H(e,t){return KT.add(e,t),{addFunction:(e,t)=>$H(e,t)}}let eU={DEFAULT_LOCALE:k,HIGHLIGHT_COLOR:_,PIVOT_TABLE_CONFIG:tt,TREND_LINE_XAXIS_ID:`x1`,CHART_AXIS_CHOICES:Jd,ChartTerms:pg};e.AbstractCellClipboardHandler=Bc,e.AbstractChart=Rg,e.AbstractFigureClipboardHandler=Qu,e.CellErrorType=j,e.CommandResult=ta,e.CorePlugin=FL,e.DispatchResult=$i,e.EvaluationError=M,e.Model=UH,e.PivotRuntimeDefinition=bF,e.Registry=h,e.Revision=hz,e.SPREADSHEET_DIMENSIONS=KH,e.Spreadsheet=YB,e.SpreadsheetPivotTable=CF,e.UIPlugin=$,e.__info__=GH,e.addFunction=$H,e.addRenderingLayer=oa,e.astToFormula=OC,e.compile=IE,e.compileTokens=LE,e.components=XH,e.constants=eU,e.convertAstNodes=wC,e.coreTypes=Xi,e.findCellInNewZone=Dr,e.functionCache=FE,e.helpers=JH,e.hooks=ZH,e.invalidateCFEvaluationCommands=qi,e.invalidateDependenciesCommands=Ki,e.invalidateEvaluationCommands=Wi,e.iterateAstNodes=TC,e.links=YH,e.load=Kh,e.parse=SC,e.parseTokens=CC,e.readonlyAllowedCommands=Yi,e.registries=qH,e.setDefaultSheetViewSize=Qe,e.setTranslationMethod=Qn,e.stores=QH,e.tokenColors=TE,e.tokenize=Wc,GH.version=`18.0.83`,GH.date=`2026-10-10T06:31:52.656Z`,GH.hash=`22b9b73`})(this.o_spreadsheet=this.o_spreadsheet||{},owl);
3315
+ `),`_rels/.rels`)}function VH(e){let t={},n=new Set;for(let r of e.sheets){let e=r.name.slice(0,31),i=1;for(;n.has(e);)e=e.slice(0,31-String(i).length)+i++;n.add(e),e!==r.name&&(t[r.name]=e,r.name=e)}if(!Object.keys(t).length)return e;let r=Object.keys(t).sort((e,t)=>t.length-e.length),i=JSON.stringify(e);for(let e of r){let n=RegExp(`'?${ot(e)}'?!`,`g`);i=i.replaceAll(n,n=>{let r=t[e];return n.replace(e,r)})}return JSON.parse(i)}function HH(e){for(let t of e.sheets)t.tables=t.tables.filter(e=>vr(rr(e.range)).numberOfRows>1);return e}var UH=class extends ud{corePlugins=[];featurePlugins=[];statefulUIPlugins=[];coreViewsPlugins=[];range;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},n={},r=[],i=new Ac,a=!1){let o=performance.now();console.debug(`##### Model creation #####`),super(),$n(),r=Qh(e,r);let s=Kh(e,a);this.state=new uV,this.uuidGenerator=i,this.config=this.setupConfig(n),this.session=this.setupSession(s.revisionId),this.coreGetters={},this.range=new QL(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.coreGetters.recomputeRanges=this.range.recomputeRanges.bind(this.range),this.coreGetters.isRangeValid=this.range.isRangeValid.bind(this.range),this.coreGetters.extendRange=this.range.extendRange.bind(this.range),this.coreGetters.getRangesUnion=this.range.getRangesUnion.bind(this.range),this.coreGetters.removeRangesSheetPrefix=this.range.removeRangesSheetPrefix.bind(this.range),this.getters={isReadonly:()=>this.config.mode===`readonly`||this.config.mode===`dashboard`,isDashboard:()=>this.config.mode===`dashboard`},this.selection=new cV(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of gB.getAll())this.setupCorePlugin(e,s);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(r);for(let e of yB.getAll()){let t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of vB.getAll()){let t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of _B.getAll()){let t=this.setupUiPlugin(e);this.featurePlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}if(this.uuidGenerator.setIsFastStrategy(!1),this.dispatch(`START`),this.selection.observe(this,{handleEvent:()=>this.trigger(`update`)}),this.setupSessionEvents(),this.joinSession(),n.snapshotRequested||e[`[Content_Types].xml`]&&!this.getters.isReadonly()){let e=performance.now();console.debug(`Snapshot requested`),this.session.snapshot(this.exportData()),this.garbageCollectExternalResources(),console.debug(`Snapshot taken in`,performance.now()-e,`ms`)}(0,t.markRaw)(this),console.debug(`Model created in`,performance.now()-o,`ms`),console.debug(`######`)}joinSession(){this.session.join(this.config.client)}async leaveSession(){let e=this.getters.isReadonly()?void 0:At(()=>this.exportData());await this.session.leave(e)}setupUiPlugin(e){let t=new e(this.uiPluginConfig);for(let n of e.getters){if(!(n in t))throw Error(`Invalid getter name: ${n} for plugin ${t.constructor}`);if(n in this.getters)throw Error(`Getter "${n}" is already defined.`);this.getters[n]=t[n].bind(t)}for(let n of e.layers)this.renderers[n]||(this.renderers[n]=[]),this.renderers[n].push(t);return t}setupCorePlugin(e,t){let n=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in n))throw Error(`Invalid getter name: ${t} for plugin ${n.constructor}`);if(t in this.coreGetters)throw Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=n[t].bind(n)}n.import(t),this.corePlugins.push(n),this.coreHandlers.push(n),this.handlers.push(n)}onRemoteRevisionReceived({commands:e}){for(let t of e){let e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new _z(iV({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{if(!this.checkDispatchAllowed(e).isSuccessful){this.dispatchToHandlers(this.coreHandlers,{type:`UNDO`,commands:[e]});return}this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1}}),this.config.transportService,e)}setupSessionEvents(){this.session.on(`remote-revision-received`,this,this.onRemoteRevisionReceived),this.session.on(`revision-undone`,this,({commands:e})=>{this.dispatchFromCorePlugin(`UNDO`,{commands:e}),this.finalize()}),this.session.on(`revision-redone`,this,({commands:e})=>{this.dispatchFromCorePlugin(`REDO`,{commands:e}),this.finalize()}),this.session.on(`unexpected-revision-id`,this,()=>this.trigger(`unexpected-revision-id`)),this.session.on(`collaborative-event-received`,this,()=>{this.trigger(`update`)})}setupConfig(e){let t=e.client||{id:this.uuidGenerator.smallUuid(),name:E(`Anonymous`).toString()},n=e.transportService||new XB;return{...e,mode:e.mode||`normal`,custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:n,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger(`notify-ui`,e),raiseBlockingErrorUI:e=>this.trigger(`raise-error-ui`,{text:e}),customColors:e.customColors||[]}}setupExternalConfig(e){let t=e.loadLocales||(()=>Promise.resolve(na));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,canDispatch:this.canDispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[]}}checkDispatchAllowed(e){let t=Zi(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some(e=>e!==`Success`)?new $i(t.flat()):$i.Success}checkDispatchAllowedCoreCommand(e){let t=this.corePlugins.map(t=>t.allowDispatch(e));return t.push(this.range.allowDispatch(e)),t}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map(t=>t.allowDispatch(e))}finalize(){this.status=3;for(let e of this.handlers)e.finalize();this.status=0,this.trigger(`command-finalized`)}canDispatch=(e,t)=>this.checkDispatchAllowed(WH(e,t));dispatch=(e,t)=>{let n=WH(e,t),r=this.status;if(this.getters.isReadonly()&&!Qi(n))return new $i(`Readonly`);if(!this.session.canApplyOptimisticUpdate())return new $i(`WaitingSessionConfirmation`);switch(r){case 0:let t=this.checkDispatchAllowed(n);if(!t.isSuccessful)return this.trigger(`update`),t;this.status=1;let{changes:r,commands:i}=this.state.recordChanges(()=>{let t=performance.now();Zi(n)&&this.state.addCommand(n),this.dispatchToHandlers(this.handlers,n),this.finalize();let r=performance.now()-t;r>5&&console.debug(e,r,`ms`)});this.session.save(n,i,r),this.status=0,this.trigger(`update`);break;case 1:if(Zi(n)){let e=this.checkDispatchAllowed(n);if(!e.isSuccessful)return e;this.state.addCommand(n)}this.dispatchToHandlers(this.handlers,n);break;case 3:throw Error(`Cannot dispatch commands in the finalize state`);case 2:if(Zi(n))throw Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,n)}return $i.Success};dispatchFromCorePlugin=(e,t)=>{let n=WH(e,t),r=this.status;this.status=2;let i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,n),this.status=r,$i.Success};dispatchToHandlers(e,t){let n=Zi(t);for(let r of e)!n&&r instanceof FL||r.beforeHandle(t);for(let r of e)!n&&r instanceof FL||r.handle(t);this.trigger(`command-dispatched`,t)}drawLayer(e,t){let n=this.renderers[t];if(n)for(let r of n)e.ctx.save(),r.drawLayer(e,t),e.ctx.restore()}exportData(){let e=ig();for(let t of this.handlers)t instanceof FL&&t.export(e);return e.revisionId=this.session.getRevisionId()||We,e=y(e),e}updateMode(e){this.config.mode=e,this.trigger(`update`)}exportXLSX(){this.dispatch(`EVALUATE_CELLS`);let e=og();for(let t of this.handlers)t instanceof PL&&t.exportForExcel(e);return e=y(e),MH(e)}garbageCollectExternalResources(){for(let e of this.corePlugins)e.garbageCollectExternalResources()}};function WH(e,t={}){let n=y(t);return n.type=e,n}let GH={},KH={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:26,HEADER_WIDTH:48,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:96,DEFAULT_CELL_HEIGHT:23,SCROLLBAR_WIDTH:15},qH={autoCompleteProviders:g_,autofillModifiersRegistry:sD,autofillRulesRegistry:cD,cellMenuRegistry:Dj,colMenuRegistry:yN,errorTypes:sa,linkMenuRegistry:uk,functionRegistry:KT,featurePluginRegistry:_B,iconsOnCellRegistry:xf,statefulUIPluginRegistry:vB,coreViewsPluginRegistry:yB,corePluginRegistry:gB,rowMenuRegistry:wN,sidePanelRegistry:xI,figureRegistry:xO,chartSidePanelComponentRegistry:fP,chartComponentRegistry:pO,chartRegistry:fO,chartSubtypeRegistry:hO,topbarMenuRegistry:AN,topbarComponentRegistry:MN,clickableCellRegistry:bB,otRegistry:jN,inverseCommandRegistry:DO,urlRegistry:no,cellPopoverRegistry:vD,numberFormatMenuRegistry:bN,repeatLocalCommandTransformRegistry:Qz,repeatCommandTransformRegistry:Zz,clipboardHandlersRegistries:sd,pivotRegistry:zF,pivotTimeAdapterRegistry:gu,pivotSidePanelRegistry:GF,pivotNormalizationValueRegistry:qu,supportedPivotPositionalFormulaRegistry:nD,pivotToFunctionValueRegistry:Ju,migrationStepRegistry:Uh},JH={arg:X,isEvaluationError:P,toBoolean:R,toJsDate:z,toNumber:F,toString:I,toNormalizedPivotValue:Uu,toXC:w,toZone:rr,toUnboundedZone:nr,toCartesian:zn,numberToLetters:kn,lettersToNumber:An,UuidGenerator:Ac,formatValue:V,createCurrencyFormat:is,ColorGenerator:On,computeTextWidth:pc,createEmptyWorkbookData:ig,createEmptySheet:rg,createEmptyExcelSheet:ag,getDefaultChartJsRuntime:i_,chartFontColor:Pd,getChartAxisTitleRuntime:zd,getChartAxisType:MD,getTrendDatasetForBarChart:Hd,getTrendDatasetForLineChart:zD,getFillingMode:l_,rgbaToHex:fn,colorToRGBA:pn,positionToZone:D,isDefined:S,isMatrix:A,lazy:At,genericRepeat:$z,createAction:m,createActions:f,transformRangeData:ld,deepEquals:C,overlap:hr,union:dr,isInside:gr,addStyleToWorkbookData:Hr,deepCopy:y,expandZoneOnInsertion:sr,reduceZoneOnDeletion:ur,unquote:lt,getMaxObjectId:Fu,getFunctionsFromTokens:GE,getFirstPivotFunction:$E,getNumberOfPivotFunctions:tD,parseDimension:Ru,isDateOrDatetimeField:zu,makeFieldProposal:JE,insertTokenAfterArgSeparator:XE,insertTokenAfterLeftParenthesis:ZE,mergeContiguousZones:Ir,getPivotHighlights:EN,pivotTimeAdapter:_u,UNDO_REDO_PIVOT_COMMANDS:RR,createPivotFormula:Hu,areDomainArgsFieldsValid:Vu,splitReference:qs,formatTickValue:Kd,sanitizeSheetName:dt,isNumber:Pi,isDateTime:ni},YH={isMarkdownLink:_t,parseMarkdownLink:bt,markdownLink:yt,openLink:so,urlRepresentation:oo},XH={Checkbox:NN,Section:PN,RoundColorPicker:ZN,ChartDataSeries:RN,ChartErrorSection:BN,ChartLabelRange:VN,ChartTitle:$N,ChartPanel:hP,ChartFigure:_O,ChartJsComponent:m_,Grid:jL,GridOverlay:cL,ScorecardChart:h_,LineConfigPanel:oP,BarConfigPanel:UN,PieChartDesignPanel:sP,GenericChartConfigPanel:HN,ChartWithAxisDesignPanel:nP,GaugeChartConfigPanel:iP,GaugeChartDesignPanel:aP,ScorecardChartConfigPanel:lP,ScorecardChartDesignPanel:uP,ChartTypePicker:pP,FigureComponent:SI,Menu:xk,Popover:_k,SelectionInput:LN,ValidationMessages:zN,AddDimensionButton:uF,PivotDimensionGranularity:mF,PivotDimensionOrder:hF,PivotDimension:pF,PivotLayoutConfigurator:vF,PivotHTMLRenderer:NL,EditableName:ML,PivotDeferUpdate:cF,PivotTitleSection:yF,CogWheelMenu:fF,TextInput:dF,SidePanelCollapsible:GN},ZH={useDragAndDropListItems:xP,useHighlights:kP,useHighlightsOnHover:OP},QH={useStoreProvider:hd,DependencyContainer:dd,CellPopoverStore:$O,ComposerFocusStore:wd,CellComposerStore:PI,FindAndReplaceStore:nF,HighlightStore:kN,HoveredCellStore:QO,ModelStore:bd,NotificationStore:gP,RendererStore:xd,SelectionInputStore:IN,SpreadsheetStore:Sd,useStore:H,useLocalStore:gd,SidePanelStore:DL,PivotSidePanelStore:UF,PivotMeasureDisplayPanelStore:oF};function $H(e,t){return KT.add(e,t),{addFunction:(e,t)=>$H(e,t)}}let eU={DEFAULT_LOCALE:k,HIGHLIGHT_COLOR:_,PIVOT_TABLE_CONFIG:tt,TREND_LINE_XAXIS_ID:`x1`,CHART_AXIS_CHOICES:Jd,ChartTerms:pg};e.AbstractCellClipboardHandler=Bc,e.AbstractChart=Rg,e.AbstractFigureClipboardHandler=Qu,e.CellErrorType=j,e.CommandResult=ta,e.CorePlugin=FL,e.DispatchResult=$i,e.EvaluationError=M,e.Model=UH,e.PivotRuntimeDefinition=bF,e.Registry=h,e.Revision=hz,e.SPREADSHEET_DIMENSIONS=KH,e.Spreadsheet=YB,e.SpreadsheetPivotTable=CF,e.UIPlugin=$,e.__info__=GH,e.addFunction=$H,e.addRenderingLayer=oa,e.astToFormula=OC,e.compile=IE,e.compileTokens=LE,e.components=XH,e.constants=eU,e.convertAstNodes=wC,e.coreTypes=Xi,e.findCellInNewZone=Dr,e.functionCache=FE,e.helpers=JH,e.hooks=ZH,e.invalidateCFEvaluationCommands=qi,e.invalidateDependenciesCommands=Ki,e.invalidateEvaluationCommands=Wi,e.iterateAstNodes=TC,e.links=YH,e.load=Kh,e.parse=SC,e.parseTokens=CC,e.readonlyAllowedCommands=Yi,e.registries=qH,e.setDefaultSheetViewSize=Qe,e.setTranslationMethod=Qn,e.stores=QH,e.tokenColors=TE,e.tokenize=Wc,GH.version=`18.0.84`,GH.date=`2026-10-14T06:49:38.664Z`,GH.hash=`56a1fca`})(this.o_spreadsheet=this.o_spreadsheet||{},owl);
@@ -1,9 +1,9 @@
1
1
  <!--
2
2
  This file is generated by o-spreadsheet build tools. Do not edit it.
3
3
  @see https://github.com/odoo/o-spreadsheet
4
- @version 18.0.83
5
- @date 2026-10-10T06:31:53.309Z
6
- @hash 22b9b73
4
+ @version 18.0.84
5
+ @date 2026-10-14T06:49:39.302Z
6
+ @hash 56a1fca
7
7
  -->
8
8
  <odoo>
9
9
  <t t-name="o-spreadsheet-ActionButton">
@@ -5362,7 +5362,6 @@
5362
5362
  <t t-set-slot="title">Range</t>
5363
5363
  <SelectionInput
5364
5364
  ranges="ranges"
5365
- required="true"
5366
5365
  isInvalid="shouldDisplayInvalidRangeError"
5367
5366
  hasSingleRange="true"
5368
5367
  onSelectionChanged="(ranges) => this.onSelectionChanged(ranges)"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odoo/o-spreadsheet",
3
- "version": "18.0.83",
3
+ "version": "18.0.84",
4
4
  "description": "A spreadsheet component",
5
5
  "type": "module",
6
6
  "main": "dist/o-spreadsheet.cjs.js",