@odoo/o-spreadsheet 19.2.23 → 19.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,7 +6,7 @@ Did you forget to inject your store instance?
|
|
|
6
6
|
|
|
7
7
|
const stores = useStoreProvider();
|
|
8
8
|
stores.inject(MyMetaStore, storeInstance);
|
|
9
|
-
`)}}return t}var cr=class{get;disposeCallbacks=[];constructor(e){this.get=e}onDispose(e){this.disposeCallbacks.push(e)}dispose(){this.disposeCallbacks.forEach(e=>e())}};function lr(){let e=(0,t.useEnv)();if(e.__spreadsheet_stores__ instanceof ar)return e.__spreadsheet_stores__;let n=new ar;return(0,t.useSubEnv)({__spreadsheet_stores__:n,getStore:e=>fr(n.get(e),()=>n.trigger(`store-updated`))}),(0,t.onWillUnmount)(()=>n.dispose()),n}function D(e){let n=pr((0,t.useEnv)());return dr(n,n.get(e))}function ur(e,...n){let r=pr((0,t.useEnv)()),i=r.instantiate(e,...n);return(0,t.onWillUnmount)(()=>i.dispose()),dr(r,i)}function dr(e,n){let r=(0,t.useComponent)();return fr(n,()=>{(0,t.status)(r)===`mounted`&&e.trigger(`store-updated`)})}function fr(e,t){return new Proxy(e,{get(n,r,i){let a=n,o=Reflect.get(n,r,a);return e.mutators?.includes(r)?new Proxy(o,{apply(e,n,r){Reflect.apply(e,a,r)!==`noStateChange`&&t()}}):o}})}function pr(e){let t=e.__spreadsheet_stores__;if(!(t instanceof ar))throw Error(`No store provider found. Did you forget to call useStoreProvider()?`);return t}let mr=sr(`Model`),hr={Background:0,Highlights:1,Clipboard:2,Chart:4,Autofill:5,Selection:6,Headers:100},gr=At(()=>Object.keys(hr).sort((e,t)=>hr[e]-hr[t]));function _r(e,t){if(hr[e])throw Error(`Layer ${e} already exists`);hr[e]=t}var vr=class{mutators=[`register`,`unRegister`,`draw`,`startAnimation`,`stopAnimation`];renderers={};model;context=void 0;animationFrameId=null;registeredAnimations=new Set;constructor(e){this.model=e(mr)}register(e){if(e.renderingLayers.length)for(let t of e.renderingLayers)this.renderers[t]||(this.renderers[t]=[]),this.renderers[t].push(e)}unRegister(e){for(let t of Object.keys(this.renderers))this.renderers[t]=this.renderers[t].filter(t=>t!==e)}drawLayer(e,t,n){let r=this.renderers[t];if(r)for(let i of r)e.ctx.save(),i.drawLayer(e,t,n),e.ctx.restore();return`noStateChange`}draw(e,t){if(e||=this.context,!e)throw Error(`Rendering context is not defined`);this.context=e;for(let n of gr())this.model.drawLayer(e,n),this.drawLayer(e,n,t);return`noStateChange`}startAnimation(e){if(this.registeredAnimations.add(e),!this.animationFrameId){let e=t=>{this.animationFrameId=requestAnimationFrame(e),this.draw(void 0,t)};this.animationFrameId=requestAnimationFrame(e)}return`noStateChange`}stopAnimation(e){return this.registeredAnimations.delete(e),this.registeredAnimations.size===0&&this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),`noStateChange`}dispose(){this.animationFrameId&&=(cancelAnimationFrame(this.animationFrameId),null)}},yr=class extends cr{model=this.get(mr);getters=this.model.getters;renderer=this.get(vr);constructor(e){super(e),this.model.on(`command-dispatched`,this,this.handle),this.model.on(`command-finalized`,this,this.finalize),this.renderer.register(this),this.onDispose(()=>{this.model.off(`command-dispatched`,this),this.model.off(`command-finalized`,this),this.renderer.unRegister(this)})}get renderingLayers(){return[]}handle(e){}finalize(){}drawLayer(e,t,n){}};let br={id:`void-composer`,get editionMode(){return`inactive`},startEdition:()=>{throw Error(`No composer is registered`)},stopEdition:()=>{throw Error(`No composer is registered`)},setCurrentContent:()=>{throw Error(`No composer is registered`)}};var xr=class extends yr{mutators=[`focusComposer`,`focusActiveComposer`];activeComposer=br;_focusMode=`inactive`;get focusMode(){return this.activeComposer.editionMode===`inactive`?`inactive`:this._focusMode}focusComposer(e,t){if(this.activeComposer=e,this.getters.isReadonly())return`noStateChange`;this._focusMode=t.focusMode||`contentFocus`,this._focusMode!==`inactive`&&this.setComposerContent(t)}focusActiveComposer(e){if(this.getters.isReadonly())return`noStateChange`;if(!this.activeComposer)throw Error(`No composer is registered`);this._focusMode=e.focusMode||`contentFocus`,this._focusMode!==`inactive`&&this.setComposerContent(e)}setComposerContent({content:e,selection:t}){this.activeComposer.editionMode===`inactive`?this.activeComposer.startEdition(e,t):e&&this.activeComposer.setCurrentContent(e,t)}};let Sr=/rgba?\(|\s+|\)/gi,Cr=/^#([A-F\d]{2}){3,4}$/,wr=/^light-dark\(\s*(rgba?\([0-9.,\s]+\)|#[a-f0-9]+)\s*,\s*(rgba?\([0-9.,\s]+\)|#[a-f0-9]+)\s*\)$/i,Tr=[`#eb6d00`,`#0074d9`,`#ad8e00`,`#169ed4`,`#b10dc9`,`#00a82d`,`#00a3a3`,`#f012be`,`#3d9970`,`#62A300`,`#ff4136`,`#949494`,`#ff5c9d`];function Er(e,t=1){let n=t===1?``:Math.round(t*255).toString(16).padStart(2,`0`);return Or(e.toString(16).padStart(6,`0`))+n}function Dr(e){return typeof e==`number`?e:Number.parseInt(Or(e).slice(1,7),16)}function Or(e){let t=e;if(e.startsWith(`light-dark`)){let t=e.match(wr);if(!t)throw Error(`Invalid light-dark color: ${e}`);return`light-dark(${Or(t[1])}, ${Or(t[2])})`}if(e.startsWith(`rgb`)?t=Pr(e):(t=e.replace(`#`,``).toUpperCase(),(t.length===3||t.length===4)&&(t=t.split(``).reduce((e,t)=>e+t+t,``)),t=`#${t}`),!Cr.test(t))throw Error(`invalid color input: ${e}`);return t}function kr(e){try{return Or(e),!0}catch{return!1}}function Ar(e){try{return zr(e),!0}catch{return!1}}let jr=e=>e>=0&&e<=255;function Mr(e,t,n,r=1){if(!jr(e)||!jr(t)||!jr(n)||r<0||r>1)throw Error(`Invalid RGBA values ${[e,t,n,r]}`);return{a:r,b:n,g:t,r:e}}function Nr(e){let{r:t,g:n,b:r}=Ir(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 Pr(e){let t=e.replace(Sr,``).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),`#`+gt(r.map(e=>e.toString(16).padStart(2,`0`))).toUpperCase()}function Fr(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 Ir(e){e=Or(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 Lr(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 Rr(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 zr(e){return Fr(Lr(e))}function Br(e){return Rr(Ir(e))}function Vr(e,t){let n=Ir(t),r=Ir(e),i=n.a+r.a*(1-n.a);return Fr({r:Math.round((n.r*n.a+r.r*r.a*(1-n.a))/i),g:Math.round((n.g*n.a+r.g*r.a*(1-n.a))/i),b:Math.round((n.b*n.a+r.b*r.a*(1-n.a))/i),a:i})}function Hr(e){return Ir(typeof e==`number`?Er(e):e)}function Ur(e,t,n=0){if(!(kr(e)&&kr(t)))return!1;let r=Ir(e),i=Ir(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 Wr(e,t){if(e.startsWith(`light-dark`)){let n=e.match(wr);if(!n)throw Error(`Invalid light-dark color: ${e}`);return`light-dark(${Wr(n[1],t)}, ${Wr(n[2],t)})`}return t===1?Or(e).slice(0,7):Fr({...Ir(e),a:t})}function Gr(e,t){let n=Br(e);return t===1?`#fff`:(n.l=t*(100-n.l)+n.l,zr(n))}function Kr(e,t){let n=Br(e);return t===1?`#000`:(n.s=Math.min(100,t*n.s+n.s),n.l-=t*n.l,zr(n))}function qr(e){return Nr(e)<.6?Gr(e,.9):Kr(e,.75)}let Jr=[`#4EA7F2`,`#EA6175`,`#43C5B1`,`#F4A261`,`#8481DD`,`#FFD86D`],Yr=[`#4EA7F2`,`#3188E6`,`#43C5B1`,`#00A78D`,`#EA6175`,`#CE4257`,`#F4A261`,`#F48935`,`#8481DD`,`#5752D1`,`#FFD86D`,`#FFBC2C`],Xr=[`#4EA7F2`,`#3188E6`,`#056BD9`,`#A76DBC`,`#7F4295`,`#6D2387`,`#EA6175`,`#CE4257`,`#982738`,`#43C5B1`,`#00A78D`,`#0E8270`,`#F4A261`,`#F48935`,`#BE5D10`,`#8481DD`,`#5752D1`,`#3A3580`,`#A4A8B6`,`#7E8290`,`#545B70`,`#FFD86D`,`#FFBC2C`,`#C08A16`],Zr=`#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(`.`),Qr=[`#4EA7F2`,`#43C5B1`,`#EA6175`,`#F4A261`,`#8481DD`,`#FFD86D`,`#3188E6`,`#00A78D`,`#CE4257`,`#F48935`,`#5752D1`,`#FFBC2C`],$r=[`#4EA7F2`,`#A76DBC`,`#EA6175`,`#43C5B1`,`#F4A261`,`#8481DD`,`#A4A8B6`,`#FFD86D`,`#3188E6`,`#7F4295`,`#CE4257`,`#00A78D`,`#F48935`,`#5752D1`,`#7E8290`,`#FFBC2C`,`#056BD9`,`#6D2387`,`#982738`,`#0E8270`,`#BE5D10`,`#3A3580`,`#545B70`,`#C08A16`],ei=`#4EA7F2.#A76DBC.#EA6175.#43C5B1.#F4A261.#8481DD.#A4A8B6.#FFD86D.#3188E6.#7F4295.#CE4257.#00A78D.#F48935.#5752D1.#7E8290.#FFBC2C.#056BD9.#6D2387.#982738.#0E8270.#BE5D10.#3A3580.#545B70.#C08A16.#155193.#4F1565.#791B29.#105F53.#7D380D.#26235F.#3F4250.#936A12`.split(`.`);function ti(e,t){return t[e%t.length]}function ni(e){return e<=6?Jr:e<=12?Yr:e<=24?Xr:Zr}function ri(e){return e<=6?Jr:e<=12?Qr:e<=24?$r:ei}var ii=class{preferredColors;currentColorIndex=0;palette;constructor(e,t=[]){this.preferredColors=t,this.palette=ni(e).filter(e=>!t.includes(e))}next(){return this.preferredColors?.[this.currentColorIndex]?this.preferredColors[this.currentColorIndex++]:ti(this.currentColorIndex++,this.palette)}},ai=class extends ii{constructor(e,t=[]){super(e,t),this.palette=ri(e).filter(e=>!t.includes(e))}},oi=class{availableColors;colors={};constructor(e=12){this.availableColors=new ai(e)}get(e){return this.colors[e]||(this.colors[e]=this.availableColors.next()),this.colors[e]}};let si={greys:[`#ffffff`,`#808080`,`#000000`],blues:[`#f7fbff`,`#6aaed6`,`#08306b`],reds:[`#fff5f0`,`#fb694a`,`#67000d`],greens:[`#f7fcf5`,`#73c476`,`#00441b`],oranges:[`#fff5eb`,`#fd8c3b`,`#7f2704`],purples:[`#fcfbfd`,`#9e9ac8`,`#3f007d`],viridis:[`#440154`,`#21918c`,`#fde725`],cividis:[`#00224e`,`#7d7c78`,`#fee838`],rainbow:[`#B41DB4`,`#FFFF00`,`#00FFFF`]},ci=Object.keys(si);function li(e){if(e.length<2)throw Error(`Color scale must have at least 2 points`);let t=[...e.sort((e,t)=>e.value-t.value)],n=[];for(let e=1;e<t.length;e++){let r=Hr(t[e-1].color).a,i=Hr(t[e].color).a,a=Dr(t[e-1].color),o=Dr(t[e].color);n.push({min:t[e-1].value,max:t[e].value,minColor:a,maxColor:o,minColorAlpha:r,maxColorAlpha:i,colorDiff:ui(t[e-1].value,t[e].value,a,o)})}return e=>{if(e<n[0].min)return Er(n[0].minColor,n[0].minColorAlpha);for(let t of n)if(e>=t.min&&e<=t.max)return Er(di(e,t.min,t.minColor,t.colorDiff),t.maxColorAlpha);return Er(n[n.length-1].maxColor,n[n.length-1].maxColorAlpha)}}function ui(e,t,n,r){let i=t-e,a=(n>>16)%256-(r>>16)%256,o=(n>>8)%256-(r>>8)%256,s=n%256-r%256;return[a/i,o/i,s/i]}function di(e,t,n,r){let[i,a,o]=r,s=Math.round((n>>16)%256-i*(e-t)),c=Math.round((n>>8)%256-a*(e-t)),l=Math.round(n%256-o*(e-t));return s<<16|c<<8|l}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 fi=new O(1899,11,30),pi=1440*60*1e3,mi=2e3,hi=O.now().getFullYear(),gi=O.now().getMonth(),_i=O.fromTimestamp(0).getTime()-fi.getTime(),vi=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,yi=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,bi=Dt.join(``),xi=RegExp(`\/|-|${Dt.join(`|`)}`),Si=RegExp(`^(\\d{1,4})[\/${bi}\-](\\d{1,4})([\/${bi}\-](\\d{1,4}))?$`),Ci=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function wi(e,t){switch(typeof e){case`number`:return e;case`string`:return Ti(e,t)?Di(e,t)?.value:!e||isNaN(Number(e))?void 0:Number(e);default:return}}function Ti(e,t){return Di(e,t)!==null}let Ei=new Map;function Di(e,t){return Ei.has(t)||Ei.set(t,new Map),Ei.get(t).has(e)||Ei.get(t).set(e,Oi(e,t)),Ei.get(t).get(e)}function Oi(e,t){e=e.trim();let n=null,r=e.match(Ci);if(r){if(n=Ii(r[0]),n===null)return null;e=e.replace(r[0],``).trim()}let i=null,a=ki(e,t);if(a){let t=a.dateString.match(xi)[0];if(i=ji(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 ki(e,t){let n=e.match(Si);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=Ai(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 Ai(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 ji(e,t){let{year:n,month:r,day:i}=e,a=Pi(r),o=Fi(i),s=Ni(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()-fi.getTime(),f=Mi(e,t,c,l);return{value:Math.round(d/pi),format:f,jsDate:u}}function Mi(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(C).join(t);case`ymd`:return[i,a,o].filter(C).join(t);case`dmy`:return[o,a,i].filter(C).join(t)}}function Ni(e){if(!e)return hi;let t=Number(e);switch(e.length){case 1:return mi+t;case 2:return mi+(mi+t>hi+10?-100:0)+t;case 3:case 4:return t}return null}function Pi(e){if(!e)return gi;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 Ii(e){if(e=e.trim(),Ci.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 Li(e){let t=Math.trunc(e),n=O.fromTimestamp(t*pi-_i),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 Ri(e){return Math.round(zi(e))}function zi(e){return(e.getTime()-fi.getTime())/pi}function Bi(e){return new O(e.getFullYear(),e.getMonth()+1,0).getDate()}function Vi(e){return Bi(e)===e.getDate()}function Hi(e,t,n){let r=e.getFullYear(),i=e.getMonth(),a=e.getDate(),o=new O(r,i+t,1);return n&&a===Bi(e)||a>Bi(o)?o.setDate(Bi(o)):o.setDate(a),o}function Ui(e){let t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function Wi(e,t,n){if(e===t)return 0;if(e>t){let n=t;t=e,e=n}let r=Li(e),i=Li(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===(Ui(l)?29:28)&&(a=30,c===1&&o===(Ui(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+=Ui(n)?366:365;n=t/e}else r?Ui(l)&&(n=366):(Ui(l)&&s<2&&(n=366),Ui(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 Gi(e,t){let n=(t.getFullYear()-e.getFullYear())*12+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?n-1:n}function Ki(e,t){let n=e.getTime(),r=t.getTime();return Math.floor((r-n)/pi)}function qi(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 Ji(e,t){return Wi(e,t,1)<1}function Yi(e,t){return Math.trunc(e)===Math.trunc(t)}function Xi(e,t,n){return t>n?Xi(e,n,t):(e=Math.trunc(e),t=Math.trunc(t),n=Math.trunc(n),e>=t&&e<=n)}function Zi(e,t){return Math.trunc(e)<Math.trunc(t)}function Qi(e,t){return Math.trunc(e)<=Math.trunc(t)}function $i(e,t){return Math.trunc(e)>Math.trunc(t)}function ea(e,t){return Math.trunc(e)>=Math.trunc(t)}let ta=At(function(e){return e=qe(e),RegExp(`(?:^-?\\d+(?:${e}?\\d*(?:(E|e)(\\+|-)?\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)}),na=At(function(e){let t=qe(e.decimalSeparator),n=`(?:\\d+(?:${qe(e.thousandsSeparator||``)}\\d{3,})*(?:${t}\\d*)?)`,r=`(?:${t}\\d+)`,i=`(?:\\s*`+n+`|`+r+`)(?:(e|E)(?:\\+|-)?(?:[0-9]|[0-9][0-9]|[12][0-9]{2}|30[0-7]))?(?:\\s*%)?`,a=`^(?:(?:`+[`(?:\\s*-)?(?:\\s*[\\$€])?`+i,`(?:\\s*-)?`+i+`(?:\\s*[\\$€])?`,`(?:\\s*[\\$€])?(?:\\s*-)?`+i].join(`)|(?:`)+`))$`;return new RegExp(a,`i`)});function ra(e,t){return e?na(t).test(e.trim()):!1}let ia=At(function(e){return RegExp(`[\$€${qe(e.thousandsSeparator||``)}]`,`g`)});function aa(e,t){e=e.replace(ia(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 oa(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)}let sa=e=>e,ca=()=>!1,la=sa,ua=ca;function da(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 fa(e,t=()=>!0){la=e,ua=t}function pa(){la===sa&&ua===ca&&(ua=()=>!0)}let k=function(e,...t){return ua()?da(la(e),...t):new ma(e,t)};var ma=class extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){let e=super.valueOf();return ua()?da(la(e),...this.values):da(e,...this.values)}toString(){return this.valueOf()}};let A={NotAvailable:`#N/A`,InvalidReference:`#REF`,BadExpression:`#BAD_EXPR`,CircularDependency:`#CYCLE`,UnknownFunction:`#NAME?`,DivisionByZero:`#DIV/0!`,InvalidNumber:`#NUM!`,SpilledBlocked:`#SPILL!`,GenericError:`#ERROR`,NullError:`#NULL!`},ha=new Set(Object.values(A));var j=class{message;value;constructor(e=k(`Error`),t=A.GenericError){this.message=e,this.value=t,this.message=e.toString()}},ga=class extends j{constructor(e=k(`Invalid expression`)){super(e,A.BadExpression)}},_a=class extends j{constructor(e=k(`Circular reference`)){super(e,A.CircularDependency)}},va=class extends j{constructor(e=k(`Invalid reference`)){super(e,A.InvalidReference)}},ya=class extends j{constructor(e=k(`Data not available`)){super(e,A.NotAvailable)}},ba=class extends j{constructor(e=k(`Unknown function`)){super(e,A.UnknownFunction)}},xa=class extends j{errorOriginPosition;constructor(e=k(`Spill range is not empty`),t){super(e,A.SpilledBlocked),this.errorOriginPosition=t}},Sa=class extends j{constructor(e=k(`Division by zero`)){super(e,A.DivisionByZero)}},Ca=class extends j{constructor(e=k(`Number too large`)){super(e,A.InvalidNumber)}};let wa=[`thin`,`medium`,`thick`,`dashed`,`dotted`];function Ta(e){return Array.isArray(e)&&Array.isArray(e[0])}let Ea=[`number`,`string`,`boolean`,`undefined`];function Da(e){if(e!==void 0)return Ta(e)?e[0][0]?.format:e.format}function M(e){return typeof e==`string`&&ha.has(e)}function Oa(e){return{value:A.NotAvailable,message:k(`Did not find value '%s' in [[FUNCTION_NAME]] evaluation.`,P(e))}}let ka=e=>k(`The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.`,e),Aa=(e,t,n)=>k(`The function [[FUNCTION_NAME]] expects a number value between %s and %s inclusive, but receives %s.`,e.toString(),t.toString(),n.toString()),ja=(e,t)=>k(`The function [[FUNCTION_NAME]] has an argument with value '%s'. It should be one of: %s.`,t,e.map(e=>`'${e}'`).join(`, `));function N(e,t){let n=Ba(e);switch(typeof n){case`number`:return n;case`boolean`:return+!!n;case`string`:if(ra(n,t)||n===``)return aa(n,t);let e=Di(n,t);if(e)return e.value;throw new j(ka(n));default:return 0}}function Ma(e,t){try{return N(e,t)}catch{return}}function Na(e,t){return L(e).map(e=>e.map(e=>{if(typeof e.value!=`number`){let n=``;throw typeof e==`object`?n=k(`Function [[FUNCTION_NAME]] expects number values for %s, but got an empty value.`,t):typeof e==`string`?n=k(`Function [[FUNCTION_NAME]] expects number values for %s, but got a string.`,t):typeof e==`boolean`&&(n=k(`Function [[FUNCTION_NAME]] expects number values for %s, but got a boolean.`,t)),new j(n)}return e.value}))}function Pa(e,t){let n=Ba(e);if(n===``)throw new j(ka(n));return N(n,t)}function Fa(e,t){return Math.trunc(N(e,t))}function Ia(e,t){return Math.trunc(Pa(e,t))}function P(e){let t=Ba(e);switch(typeof t){case`string`:return t;case`number`:return t.toString();case`boolean`:return t?`TRUE`:`FALSE`;default:return``}}let La=At(function(e){return e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``)}),Ra=e=>k(`The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a boolean.`,e);function F(e){let t=Ba(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 j(Ra(t))}else return!1;case`number`:return!!t;default:return!1}}function za(e){let t=Ba(e);if(t===``)throw new j(Ra(t));return F(t)}function I(e,t){return Li(N(Ba(e),t))}function Ba(e){if(typeof e==`object`&&e&&`value`in e){if(M(e.value))throw e;return e.value}if(M(e))throw new j(``,e);return e}function Va(e,t,n){for(let r of e)if(Ta(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 Ha(e,t){Va(e,e=>{if(M(e.value))throw e;t(e)},e=>{if(M(e?.value))throw e;t(e)})}function Ua(e,t,n){Va(e,e=>{if(typeof e?.value==`number`&&t(e),M(e?.value))throw e},e=>{t({value:Pa(e,n),format:e?.format})})}function Wa(e,t,n,r,i=`rowFirst`){let a=r;for(let r of e)if(Ta(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 Ga(e,t,n,r=`rowFirst`){return Wa(e,t,t,n,r)}function Ka(e,t,n,r){return Wa(e,(e,n)=>{let r=n?.value;if(typeof r==`number`)return t(e,r);if(M(r))throw n;return e},(e,n)=>t(e,Pa(n,r)),n)}function qa(e,t,n,r){return Wa(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,N(i,r));if(M(i))throw n;return t(e,0)}return e},(e,n)=>t(e,N(n,r)),n)}function Ja(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 Ya(e,t){return e.length===0?[]:Ja(e.length,e[0].length,(n,r)=>t(e[n][r]))}function Xa(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 Za(e){return e.length?Ja(e[0].length,e.length,(t,n)=>e[n][t]):[]}function Qa(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(Ta(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=(e,n)=>t.map((t,r)=>{switch(s?.[r]){case`matrix`:return t[e][n];case`horizontal`:return t[e][0];case`vertical`:return t[0][n];case void 0:return t}});return Ja(r,i,(t,n)=>{if(t>a-1||n>o-1)return new ya(k(`Array arguments to [[FUNCTION_NAME]] are of different size.`));let r=e(...c(t,n));return Ta(r)?r[0][0]:r})}function $a(e,t,n){for(let r of e)if(Ta(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 eo(e,t){return $a(e,e=>{let n=e?.value;if(typeof n==`boolean`)return t(n);if(typeof n==`number`)return t(!!n);if(M(n))throw e;return!0},e=>e!==void 0&&e.value!==null?t(za(e)):!0)}function to(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)),ra(r,t)||Ti(r,t)?r=N(r,t):(r===`TRUE`||r===`FALSE`)&&(r=F(r)),{operator:n,operand:r}}let no=At(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 ro(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`&&(ra(e,n)||Ti(e,n))?N(e,n)===i:e===i;if(r===`<>`||r===`=`){let t;return t=typeof e==typeof i?e===``&&i===``?!0:typeof e==`string`&&typeof i==`string`?no(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 io(e,t,n,r=!1){let i=e.length;if(i%2==1)throw new j(k(`Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs.`));let a=L(e[0]),o=a.length,s=a[0].length,c=[];for(let t=0;t<i-1;t+=2){let i=L(e[t]);if(i.length!==o||i[0].length!==s)throw new j(k(`Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension`));let a=to(P(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=L(e[t])[r][a].value,s=c[t/2];if(o=ro(i??void 0,s,n),!o)break}o&&t(r,a)}}function ao(e,t,n,r,i,a){if(t===void 0||t.value===null)return-1;if(M(t.value))throw t;let o=co(t.value),s=typeof o,c,l,u=0,d=i-1,f,p,m,h,g=r===`desc`?t=>co(a(e,i-t-1)):t=>co(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 oo(e,t,n,r,i,a,o=!1){if(t===void 0||t.value===null)return-1;if(M(t.value))throw t;let s=co(t.value),c=o?(e,t)=>co(i(e,r-t-1)):(e,t)=>co(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`||n===`wildcard`)return-1}let u=so(e,s,n,r,c);return o&&u!==-1?r-u-1:u}function so(e,t,n,r,i){let a=n=>i(e,n)===t;if(n===`wildcard`&&typeof t==`string`&&(t.includes(`*`)||t.includes(`?`))){let n=no(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&&lo(t,r)>=0||lo(t,r)>=0&&lo(r,o)>0)&&(o=r,s=n),r===t}),n===`nextGreater`&&(a=n=>{let r=i(e,n);return(!o&&lo(t,r)<=0||lo(t,r)<=0&&lo(r,o)<0)&&(o=r,s=n),r===t});for(let e=0;e<r;e++)if(a(e))return e;return s}function co(e){return typeof e==`string`?La(e):e}function lo(e,t){let n=Ea.indexOf(typeof e)-Ea.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 L(e){return e===void 0?[[]]:Ta(e)?e:[[e]]}function uo(e,t){return Ga(e,(e,n)=>(e.push(t(n)),e),[],`rowFirst`)}function fo(e){if(e===void 0)return!1;let{value:t}=e;return!(t===null||t===``)}let po=k(`[[FUNCTION_NAME]] has no valid input data.`);function mo(e){return k(`[[FUNCTION_NAME]] expects the provided values of %(argName)s to be a non-empty matrix.`,{argName:e})}let ho=[{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:`;`}],R=ho[0];function go(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=To(t)||_o(t)||yo(t)||bo(t)||So(t)||Co(t)||wo(t)||Do(t)||xo(t)||Oo(t);if(!e)throw Error(`Unknown token at `+t.remaining());r.push(e)}return n}function _o(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 vo=new Set(`$+-/():!^&~{}<>= `);function yo(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 vo.has(e.current)?{type:`CHAR`,value:e.shift()}:null}function bo(e){return e.current===`,`?(e.shift(),{type:`THOUSANDS_SEPARATOR`,value:`,`}):null}function xo(e){return e.current===`@`?(e.shift(),{type:`TEXT_PLACEHOLDER`,value:`@`}):null}function So(e){return e.current===`.`?(e.shift(),{type:`DECIMAL_POINT`,value:`.`}):null}function Co(e){return e.current===`%`?(e.shift(),{type:`PERCENT`,value:`%`}):null}function wo(e){return e.current===`e`?(e.shift(),{type:`SCIENTIFIC`,value:`e`}):null}function To(e){if(e.current===`0`||e.current===`#`){let t=e.current;return e.shift(),{type:`DIGIT`,value:t}}return null}let Eo=new Set(`dmqyhsa`);function Do(e){if(!Eo.has(e.current))return null;let t=e.current,n=``;for(;e.current===t;)n+=e.shift();return{type:`DATE_PART`,value:n}}function Oo(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 ko={};function Ao(e){let t=ko[e];return t===void 0&&(t=jo(e),ko[e]=t),t}function jo(e){let t=go(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=Io(t[0])||Fo(t[0])||Lo(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=Io(t[1])||Fo(t[1]);if(t[1]?.length&&!r)throw Error(`Invalid second format part of: `+e);let i=Io(t[2])||Fo(t[2]);if(t[2]?.length&&!i)throw Error(`Invalid third format part of: `+e);let a=Lo(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 Mo(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 No(e){return e.every(e=>e.type===`DIGIT`||e.type===`DECIMAL_POINT`||e.type===`THOUSANDS_SEPARATOR`||e.type===`PERCENT`||e.type===`SCIENTIFIC`||e.type===`STRING`||e.type===`CHAR`||e.type===`REPEATED_CHAR`)}function Po(e){return e.every(e=>e.type===`STRING`||e.type===`TEXT_PLACEHOLDER`||e.type===`CHAR`||e.type===`REPEATED_CHAR`)}function Fo(e){if(!e||!No(e))return;let t=[],n,r=t,i=0,a=!1,o=0,s=e.findLastIndex(e=>e.type===`DIGIT`),c=!1,l=0;for(let u=0;u<e.length;u++){let d=e[u];switch(d.type){case`DIGIT`:r===t?r.push(d):l<20&&(r.push(d),l++);break;case`DECIMAL_POINT`:if(r===t)n=[],r=n;else throw Error(`Multiple decimal points in a number format`);break;case`SCIENTIFIC`:a=!0;break;case`REPEATED_CHAR`:case`CHAR`:case`STRING`:r.push(d);break;case`PERCENT`:i++,r.push(d);break;case`THOUSANDS_SEPARATOR`:u-1===s?(o+=1,s++,r.push(d)):e[u+1]?.type===`DIGIT`&&e[u-1]?.type===`DIGIT`?(r===t&&(c=!0),r.push(d)):r.push({type:`CHAR`,value:`,`});break}}return{type:`number`,integerPart:t,decimalPart:n,percentSymbols:i,scientific:a,thousandsSeparator:c,magnitude:o}}function Io(e){let t=e&&Mo(e)?{type:`date`,tokens:e}:void 0;if(!(!t||!e?.some(e=>e.type===`DATE_PART`))){if(t.tokens.length&&t.tokens.every(e=>e.type===`DATE_PART`&&e.value===`a`))throw Error(`Invalid date format`);return{type:`date`,tokens:Ro(t.tokens.map(e=>e.type===`THOUSANDS_SEPARATOR`||e.type===`DECIMAL_POINT`?{type:`CHAR`,value:e.value}:e))}}}function Lo(e){return e&&Po(e)?{type:`text`,tokens:e}:void 0}function Ro(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 zo(e){return[Bo(e.positive),Bo(e.negative),Bo(e.zero),Bo(e.text)].filter(C).join(`;`)}function Bo(e){if(!e)return;let t=``,n=e.type===`number`?Vo(e):e.tokens;for(let e of n)switch(e.type){case`STRING`:t+=`[$${e.value}]`;break;case`CHAR`:t+=Ho(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 Vo(e){let t=[...e.integerPart];return e.decimalPart&&(t.push({type:`DECIMAL_POINT`,value:`.`}),t.push(...e.decimalPart)),e.scientific&&t.push({type:`SCIENTIFIC`,value:`e`}),t}function Ho(e){return!vo.has(e)}let Uo=`REPEATED_CHAR_PLACEHOLDER_`,Wo={0:k(`January`),1:k(`February`),2:k(`March`),3:k(`April`),4:k(`May`),5:k(`June`),6:k(`July`),7:k(`August`),8:k(`September`),9:k(`October`),10:k(`November`),11:k(`December`)},Go={0:k(`Sunday`),1:k(`Monday`),2:k(`Tuesday`),3:k(`Wednesday`),4:k(`Thursday`),5:k(`Friday`),6:k(`Saturday`)};function Ko(e,t,n,r=!1){return r?ys({value:e,format:t},n):z(e,{format:t,locale:n})}function z(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=Ao(t),i=qo(e,n).format;return!i||i.type!==`text`?e:Jo(e,i,r)}case`number`:t||=us(e);let i=Ao(t),{format:a,isNegativeFormat:o}=qo(e,i);if(!a)return e.toString();if(a.type===`text`)return Jo(e.toString(),a,r);if(o&&(e=Math.abs(e)),a.type===`date`)return Yo(ss(e,a),r);let s=e<0,c=Yo(Xo(Math.abs(e),a,n),r);return s?`-`+c:c;case`object`:return``}}function qo(e,t){let n,r=!1;switch(typeof e){case`number`:e<0&&t.negative?(n=t.negative,r=!0):n=e===0&&t.zero?t.zero:t.positive;break;case`string`:let i=t.text||t.positive;i.type===`text`&&(n=i);break}return{format:n,isNegativeFormat:r}}function Jo(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+=Uo+n.value;break}return Yo(r,n)}function Yo(e,t){let n=e.indexOf(Uo);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 Xo(e,t,n){if(!t.integerPart.length&&!t.decimalPart?.length)return``;if(e===1/0)return`∞`+(t.percentSymbols?`%`:``);let r=Math.floor(Math.log10(Math.abs(e)));r===-1/0&&(r=0),t.scientific&&(e/=10**r);let i=t.percentSymbols*2-t.magnitude*3;e*=10**i;let a=0;t.decimalPart!==void 0&&(a=t.decimalPart.filter(e=>e.type===`DIGIT`).length);let{integerDigits:o,decimalDigits:s}=es(Math.abs(e),a),c=!!t.decimalPart?.some(e=>e.type===`DIGIT`),l=Zo(o,t,t.thousandsSeparator?n.thousandsSeparator:void 0,c);if(t.decimalPart!==void 0&&(l+=n.decimalSeparator+Qo(s||``,t)),t.scientific){let e=Math.abs(r).toString().padStart(2,`0`);l+=`e`+(r>=0?`+`:`-`)+e}return l}function Zo(e,t,n,r){let i=t.integerPart;r&&!i.some(e=>e.type===`DIGIT`)&&(i=[...i,{type:`DIGIT`,value:`#`}]),e===`0`&&(e=``);let a=``,o=i.findIndex(e=>e.type===`DIGIT`),s=e.length-1;function c(t,r){if(r===`0`&&(t||=`0`),!t)return;let i=e.length-1-s;a=n&&i>0&&i%3==0?t+n+a:t+a}for(let t=i.length-1;t>=0;t--){let n=i[t];switch(n.type){case`DIGIT`:let r=e[s];if(c(r,n.value),s--,o===t)for(;s>=0;)c(e[s],`0`),s--;break;case`THOUSANDS_SEPARATOR`:break;case`REPEATED_CHAR`:a=Uo+n.value+a;break;default:a=n.value+a;break}}return a}function Qo(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+=Uo+i.value;break;default:n+=i.value;break}return n}let $o=[];function es(e,t=20){let n=e.toString();if(n.includes(`e`))return is(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}=rs(a,t);a=n,e!==`0`&&(i=(Number(i)+Number(e)).toString())}return{integerDigits:i,decimalDigits:ts(a||``)}}function ts(e){let t=e.length-1;for(;t>=0&&e[t]===`0`;)t--;return e.slice(0,t+1)||void 0}let ns=/^0+/;function rs(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(ns)?.[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 is(e,t=20){let n=$o[t];n||(n=new Intl.NumberFormat(`en-US`,{maximumFractionDigits:t,useGrouping:!1}),$o[t]=n);let[r,i]=n.format(e).split(`.`);return{integerDigits:r,decimalDigits:i}}function as(e,t){let{integerDigits:n,decimalDigits:r}=es(e,20);return r?n+t+r:n}let os=At(function(e){if(!e)return!1;try{return Ao(e).positive.type===`date`}catch{return!1}});function ss(e,t){let n=Li(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+=cs(n,e.value,r);break;case`REPEATED_CHAR`:i+=Uo+e.value;break;default:i+=e.value;break}return i}function cs(e,t,n){switch(t){case`d`:return e.getDate();case`dd`:return e.getDate().toString().padStart(2,`0`);case`ddd`:return Go[e.getDay()].slice(0,3);case`dddd`:return Go[e.getDay()].toString();case`m`:return e.getMonth()+1;case`mm`:return String(e.getMonth()+1).padStart(2,`0`);case`mmm`:return Wo[e.getMonth()].slice(0,3);case`mmmm`:return Wo[e.getMonth()].toString();case`mmmmm`:return Wo[e.getMonth()].slice(0,1);case`qq`:return k(`Q%(quarter)s`,{quarter:e.getQuarter()}).toString();case`qqqq`:return k(`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()-fi.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 ls=At(function(e){return RegExp(`[0-9]+${qe(e.decimalSeparator)}[0-9]`)});function us(e){let{integerDigits:t,decimalDigits:n}=es(e);if(!n)return`0`;let r=t.replace(`-`,``).length;if(r+2>11)return`0`;let i=11-r-1;return{decimalDigits:n}=es(e,Math.min(i,n.length)),n?`0.`+`0`.repeat(n.length):`0`}function ds(e,t){if(Ti(e,t))return Di(e,t).format}function fs(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 ps(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),gs(o,n,a)}function ms(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),[hs(o,n,` ${a} `),hs(o,n,`(${a})`),hs(o,n,` - `)].join(`;`)}function hs(e,t,n){let r=`[$${e}]`;return t===`before`?r+`* `+n:n+`* `+r}function gs(e,t,n){let r=`[$${e}]`;return t===`before`?r+n:n+r}function _s(e){let t=Ao(e);return zo({positive:vs(t.positive),negative:t.negative?vs(t.negative):void 0,zero:t.zero?vs(t.zero):void 0,text:t.text})}function vs(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 ys({value:e,format:t},n){let r=Ma(e,n);if(r===void 0)return``;let i=t;if(Math.abs(r)<1e3){let e=r%1!=0;i=!t&&e?Math.abs(r)<.01?`0.00e`:`0.##`:t}else i=bs({value:e,format:t},void 0,n);return z(e,{format:i,locale:n})}function bs(e,t,n){let r=0;try{r=Math.abs(N(e?.value,n))}catch{return``}let i=e?.format;if(t!==void 0)switch(t?.value){case`k`:return xs(i,1,`k`);case`m`:return xs(i,2,`m`);case`b`:return xs(i,3,`b`);default:throw new j(k(`The formatting unit should be 'k', 'm' or 'b'.`))}return r<1e5?xs(i,0,``):r<1e8?xs(i,1,`k`):r<1e11?xs(i,2,`m`):r<0x5af3107a4000?xs(i,3,`b`):`0.00e`}function xs(e,t,n){let r=Ao(e||`#,##0`);return zo({positive:Ss(r.positive,t,n),negative:r.negative?Ss(r.negative,t,n):void 0,zero:r.zero?Ss(r.zero,t,n):void 0,text:r.text})}function Ss(e,t,n){if(e.type!==`number`||e.scientific)return e;let r=vs(e),i={type:`STRING`,value:n},a=[...r.integerPart],o=a.findLastIndex(e=>e.type===`DIGIT`);if(o===-1)return e;for(;a[o+1]?.type===`THOUSANDS_SEPARATOR`;)a=jt(a,[o+1]);let s=a[o+1];a=s?.type===`STRING`&&[`m`,`k`,`b`].includes(s.value)?Nt(a,i,o+1):Mt(a,[i],o+1),t>0&&(a=Mt(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 Cs(e,t){let n=Ao(e);return zo(Ao(zo({positive:ws(n.positive,t),negative:n.negative?ws(n.negative,t):void 0,zero:n.zero?ws(n.zero,t):void 0,text:n.text})))}function ws(e,t){return e.type===`number`?t>0?Es(e,t):Ts(e,Math.abs(t)):e}function Ts(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=jt(n,r),n.some(e=>e.type===`DIGIT`)?{...e,decimalPart:n}:{...e,decimalPart:void 0,integerPart:[...e.integerPart,...n]}}function Es(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=S(0,t).map(()=>({type:`DIGIT`,value:`0`})),a=r.findLastIndex(e=>e.type===`DIGIT`);return r=a===-1?[...i,...r]:Mt(r,i,a+1),{...e,decimalPart:r,integerPart:n}}function Ds(e){let t=Ao(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 Os(e){if(!e)return!1;try{return Ao(e).positive.type===`text`}catch{return!1}}function ks(e,t){if(!t)return!1;try{let{format:n}=qo(e,Ao(t));if(n?.type===`text`||n?.type===`date`)return n.tokens.some(e=>e.type===`REPEATED_CHAR`);if(n?.type===`number`)return n.integerPart.some(e=>e.type===`REPEATED_CHAR`)||(n.decimalPart?n.decimalPart.some(e=>e.type===`REPEATED_CHAR`):!1)}catch{}return!1}function As(e){try{return z(0,{format:e,locale:R}),!0}catch{return!1}}function js(e){return go(e).length}var B=class{content={};add(e,t){if(e in this.content)throw Error(`${e} is already present in this registry!`);return this.replace(e,t)}replace(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]}};function Ms(e){return`sheetId`in e}function Ns(e){return`dimension`in e&&`sheetId`in e&&`elements`in e}function Ps(e){return`target`in e&&`sheetId`in e}function Fs(e){return`ranges`in e}function Is(e){return`col`in e&&`row`in e&&`sheetId`in e}function Ls(e){return`sheetId`in e&&`zone`in e}let Rs=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`]),zs=new Set([`EVALUATE_CELLS`,`EVALUATE_CHARTS`,`UPDATE_CELL`,`UNHIDE_COLUMNS_ROWS`,`HIDE_COLUMNS_ROWS`,`GROUP_HEADERS`,`UNGROUP_HEADERS`,`FOLD_ALL_HEADER_GROUPS`,`FOLD_HEADER_GROUP`,`FOLD_HEADER_GROUPS_IN_ZONE`,`UNFOLD_ALL_HEADER_GROUPS`,`UNFOLD_HEADER_GROUP`,`UNFOLD_HEADER_GROUPS_IN_ZONE`,`UPDATE_TABLE`,`UPDATE_FILTER`,`UNDO`,`REDO`]),Bs=new Set([`MOVE_RANGES`]),Vs=new Set([`EVALUATE_CELLS`,`ADD_CONDITIONAL_FORMAT`,`REMOVE_CONDITIONAL_FORMAT`,`CHANGE_CONDITIONAL_FORMAT_PRIORITY`]),Hs=new Set([`AUTOFILL_CELL`,`SET_BORDER`,`SET_ZONE_BORDERS`,`SET_BORDERS_ON_TARGET`]),Us=new Set([`UNHIDE_COLUMNS_ROWS`,`HIDE_COLUMNS_ROWS`,`GROUP_HEADERS`,`UNGROUP_HEADERS`,`FOLD_ALL_HEADER_GROUPS`,`FOLD_HEADER_GROUP`,`FOLD_HEADER_GROUPS_IN_ZONE`,`UNFOLD_ALL_HEADER_GROUPS`,`UNFOLD_HEADER_GROUP`,`UNFOLD_HEADER_GROUPS_IN_ZONE`,`UPDATE_TABLE`,`UPDATE_FILTER`]),Ws=new Set([`START`,`ACTIVATE_SHEET`,`COPY`,`RESIZE_SHEETVIEW`,`SET_VIEWPORT_OFFSET`,`SET_ZOOM`,`EVALUATE_CELLS`,`EVALUATE_CHARTS`,`SET_FORMULA_VISIBILITY`,`UPDATE_FILTER`,`UPDATE_CHART`,`UPDATE_CAROUSEL_ACTIVE_ITEM`,`UPDATE_PIVOT`]),Gs=new Set(`LOCK_SHEET.UNLOCK_SHEET.MOVE_SHEET.DUPLICATE_SHEET.CREATE_SHEET.HIDE_SHEET.SHOW_SHEET.COPY.START.SCROLL_TO_CELL.ACTIVATE_SHEET.RESIZE_SHEETVIEW.SET_VIEWPORT_OFFSET.SET_FORMULA_VISIBILITY.SELECT_FIGURE.EVALUATE_CHARTS.EVALUATE_CELLS.REQUEST_UNDO.REQUEST_REDO.REPLACE_SEARCH.SET_ZOOM.UPDATE_CAROUSEL_ACTIVE_ITEM.DUPLICATE_PIVOT_IN_NEW_SHEET.UPDATE_FILTER.ACTIVATE_NEXT_SHEET.ACTIVATE_PREVIOUS_SHEET.SCROLL_TO_CELL.SHIFT_VIEWPORT_DOWN.SHIFT_VIEWPORT_UP`.split(`.`)),Ks=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.LOCK_SHEET.UNLOCK_SHEET.MOVE_RANGES.ADD_CONDITIONAL_FORMAT.REMOVE_CONDITIONAL_FORMAT.CHANGE_CONDITIONAL_FORMAT_PRIORITY.CREATE_FIGURE.DELETE_FIGURE.UPDATE_FIGURE.CREATE_CAROUSEL.UPDATE_CAROUSEL.SET_FORMATTING.CLEAR_FORMATTING.SET_BORDER.SET_ZONE_BORDERS.SET_BORDERS_ON_TARGET.CREATE_CHART.UPDATE_CHART.DELETE_CHART.CREATE_TABLE.REMOVE_TABLE.UPDATE_TABLE.CREATE_TABLE_STYLE.REMOVE_TABLE_STYLE.CREATE_IMAGE.GROUP_HEADERS.UNGROUP_HEADERS.UNFOLD_HEADER_GROUP.FOLD_HEADER_GROUP.FOLD_ALL_HEADER_GROUPS.UNFOLD_ALL_HEADER_GROUPS.UNFOLD_HEADER_GROUPS_IN_ZONE.FOLD_HEADER_GROUPS_IN_ZONE.ADD_DATA_VALIDATION_RULE.REMOVE_DATA_VALIDATION_RULE.UPDATE_LOCALE.ADD_PIVOT.UPDATE_PIVOT.INSERT_PIVOT.RENAME_PIVOT.REMOVE_PIVOT.DUPLICATE_PIVOT`.split(`.`));function qs(e){return Ks.has(e.type)}function Js(e){return Ws.has(e.type)}var Ys=class{reasons;constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter(e=>e!==`Success`)}static get Success(){return Xs}get isSuccessful(){return this.reasons.length===0}isCancelledBecause(e){return this.reasons.includes(e)}};let Xs=new Ys,Zs=function(e){return e.Success=`Success`,e.CancelledForUnknownReason=`CancelledForUnknownReason`,e.WillRemoveExistingMerge=`WillRemoveExistingMerge`,e.CannotMoveTableHeader=`CannotMoveTableHeader`,e.MergeIsDestructive=`MergeIsDestructive`,e.CellIsMerged=`CellIsMerged`,e.InvalidTarget=`InvalidTarget`,e.EmptyUndoStack=`EmptyUndoStack`,e.EmptyRedoStack=`EmptyRedoStack`,e.NotEnoughElements=`NotEnoughElements`,e.NotEnoughSheets=`NotEnoughSheets`,e.MissingSheetName=`MissingSheetName`,e.UnchangedSheetName=`UnchangedSheetName`,e.DuplicatedSheetName=`DuplicatedSheetName`,e.DuplicatedSheetId=`DuplicatedSheetId`,e.ForbiddenCharactersInSheetName=`ForbiddenCharactersInSheetName`,e.WrongSheetMove=`WrongSheetMove`,e.WrongSheetPosition=`WrongSheetPosition`,e.InvalidAnchorZone=`InvalidAnchorZone`,e.SelectionOutOfBound=`SelectionOutOfBound`,e.TargetOutOfSheet=`TargetOutOfSheet`,e.WrongCutSelection=`WrongCutSelection`,e.WrongPasteSelection=`WrongPasteSelection`,e.WrongPasteOption=`WrongPasteOption`,e.WrongFigurePasteOption=`WrongFigurePasteOption`,e.EmptyClipboard=`EmptyClipboard`,e.EmptyRange=`EmptyRange`,e.EmptyTarget=`EmptyTarget`,e.InvalidRange=`InvalidRange`,e.InvalidZones=`InvalidZones`,e.InvalidSheetId=`InvalidSheetId`,e.InvalidCellId=`InvalidCellId`,e.InvalidFigureId=`InvalidFigureId`,e.InputAlreadyFocused=`InputAlreadyFocused`,e.MaximumRangesReached=`MaximumRangesReached`,e.MinimumRangesReached=`MinimumRangesReached`,e.InvalidChartDefinition=`InvalidChartDefinition`,e.InvalidDataSet=`InvalidDataSet`,e.InvalidLabelRange=`InvalidLabelRange`,e.InvalidScorecardKeyValue=`InvalidScorecardKeyValue`,e.InvalidScorecardBaseline=`InvalidScorecardBaseline`,e.InvalidGaugeDataRange=`InvalidGaugeDataRange`,e.EmptyGaugeRangeMin=`EmptyGaugeRangeMin`,e.GaugeRangeMinNaN=`GaugeRangeMinNaN`,e.EmptyGaugeRangeMax=`EmptyGaugeRangeMax`,e.GaugeRangeMaxNaN=`GaugeRangeMaxNaN`,e.GaugeLowerInflectionPointNaN=`GaugeLowerInflectionPointNaN`,e.GaugeUpperInflectionPointNaN=`GaugeUpperInflectionPointNaN`,e.InvalidAutofillSelection=`InvalidAutofillSelection`,e.MinBiggerThanMax=`MinBiggerThanMax`,e.LowerBiggerThanUpper=`LowerBiggerThanUpper`,e.MidBiggerThanMax=`MidBiggerThanMax`,e.MinBiggerThanMid=`MinBiggerThanMid`,e.FirstArgMissing=`FirstArgMissing`,e.SecondArgMissing=`SecondArgMissing`,e.MinNaN=`MinNaN`,e.MidNaN=`MidNaN`,e.MaxNaN=`MaxNaN`,e.ValueUpperInflectionNaN=`ValueUpperInflectionNaN`,e.ValueLowerInflectionNaN=`ValueLowerInflectionNaN`,e.MinInvalidFormula=`MinInvalidFormula`,e.MidInvalidFormula=`MidInvalidFormula`,e.MaxInvalidFormula=`MaxInvalidFormula`,e.ValueUpperInvalidFormula=`ValueUpperInvalidFormula`,e.ValueLowerInvalidFormula=`ValueLowerInvalidFormula`,e.InvalidSortAnchor=`InvalidSortAnchor`,e.InvalidSortZone=`InvalidSortZone`,e.SortZoneWithArrayFormulas=`SortZoneWithArrayFormulas`,e.WaitingSessionConfirmation=`WaitingSessionConfirmation`,e.MergeOverlap=`MergeOverlap`,e.TooManyHiddenElements=`TooManyHiddenElements`,e.Readonly=`Readonly`,e.InvalidViewportSize=`InvalidViewportSize`,e.InvalidScrollingDirection=`InvalidScrollingDirection`,e.ViewportScrollLimitsReached=`ViewportScrollLimitsReached`,e.FigureDoesNotExist=`FigureDoesNotExist`,e.InvalidConditionalFormatId=`InvalidConditionalFormatId`,e.InvalidConditionalFormatType=`InvalidConditionalFormatType`,e.InvalidCellPopover=`InvalidCellPopover`,e.EmptySelectedRange=`EmptySelectedRange`,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.PivotIdTaken=`PivotIdTaken`,e.PivotInError=`PivotInError`,e.EmptyName=`EmptyName`,e.ValueCellIsInvalidFormula=`ValueCellIsInvalidFormula`,e.InvalidDefinition=`InvalidDefinition`,e.InvalidColor=`InvalidColor`,e.InvalidPivotDataSet=`InvalidPivotDataSet`,e.InvalidPivotCustomField=`InvalidPivotCustomField`,e.MissingFigureArguments=`MissingFigureArguments`,e.InvalidCarouselItem=`InvalidCarouselItem`,e.SheetLocked=`SheetLocked`,e.InvalidZoomLevel=`InvalidZoomLevel`,e.SubCommandOnly=`SubCommandOnly`,e}({});function Qs(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}let $s=new B;function ec(e,t){return e=Qs(e),{url:e,label:t||e,isExternal:!0,isUrlEditable:!0}}$s.add(`sheet_URL`,{match:e=>lt(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){let n=dt(e);return t.tryGetSheetName(n)||k(`Invalid sheet`)},open(e,t){let n=dt(e);t.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:n}).isCancelledBecause(`SheetIsHidden`)&&t.notifyUser({type:`warning`,sticky:!1,text:k(`Cannot open the link because the linked sheet is hidden.`)})},sequence:0});let tc={createLink:ec,match:e=>at(e),open:e=>window.open(e,`_blank`),urlRepresentation:e=>e,sequence:0};function nc(e){return $s.getAll().sort((e,t)=>e.sequence-t.sequence).find(t=>t.match(e))||tc}function rc(e,t){return nc(e.url).urlRepresentation(e.url,t)}function ic(e,t,n){nc(e.url).open(e.url,t,n)}function ac(e){if(typeof e==`string`){if(it(e)){let{label:t,url:n}=st(e);return nc(n).createLink(n,t)}else if(at(e))return ec(e)}}function oc(e,t,n){return cc({value:Os(t.format)&&e.parsedValue!==null?e.content:e.parsedValue,format:t.format,origin:n},t.locale)}function sc(e,t){if(e.startsWith(`=`))throw Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);if(e.startsWith(`'`))return e.slice(1);if(e===``)return null;if(e.includes(`
|
|
9
|
+
`)}}return t}var cr=class{get;disposeCallbacks=[];constructor(e){this.get=e}onDispose(e){this.disposeCallbacks.push(e)}dispose(){this.disposeCallbacks.forEach(e=>e())}};function lr(){let e=(0,t.useEnv)();if(e.__spreadsheet_stores__ instanceof ar)return e.__spreadsheet_stores__;let n=new ar;return(0,t.useSubEnv)({__spreadsheet_stores__:n,getStore:e=>fr(n.get(e),()=>n.trigger(`store-updated`))}),(0,t.onWillUnmount)(()=>n.dispose()),n}function D(e){let n=pr((0,t.useEnv)());return dr(n,n.get(e))}function ur(e,...n){let r=pr((0,t.useEnv)()),i=r.instantiate(e,...n);return(0,t.onWillUnmount)(()=>i.dispose()),dr(r,i)}function dr(e,n){let r=(0,t.useComponent)();return fr(n,()=>{(0,t.status)(r)===`mounted`&&e.trigger(`store-updated`)})}function fr(e,t){return new Proxy(e,{get(n,r,i){let a=n,o=Reflect.get(n,r,a);return e.mutators?.includes(r)?new Proxy(o,{apply(e,n,r){Reflect.apply(e,a,r)!==`noStateChange`&&t()}}):o}})}function pr(e){let t=e.__spreadsheet_stores__;if(!(t instanceof ar))throw Error(`No store provider found. Did you forget to call useStoreProvider()?`);return t}let mr=sr(`Model`),hr={Background:0,Highlights:1,Clipboard:2,Chart:4,Autofill:5,Selection:6,Headers:100},gr=At(()=>Object.keys(hr).sort((e,t)=>hr[e]-hr[t]));function _r(e,t){if(hr[e])throw Error(`Layer ${e} already exists`);hr[e]=t}var vr=class{mutators=[`register`,`unRegister`,`draw`,`startAnimation`,`stopAnimation`];renderers={};model;context=void 0;animationFrameId=null;registeredAnimations=new Set;constructor(e){this.model=e(mr)}register(e){if(e.renderingLayers.length)for(let t of e.renderingLayers)this.renderers[t]||(this.renderers[t]=[]),this.renderers[t].push(e)}unRegister(e){for(let t of Object.keys(this.renderers))this.renderers[t]=this.renderers[t].filter(t=>t!==e)}drawLayer(e,t,n){let r=this.renderers[t];if(r)for(let i of r)e.ctx.save(),i.drawLayer(e,t,n),e.ctx.restore();return`noStateChange`}draw(e,t){if(e||=this.context,!e)throw Error(`Rendering context is not defined`);this.context=e;for(let n of gr())this.model.drawLayer(e,n),this.drawLayer(e,n,t);return`noStateChange`}startAnimation(e){if(this.registeredAnimations.add(e),!this.animationFrameId){let e=t=>{this.animationFrameId=requestAnimationFrame(e),this.draw(void 0,t)};this.animationFrameId=requestAnimationFrame(e)}return`noStateChange`}stopAnimation(e){return this.registeredAnimations.delete(e),this.registeredAnimations.size===0&&this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),`noStateChange`}dispose(){this.animationFrameId&&=(cancelAnimationFrame(this.animationFrameId),null)}},yr=class extends cr{model=this.get(mr);getters=this.model.getters;renderer=this.get(vr);constructor(e){super(e),this.model.on(`command-dispatched`,this,this.handle),this.model.on(`command-finalized`,this,this.finalize),this.renderer.register(this),this.onDispose(()=>{this.model.off(`command-dispatched`,this),this.model.off(`command-finalized`,this),this.renderer.unRegister(this)})}get renderingLayers(){return[]}handle(e){}finalize(){}drawLayer(e,t,n){}};let br={id:`void-composer`,get editionMode(){return`inactive`},startEdition:()=>{throw Error(`No composer is registered`)},stopEdition:()=>{throw Error(`No composer is registered`)},setCurrentContent:()=>{throw Error(`No composer is registered`)}};var xr=class extends yr{mutators=[`focusComposer`,`focusActiveComposer`];activeComposer=br;_focusMode=`inactive`;get focusMode(){return this.activeComposer.editionMode===`inactive`?`inactive`:this._focusMode}focusComposer(e,t){if(this.activeComposer=e,this.getters.isReadonly())return`noStateChange`;this._focusMode=t.focusMode||`contentFocus`,this._focusMode!==`inactive`&&this.setComposerContent(t)}focusActiveComposer(e){if(this.getters.isReadonly())return`noStateChange`;if(!this.activeComposer)throw Error(`No composer is registered`);this._focusMode=e.focusMode||`contentFocus`,this._focusMode!==`inactive`&&this.setComposerContent(e)}setComposerContent({content:e,selection:t}){this.activeComposer.editionMode===`inactive`?this.activeComposer.startEdition(e,t):e&&this.activeComposer.setCurrentContent(e,t)}};let Sr=/rgba?\(|\s+|\)/gi,Cr=/^#([A-F\d]{2}){3,4}$/,wr=/^light-dark\(\s*(rgba?\([0-9.,\s]+\)|#[a-f0-9]+)\s*,\s*(rgba?\([0-9.,\s]+\)|#[a-f0-9]+)\s*\)$/i,Tr=[`#eb6d00`,`#0074d9`,`#ad8e00`,`#169ed4`,`#b10dc9`,`#00a82d`,`#00a3a3`,`#f012be`,`#3d9970`,`#62A300`,`#ff4136`,`#949494`,`#ff5c9d`];function Er(e,t=1){let n=t===1?``:Math.round(t*255).toString(16).padStart(2,`0`);return Or(e.toString(16).padStart(6,`0`))+n}function Dr(e){return typeof e==`number`?e:Number.parseInt(Or(e).slice(1,7),16)}function Or(e){let t=e;if(e.startsWith(`light-dark`)){let t=e.match(wr);if(!t)throw Error(`Invalid light-dark color: ${e}`);return`light-dark(${Or(t[1])}, ${Or(t[2])})`}if(e.startsWith(`rgb`)?t=Pr(e):(t=e.replace(`#`,``).toUpperCase(),(t.length===3||t.length===4)&&(t=t.split(``).reduce((e,t)=>e+t+t,``)),t=`#${t}`),!Cr.test(t))throw Error(`invalid color input: ${e}`);return t}function kr(e){try{return Or(e),!0}catch{return!1}}function Ar(e){try{return zr(e),!0}catch{return!1}}let jr=e=>e>=0&&e<=255;function Mr(e,t,n,r=1){if(!jr(e)||!jr(t)||!jr(n)||r<0||r>1)throw Error(`Invalid RGBA values ${[e,t,n,r]}`);return{a:r,b:n,g:t,r:e}}function Nr(e){let{r:t,g:n,b:r}=Ir(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 Pr(e){let t=e.replace(Sr,``).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),`#`+gt(r.map(e=>e.toString(16).padStart(2,`0`))).toUpperCase()}function Fr(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 Ir(e){e=Or(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 Lr(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 Rr(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 zr(e){return Fr(Lr(e))}function Br(e){return Rr(Ir(e))}function Vr(e,t){let n=Ir(t),r=Ir(e),i=n.a+r.a*(1-n.a);return Fr({r:Math.round((n.r*n.a+r.r*r.a*(1-n.a))/i),g:Math.round((n.g*n.a+r.g*r.a*(1-n.a))/i),b:Math.round((n.b*n.a+r.b*r.a*(1-n.a))/i),a:i})}function Hr(e){return Ir(typeof e==`number`?Er(e):e)}function Ur(e,t,n=0){if(!(kr(e)&&kr(t)))return!1;let r=Ir(e),i=Ir(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 Wr(e,t){if(e.startsWith(`light-dark`)){let n=e.match(wr);if(!n)throw Error(`Invalid light-dark color: ${e}`);return`light-dark(${Wr(n[1],t)}, ${Wr(n[2],t)})`}return t===1?Or(e).slice(0,7):Fr({...Ir(e),a:t})}function Gr(e,t){let n=Br(e);return t===1?`#fff`:(n.l=t*(100-n.l)+n.l,zr(n))}function Kr(e,t){let n=Br(e);return t===1?`#000`:(n.s=Math.min(100,t*n.s+n.s),n.l-=t*n.l,zr(n))}function qr(e){return Nr(e)<.6?Gr(e,.9):Kr(e,.75)}let Jr=[`#4EA7F2`,`#EA6175`,`#43C5B1`,`#F4A261`,`#8481DD`,`#FFD86D`],Yr=[`#4EA7F2`,`#3188E6`,`#43C5B1`,`#00A78D`,`#EA6175`,`#CE4257`,`#F4A261`,`#F48935`,`#8481DD`,`#5752D1`,`#FFD86D`,`#FFBC2C`],Xr=[`#4EA7F2`,`#3188E6`,`#056BD9`,`#A76DBC`,`#7F4295`,`#6D2387`,`#EA6175`,`#CE4257`,`#982738`,`#43C5B1`,`#00A78D`,`#0E8270`,`#F4A261`,`#F48935`,`#BE5D10`,`#8481DD`,`#5752D1`,`#3A3580`,`#A4A8B6`,`#7E8290`,`#545B70`,`#FFD86D`,`#FFBC2C`,`#C08A16`],Zr=`#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(`.`),Qr=[`#4EA7F2`,`#43C5B1`,`#EA6175`,`#F4A261`,`#8481DD`,`#FFD86D`,`#3188E6`,`#00A78D`,`#CE4257`,`#F48935`,`#5752D1`,`#FFBC2C`],$r=[`#4EA7F2`,`#A76DBC`,`#EA6175`,`#43C5B1`,`#F4A261`,`#8481DD`,`#A4A8B6`,`#FFD86D`,`#3188E6`,`#7F4295`,`#CE4257`,`#00A78D`,`#F48935`,`#5752D1`,`#7E8290`,`#FFBC2C`,`#056BD9`,`#6D2387`,`#982738`,`#0E8270`,`#BE5D10`,`#3A3580`,`#545B70`,`#C08A16`],ei=`#4EA7F2.#A76DBC.#EA6175.#43C5B1.#F4A261.#8481DD.#A4A8B6.#FFD86D.#3188E6.#7F4295.#CE4257.#00A78D.#F48935.#5752D1.#7E8290.#FFBC2C.#056BD9.#6D2387.#982738.#0E8270.#BE5D10.#3A3580.#545B70.#C08A16.#155193.#4F1565.#791B29.#105F53.#7D380D.#26235F.#3F4250.#936A12`.split(`.`);function ti(e,t){return t[e%t.length]}function ni(e){return e<=6?Jr:e<=12?Yr:e<=24?Xr:Zr}function ri(e){return e<=6?Jr:e<=12?Qr:e<=24?$r:ei}var ii=class{preferredColors;currentColorIndex=0;palette;constructor(e,t=[]){this.preferredColors=t,this.palette=ni(e).filter(e=>!t.includes(e))}next(){return this.preferredColors?.[this.currentColorIndex]?this.preferredColors[this.currentColorIndex++]:ti(this.currentColorIndex++,this.palette)}},ai=class extends ii{constructor(e,t=[]){super(e,t),this.palette=ri(e).filter(e=>!t.includes(e))}},oi=class{availableColors;colors={};constructor(e=12){this.availableColors=new ai(e)}get(e){return this.colors[e]||(this.colors[e]=this.availableColors.next()),this.colors[e]}};let si={greys:[`#ffffff`,`#808080`,`#000000`],blues:[`#f7fbff`,`#6aaed6`,`#08306b`],reds:[`#fff5f0`,`#fb694a`,`#67000d`],greens:[`#f7fcf5`,`#73c476`,`#00441b`],oranges:[`#fff5eb`,`#fd8c3b`,`#7f2704`],purples:[`#fcfbfd`,`#9e9ac8`,`#3f007d`],viridis:[`#440154`,`#21918c`,`#fde725`],cividis:[`#00224e`,`#7d7c78`,`#fee838`],rainbow:[`#B41DB4`,`#FFFF00`,`#00FFFF`]},ci=Object.keys(si);function li(e){if(e.length<2)throw Error(`Color scale must have at least 2 points`);let t=[...e.sort((e,t)=>e.value-t.value)],n=[];for(let e=1;e<t.length;e++){let r=Hr(t[e-1].color).a,i=Hr(t[e].color).a,a=Dr(t[e-1].color),o=Dr(t[e].color);n.push({min:t[e-1].value,max:t[e].value,minColor:a,maxColor:o,minColorAlpha:r,maxColorAlpha:i,colorDiff:ui(t[e-1].value,t[e].value,a,o)})}return e=>{if(e<n[0].min)return Er(n[0].minColor,n[0].minColorAlpha);for(let t of n)if(e>=t.min&&e<=t.max)return Er(di(e,t.min,t.minColor,t.colorDiff),t.maxColorAlpha);return Er(n[n.length-1].maxColor,n[n.length-1].maxColorAlpha)}}function ui(e,t,n,r){let i=t-e,a=(n>>16)%256-(r>>16)%256,o=(n>>8)%256-(r>>8)%256,s=n%256-r%256;return[a/i,o/i,s/i]}function di(e,t,n,r){let[i,a,o]=r,s=Math.round((n>>16)%256-i*(e-t)),c=Math.round((n>>8)%256-a*(e-t)),l=Math.round(n%256-o*(e-t));return s<<16|c<<8|l}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 fi=new O(1899,11,30),pi=1440*60*1e3,mi=2e3,hi=O.now().getFullYear(),gi=O.now().getMonth(),_i=O.fromTimestamp(0).getTime()-fi.getTime(),vi=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,yi=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,bi=Dt.join(``),xi=RegExp(`\/|-|${Dt.join(`|`)}`),Si=RegExp(`^(\\d{1,4})[\/${bi}\-](\\d{1,4})([\/${bi}\-](\\d{1,4}))?$`),Ci=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function wi(e,t){switch(typeof e){case`number`:return e;case`string`:return Ti(e,t)?Di(e,t)?.value:!e||isNaN(Number(e))?void 0:Number(e);default:return}}function Ti(e,t){return Di(e,t)!==null}let Ei=new Map;function Di(e,t){return Ei.has(t)||Ei.set(t,new Map),Ei.get(t).has(e)||Ei.get(t).set(e,Oi(e,t)),Ei.get(t).get(e)}function Oi(e,t){e=e.trim();let n=null,r=e.match(Ci);if(r){if(n=Ii(r[0]),n===null)return null;e=e.replace(r[0],``).trim()}let i=null,a=ki(e,t);if(a){let t=a.dateString.match(xi)[0];if(i=ji(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 ki(e,t){let n=e.match(Si);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=Ai(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 Ai(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 ji(e,t){let{year:n,month:r,day:i}=e,a=Pi(r),o=Fi(i),s=Ni(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()-fi.getTime(),f=Mi(e,t,c,l);return{value:Math.round(d/pi),format:f,jsDate:u}}function Mi(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(C).join(t);case`ymd`:return[i,a,o].filter(C).join(t);case`dmy`:return[o,a,i].filter(C).join(t)}}function Ni(e){if(!e)return hi;let t=Number(e);switch(e.length){case 1:return mi+t;case 2:return mi+(mi+t>hi+10?-100:0)+t;case 3:case 4:return t}return null}function Pi(e){if(!e)return gi;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 Ii(e){if(e=e.trim(),Ci.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 Li(e){let t=Math.trunc(e),n=O.fromTimestamp(t*pi-_i),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 Ri(e){return Math.round(zi(e))}function zi(e){return(e.getTime()-fi.getTime())/pi}function Bi(e){return new O(e.getFullYear(),e.getMonth()+1,0).getDate()}function Vi(e){return Bi(e)===e.getDate()}function Hi(e,t,n){let r=e.getFullYear(),i=e.getMonth(),a=e.getDate(),o=new O(r,i+t,1);return n&&a===Bi(e)||a>Bi(o)?o.setDate(Bi(o)):o.setDate(a),o}function Ui(e){let t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function Wi(e,t,n){if(e===t)return 0;if(e>t){let n=t;t=e,e=n}let r=Li(e),i=Li(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===(Ui(l)?29:28)&&(a=30,c===1&&o===(Ui(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+=Ui(n)?366:365;n=t/e}else r?Ui(l)&&(n=366):(Ui(l)&&s<2&&(n=366),Ui(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 Gi(e,t){let n=(t.getFullYear()-e.getFullYear())*12+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?n-1:n}function Ki(e,t){let n=e.getTime(),r=t.getTime();return Math.floor((r-n)/pi)}function qi(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 Ji(e,t){return Wi(e,t,1)<1}function Yi(e,t){return Math.trunc(e)===Math.trunc(t)}function Xi(e,t,n){return t>n?Xi(e,n,t):(e=Math.trunc(e),t=Math.trunc(t),n=Math.trunc(n),e>=t&&e<=n)}function Zi(e,t){return Math.trunc(e)<Math.trunc(t)}function Qi(e,t){return Math.trunc(e)<=Math.trunc(t)}function $i(e,t){return Math.trunc(e)>Math.trunc(t)}function ea(e,t){return Math.trunc(e)>=Math.trunc(t)}let ta=At(function(e){return e=qe(e),RegExp(`(?:^-?\\d+(?:${e}?\\d*(?:(E|e)(\\+|-)?\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)}),na=At(function(e){let t=qe(e.decimalSeparator),n=`(?:\\d+(?:${qe(e.thousandsSeparator||``)}\\d{3,})*(?:${t}\\d*)?)`,r=`(?:${t}\\d+)`,i=`(?:\\s*`+n+`|`+r+`)(?:(e|E)(?:\\+|-)?(?:[0-9]|[0-9][0-9]|[12][0-9]{2}|30[0-7]))?(?:\\s*%)?`,a=`^(?:(?:`+[`(?:\\s*-)?(?:\\s*[\\$€])?`+i,`(?:\\s*-)?`+i+`(?:\\s*[\\$€])?`,`(?:\\s*[\\$€])?(?:\\s*-)?`+i].join(`)|(?:`)+`))$`;return new RegExp(a,`i`)});function ra(e,t){return e?na(t).test(e.trim()):!1}let ia=At(function(e){return RegExp(`[\$€${qe(e.thousandsSeparator||``)}]`,`g`)});function aa(e,t){e=e.replace(ia(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 oa(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)}let sa=e=>e,ca=()=>!1,la=sa,ua=ca;function da(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 fa(e,t=()=>!0){la=e,ua=t}function pa(){la===sa&&ua===ca&&(ua=()=>!0)}let k=function(e,...t){return ua()?da(la(e),...t):new ma(e,t)};var ma=class extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){let e=super.valueOf();return ua()?da(la(e),...this.values):da(e,...this.values)}toString(){return this.valueOf()}};let A={NotAvailable:`#N/A`,InvalidReference:`#REF`,BadExpression:`#BAD_EXPR`,CircularDependency:`#CYCLE`,UnknownFunction:`#NAME?`,DivisionByZero:`#DIV/0!`,InvalidNumber:`#NUM!`,SpilledBlocked:`#SPILL!`,GenericError:`#ERROR`,NullError:`#NULL!`},ha=new Set(Object.values(A));var j=class{message;value;constructor(e=k(`Error`),t=A.GenericError){this.message=e,this.value=t,this.message=e.toString()}},ga=class extends j{constructor(e=k(`Invalid expression`)){super(e,A.BadExpression)}},_a=class extends j{constructor(e=k(`Circular reference`)){super(e,A.CircularDependency)}},va=class extends j{constructor(e=k(`Invalid reference`)){super(e,A.InvalidReference)}},ya=class extends j{constructor(e=k(`Data not available`)){super(e,A.NotAvailable)}},ba=class extends j{constructor(e=k(`Unknown function`)){super(e,A.UnknownFunction)}},xa=class extends j{errorOriginPosition;constructor(e=k(`Spill range is not empty`),t){super(e,A.SpilledBlocked),this.errorOriginPosition=t}},Sa=class extends j{constructor(e=k(`Division by zero`)){super(e,A.DivisionByZero)}},Ca=class extends j{constructor(e=k(`Number too large`)){super(e,A.InvalidNumber)}};let wa=[`thin`,`medium`,`thick`,`dashed`,`dotted`];function Ta(e){return Array.isArray(e)&&Array.isArray(e[0])}let Ea=[`number`,`string`,`boolean`,`undefined`];function Da(e){if(e!==void 0)return Ta(e)?e[0][0]?.format:e.format}function M(e){return typeof e==`string`&&ha.has(e)}function Oa(e){return{value:A.NotAvailable,message:k(`Did not find value '%s' in [[FUNCTION_NAME]] evaluation.`,P(e))}}let ka=e=>k(`The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.`,e),Aa=(e,t,n)=>k(`The function [[FUNCTION_NAME]] expects a number value between %s and %s inclusive, but receives %s.`,e.toString(),t.toString(),n.toString()),ja=(e,t)=>k(`The function [[FUNCTION_NAME]] has an argument with value '%s'. It should be one of: %s.`,t,e.map(e=>`'${e}'`).join(`, `));function N(e,t){let n=Ba(e);switch(typeof n){case`number`:return n;case`boolean`:return+!!n;case`string`:if(ra(n,t)||n===``)return aa(n,t);let e=Di(n,t);if(e)return e.value;throw new j(ka(n));default:return 0}}function Ma(e,t){try{return N(e,t)}catch{return}}function Na(e,t){return L(e).map(e=>e.map(e=>{if(typeof e.value!=`number`){let n=``;throw typeof e==`object`?n=k(`Function [[FUNCTION_NAME]] expects number values for %s, but got an empty value.`,t):typeof e==`string`?n=k(`Function [[FUNCTION_NAME]] expects number values for %s, but got a string.`,t):typeof e==`boolean`&&(n=k(`Function [[FUNCTION_NAME]] expects number values for %s, but got a boolean.`,t)),new j(n)}return e.value}))}function Pa(e,t){let n=Ba(e);if(n===``)throw new j(ka(n));return N(n,t)}function Fa(e,t){return Math.trunc(N(e,t))}function Ia(e,t){return Math.trunc(Pa(e,t))}function P(e){let t=Ba(e);switch(typeof t){case`string`:return t;case`number`:return t.toString();case`boolean`:return t?`TRUE`:`FALSE`;default:return``}}let La=At(function(e){return e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``)}),Ra=e=>k(`The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a boolean.`,e);function F(e){let t=Ba(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 j(Ra(t))}else return!1;case`number`:return!!t;default:return!1}}function za(e){let t=Ba(e);if(t===``)throw new j(Ra(t));return F(t)}function I(e,t){return Li(N(Ba(e),t))}function Ba(e){if(typeof e==`object`&&e&&`value`in e){if(M(e.value))throw e;return e.value}if(M(e))throw new j(``,e);return e}function Va(e,t,n){for(let r of e)if(Ta(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 Ha(e,t){Va(e,e=>{if(M(e.value))throw e;t(e)},e=>{if(M(e?.value))throw e;t(e)})}function Ua(e,t,n){Va(e,e=>{if(typeof e?.value==`number`&&t(e),M(e?.value))throw e},e=>{t({value:Pa(e,n),format:e?.format})})}function Wa(e,t,n,r,i=`rowFirst`){let a=r;for(let r of e)if(Ta(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 Ga(e,t,n,r=`rowFirst`){return Wa(e,t,t,n,r)}function Ka(e,t,n,r){return Wa(e,(e,n)=>{let r=n?.value;if(typeof r==`number`)return t(e,r);if(M(r))throw n;return e},(e,n)=>t(e,Pa(n,r)),n)}function qa(e,t,n,r){return Wa(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,N(i,r));if(M(i))throw n;return t(e,0)}return e},(e,n)=>t(e,N(n,r)),n)}function Ja(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 Ya(e,t){return e.length===0?[]:Ja(e.length,e[0].length,(n,r)=>t(e[n][r]))}function Xa(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 Za(e){return e.length?Ja(e[0].length,e.length,(t,n)=>e[n][t]):[]}function Qa(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(Ta(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 ya(k(`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]=Ta(r)?r[0][0]:r}}return p}function $a(e,t,n){for(let r of e)if(Ta(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 eo(e,t){return $a(e,e=>{let n=e?.value;if(typeof n==`boolean`)return t(n);if(typeof n==`number`)return t(!!n);if(M(n))throw e;return!0},e=>e!==void 0&&e.value!==null?t(za(e)):!0)}function to(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)),ra(r,t)||Ti(r,t)?r=N(r,t):(r===`TRUE`||r===`FALSE`)&&(r=F(r)),{operator:n,operand:r}}let no=At(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 ro(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`&&(ra(e,n)||Ti(e,n))?N(e,n)===i:e===i;if(r===`<>`||r===`=`){let t;return t=typeof e==typeof i?e===``&&i===``?!0:typeof e==`string`&&typeof i==`string`?no(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 io(e,t,n,r=!1){let i=e.length;if(i%2==1)throw new j(k(`Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs.`));let a=L(e[0]),o=a.length,s=a[0].length,c=[];for(let t=0;t<i-1;t+=2){let i=L(e[t]);if(i.length!==o||i[0].length!==s)throw new j(k(`Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension`));let a=to(P(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=L(e[t])[r][a].value,s=c[t/2];if(o=ro(i??void 0,s,n),!o)break}o&&t(r,a)}}function ao(e,t,n,r,i,a){if(t===void 0||t.value===null)return-1;if(M(t.value))throw t;let o=co(t.value),s=typeof o,c,l,u=0,d=i-1,f,p,m,h,g=r===`desc`?t=>co(a(e,i-t-1)):t=>co(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 oo(e,t,n,r,i,a,o=!1){if(t===void 0||t.value===null)return-1;if(M(t.value))throw t;let s=co(t.value),c=o?(e,t)=>co(i(e,r-t-1)):(e,t)=>co(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`||n===`wildcard`)return-1}let u=so(e,s,n,r,c);return o&&u!==-1?r-u-1:u}function so(e,t,n,r,i){let a=n=>i(e,n)===t;if(n===`wildcard`&&typeof t==`string`&&(t.includes(`*`)||t.includes(`?`))){let n=no(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&&lo(t,r)>=0||lo(t,r)>=0&&lo(r,o)>0)&&(o=r,s=n),r===t}),n===`nextGreater`&&(a=n=>{let r=i(e,n);return(!o&&lo(t,r)<=0||lo(t,r)<=0&&lo(r,o)<0)&&(o=r,s=n),r===t});for(let e=0;e<r;e++)if(a(e))return e;return s}function co(e){return typeof e==`string`?La(e):e}function lo(e,t){let n=Ea.indexOf(typeof e)-Ea.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 L(e){return e===void 0?[[]]:Ta(e)?e:[[e]]}function uo(e,t){return Ga(e,(e,n)=>(e.push(t(n)),e),[],`rowFirst`)}function fo(e){if(e===void 0)return!1;let{value:t}=e;return!(t===null||t===``)}let po=k(`[[FUNCTION_NAME]] has no valid input data.`);function mo(e){return k(`[[FUNCTION_NAME]] expects the provided values of %(argName)s to be a non-empty matrix.`,{argName:e})}let ho=[{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:`;`}],R=ho[0];function go(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=To(t)||_o(t)||yo(t)||bo(t)||So(t)||Co(t)||wo(t)||Do(t)||xo(t)||Oo(t);if(!e)throw Error(`Unknown token at `+t.remaining());r.push(e)}return n}function _o(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 vo=new Set(`$+-/():!^&~{}<>= `);function yo(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 vo.has(e.current)?{type:`CHAR`,value:e.shift()}:null}function bo(e){return e.current===`,`?(e.shift(),{type:`THOUSANDS_SEPARATOR`,value:`,`}):null}function xo(e){return e.current===`@`?(e.shift(),{type:`TEXT_PLACEHOLDER`,value:`@`}):null}function So(e){return e.current===`.`?(e.shift(),{type:`DECIMAL_POINT`,value:`.`}):null}function Co(e){return e.current===`%`?(e.shift(),{type:`PERCENT`,value:`%`}):null}function wo(e){return e.current===`e`?(e.shift(),{type:`SCIENTIFIC`,value:`e`}):null}function To(e){if(e.current===`0`||e.current===`#`){let t=e.current;return e.shift(),{type:`DIGIT`,value:t}}return null}let Eo=new Set(`dmqyhsa`);function Do(e){if(!Eo.has(e.current))return null;let t=e.current,n=``;for(;e.current===t;)n+=e.shift();return{type:`DATE_PART`,value:n}}function Oo(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 ko={};function Ao(e){let t=ko[e];return t===void 0&&(t=jo(e),ko[e]=t),t}function jo(e){let t=go(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=Io(t[0])||Fo(t[0])||Lo(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=Io(t[1])||Fo(t[1]);if(t[1]?.length&&!r)throw Error(`Invalid second format part of: `+e);let i=Io(t[2])||Fo(t[2]);if(t[2]?.length&&!i)throw Error(`Invalid third format part of: `+e);let a=Lo(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 Mo(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 No(e){return e.every(e=>e.type===`DIGIT`||e.type===`DECIMAL_POINT`||e.type===`THOUSANDS_SEPARATOR`||e.type===`PERCENT`||e.type===`SCIENTIFIC`||e.type===`STRING`||e.type===`CHAR`||e.type===`REPEATED_CHAR`)}function Po(e){return e.every(e=>e.type===`STRING`||e.type===`TEXT_PLACEHOLDER`||e.type===`CHAR`||e.type===`REPEATED_CHAR`)}function Fo(e){if(!e||!No(e))return;let t=[],n,r=t,i=0,a=!1,o=0,s=e.findLastIndex(e=>e.type===`DIGIT`),c=!1,l=0;for(let u=0;u<e.length;u++){let d=e[u];switch(d.type){case`DIGIT`:r===t?r.push(d):l<20&&(r.push(d),l++);break;case`DECIMAL_POINT`:if(r===t)n=[],r=n;else throw Error(`Multiple decimal points in a number format`);break;case`SCIENTIFIC`:a=!0;break;case`REPEATED_CHAR`:case`CHAR`:case`STRING`:r.push(d);break;case`PERCENT`:i++,r.push(d);break;case`THOUSANDS_SEPARATOR`:u-1===s?(o+=1,s++,r.push(d)):e[u+1]?.type===`DIGIT`&&e[u-1]?.type===`DIGIT`?(r===t&&(c=!0),r.push(d)):r.push({type:`CHAR`,value:`,`});break}}return{type:`number`,integerPart:t,decimalPart:n,percentSymbols:i,scientific:a,thousandsSeparator:c,magnitude:o}}function Io(e){let t=e&&Mo(e)?{type:`date`,tokens:e}:void 0;if(!(!t||!e?.some(e=>e.type===`DATE_PART`))){if(t.tokens.length&&t.tokens.every(e=>e.type===`DATE_PART`&&e.value===`a`))throw Error(`Invalid date format`);return{type:`date`,tokens:Ro(t.tokens.map(e=>e.type===`THOUSANDS_SEPARATOR`||e.type===`DECIMAL_POINT`?{type:`CHAR`,value:e.value}:e))}}}function Lo(e){return e&&Po(e)?{type:`text`,tokens:e}:void 0}function Ro(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 zo(e){return[Bo(e.positive),Bo(e.negative),Bo(e.zero),Bo(e.text)].filter(C).join(`;`)}function Bo(e){if(!e)return;let t=``,n=e.type===`number`?Vo(e):e.tokens;for(let e of n)switch(e.type){case`STRING`:t+=`[$${e.value}]`;break;case`CHAR`:t+=Ho(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 Vo(e){let t=[...e.integerPart];return e.decimalPart&&(t.push({type:`DECIMAL_POINT`,value:`.`}),t.push(...e.decimalPart)),e.scientific&&t.push({type:`SCIENTIFIC`,value:`e`}),t}function Ho(e){return!vo.has(e)}let Uo=`REPEATED_CHAR_PLACEHOLDER_`,Wo={0:k(`January`),1:k(`February`),2:k(`March`),3:k(`April`),4:k(`May`),5:k(`June`),6:k(`July`),7:k(`August`),8:k(`September`),9:k(`October`),10:k(`November`),11:k(`December`)},Go={0:k(`Sunday`),1:k(`Monday`),2:k(`Tuesday`),3:k(`Wednesday`),4:k(`Thursday`),5:k(`Friday`),6:k(`Saturday`)};function Ko(e,t,n,r=!1){return r?ys({value:e,format:t},n):z(e,{format:t,locale:n})}function z(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=Ao(t),i=qo(e,n).format;return!i||i.type!==`text`?e:Jo(e,i,r)}case`number`:t||=us(e);let i=Ao(t),{format:a,isNegativeFormat:o}=qo(e,i);if(!a)return e.toString();if(a.type===`text`)return Jo(e.toString(),a,r);if(o&&(e=Math.abs(e)),a.type===`date`)return Yo(ss(e,a),r);let s=e<0,c=Yo(Xo(Math.abs(e),a,n),r);return s?`-`+c:c;case`object`:return``}}function qo(e,t){let n,r=!1;switch(typeof e){case`number`:e<0&&t.negative?(n=t.negative,r=!0):n=e===0&&t.zero?t.zero:t.positive;break;case`string`:let i=t.text||t.positive;i.type===`text`&&(n=i);break}return{format:n,isNegativeFormat:r}}function Jo(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+=Uo+n.value;break}return Yo(r,n)}function Yo(e,t){let n=e.indexOf(Uo);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 Xo(e,t,n){if(!t.integerPart.length&&!t.decimalPart?.length)return``;if(e===1/0)return`∞`+(t.percentSymbols?`%`:``);let r=Math.floor(Math.log10(Math.abs(e)));r===-1/0&&(r=0),t.scientific&&(e/=10**r);let i=t.percentSymbols*2-t.magnitude*3;e*=10**i;let a=0;t.decimalPart!==void 0&&(a=t.decimalPart.filter(e=>e.type===`DIGIT`).length);let{integerDigits:o,decimalDigits:s}=es(Math.abs(e),a),c=!!t.decimalPart?.some(e=>e.type===`DIGIT`),l=Zo(o,t,t.thousandsSeparator?n.thousandsSeparator:void 0,c);if(t.decimalPart!==void 0&&(l+=n.decimalSeparator+Qo(s||``,t)),t.scientific){let e=Math.abs(r).toString().padStart(2,`0`);l+=`e`+(r>=0?`+`:`-`)+e}return l}function Zo(e,t,n,r){let i=t.integerPart;r&&!i.some(e=>e.type===`DIGIT`)&&(i=[...i,{type:`DIGIT`,value:`#`}]),e===`0`&&(e=``);let a=``,o=i.findIndex(e=>e.type===`DIGIT`),s=e.length-1;function c(t,r){if(r===`0`&&(t||=`0`),!t)return;let i=e.length-1-s;a=n&&i>0&&i%3==0?t+n+a:t+a}for(let t=i.length-1;t>=0;t--){let n=i[t];switch(n.type){case`DIGIT`:let r=e[s];if(c(r,n.value),s--,o===t)for(;s>=0;)c(e[s],`0`),s--;break;case`THOUSANDS_SEPARATOR`:break;case`REPEATED_CHAR`:a=Uo+n.value+a;break;default:a=n.value+a;break}}return a}function Qo(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+=Uo+i.value;break;default:n+=i.value;break}return n}let $o=[];function es(e,t=20){let n=e.toString();if(n.includes(`e`))return is(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}=rs(a,t);a=n,e!==`0`&&(i=(Number(i)+Number(e)).toString())}return{integerDigits:i,decimalDigits:ts(a||``)}}function ts(e){let t=e.length-1;for(;t>=0&&e[t]===`0`;)t--;return e.slice(0,t+1)||void 0}let ns=/^0+/;function rs(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(ns)?.[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 is(e,t=20){let n=$o[t];n||(n=new Intl.NumberFormat(`en-US`,{maximumFractionDigits:t,useGrouping:!1}),$o[t]=n);let[r,i]=n.format(e).split(`.`);return{integerDigits:r,decimalDigits:i}}function as(e,t){let{integerDigits:n,decimalDigits:r}=es(e,20);return r?n+t+r:n}let os=At(function(e){if(!e)return!1;try{return Ao(e).positive.type===`date`}catch{return!1}});function ss(e,t){let n=Li(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+=cs(n,e.value,r);break;case`REPEATED_CHAR`:i+=Uo+e.value;break;default:i+=e.value;break}return i}function cs(e,t,n){switch(t){case`d`:return e.getDate();case`dd`:return e.getDate().toString().padStart(2,`0`);case`ddd`:return Go[e.getDay()].slice(0,3);case`dddd`:return Go[e.getDay()].toString();case`m`:return e.getMonth()+1;case`mm`:return String(e.getMonth()+1).padStart(2,`0`);case`mmm`:return Wo[e.getMonth()].slice(0,3);case`mmmm`:return Wo[e.getMonth()].toString();case`mmmmm`:return Wo[e.getMonth()].slice(0,1);case`qq`:return k(`Q%(quarter)s`,{quarter:e.getQuarter()}).toString();case`qqqq`:return k(`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()-fi.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 ls=At(function(e){return RegExp(`[0-9]+${qe(e.decimalSeparator)}[0-9]`)});function us(e){let{integerDigits:t,decimalDigits:n}=es(e);if(!n)return`0`;let r=t.replace(`-`,``).length;if(r+2>11)return`0`;let i=11-r-1;return{decimalDigits:n}=es(e,Math.min(i,n.length)),n?`0.`+`0`.repeat(n.length):`0`}function ds(e,t){if(Ti(e,t))return Di(e,t).format}function fs(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 ps(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),gs(o,n,a)}function ms(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),[hs(o,n,` ${a} `),hs(o,n,`(${a})`),hs(o,n,` - `)].join(`;`)}function hs(e,t,n){let r=`[$${e}]`;return t===`before`?r+`* `+n:n+`* `+r}function gs(e,t,n){let r=`[$${e}]`;return t===`before`?r+n:n+r}function _s(e){let t=Ao(e);return zo({positive:vs(t.positive),negative:t.negative?vs(t.negative):void 0,zero:t.zero?vs(t.zero):void 0,text:t.text})}function vs(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 ys({value:e,format:t},n){let r=Ma(e,n);if(r===void 0)return``;let i=t;if(Math.abs(r)<1e3){let e=r%1!=0;i=!t&&e?Math.abs(r)<.01?`0.00e`:`0.##`:t}else i=bs({value:e,format:t},void 0,n);return z(e,{format:i,locale:n})}function bs(e,t,n){let r=0;try{r=Math.abs(N(e?.value,n))}catch{return``}let i=e?.format;if(t!==void 0)switch(t?.value){case`k`:return xs(i,1,`k`);case`m`:return xs(i,2,`m`);case`b`:return xs(i,3,`b`);default:throw new j(k(`The formatting unit should be 'k', 'm' or 'b'.`))}return r<1e5?xs(i,0,``):r<1e8?xs(i,1,`k`):r<1e11?xs(i,2,`m`):r<0x5af3107a4000?xs(i,3,`b`):`0.00e`}function xs(e,t,n){let r=Ao(e||`#,##0`);return zo({positive:Ss(r.positive,t,n),negative:r.negative?Ss(r.negative,t,n):void 0,zero:r.zero?Ss(r.zero,t,n):void 0,text:r.text})}function Ss(e,t,n){if(e.type!==`number`||e.scientific)return e;let r=vs(e),i={type:`STRING`,value:n},a=[...r.integerPart],o=a.findLastIndex(e=>e.type===`DIGIT`);if(o===-1)return e;for(;a[o+1]?.type===`THOUSANDS_SEPARATOR`;)a=jt(a,[o+1]);let s=a[o+1];a=s?.type===`STRING`&&[`m`,`k`,`b`].includes(s.value)?Nt(a,i,o+1):Mt(a,[i],o+1),t>0&&(a=Mt(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 Cs(e,t){let n=Ao(e);return zo(Ao(zo({positive:ws(n.positive,t),negative:n.negative?ws(n.negative,t):void 0,zero:n.zero?ws(n.zero,t):void 0,text:n.text})))}function ws(e,t){return e.type===`number`?t>0?Es(e,t):Ts(e,Math.abs(t)):e}function Ts(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=jt(n,r),n.some(e=>e.type===`DIGIT`)?{...e,decimalPart:n}:{...e,decimalPart:void 0,integerPart:[...e.integerPart,...n]}}function Es(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=S(0,t).map(()=>({type:`DIGIT`,value:`0`})),a=r.findLastIndex(e=>e.type===`DIGIT`);return r=a===-1?[...i,...r]:Mt(r,i,a+1),{...e,decimalPart:r,integerPart:n}}function Ds(e){let t=Ao(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 Os(e){if(!e)return!1;try{return Ao(e).positive.type===`text`}catch{return!1}}function ks(e,t){if(!t)return!1;try{let{format:n}=qo(e,Ao(t));if(n?.type===`text`||n?.type===`date`)return n.tokens.some(e=>e.type===`REPEATED_CHAR`);if(n?.type===`number`)return n.integerPart.some(e=>e.type===`REPEATED_CHAR`)||(n.decimalPart?n.decimalPart.some(e=>e.type===`REPEATED_CHAR`):!1)}catch{}return!1}function As(e){try{return z(0,{format:e,locale:R}),!0}catch{return!1}}function js(e){return go(e).length}var B=class{content={};add(e,t){if(e in this.content)throw Error(`${e} is already present in this registry!`);return this.replace(e,t)}replace(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]}};function Ms(e){return`sheetId`in e}function Ns(e){return`dimension`in e&&`sheetId`in e&&`elements`in e}function Ps(e){return`target`in e&&`sheetId`in e}function Fs(e){return`ranges`in e}function Is(e){return`col`in e&&`row`in e&&`sheetId`in e}function Ls(e){return`sheetId`in e&&`zone`in e}let Rs=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`]),zs=new Set([`EVALUATE_CELLS`,`EVALUATE_CHARTS`,`UPDATE_CELL`,`UNHIDE_COLUMNS_ROWS`,`HIDE_COLUMNS_ROWS`,`GROUP_HEADERS`,`UNGROUP_HEADERS`,`FOLD_ALL_HEADER_GROUPS`,`FOLD_HEADER_GROUP`,`FOLD_HEADER_GROUPS_IN_ZONE`,`UNFOLD_ALL_HEADER_GROUPS`,`UNFOLD_HEADER_GROUP`,`UNFOLD_HEADER_GROUPS_IN_ZONE`,`UPDATE_TABLE`,`UPDATE_FILTER`,`UNDO`,`REDO`]),Bs=new Set([`MOVE_RANGES`]),Vs=new Set([`EVALUATE_CELLS`,`ADD_CONDITIONAL_FORMAT`,`REMOVE_CONDITIONAL_FORMAT`,`CHANGE_CONDITIONAL_FORMAT_PRIORITY`]),Hs=new Set([`AUTOFILL_CELL`,`SET_BORDER`,`SET_ZONE_BORDERS`,`SET_BORDERS_ON_TARGET`]),Us=new Set([`UNHIDE_COLUMNS_ROWS`,`HIDE_COLUMNS_ROWS`,`GROUP_HEADERS`,`UNGROUP_HEADERS`,`FOLD_ALL_HEADER_GROUPS`,`FOLD_HEADER_GROUP`,`FOLD_HEADER_GROUPS_IN_ZONE`,`UNFOLD_ALL_HEADER_GROUPS`,`UNFOLD_HEADER_GROUP`,`UNFOLD_HEADER_GROUPS_IN_ZONE`,`UPDATE_TABLE`,`UPDATE_FILTER`]),Ws=new Set([`START`,`ACTIVATE_SHEET`,`COPY`,`RESIZE_SHEETVIEW`,`SET_VIEWPORT_OFFSET`,`SET_ZOOM`,`EVALUATE_CELLS`,`EVALUATE_CHARTS`,`SET_FORMULA_VISIBILITY`,`UPDATE_FILTER`,`UPDATE_CHART`,`UPDATE_CAROUSEL_ACTIVE_ITEM`,`UPDATE_PIVOT`]),Gs=new Set(`LOCK_SHEET.UNLOCK_SHEET.MOVE_SHEET.DUPLICATE_SHEET.CREATE_SHEET.HIDE_SHEET.SHOW_SHEET.COPY.START.SCROLL_TO_CELL.ACTIVATE_SHEET.RESIZE_SHEETVIEW.SET_VIEWPORT_OFFSET.SET_FORMULA_VISIBILITY.SELECT_FIGURE.EVALUATE_CHARTS.EVALUATE_CELLS.REQUEST_UNDO.REQUEST_REDO.REPLACE_SEARCH.SET_ZOOM.UPDATE_CAROUSEL_ACTIVE_ITEM.DUPLICATE_PIVOT_IN_NEW_SHEET.UPDATE_FILTER.ACTIVATE_NEXT_SHEET.ACTIVATE_PREVIOUS_SHEET.SCROLL_TO_CELL.SHIFT_VIEWPORT_DOWN.SHIFT_VIEWPORT_UP`.split(`.`)),Ks=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.LOCK_SHEET.UNLOCK_SHEET.MOVE_RANGES.ADD_CONDITIONAL_FORMAT.REMOVE_CONDITIONAL_FORMAT.CHANGE_CONDITIONAL_FORMAT_PRIORITY.CREATE_FIGURE.DELETE_FIGURE.UPDATE_FIGURE.CREATE_CAROUSEL.UPDATE_CAROUSEL.SET_FORMATTING.CLEAR_FORMATTING.SET_BORDER.SET_ZONE_BORDERS.SET_BORDERS_ON_TARGET.CREATE_CHART.UPDATE_CHART.DELETE_CHART.CREATE_TABLE.REMOVE_TABLE.UPDATE_TABLE.CREATE_TABLE_STYLE.REMOVE_TABLE_STYLE.CREATE_IMAGE.GROUP_HEADERS.UNGROUP_HEADERS.UNFOLD_HEADER_GROUP.FOLD_HEADER_GROUP.FOLD_ALL_HEADER_GROUPS.UNFOLD_ALL_HEADER_GROUPS.UNFOLD_HEADER_GROUPS_IN_ZONE.FOLD_HEADER_GROUPS_IN_ZONE.ADD_DATA_VALIDATION_RULE.REMOVE_DATA_VALIDATION_RULE.UPDATE_LOCALE.ADD_PIVOT.UPDATE_PIVOT.INSERT_PIVOT.RENAME_PIVOT.REMOVE_PIVOT.DUPLICATE_PIVOT`.split(`.`));function qs(e){return Ks.has(e.type)}function Js(e){return Ws.has(e.type)}var Ys=class{reasons;constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter(e=>e!==`Success`)}static get Success(){return Xs}get isSuccessful(){return this.reasons.length===0}isCancelledBecause(e){return this.reasons.includes(e)}};let Xs=new Ys,Zs=function(e){return e.Success=`Success`,e.CancelledForUnknownReason=`CancelledForUnknownReason`,e.WillRemoveExistingMerge=`WillRemoveExistingMerge`,e.CannotMoveTableHeader=`CannotMoveTableHeader`,e.MergeIsDestructive=`MergeIsDestructive`,e.CellIsMerged=`CellIsMerged`,e.InvalidTarget=`InvalidTarget`,e.EmptyUndoStack=`EmptyUndoStack`,e.EmptyRedoStack=`EmptyRedoStack`,e.NotEnoughElements=`NotEnoughElements`,e.NotEnoughSheets=`NotEnoughSheets`,e.MissingSheetName=`MissingSheetName`,e.UnchangedSheetName=`UnchangedSheetName`,e.DuplicatedSheetName=`DuplicatedSheetName`,e.DuplicatedSheetId=`DuplicatedSheetId`,e.ForbiddenCharactersInSheetName=`ForbiddenCharactersInSheetName`,e.WrongSheetMove=`WrongSheetMove`,e.WrongSheetPosition=`WrongSheetPosition`,e.InvalidAnchorZone=`InvalidAnchorZone`,e.SelectionOutOfBound=`SelectionOutOfBound`,e.TargetOutOfSheet=`TargetOutOfSheet`,e.WrongCutSelection=`WrongCutSelection`,e.WrongPasteSelection=`WrongPasteSelection`,e.WrongPasteOption=`WrongPasteOption`,e.WrongFigurePasteOption=`WrongFigurePasteOption`,e.EmptyClipboard=`EmptyClipboard`,e.EmptyRange=`EmptyRange`,e.EmptyTarget=`EmptyTarget`,e.InvalidRange=`InvalidRange`,e.InvalidZones=`InvalidZones`,e.InvalidSheetId=`InvalidSheetId`,e.InvalidCellId=`InvalidCellId`,e.InvalidFigureId=`InvalidFigureId`,e.InputAlreadyFocused=`InputAlreadyFocused`,e.MaximumRangesReached=`MaximumRangesReached`,e.MinimumRangesReached=`MinimumRangesReached`,e.InvalidChartDefinition=`InvalidChartDefinition`,e.InvalidDataSet=`InvalidDataSet`,e.InvalidLabelRange=`InvalidLabelRange`,e.InvalidScorecardKeyValue=`InvalidScorecardKeyValue`,e.InvalidScorecardBaseline=`InvalidScorecardBaseline`,e.InvalidGaugeDataRange=`InvalidGaugeDataRange`,e.EmptyGaugeRangeMin=`EmptyGaugeRangeMin`,e.GaugeRangeMinNaN=`GaugeRangeMinNaN`,e.EmptyGaugeRangeMax=`EmptyGaugeRangeMax`,e.GaugeRangeMaxNaN=`GaugeRangeMaxNaN`,e.GaugeLowerInflectionPointNaN=`GaugeLowerInflectionPointNaN`,e.GaugeUpperInflectionPointNaN=`GaugeUpperInflectionPointNaN`,e.InvalidAutofillSelection=`InvalidAutofillSelection`,e.MinBiggerThanMax=`MinBiggerThanMax`,e.LowerBiggerThanUpper=`LowerBiggerThanUpper`,e.MidBiggerThanMax=`MidBiggerThanMax`,e.MinBiggerThanMid=`MinBiggerThanMid`,e.FirstArgMissing=`FirstArgMissing`,e.SecondArgMissing=`SecondArgMissing`,e.MinNaN=`MinNaN`,e.MidNaN=`MidNaN`,e.MaxNaN=`MaxNaN`,e.ValueUpperInflectionNaN=`ValueUpperInflectionNaN`,e.ValueLowerInflectionNaN=`ValueLowerInflectionNaN`,e.MinInvalidFormula=`MinInvalidFormula`,e.MidInvalidFormula=`MidInvalidFormula`,e.MaxInvalidFormula=`MaxInvalidFormula`,e.ValueUpperInvalidFormula=`ValueUpperInvalidFormula`,e.ValueLowerInvalidFormula=`ValueLowerInvalidFormula`,e.InvalidSortAnchor=`InvalidSortAnchor`,e.InvalidSortZone=`InvalidSortZone`,e.SortZoneWithArrayFormulas=`SortZoneWithArrayFormulas`,e.WaitingSessionConfirmation=`WaitingSessionConfirmation`,e.MergeOverlap=`MergeOverlap`,e.TooManyHiddenElements=`TooManyHiddenElements`,e.Readonly=`Readonly`,e.InvalidViewportSize=`InvalidViewportSize`,e.InvalidScrollingDirection=`InvalidScrollingDirection`,e.ViewportScrollLimitsReached=`ViewportScrollLimitsReached`,e.FigureDoesNotExist=`FigureDoesNotExist`,e.InvalidConditionalFormatId=`InvalidConditionalFormatId`,e.InvalidConditionalFormatType=`InvalidConditionalFormatType`,e.InvalidCellPopover=`InvalidCellPopover`,e.EmptySelectedRange=`EmptySelectedRange`,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.PivotIdTaken=`PivotIdTaken`,e.PivotInError=`PivotInError`,e.EmptyName=`EmptyName`,e.ValueCellIsInvalidFormula=`ValueCellIsInvalidFormula`,e.InvalidDefinition=`InvalidDefinition`,e.InvalidColor=`InvalidColor`,e.InvalidPivotDataSet=`InvalidPivotDataSet`,e.InvalidPivotCustomField=`InvalidPivotCustomField`,e.MissingFigureArguments=`MissingFigureArguments`,e.InvalidCarouselItem=`InvalidCarouselItem`,e.SheetLocked=`SheetLocked`,e.InvalidZoomLevel=`InvalidZoomLevel`,e.SubCommandOnly=`SubCommandOnly`,e}({});function Qs(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}let $s=new B;function ec(e,t){return e=Qs(e),{url:e,label:t||e,isExternal:!0,isUrlEditable:!0}}$s.add(`sheet_URL`,{match:e=>lt(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){let n=dt(e);return t.tryGetSheetName(n)||k(`Invalid sheet`)},open(e,t){let n=dt(e);t.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:n}).isCancelledBecause(`SheetIsHidden`)&&t.notifyUser({type:`warning`,sticky:!1,text:k(`Cannot open the link because the linked sheet is hidden.`)})},sequence:0});let tc={createLink:ec,match:e=>at(e),open:e=>window.open(e,`_blank`),urlRepresentation:e=>e,sequence:0};function nc(e){return $s.getAll().sort((e,t)=>e.sequence-t.sequence).find(t=>t.match(e))||tc}function rc(e,t){return nc(e.url).urlRepresentation(e.url,t)}function ic(e,t,n){nc(e.url).open(e.url,t,n)}function ac(e){if(typeof e==`string`){if(it(e)){let{label:t,url:n}=st(e);return nc(n).createLink(n,t)}else if(at(e))return ec(e)}}function oc(e,t,n){return cc({value:Os(t.format)&&e.parsedValue!==null?e.content:e.parsedValue,format:t.format,origin:n},t.locale)}function sc(e,t){if(e.startsWith(`=`))throw Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);if(e.startsWith(`'`))return e.slice(1);if(e===``)return null;if(e.includes(`
|
|
10
10
|
`))return e;if(ra(e,R))return aa(e,R);let n=Di(e,t);return n?n.value:tt(e)?e.toUpperCase()===`TRUE`:e}function cc(e,t=R,n,r){let i=ac(e.value);if(!i)return gc(lc(e,t,n),e.origin??r);let a=sc(i.label,t);return gc({...lc({value:a,format:e.format||(typeof a==`number`?ds(i.label,t)||fs(i.label):void 0)},t,n),link:i},e.origin??r)}function lc(e,t,n){let{value:r,format:i,message:a,errorOriginPosition:o}=e;i=n?.format||i;let s=z(r,{format:i,locale:t});return M(r)?hc(r,a,o):r===null?fc(i):Os(i)?uc(P(r),i,s):typeof r==`number`?os(i||``)?pc(r,i,s):dc(r,i,s):typeof r==`boolean`?mc(r,i,s):uc(r,i,s)}function uc(e,t,n){return{value:e,format:t,formattedValue:n,type:`text`,isAutoSummable:!0,defaultAlign:`left`}}function dc(e,t,n){return{value:e||0,format:t,formattedValue:n,type:`number`,isAutoSummable:!0,defaultAlign:`right`}}let fc=At(function(e){return{value:null,format:e,formattedValue:``,type:`empty`,isAutoSummable:!0,defaultAlign:`left`}});function pc(e,t,n){return{value:e,format:t,formattedValue:n,type:`number`,isAutoSummable:!1,defaultAlign:`right`}}function mc(e,t,n){return{value:e,format:t,formattedValue:n,type:`boolean`,isAutoSummable:!1,defaultAlign:`center`}}function hc(e,t,n){return{value:e,formattedValue:e,message:t,type:`error`,isAutoSummable:!1,defaultAlign:`center`,errorOriginPosition:n}}function gc(e,t){return e.value===null||`origin`in e||(e.origin=t),e}function _c(e){let t=O.now();switch(e){case`today`:return Math.floor(zi(t));case`yesterday`:return t.setDate(t.getDate()-1),Math.floor(zi(t));case`tomorrow`:return t.setDate(t.getDate()+1),Math.floor(zi(t));case`lastWeek`:return t.setDate(t.getDate()-6),Math.floor(zi(t));case`lastMonth`:{let e=t.getMonth()===0?11:t.getMonth()-1,n=new O(t.getFullYear(),e,1);return t.getDate()>Bi(n)?t.setDate(1):(t.setDate(t.getDate()+1),t.setMonth(t.getMonth()-1)),Math.floor(zi(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(zi(t))}}function vc(e,t){return`dateValue`in e&&e.dateValue!==`exactDate`?[_c(e.dateValue)]:e.values.map(e=>wi(e,t))}function yc(e,t){return e.map(e=>{if(e.startsWith(`=`))return e;let n=sc(e,t);return typeof n==`number`?z(n,{format:t.dateFormat,locale:t}):``})}let bc=new WeakMap,xc=new WeakMap;function Sc(e,t){bc.has(t)||(bc.set(t,new Map),xc.set(t,0));let n=bc.get(t),r=Tc(e);if(n.has(r)){let i=n.get(r);return t[i]=e,i}let i=xc.get(t)+1;return n.set(r,i),xc.set(t,i),t[i]=e,i}function Cc(e){let t={};for(let n in e){let r=nn(e[n].map(E));for(let e of r)t[yn(e)]=Number(n)}return t}function*wc(e,t){for(let n in t){let r=mn(n),i=t[n];for(let t=r.top;t<=r.bottom;t++)for(let n=r.left;n<=r.right;n++)yield[{sheetId:e,col:n,row:t},i]}}function Tc(e){if(e===null)return`null`;if(e===void 0)return`undefined`;if(typeof e!=`object`)return String(e);if(Array.isArray(e)){let t=e.length,n=`[`;for(let r=0;r<t;r++)r>0&&(n+=`,`),n+=Tc(e[r]);return n+`]`}let t=Object.keys(e).sort(),n=`{`;for(let r of t)e[r]!==void 0&&(n+=`"${r}":${Tc(e[r])},`);return n+=`}`,n}function Ec(e){return 20+120*Math.exp(-.035*(e-1))}let Dc=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,`i`),Oc=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,`i`),kc=new RegExp(/^\$?([A-Z]{1,3})+$/,`i`),Ac=new RegExp(/^\$?([0-9]{1,7})+$/,`i`),jc=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,`i`),Mc=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,`i`),Nc=RegExp(`^\\s*('.+'!|[^']+!)?(`+[Dc.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 Pc(e){return jc.test(e)}function Fc(e){return Mc.test(e)}function Ic(e){return kc.test(e)}function Lc(e){return Ac.test(e)}function Rc(e){return Oc.test(e)}function zc(e){if(!e.includes(`!`))return{xc:e};let t=e.split(`!`),n=t.pop();return{sheetName:Ye(t.join(`!`))||void 0,xc:n}}function Bc(e,t){return e===void 0?t:`${Ze(e)}!${t}`}function Vc(e){if(e.type!==`REFERENCE`)return e;let{xc:t,sheetName:n}=zc(e.value),[r,i]=t.split(`:`),a=Hc(r),o=i?`:${Hc(i)}`:``;return{...e,value:Bc(n,a+o)}}function Hc(e){switch(Gc(e)){case`none`:e=Uc(e,`colrow`);break;case`colrow`:e=Uc(e,`row`);break;case`row`:e=Uc(e,`col`);break;case`col`:e=Uc(e,`none`);break}return e}function Uc(e,t){let n;({sheetName:n,xc:e}=zc(e)),n=n?Ze(n)+`!`:``,e=e.replace(/\$/g,``);let r=e.indexOf(`:`);return r>=0?`${n}${Wc(e.slice(0,r),t)}:${Wc(e.slice(r+1),t)}`:n+Wc(e,t)}function Wc(e,t){let n=e.search(/[0-9]/),r=n!==0,i=n>=0;switch(t){case`col`:return r?`$`+e:e;case`row`:return i?e.slice(0,n)+`$`+e.slice(n):e;case`colrow`:return!i||!r?`$`+e:`$`+e.slice(0,n)+`$`+e.slice(n);case`none`:return e}}function Gc(e){return Jc(e)?`colrow`:Kc(e)?`col`:qc(e)?`row`:`none`}function Kc(e){return e.startsWith(`$`)}function qc(e){return e.includes(`$`,1)}function Jc(e){return e.startsWith(`$`)&&e.length>1&&e.slice(1).includes(`$`)}function Yc(e,t){let n=e.zone,r=Jn(n,t(e.sheetId)),i=e.parts;return e.parts.length===1&&Gn(r)>1?i=[e.parts[0],e.parts[0]]:e.parts.length===2&&Gn(r)===1&&(i=[e.parts[0]]),{unboundedZone:n,zone:r,parts:i,prefixSheet:e.prefixSheet,invalidSheetName:e.invalidSheetName,sheetId:e.sheetId}}function Xc(e,t){let n=e.xc,{xc:r,sheetName:i}=zc(n),a=pn(r);return Yc({zone:a,parts:il(r,a),sheetId:e.sheetId,prefixSheet:!!i,invalidSheetName:e.invalidSheetName},t)}function Zc(e){let t={left:-1,top:-1,right:-1,bottom:-1};return{sheetId:``,zone:t,unboundedZone:t,parts:[],invalidXc:e,prefixSheet:!1}}function Qc(e){return Wn(e.unboundedZone)}function $c(e){return Un(e.unboundedZone)}function el(e,t,n,r={useBoundedReference:!1,useFixedReference:!1}){if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0||e.zone.left<0||e.zone.top<0)return A.InvalidReference;let i=e.sheetId!==t||e.invalidSheetName||e.prefixSheet,a=``;if(i&&(a=e.invalidSheetName?Ze(e.invalidSheetName):Ze(n(e.sheetId))),i&&!a)return A.InvalidReference;let o=hl(e,0,r);return e.parts&&e.parts.length===2&&(e.zone.top!==e.zone.bottom||e.zone.left!==e.zone.right||e.parts[0].rowFixed||e.parts[0].colFixed||e.parts[1].rowFixed||e.parts[1].colFixed||r.doNotSimplifyRange)&&(o+=`:`,o+=hl(e,1,r)),`${i?a+`!`:``}${o}`}function tl(e,t,n){let r=n.sheetId===e?t:n.sheetId;return{...n,sheetId:r}}function nl(e,t,n){if(!n)return;let r=e.getRangeFromSheetXC(t,n);return r.invalidSheetName||r.invalidXc?void 0:r}function rl(e){let t=[];for(let n of e)for(let e of Fn(n.zone))t.push({...e,sheetId:n.sheetId});return t}function il(e,t){let n=e.split(`:`).map(e=>{let t=Fc(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}function al(e){let t={left:e.col,top:e.row,right:e.col,bottom:e.row};return{sheetId:e.sheetId,zone:t}}function ol(e){if(vn(e.zone))return e;let t={...e.unboundedZone},n={...e.zone},r=e.parts;if(t.right!==void 0&&t.right<t.left){let e=t.right;t.right=t.left,t.left=e,n.right=n.left,n.left=e,r=[{colFixed:r[1]?.colFixed||!1,rowFixed:r[0]?.rowFixed||!1},{colFixed:r[0]?.colFixed||!1,rowFixed:r[1]?.rowFixed||!1}]}if(t.bottom!==void 0&&t.bottom<t.top){let e=t.bottom;t.bottom=t.top,t.top=e,n.bottom=n.top,n.top=e,r=[{colFixed:r[0]?.colFixed||!1,rowFixed:r[1]?.rowFixed||!1},{colFixed:r[1]?.colFixed||!1,rowFixed:r[0]?.rowFixed||!1}]}return{unboundedZone:t,zone:n,parts:r,invalidXc:e.invalidXc,prefixSheet:e.prefixSheet,invalidSheetName:e.invalidSheetName,sheetId:e.sheetId}}function sl(e){return cl.get(e.type)?.(e)}let cl=new class extends B{add(e,t){return super.add(e,t),this}get(e){return this.content[e]}};cl.add(`REMOVE_COLUMNS_ROWS`,e=>({applyChange:ll(e),sheetId:e.sheetId,sheetName:{old:e.sheetName,current:e.sheetName}})).add(`ADD_COLUMNS_ROWS`,e=>({applyChange:ul(e),sheetId:e.sheetId,sheetName:{old:e.sheetName,current:e.sheetName}})).add(`DELETE_SHEET`,e=>({applyChange:dl(e),sheetId:e.sheetId,sheetName:{old:e.sheetName,current:e.sheetName}})).add(`RENAME_SHEET`,e=>({applyChange:fl(e),sheetId:e.sheetId,sheetName:{old:e.oldName,current:e.newName}})).add(`MOVE_RANGES`,e=>({applyChange:pl(e),sheetId:e.sheetId,sheetName:{old:e.sheetName,current:e.sheetName}}));function ll(e){let t=e.dimension===`COL`?`left`:`top`,n=e.dimension===`COL`?`right`:`bottom`,r=e.dimension===`COL`?`columns`:`rows`,i=[...e.elements];i.sort((e,t)=>t-e);let a=$e(i);return i=>{if(i.sheetId!==e.sheetId)return{changeType:`NONE`,range:i};let o=i,s=`NONE`;for(let e of a){let a=Rt(e),c=Lt(e);if(i.zone[t]<=a&&a<=i.zone[n]){let e=Math.min(i.zone[n],c)-a+1;s=`RESIZE`,o=ml(o,r,s,-e)}else if(i.zone[t]>=a&&i.zone[n]<=c)s=`REMOVE`,o=Zc(A.InvalidReference);else if(i.zone[t]<=c&&i.zone[n]>=c){let e=c-i.zone[t]+1;s=`RESIZE`,o=ml(o,r,s,-e),o=ml(o,r,`MOVE`,-(i.zone[t]-a))}else a<i.zone[t]&&(s=`MOVE`,o=ml(o,r,s,-(c-a+1)))}return{changeType:s,range:o}}}function ul(e){let t=e.dimension===`COL`?`left`:`top`,n=e.dimension===`COL`?`right`:`bottom`,r=e.dimension===`COL`?`columns`:`rows`;return i=>{if(i.sheetId!==e.sheetId)return{changeType:`NONE`,range:i};let a=i.unboundedZone[n]===void 0;if(a&&!i.unboundedZone.hasHeader)return{changeType:`RESIZE`,range:ml(i,r,`RESIZE`,e.quantity)};if(e.position===`after`){if(i.zone[t]<=e.base&&(e.base<i.zone[n]||a))return{changeType:`RESIZE`,range:ml(i,r,`RESIZE`,e.quantity)};if(e.base<i.zone[t])return{changeType:`MOVE`,range:ml(i,r,`MOVE`,e.quantity)}}else{if(i.zone[t]<e.base&&e.base<=i.zone[n])return{changeType:`RESIZE`,range:ml(i,r,`RESIZE`,e.quantity)};if(e.base<=i.zone[t])return{changeType:`MOVE`,range:ml(i,r,`MOVE`,e.quantity)}}return{changeType:`NONE`,range:i}}}function dl(e){return t=>{if(t.sheetId!==e.sheetId&&t.invalidSheetName!==e.sheetName)return{changeType:`NONE`,range:t};let n=e.sheetName;return t={...Zc(A.InvalidReference),invalidSheetName:n},{changeType:`REMOVE`,range:t}}}function fl(e){return t=>{if(t.sheetId===e.sheetId)return{changeType:`CHANGE`,range:t};if(e.newName&&t.invalidSheetName===e.newName){let n=e.sheetId;return{changeType:`CHANGE`,range:{...t,sheetId:n,invalidSheetName:void 0}}}if(e.oldName&&t.invalidSheetName===e.oldName){let n=e.sheetId;return{changeType:`CHANGE`,range:{...t,sheetId:n,invalidSheetName:void 0}}}return{changeType:`NONE`,range:t}}}function pl(e){let t=e.target[0];return n=>{if(n.sheetId!==e.sheetId||!jn(n.zone,t))return{changeType:`NONE`,range:n};let r=e.targetSheetId,i=ml(n,`both`,`MOVE`,[e.col-t.left,e.row-t.top]),a=e.sheetId===r?i.prefixSheet:!0;return{changeType:`MOVE`,range:{...i,sheetId:r,prefixSheet:a}}}}function ml(e,t,n,r){return{...e,unboundedZone:Rn(e.unboundedZone,t,n,r),zone:Rn(e.zone,t,n,r)}}function hl(e,t,n={useBoundedReference:!1,useFixedReference:!1}){let r=e.parts[t]?.colFixed||n.useFixedReference?`$`:``,i=Kt(t===0?e.zone.left:e.zone.right),a=e.parts[t]?.rowFixed||n.useFixedReference?`$`:``,o=String(t===0?e.zone.top+1:e.zone.bottom+1),s=``;return s=Wn(e.unboundedZone)&&!n.useBoundedReference?t===0&&e.unboundedZone.hasHeader?r+i+a+o:r+i:Un(e.unboundedZone)&&!n.useBoundedReference?t===0&&e.unboundedZone.hasHeader?r+i+a+o:a+o:r+i+a+o,s}function gl(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 _l(e,t,n){let r=[];return t.forEach(t=>{let i=gl(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 vl(e){let t=[];for(let n=0;n<e;n++)t.push({cells:{}});return t}function yl(e,t,n){return n.map(n=>n>=e?n+t:n)}function bl(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(C)}function xl(e,t=`Sheet`){let n=1,r=`${t}${n}`;for(;e.includes(r);)r=`${t}${n}`,n++;return r}function Sl(e,t){let n=1,r=k(`Copy of %s`,e),i=r.toString();for(;t.includes(i);)i=`${r} (${n})`,n++;return i}let Cl=At(function(e){return Ye(e.trim().toUpperCase())});function wl(e,t){return e===void 0||t===void 0?!1:Cl(e)===Cl(t)}function Tl(e){if(typeof e==`string`)return{};if(typeof e==`number`)return[];throw Error(`Cannot create new node`)}function El(e,t=1){return t*(e+4)-4}function Dl(e=100,t=100){return new OffscreenCanvas(e,t).getContext(`2d`)}function Ol(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=z(sc(t.content,n),e)}}catch{i=A.GenericError}return kl(e,i,t.style,r)}function kl(e,t,n,r){return jl(e,Vl(e,t,n,n?.wrapping===`wrap`?r-8:void 0),n).height+6}function Al(e,t=!1,n=!1){return`${n?`italic`:``} ${t?`bold`:``} ${e}px ${Te}`}function jl(e,t,n={},r=`pt`){if(!t.length)return{width:0,height:0};let i=Rl(n,r),a=t.map(t=>Il(e,t,i)),o=El(a[0].height,t.length),s=Math.max(...a.map(e=>e.width));if(!n.rotation)return{height:o,width:s};let c=Math.abs(Math.cos(n.rotation)),l=Math.abs(Math.sin(n.rotation));return{width:s*c+o*l,height:l*s+c*o}}function Ml(e,t,n={},r=`pt`){return Nl(e,t,Rl(n,r),n.rotation)}function Nl(e,t,n,r){let i=Il(e,t,n);if(!r)return i.width;let a=Math.abs(Math.cos(r)),o=Math.abs(Math.sin(r));return i.width*a+i.height*o}let Pl={};function Fl(e,t,n,r=`pt`){let i=Il(e,t,Rl(n,r));if(!n.rotation)return i;let a=Math.abs(Math.cos(n.rotation)),o=Math.abs(Math.sin(n.rotation));return{width:i.width*a+i.height*o,height:i.height*a+i.width*o}}function Il(e,t,n){if(Pl[n]||(Pl[n]={}),Pl[n][t]===void 0){e.save(),e.font=n;let r=e.measureText(t);e.restore();let i=r.width,a=r.fontBoundingBoxAscent+r.fontBoundingBoxDescent;Pl[n][t]={width:i,height:a}}return Pl[n][t]}function Ll(e){return Math.round(e*96/72)}function Rl(e,t=`pt`){return`${e.italic?`italic `:``}${e.bold?`bold`:`400`} ${(t===`pt`?zl(e):e.fontSize)??we}px ${Te}`}function zl(e){return Ll(e?.fontSize||we)}function Bl(e,t,n,r){if(Ml(e,t,r)<=n)return[t];let i=[],a=``;for(let o of t)Ml(e,a+o,r)>n?(i.push(a),a=o):a+=o;return i.push(a),i}function Vl(e,t,n,r){n||={},it(t)&&(t=st(t).label);let i=[],a=t.includes(`
|
|
11
11
|
`)?t.split(`
|
|
12
12
|
`):[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=Bl(e,t,r,n),c=a.pop(),l=Ml(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=Ml(e,t,n);a<=s?(o+=t,s-=a):(i.push(o),o=c,s=r-l)}}o!==``&&i.push(o)}return i}function Hl(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 Ul(e){return e?e.toLowerCase().trim():``}let Wl=/([0-9\.]*)px/;function Gl(e){return Number(e.match(Wl)?.[1])}function Kl(e,t,n){let r=Nl(e,t,e.font);if(r<=n)return t;let i=Nl(e,`…`,e.font);if(r<=i)return t;let a=t.length;for(;r>=n-i&&a-->0;)t=t.substring(0,a),r=Nl(e,t,e.font);return t+`…`}function ql(e,t,n,r=!1,i=!1,a=Gl(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())}function Jl(e,t,n,r,i=`pt`){if(Ml(e,n,r,i)<=t)return n;let a=Ml(e,`...`,r,i);if(a>=t)return``;let o=1,s=n.length,c;for(;o<=s;){let l=Math.floor((o+s)/2);c=Ml(e,n.slice(0,l),r,i),c+a>t?s=l-1:o=l+1}let l=n.slice(0,Math.max(0,o-1));return l?l+`...`:``}function Yl(e,t){if(!t.rotation||t.rotation%(Math.PI*2)==0)return e;let{x:n,y:r}=e,i=Math.cos(-t.rotation),a=Math.sin(-t.rotation),o=e.textWidth-8,s=e.textHeight,c=t.align===`center`,l=t.align===`left`==a<0,u=a*s,d=Math.abs(a*o),f=i*s;return t.verticalAlign===`top`?c?(r+=d/2,n-=u/2):l?n-=u:r+=d:!t.verticalAlign||t.verticalAlign===`bottom`?(r+=s-f,c?(r-=d/2,n-=u/2):l&&(n-=u,r-=d)):c?(n-=u/2,r-=s/2,l?r+=u:r-=u):l?(n-=u,r-=d/2):r+=d/2+f/4,{x:i*n-a*r,y:i*r+a*n}}var Xl=class{getCrypto(){if(typeof globalThis<`u`&&globalThis.crypto)return globalThis.crypto}smallUuid(){let e=this.getCrypto();return e?`10000000-1000`.replace(/[01]/g,t=>{let n=Number(t);return(n^e.getRandomValues(new Uint8Array(1))[0]&15>>n/4).toString(16)}):`xxxxxxxx-xxxx`.replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}uuidv4(){let e=this.getCrypto();return e?`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,t=>{let n=Number(t);return(n^e.getRandomValues(new Uint8Array(1))[0]&15>>n/4).toString(16)}):`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}};let Zl=new B;function Ql(){return globalThis.Chart?!!globalThis.Chart.registry.plugins.get(`chartShowValuesPlugin`):!0}function $l(){if(!(!globalThis.Chart||Ql()))for(let e of Zl.getAll())e.register(globalThis.Chart)}function eu(){if(globalThis.Chart)for(let e of Zl.getAll())e.unregister(globalThis.Chart)}var tu=class extends yr{mutators=[`disableAnimationForChart`,`enableAnimationForChart`];animationPlayed={};disableAnimationForChart(e,t){return this.animationPlayed[e]=t,`noStateChange`}enableAnimationForChart(e){return this.animationPlayed[e]=void 0,`noStateChange`}};let nu={id:`background`,beforeDraw(e,t,n){let{ctx:r}=e;r.save(),r.globalCompositeOperation=`destination-over`,r.fillStyle=n.color||`#FFFFFF`,r.fillRect(0,0,e.width,e.height),r.restore()}};function ru(){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);return class extends globalThis.Chart.BarController{static id=`calendar`;static defaults={...globalThis.Chart?.BarController.defaults,dataElementType:`bar`,animations:{numbers:{type:`number`,properties:[]}}};updateElements(e,t,n,r){super.updateElements(e,t,n,r);let i=this.chart.config.options?.plugins?.background?.color||`#FFFFFF`;for(let a=t;a<t+n;a++)r===`reset`&&this.updateElement(e[a],a,{options:{backgroundColor:i}},r)}}}let iu={id:`chartColorScalePlugin`,afterDatasetsDraw(e,t,n){if(!n.position||n.position===`none`||!n.colorScale.length)return;let r=e.ctx;r.save(),r.textAlign=`center`,r.textBaseline=`middle`,r.miterLimit=1;let i=(e.chartArea.bottom-e.chartArea.top)/2,a=n.position===`left`?20:r.canvas.width-70,o=e.chartArea.top,s=r.createLinearGradient(0,o+i,0,o),c=1/(n.colorScale.length-1);n.colorScale.forEach((e,t)=>{s.addColorStop(t*c,e)}),r.fillStyle=s,r.fillRect(a,o,10,i),r.fillStyle=n.fontColor??`black`,r.font=Al(12),r.textAlign=`left`;let l=Math.round(n.minValue*100)/100,u=Math.round(n.maxValue*100)/100;n.minValue===n.maxValue&&(--l,u+=1);let d=ys({value:u,format:void 0},n.locale),f=ys({value:l,format:void 0},n.locale);r.fillText(f,a+10+5,o+i-6),r.fillText(d,a+10+5,o+6),r.restore()}};function au(){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);return class extends globalThis.Chart.BarController{static id=`funnel`;static defaults={...globalThis.Chart?.BarController.defaults,dataElementType:`funnel`,animation:{duration:e=>e.type===`data`?1e3*(e.raw[1]/Math.max(...e.dataset.data.map(e=>e[1]))):1e3}};updateElements(e,t,n,r){super.updateElements(e,t,n,r);for(let i=t;i<t+n;i++){let t=e[i];this.updateElement(t,i,{nextElement:e[i+1]},r)}}}}function ou(){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);return class extends globalThis.Chart.BarElement{static id=`funnel`;draw(e){e.save();let{x:t,y:n,height:r,nextElement:i,base:a,options:o}=this.getProps([`x`,`y`,`width`,`height`,`nextElement`,`base`,`options`]),s=su(this),c=(s-(i?su(i):0))/2,l=Math.min(t,a),u=n-r/2;e.fillStyle=o.backgroundColor,e.beginPath(),e.moveTo(l,u),e.lineTo(l+s,u),e.lineTo(l+s-c,u+r),e.lineTo(l+c,u+r),e.closePath(),e.fill(),o.borderWidth&&(e.strokeStyle=o.borderColor,e.lineWidth=o.borderWidth,e.stroke()),e.restore()}inRange(e,t){let{x:n,y:r,height:i,nextElement:a,base:o}=this.getProps([`x`,`y`,`width`,`height`,`nextElement`,`base`,`options`]),s=su(this),c=a?su(a):0,l=Math.min(n,o),u=r-i/2;if(t<u||t>u+i)return!1;let d=(s-c)/2,f=l+d*(t-u)/i,p=l+s-d*(t-u)/i;return!(e<f||e>p)}}}function su(e){let{x:t,base:n}=e.getProps([`x`,`base`]);return Math.max(t,n)-Math.min(t,n)}let cu=function(e){if(!e.length)return{x:0,y:0};let{x:t,y:n,base:r,width:i,height:a}=e[0].element.getProps([`x`,`y`,`width`,`height`,`base`]),o=Math.min(t,r),s=n-a/2;return{x:o+i*2/3,y:s+a/2}},lu=`000000`,uu={arrows:`3Arrows`,smiley:`3Symbols`,dots:`3TrafficLights1`},du={styleSheet:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,sst:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,Relationships:`http://schemas.openxmlformats.org/package/2006/relationships`,Types:`http://schemas.openxmlformats.org/package/2006/content-types`,worksheet:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,workbook:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,drawing:`http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing`,table:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,revision:`http://schemas.microsoft.com/office/spreadsheetml/2014/revision`,revision3:`http://schemas.microsoft.com/office/spreadsheetml/2016/revision3`,markupCompatibility:`http://schemas.openxmlformats.org/markup-compatibility/2006`},fu=`http://schemas.openxmlformats.org/drawingml/2006/main`,pu=`http://schemas.openxmlformats.org/drawingml/2006/chart`,mu={workbook:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml`,macroEnabledWorkbook:`application/vnd.ms-excel.sheet.macroEnabled.main+xml`,templateWorkbook:`application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml`,macroEnabledTemplateWorkbook:`application/vnd.ms-excel.template.macroEnabled.main+xml`,excelAddInWorkbook:`application/vnd.ms-excel.addin.macroEnabled.main+xml`,sheet:`application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml`,metadata:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml`,sharedStrings:`application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml`,styles:`application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml`,drawing:`application/vnd.openxmlformats-officedocument.drawing+xml`,chart:`application/vnd.openxmlformats-officedocument.drawingml.chart+xml`,themes:`application/vnd.openxmlformats-officedocument.theme+xml`,table:`application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml`,pivot:`application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml`,externalLink:`application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml`},hu={document:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument`,sheet:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet`,metadata:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/sheetMetadata`,sharedStrings:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings`,styles:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles`,drawing:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,chart:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart`,theme:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme`,table:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/table`,hyperlink:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink`,image:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/image`},gu=`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,_u=.75,vu=.143,yu=8.43,bu=12.75,xu={FLOOR:[{type:`NUMBER`,value:1}],CEILING:[{type:`NUMBER`,value:1}],ROUND:[{type:`NUMBER`,value:0}],ROUNDUP:[{type:`NUMBER`,value:0}],ROUNDDOWN:[{type:`NUMBER`,value:0}],IFERROR:[{type:`NUMBER`,value:0}]},Su=`ACOT,ACOTH,AGGREGATE,ARABIC,BASE,BETA.DIST,BETA.INV,BINOM.DIST,BINOM.DIST.RANGE,BINOM.INV,BITAND,BITLSHIFT,BITOR,BITRSHIFT,BITXOR,BYCOL,BYROW,CEILING.MATH,CEILING.PRECISE,CHISQ.DIST,CHISQ.DIST.RT,CHISQ.INV,CHISQ.INV.RT,CHISQ.TEST,CHOOSECOLS,CHOOSEROWS,COMBINA,CONCAT,CONFIDENCE.NORM,CONFIDENCE.T,COT,COTH,COVARIANCE.P,COVARIANCE.S,CSC,CSCH,DAYS,DECIMAL,DROP,ERF.PRECISE,ERFC.PRECISE,EXPAND,EXPON.DIST,F.DIST,F.DIST.RT,F.INV,F.INV.RT,F.TEST,FIELDVALUE,FILTERXML,FLOOR.MATH,FLOOR.PRECISE,FORECAST.ETS,FORECAST.ETS.CONFINT,FORECAST.ETS.SEASONALITY,FORECAST.ETS.STAT,FORECAST.LINEAR,FORMULATEXT,GAMMA,GAMMA.DIST,GAMMA.INV,GAMMALN.PRECISE,GAUSS,HSTACK,HYPGEOM.DIST,IFNA,IFS,IMCOSH,IMCOT,IMCSC,IMCSCH,IMSEC,IMSECH,IMSINH,IMTAN,ISFORMULA,ISOMITTED,ISOWEEKNUM,LAMBDA,LET,LOGNORM.DIST,LOGNORM.INV,MAKEARRAY,MAP,MAXIFS,MINIFS,MODE.MULT,MODE.SNGL,MUNIT,NEGBINOM.DIST,NORM.DIST,NORM.INV,NORM.S.DIST,NORM.S.INV,NUMBERVALUE,PDURATION,PERCENTILE.EXC,PERCENTILE.INC,PERCENTRANK.EXC,PERCENTRANK.INC,PERMUTATIONA,PHI,POISSON.DIST,PQSOURCE,PYTHON_STR,PYTHON_TYPE,PYTHON_TYPENAME,QUARTILE.EXC,QUARTILE.INC,QUERYSTRING,RANDARRAY,RANK.AVG,RANK.EQ,REDUCE,RRI,SCAN,SEC,SECH,SEQUENCE,SHEET,SHEETS,SKEW.P,SORTBY,STDEV.P,STDEV.S,SWITCH,T.DIST,T.DIST.2T,T.DIST.RT,T.INV,T.INV.2T,T.TEST,TAKE,TEXTAFTER,TEXTBEFORE,TEXTJOIN,TEXTSPLIT,TOCOL,TOROW,UNICHAR,UNICODE,UNIQUE,VAR.P,VAR.S,VSTACK,WEBSERVICE,WEIBULL.DIST,WRAPCOLS,WRAPROWS,XLOOKUP,XOR,Z.TEST`.split(`,`),Cu=[`%`],wu=`+,-,*,/,:,=,<>,>=,>,<=,<,^,&,#`.split(`,`).concat(Cu);function Tu(e,t=R){e=Ot(e);let n=new zt(e),r=[],i=Tt.test(e)?Bu:Vu;for(;!n.isOver();){let e=Hu(n)||i(n)||Mu(n,t)||ju(n,t)||Au(n)||Ou(n)||Uu(n)||Nu(n)||Iu(n)||Eu(n)||Fu(n,t)||zu(n);e||={type:`UNKNOWN`,value:n.shift()},r.push(e)}return r}function Eu(e){return e.current===`?`?(e.shift(),{type:`DEBUGGER`,value:`?`}):null}let Du={"(":{type:`LEFT_PAREN`,value:`(`},")":{type:`RIGHT_PAREN`,value:`)`}};function Ou(e){return e.current===`(`||e.current===`)`?Du[e.shift()]:null}let ku={"{":{type:`LEFT_BRACE`,value:`{`},"}":{type:`RIGHT_BRACE`,value:`}`}};function Au(e){return e.current===`{`||e.current===`}`?ku[e.shift()]:null}function ju(e,t){return e.current===t.formulaArgSeparator?{type:`ARG_SEPARATOR`,value:e.shift()}:null}function Mu(e,t){let n=t.formulaArgSeparator===`;`?`\\`:`;`;return n&&e.current===n?(e.shift(),{type:`ARRAY_ROW_SEPARATOR`,value:n}):null}function Nu(e){for(let t of wu)if(e.currentStartsWith(t))return e.advanceBy(t.length),{type:`OPERATOR`,value:t};return null}let Pu=new Set(`0123456789`);function Fu(e,t){if(!Pu.has(e.current)&&e.current!==t.decimalSeparator)return null;let n=e.remaining().match(ta(t.decimalSeparator));return n?(e.advanceBy(n[0].length),{type:`NUMBER`,value:n[0]}):null}function Iu(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 Lu=/\p{L}|\p{N}|_|\.|!|\$/u,Ru=new Set(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.!$`);function zu(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&&(Ru.has(e.current)||e.current.match(Lu));)t+=e.shift();if(t.length){let e=t;return Nc.test(e)?{type:`REFERENCE`,value:e}:{type:`SYMBOL`,value:e}}return null}function Bu(e){let t=``;for(;e.current===` `||e.current&&e.current.match(Tt);)t+=e.shift();return t?{type:`SPACE`,value:t}:null}function Vu(e){let t=``;for(;e.current===` `;)t+=e.shift();return t?{type:`SPACE`,value:t}:null}function Hu(e){let t=0;for(;e.current===`
|
|
@@ -62,7 +62,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
62
62
|
`),r=t?.content?.textLines?.join(`
|
|
63
63
|
`);return!!(n&&!r)},updateAnimation:function(e,t,n,r){let i=1-pv[this.easingFn](e),a={...n.style};delete a.fillColor,t.textOpacity=i,t.content=n.content,t.clipRect=n.clipRect,Object.assign(t.style,a)}}),fv.add(`iconFadeIn`,{id:`iconFadeIn`,easingFn:`easeInCubic`,hasAnimation:(e,t)=>!!(!e?.icons?.left&&t?.icons?.left||!e?.icons?.right&&t?.icons?.right||!e?.icons?.center&&t?.icons?.center),updateAnimation:function(e,t,n,r){let i=pv[this.easingFn](e);t.icons.left&&r.icons.left&&!n.icons.left&&(t.icons.left.opacity=i),t.icons.right&&r.icons.right&&!n.icons.right&&(t.icons.right.opacity=i),t.icons.center&&r.icons.center&&!n.icons.center&&(t.icons.center.opacity=i)}}),fv.add(`iconFadeOut`,{id:`iconFadeOut`,easingFn:`easeOutCubic`,hasAnimation:(e,t)=>!!(e?.icons?.left&&!t?.icons?.left||e?.icons?.right&&!t?.icons?.right||e?.icons?.center&&!t?.icons?.center),updateAnimation:function(e,t,n,r){let i=1-pv[this.easingFn](e);t.icons||={},n.icons.left&&!r.icons.left&&(t.icons.left={...n.icons.left,opacity:i}),n.icons.right&&!r.icons.right&&(t.icons.right={...n.icons.right,opacity:i}),n.icons.center&&!r.icons.center&&(t.icons.center={...n.icons.center,opacity:i})}}),fv.add(`textChange`,{id:`textChange`,easingFn:`easeOutCubic`,hasAnimation:(e,t)=>{let n=e?.content?.textLines?.join(`
|
|
64
64
|
`),r=t?.content?.textLines?.join(`
|
|
65
|
-
`);return!!(n&&r&&(n!==r||gv(t,e)))},updateAnimation:function(e,t,n,r){let i=pv[this.easingFn](e),a=r.y+(i-1)*r.height,o=r.y+i*r.height,s=gv(r,n),c={id:r.id+`-text-slide-in`,x:r.x,y:a,width:r.width,height:r.height,style:{...r.style,hideGridLines:!0},content:r.content?{...r.content}:void 0,clipRect:r.clipRect||{...r,x:Math.max(0,r.x-(r.content?.width||0)),width:r.width+(r.content?.width||0)*2},icons:s?hv(r.icons,r):mv(r.icons)},l={id:n.id+`-text-slide-out`,x:r.x,y:o,width:r.width,height:r.height,style:{...n.style,hideGridLines:!0},content:n.content?{...n.content}:void 0,clipRect:n.clipRect||{...r,x:Math.max(0,r.x-(n.content?.width||0)),width:r.width+(n.content?.width||0)*2},icons:s?hv(n.icons,r):mv(n.icons)};if(r.content&&n.content&&c.content&&l.content){let e=r.content.y+(i-1)*r.height,t=r.content.y+i*r.height;c.content.y=e,l.content.y=t}return l.style.fillColor=c.style.fillColor=void 0,t.content=void 0,t.icons=s?{}:t.icons,{newBoxes:[c,l]}}}),fv.add(`borderFadeIn`,{id:`borderFadeIn`,easingFn:`easeInCubic`,hasAnimation:(e,t)=>!!(!e?.border?.bottom&&t?.border?.bottom||!e?.border?.top&&t?.border?.top||!e?.border?.left&&t?.border?.left||!e?.border?.right&&t?.border?.right),updateAnimation:function(e,t,n,r){let i=pv[this.easingFn](e);t.border?.top&&r.border?.top&&!n.border?.top&&(t.border.top.opacity=i),t.border?.bottom&&r.border?.bottom&&!n.border?.bottom&&(t.border.bottom.opacity=i),t.border?.left&&r.border?.left&&!n.border?.left&&(t.border.left.opacity=i),t.border?.right&&r.border?.right&&!n.border?.right&&(t.border.right.opacity=i)}}),fv.add(`borderFadeOut`,{id:`borderFadeOut`,easingFn:`easeOutCubic`,hasAnimation:(e,t)=>!!(e?.border?.bottom&&!t?.border?.bottom||e?.border?.top&&!t?.border?.top||e?.border?.left&&!t?.border?.left||e?.border?.right&&!t?.border?.right),updateAnimation:function(e,t,n,r){let i=1-pv[this.easingFn](e);t.border||={},n.border?.top&&!r.border?.top&&(t.border.top={...n.border.top,opacity:i}),n.border?.bottom&&!r.border?.bottom&&(t.border.bottom={...n.border.bottom,opacity:i}),n.border?.left&&!r.border?.left&&(t.border.left={...n.border.left,opacity:i}),n.border?.right&&!r.border?.right&&(t.border.right={...n.border.right,opacity:i})}}),fv.add(`borderColorChange`,{id:`borderColorChange`,easingFn:`easeOutCubic`,hasAnimation:(e,t)=>{let n=e?.border,r=t?.border;return!n||!r?!1:n.bottom?.color!==r.bottom?.color||n.top?.color!==r.top?.color||n.left?.color!==r.left?.color||n.right?.color!==r.right?.color},updateAnimation:function(e,t,n,r){let i=i=>{let a=n?.border?.[i],o=r?.border?.[i],s=t.border?.[i];a&&o&&s&&(s.color=li([{value:0,color:a.color||`#000000`},{value:1,color:o.color||`#000000`}])(pv[this.easingFn](e)))};i(`top`),i(`bottom`),i(`left`),i(`right`)}}),fv.add(`iconChange`,{id:`iconChange`,easingFn:`easeOutCubic`,hasAnimation:(e,t)=>!gv(t,e)&&(e?.icons?.center?.svg?.name!==t?.icons?.center?.svg?.name||e?.icons?.left?.svg?.name!==t?.icons?.left?.svg?.name||e?.icons?.right?.svg?.name!==t?.icons?.right?.svg?.name),updateAnimation:function(e,t,n,r){let i=pv[this.easingFn](e),a=r.y+(i-1)*r.height,o=r.y+i*r.height,s=[],c=e=>{let i=n.icons?.[e],c=r.icons?.[e],l={id:`${r.id}-icon-${e}-slide-in`,style:{verticalAlign:r.style.verticalAlign,hideGridLines:!0},x:r.x,y:a,width:r.width,height:r.height,icons:{[e]:{...c,clipRect:r}}},u={id:`${r.id}-icon-${e}-slide-out`,style:{verticalAlign:n.style.verticalAlign,hideGridLines:!0},x:r.x,y:o,width:r.width,height:r.height,icons:{[e]:{...i,clipRect:r}}};t.icons[e]=mv(r.icons)[e],s.push(l,u)};return c(`left`),c(`right`),c(`center`),{newBoxes:s}}});let pv={linear:e=>e,easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeOutQuart:e=>-(--e*e*e*e-1)};function mv(e){return{left:e.left?{...e.left,svg:void 0}:void 0,right:e.right?{...e.right,svg:void 0}:void 0,center:e.center?{...e.center,svg:void 0}:void 0}}function hv(e,t){return{left:e.left?{...e.left,clipRect:t}:void 0,right:e.right?{...e.right,clipRect:t}:void 0,center:e.center?{...e.center,clipRect:t}:void 0}}function gv(e,t){let n=(e,t)=>t&&e?!!(e.horizontalAlign!==t.horizontalAlign||e.size!==t.size||e.margin!==t.margin||e.svg&&!t.svg||!e.svg&&t.svg):!!(e&&!t||!e&&t);return n(e?.icons.left,t?.icons.left)||n(e?.icons.right,t?.icons.right)||n(e?.icons.center,t?.icons.center)}var _v=class extends t.Component{static template=`o-spreadsheet-GaugeChartComponent`;static props={chartId:String,isFullScreen:{type:Boolean,optional:!0}};canvas=(0,t.useRef)(`chartContainer`);animationStore;get runtime(){return this.env.model.getters.getChartRuntime(this.props.chartId)}setup(){this.env.model.getters.isDashboard()&&(this.animationStore=D(tu));let e=null,n;(0,t.useEffect)(()=>{if(this.env.isDashboard()&&n===void 0&&this.animationStore?.animationPlayed[this.animationChartId]!==`gauge`)e=this.drawGaugeWithAnimation(),this.animationStore?.disableAnimationForChart(this.animationChartId,`gauge`);else if(this.env.isDashboard()&&n!==void 0&&!w(this.runtime,n))e=this.drawGaugeWithAnimation(),this.animationStore?.disableAnimationForChart(this.animationChartId,`gauge`);else{let e=this.env.model.getters.getViewportZoomLevel();Mp(this.canvasEl,this.runtime,e)}return n=this.runtime,()=>e?.stop()},()=>{let e=this.canvasEl.getBoundingClientRect();return[e.width,e.height,this.runtime,this.canvas.el,window.devicePixelRatio]})}drawGaugeWithAnimation(){Mp(this.canvasEl,{...this.runtime,animationValue:0},void 0);let e=this.runtime.gaugeValue?.value||0,t=this.runtime.maxValue.value,n=Math.sign(e)*Math.min(Math.abs(e),Math.abs(t));if(n===0)return null;let r=this.runtime.minValue.value,i=new vv(r,n,1e3,e=>Mp(this.canvasEl,{...this.runtime,animationValue:e},void 0));return i.start(),i}get canvasEl(){return this.canvas.el}get animationChartId(){return this.props.isFullScreen?this.props.chartId+`-fullscreen`:this.props.chartId}},vv=class{startValue;endValue;duration;callback;startTime=void 0;animationFrameId=null;constructor(e,t,n,r){this.startValue=e,this.endValue=t,this.duration=n,this.callback=r}start(){this.animationFrameId=requestAnimationFrame(this.animate.bind(this))}stop(){this.animationFrameId&&=(cancelAnimationFrame(this.animationFrameId),null)}animate(e){this.startTime||=e;let t=e-this.startTime,n=Math.min(t/this.duration,1),r=this.startValue+(this.endValue-this.startValue)*pv.easeOutQuart(n);this.callback(r),n<1?this.animationFrameId=requestAnimationFrame(this.animate.bind(this)):this.stop()}};let yv=new B;yv.add(`line`,dv),yv.add(`bar`,dv),yv.add(`combo`,dv),yv.add(`pie`,Pf),yv.add(`gauge`,_v),yv.add(`scatter`,Pf),yv.add(`scorecard`,Ap),yv.add(`waterfall`,dv),yv.add(`pyramid`,Pf),yv.add(`radar`,Pf),yv.add(`geo`,Pf),yv.add(`funnel`,Pf),yv.add(`sunburst`,Pf),yv.add(`treemap`,Pf),yv.add(`calendar`,Pf);var bv=class extends yr{mutators=[`toggleFullScreenFigure`];fullScreenFigure=void 0;toggleFullScreenFigure(e){this.fullScreenFigure?.id===e?this.fullScreenFigure=void 0:this.makeFullScreen(e)}makeFullScreen(e){let t=this.getters.getActiveSheetId(),n=this.getters.getFigure(t,e);n&&(this.fullScreenFigure={...n,x:0,y:0,width:0,height:0})}};function xv(e,n){let r,{setInterval:i,clearInterval:a}=window,o=()=>{a(r),r=void 0},s=()=>{try{e()}catch(e){throw o(),e}};return(0,t.useEffect)(()=>(r=i(s,n),()=>a(r)),()=>[n]),{pause:o,resume:()=>{r===void 0&&(r=i(s,n))}}}function Sv(){let e;function n(){e!==void 0&&(clearTimeout(e),e=void 0)}function r(t,r){n(),e=setTimeout(t,r)}return(0,t.onWillUnmount)(n),{clear:n,schedule:r}}var Cv=class extends t.Component{static template=`o-spreadsheet-Menu`;static props={menuItems:Array,onClose:Function,onClickMenu:{type:Function,optional:!0},onMouseEnter:{type:Function,optional:!0},onMouseOver:{type:Function,optional:!0},onMouseLeave:{type:Function,optional:!0},width:{type:Number,optional:!0},isActive:{type:Function,optional:!0},onScroll:{type:Function,optional:!0}};static components={};static defaultProps={};hoveredMenu=void 0;setup(){(0,t.onWillUnmount)(()=>{this.hoveredMenu?.onStopHover?.(this.env)})}get childrenHaveIcon(){return this.props.menuItems.some(e=>e!==`separator`&&!!this.getIconName(e))}getIconName(e){return e.icon(this.env)?e.icon(this.env):e.isActive?.(this.env)?`o-spreadsheet-Icon.CHECK`:``}getColor(e){return U({color:e.textColor})}getIconColor(e){return U({color:e.iconColor})}getName(e){return e.name(this.env)}isRoot(e){return _(e)}isEnabled(e){let t=e.children?.(this.env);if(t.length)return t.some(e=>this.isEnabled(e));if(e.isEnabled(this.env)){let t=e.isEnabledOnLockedSheet||!this.env.model.getters.isCurrentSheetLocked();return this.env.model.getters.isReadonly()?e.isReadonlyAllowed:t}return!1}get menuStyle(){return this.props.width?U({width:this.props.width+`px`}):``}onMouseEnter(e,t){this.hoveredMenu=e,e.onStartHover?.(this.env),this.props.onMouseEnter?.(e,t)}onMouseLeave(e,t){this.hoveredMenu=void 0,e.onStopHover?.(this.env),this.props.onMouseLeave?.(e,t)}onClickMenu(e,t){this.isEnabled(e)&&this.props.onClickMenu?.(e,t)}};function wv(e,t){return Dv(En(Ev(e),Ev(t)))}function Tv(...e){return Dv(wn(...e.map(Ev)))}function Ev(e){return{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height}}function Dv(e){if(e)return{x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top}}function Ov(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function kv(){let e=(0,t.useState)({x:0,y:0,width:0,height:0}),n=null;function r(){if(n||=document.querySelector(`.o-spreadsheet`),n){let{top:t,left:r,width:i,height:a}=n.getBoundingClientRect();e.x=r,e.y=t,e.width=i,e.height=a}}return(0,t.onMounted)(r),(0,t.onPatched)(r),e}function Av(){let e=(0,t.useState)({x:0,y:0,width:0,height:0}),n=(0,t.useComponent)(),r=kv();function i(){let t=n.env,i=`getPopoverContainerRect`in t&&t.getPopoverContainerRect?t.getPopoverContainerRect():r;e.x=i.x,e.y=i.y,e.width=i.width,e.height=i.height}return i(),(0,t.onMounted)(i),(0,t.onPatched)(i),e}var jv=class extends t.Component{static template=`o-spreadsheet-Popover`;static props={anchorRect:Object,containerRect:{type:Object,optional:!0},positioning:{type:String,optional:!0},maxWidth:{type:Number,optional:!0},maxHeight:{type:Number,optional:!0},verticalOffset:{type:Number,optional:!0},onMouseWheel:{type:Function,optional:!0},onPopoverHidden:{type:Function,optional:!0},onPopoverMoved:{type:Function,optional:!0},zIndex:{type:Number,optional:!0},class:{type:String,optional:!0},slots:Object};static defaultProps={positioning:`bottom-left`,verticalOffset:0,onMouseWheel:()=>{},onPopoverMoved:()=>{},onPopoverHidden:()=>{}};popoverRef=(0,t.useRef)(`popover`);popoverContentRef=(0,t.useRef)(`popoverContent`);currentPosition=void 0;currentDisplayValue=void 0;spreadsheetRect=kv();containerRect;setup(){this.containerRect=Av();let e=new ResizeObserver(this.computePopoverPosition.bind(this));(0,t.onMounted)(()=>{e.observe(this.popoverContentRef.el)}),(0,t.onWillUnmount)(()=>{e.disconnect()}),(0,t.useEffect)(this.computePopoverPosition.bind(this))}computePopoverPosition(){if(!this.containerRect)throw Error(`Popover container is not defined`);let e=this.popoverRef.el,t=this.popoverContentRef.el,n=wv(this.props.anchorRect,this.containerRect),r=n?`block`:`none`;if(this.currentDisplayValue!==`none`&&r===`none`&&this.props.onPopoverHidden?.(),e.style.display=r,this.currentDisplayValue=r,!n)return;let i={width:this.props.maxWidth,height:this.props.maxHeight},a={width:t.getBoundingClientRect().width,height:t.getBoundingClientRect().height},o=this.spreadsheetRect,s=this.props.positioning===`bottom-left`?new Nv(n,this.containerRect,i,o,this.currentPosition):new Pv(n,this.containerRect,i,o,this.currentPosition);e.style[`max-height`]=s.getMaxHeight(a.height)+`px`,e.style[`max-width`]=s.getMaxWidth(a.width)+`px`,a={width:e.getBoundingClientRect().width,height:e.getBoundingClientRect().height};let c=s.getCss(a,this.props.verticalOffset);for(let t of Object.keys(c))e.style[t]=c[t];let l=s.getCurrentPosition(a);this.currentPosition&&l!==this.currentPosition&&this.props.onPopoverMoved?.(),this.currentPosition=l}},Mv=class{anchorRect;containerRect;propsMaxSize;spreadsheetOffset;lastPosition;constructor(e,t,n,r,i){this.anchorRect=e,this.containerRect=t,this.propsMaxSize=n,this.spreadsheetOffset=r,this.lastPosition=i}shouldRenderAtBottom(e){return this.lastPosition===`top-left`||this.lastPosition===`top-right`?!(e<=this.availableHeightUp||this.availableHeightUp>=this.availableHeightDown):e<=this.availableHeightDown||this.availableHeightDown>=this.availableHeightUp}shouldRenderAtRight(e){return this.lastPosition===`bottom-left`||this.lastPosition===`top-left`?!(e<=this.availableWidthLeft||this.availableWidthLeft>=this.availableWidthRight):e<=this.availableWidthRight||this.availableWidthRight>=this.availableWidthLeft}getMaxHeight(e){let t=this.shouldRenderAtBottom(e)?this.availableHeightDown:this.availableHeightUp;return this.propsMaxSize.height?Math.min(t,this.propsMaxSize.height):t}getMaxWidth(e){let t=this.shouldRenderAtRight(e)?this.availableWidthRight:this.availableWidthLeft;return this.propsMaxSize.width?Math.min(t,this.propsMaxSize.width):t}getCss(e,t){let n=this.getMaxHeight(e.height),r=this.getMaxWidth(e.width),i=Math.min(n,e.height),a=Math.min(r,e.width),o=this.shouldRenderAtBottom(e.height),s=this.shouldRenderAtRight(e.width);return t=o?t:-t,{top:this.getTopCoordinate(i,o)-this.spreadsheetOffset.y-t+`px`,left:this.getLeftCoordinate(a,s)-this.spreadsheetOffset.x+`px`}}getCurrentPosition(e){let t=this.shouldRenderAtBottom(e.height),n=this.shouldRenderAtRight(e.width);return t&&n?`bottom-right`:t&&!n?`bottom-left`:!t&&n?`top-right`:`top-left`}},Nv=class extends Mv{get availableHeightUp(){return this.anchorRect.y-this.containerRect.y}get availableHeightDown(){return this.containerRect.height-this.availableHeightUp-this.anchorRect.height}get availableWidthRight(){return this.containerRect.x+this.containerRect.width-this.anchorRect.x}get availableWidthLeft(){return this.anchorRect.x+this.anchorRect.width-this.containerRect.x}getTopCoordinate(e,t){return t?this.anchorRect.y+this.anchorRect.height:this.anchorRect.y-e}getLeftCoordinate(e,t){return t?this.anchorRect.x:this.anchorRect.x+this.anchorRect.width-e}},Pv=class extends Mv{get availableHeightUp(){return this.anchorRect.y+this.anchorRect.height-this.containerRect.y}get availableHeightDown(){return this.containerRect.y+this.containerRect.height-this.anchorRect.y}get availableWidthRight(){return this.containerRect.width-this.anchorRect.width-this.availableWidthLeft}get availableWidthLeft(){return this.anchorRect.x-this.containerRect.x}getTopCoordinate(e,t){return t?this.anchorRect.y:this.anchorRect.y+this.anchorRect.height-e}getLeftCoordinate(e,t){return t?this.anchorRect.x+this.anchorRect.width:this.anchorRect.x-e}},Fv=class e extends t.Component{static template=`o-spreadsheet-Menu-Popover`;static props={anchorRect:Object,popoverPositioning:{type:String,optional:!0},menuItems:Array,depth:{type:Number,optional:!0},maxHeight:{type:Number,optional:!0},onClose:Function,onMenuClicked:{type:Function,optional:!0},menuId:{type:String,optional:!0},onMouseOver:{type:Function,optional:!0},width:{type:Number,optional:!0}};static components={MenuPopover:e,Menu:Cv,Popover:jv};static defaultProps={depth:1,popoverPositioning:`top-right`};subMenu=(0,t.useState)({isOpen:!1,anchorRect:null,scrollOffset:0,menuItems:[],isHoveringChild:!1});menuRef=(0,t.useRef)(`menu`);hoveredMenu=void 0;openingTimeOut=Sv();setup(){(0,t.useExternalListener)(window,`click`,this.onExternalClick,{capture:!0}),(0,t.useExternalListener)(window,`contextmenu`,this.onExternalClick,{capture:!0}),(0,t.onWillUpdateProps)(e=>{e.menuItems!==this.props.menuItems&&this.closeSubMenu()}),(0,t.onWillUnmount)(()=>{this.hoveredMenu?.onStopHover?.(this.env)})}get menuProps(){return{menuItems:this.menuItems,onClose:this.close.bind(this),onClickMenu:this.onClickMenu.bind(this),onMouseOver:this.onMouseOver.bind(this),onMouseLeave:this.onMouseLeave.bind(this),width:this.props.width||250,isActive:this.isActive.bind(this),onScroll:this.onScroll.bind(this)}}get subMenuAnchorRect(){let e=Object.assign({},this.subMenu.anchorRect);return e.y-=this.subMenu.scrollOffset||0,e}get popoverProps(){let e=this.props.depth===1;return{anchorRect:{x:this.props.anchorRect.x,y:this.props.anchorRect.y,width:e?this.props.anchorRect.width:this.props.width||250,height:e?this.props.anchorRect.height:26},positioning:this.props.popoverPositioning,verticalOffset:e?0:6,onPopoverHidden:()=>this.closeSubMenu(),onPopoverMoved:()=>this.closeSubMenu(),maxHeight:this.props.maxHeight}}get childrenHaveIcon(){return this.props.menuItems.some(e=>!!this.getIconName(e))}getIconName(e){return e.icon(this.env)?e.icon(this.env):e.isActive?.(this.env)?`o-spreadsheet-Icon.CHECK`:``}getColor(e){return U({color:e.textColor})}getIconColor(e){return U({color:e.iconColor})}async activateMenu(e,t){let n=await e.execute?.(this.env,t);this.close(),this.props.onMenuClicked?.({detail:n})}close(){this.closeSubMenu(),this.props.onClose()}onExternalClick(e){this.menuRef.el&&cp().some(t=>np(t,e))||(e.closedMenuId=this.props.menuId,this.close())}get menuItems(){return g(this.env,this.props.menuItems)}getName(e){return e.name(this.env)}isRoot(e){return!e.execute}isEnabled(e){return e.isEnabled(this.env)?this.env.model.getters.isReadonly()?e.isReadonlyAllowed:!0:!1}isActive(e){return(this.subMenu?.isHoveringChild||!1)&&this.isParentMenu(this.subMenu,e)}onScroll(e){this.subMenu.scrollOffset=e.target.scrollTop}openSubMenu(e,t){if(!t)return;let n=t.getBoundingClientRect().top;this.subMenu.anchorRect={x:ap(this.menuRef).x,y:n-(this.subMenu.scrollOffset||0),width:this.props.width||250,height:26},this.subMenu.menuItems=e.children(this.env),this.subMenu.isOpen=!0,this.subMenu.parentMenu=e}isParentMenu(e,t){return e.parentMenu?.id===t.id}closeSubMenu(){this.subMenu.isHoveringChild||(this.subMenu.isOpen=!1,this.subMenu.parentMenu=void 0)}onClickMenu(e,t){this.isRoot(e)?this.openSubMenu(e,t.currentTarget):this.activateMenu(e,gp(t))}onMouseOver(e,t){if(this.isParentMenu(this.subMenu,e)){this.openingTimeOut.clear();return}let n=t.currentTarget;this.isRoot(e)&&this.openingTimeOut.schedule(()=>{this.openSubMenu(e,n)},250)}onMouseOverMainMenu(){this.props.onMouseOver?.(),this.subMenu.isHoveringChild=!1}onMouseOverChildMenu(){this.subMenu.isHoveringChild=!0,this.openingTimeOut.clear()}onMouseLeave(e){this.openingTimeOut.schedule(this.closeSubMenu.bind(this),250)}get menuStyle(){return this.props.width?U({width:this.props.width+`px`}):``}},Iv=class extends t.Component{static template=`o-spreadsheet-ChartDashboardMenu`;static components={MenuPopover:Fv};static props={chartId:String,hasFullScreenButton:{type:Boolean,optional:!0}};static defaultProps={hasFullScreenButton:!0};fullScreenFigureStore;menuState=(0,t.useState)({isOpen:!1,anchorRect:null,menuItems:[]});setup(){super.setup(),this.fullScreenFigureStore=D(bv)}getMenuItems(){return[this.fullScreenMenuItem].filter(C)}get backgroundColor(){return`background-color: `+(this.env.model.getters.getChartDefinition(this.props.chartId).background||`#FFFFFF`)}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.anchorRect=op(e.currentTarget);let t=this.env.model.getters.getFigureIdFromChartId(this.props.chartId);this.menuState.menuItems=K_(t,this.env)}get fullScreenMenuItem(){if(!this.props.hasFullScreenButton)return;let e=this.env.model.getters.getChartDefinition(this.props.chartId),t=this.env.model.getters.getFigureIdFromChartId(this.props.chartId);if(e.type===`scorecard`)return;let n=t===this.fullScreenFigureStore.fullScreenFigure?.id;return{id:`fullScreenChart`,label:k(n?`Exit Full Screen`:`Full Screen`),class:`text-muted fa ${n?`fa-compress`:`fa-expand`}`,onClick:()=>{this.fullScreenFigureStore.toggleFullScreenFigure(t)}}}},Lv=class extends t.Component{static template=`o-spreadsheet-CarouselFigure`;static props={figureUI:Object,editFigureStyle:{type:Function,optional:!0},isFullScreen:{type:Boolean,optional:!0},openContextMenu:{type:Function,optional:!0}};static components={ChartDashboardMenu:Iv,MenuPopover:Fv};carouselTabsRef=(0,t.useRef)(`carouselTabs`);carouselTabsDropdownRef=(0,t.useRef)(`carouselTabsDropdown`);menuState=(0,t.useState)({isOpen:!1,anchorRect:null,menuItems:[]});hiddenItems=[];animationStore;fullScreenFigureStore;setup(){this.animationStore=D(tu),this.fullScreenFigureStore=D(bv),(0,t.useEffect)(()=>{this.selectedCarouselItem?.type===`carouselDataView`?this.props.editFigureStyle?.({"pointer-events":`none`}):this.props.editFigureStyle?.({"pointer-events":`auto`}),this.updateTabsVisibility()})}get carousel(){return this.env.model.getters.getCarousel(this.props.figureUI.id)}get selectedCarouselItem(){return this.env.model.getters.getSelectedCarouselItem(this.props.figureUI.id)}get chartComponent(){let e=this.selectedCarouselItem;if(e?.type!==`chart`)throw Error(`Selected item is not a chart`);let t=this.env.model.getters.getChartType(e.chartId),n=yv.get(t);if(!n)throw Error(`Component is not defined for type ${t}`);return n}onCarouselDoubleClick(){this.env.model.dispatch(`SELECT_FIGURE`,{figureId:this.props.figureUI.id}),this.env.openSidePanel(`CarouselPanel`,{figureId:this.props.figureUI.id})}isItemSelected(e){let t=this.selectedCarouselItem;return w(t,e)}getItemTitle(e){return rv(this.env.model.getters,e)}onCarouselTabClick(e){if(this.env.model.dispatch(`UPDATE_CAROUSEL_ACTIVE_ITEM`,{figureId:this.props.figureUI.id,sheetId:this.env.model.getters.getActiveSheetId(),item:e}),e.type===`chart`){let t=e.chartId+(this.props.isFullScreen?`-fullscreen`:``);this.animationStore?.enableAnimationForChart(t)}}get headerStyle(){let e={};if(this.selectedCarouselItem?.type===`chart`){let t=this.env.model.getters.getChartRuntime(this.selectedCarouselItem.chartId);`background`in t&&t.background?e[`background-color`]=t.background:`chartJsConfig`in t&&(e[`background-color`]=t.chartJsConfig.options?.plugins?.background?.color||`#FFFFFF`)}else e[`background-color`]=oe;return U(e)}get title(){return this.carousel.title?.text??``}get titleStyle(){return U(ov(Wt({...Ve,...this.carousel.title})))}updateTabsVisibility(){let e=this.carouselTabsRef.el,t=this.carouselTabsDropdownRef.el;if(!e||!t)return;this.hiddenItems=[];let n=op(e),r=Array.from(e.children);for(let e of r)e.style.display=`block`;let i=r.map(e=>op(e).width),a=0;for(let e=0;e<r.length;e++){let t=a+i[e]>n.width;a+=i[e],t&&(r[e].style.display=`none`,this.hiddenItems.push(this.carousel.items[e]))}t.style.display=this.hiddenItems.length?`block`:`none`}get menuId(){return`carousel-tabs-menu-`}toggleMenu(e){if(e.closedMenuId===this.menuId){this.menuState.isOpen=!1;return}let t=ap(this.carouselTabsDropdownRef),n=this.hiddenItems.map(e=>({name:this.getItemTitle(e),execute:()=>this.onCarouselTabClick(e),isActive:()=>this.isItemSelected(e),isReadonlyAllowed:!0}));this.menuState.isOpen=!0,this.menuState.anchorRect=t,this.menuState.menuItems=p(n)}toggleFullScreen(){this.selectedCarouselItem?.type===`chart`&&this.fullScreenFigureStore.toggleFullScreenFigure(this.props.figureUI.id)}get fullScreenButtonTitle(){return this.props.isFullScreen?k(`Exit Full Screen`):k(`Full Screen`)}get visibleCarouselItems(){return this.carousel.items.filter(e=>!(e.type===`carouselDataView`&&this.props.isFullScreen))}openContextMenu(e){let t=e.currentTarget;t&&this.props.openContextMenu?.(op(t))}},Rv=class extends t.Component{static template=`o-spreadsheet-ChartFigure`;static props={figureUI:Object,editFigureStyle:{type:Function,optional:!0},isFullScreen:{type:Boolean,optional:!0},openContextMenu:{type:Function,optional:!0}};static components={ChartDashboardMenu:Iv};onDoubleClick(){this.env.model.dispatch(`SELECT_FIGURE`,{figureId:this.props.figureUI.id}),this.env.openSidePanel(`ChartPanel`)}get chartType(){return this.env.model.getters.getChartType(this.chartId)}get chartId(){let e=this.env.model.getters.getChartIdFromFigureId(this.props.figureUI.id);if(!e)throw Error(`No chart found for figure ID: ${this.props.figureUI.id}`);return e}get chartComponent(){let e=this.chartType,t=yv.get(e);if(!t)throw Error(`Component is not defined for type ${e}`);return t}},zv=class extends t.Component{static template=`o-spreadsheet-ImageFigure`;static props={figureUI:Object,editFigureStyle:{type:Function,optional:!0},openContextMenu:{type:Function,optional:!0}};static components={};get figureId(){return this.props.figureUI.id}get getImagePath(){return this.env.model.getters.getImagePath(this.figureId)}};let Bv=new B;Bv.add(`chart`,{Component:Rv,SidePanelComponent:`ChartPanel`,menuBuilder:K_}),Bv.add(`image`,{Component:zv,keepRatio:!0,minFigSize:20,borderWidth:0,menuBuilder:q_}),Bv.add(`carousel`,{Component:Lv,menuBuilder:J_});var Vv=class extends t.Component{static template=`o-spreadsheet-FigureComponent`;static props={figureUI:Object,style:{type:String,optional:!0},class:{type:String,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}};static components={MenuPopover:Fv};static defaultProps={onMouseDown:()=>{},onClickAnchor:()=>{}};menuState=(0,t.useState)({isOpen:!1,anchorRect:null,menuItems:[]});figureRef=(0,t.useRef)(`figure`);figureWrapperRef=(0,t.useRef)(`figureWrapper`);menuButtonRef=(0,t.useRef)(`menuButton`);borderWidth;get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figureUI.id}get figureRegistry(){return Bv}getBorderWidth(){return this.env.isDashboard()?0:this.isSelected?2:this.borderWidth}getBorderStyle(e){return`border-${e}-width: ${this.getBorderWidth()}px;`}get wrapperStyle(){let{x:e,y:t,width:n,height:r}=this.props.figureUI;return U({left:`${e}px`,top:`${t}px`,width:`${n}px`,height:`${r}px`})}getResizerPosition(e){let t={};return e.includes(`top`)?t.top=`-3px`:e.includes(`bottom`)?t.bottom=`-3px`:t.bottom=`calc(50% - 3px)`,e.includes(`left`)?t.left=`-3px`:e.includes(`right`)?t.right=`-3px`:t.right=`calc(50% - 3px)`,U(t)}setup(){let e=Bv.get(this.props.figureUI.tag).borderWidth;this.borderWidth=e===void 0?1:e,(0,t.useEffect)((e,t,n)=>{e===t&&n?.focus({preventScroll:!0})},()=>[this.env.model.getters.getSelectedFigureId(),this.props.figureUI.id,this.figureRef.el])}clickAnchor(e,t,n){this.props.onClickAnchor(e,t,n)}onMouseDown(e){this.env.isMobile()||this.props.onMouseDown(e)}onClick(e){this.env.isMobile()&&this.props.onMouseDown(e)}onKeyDown(e){let t=pp(e);switch(t){case`Delete`:case`Backspace`:this.env.model.dispatch(`DELETE_FIGURE`,{sheetId:this.env.model.getters.getActiveSheetId(),figureId:this.props.figureUI.id}),e.preventDefault(),e.stopPropagation();break;case`ArrowDown`:case`ArrowLeft`:case`ArrowRight`:case`ArrowUp`:let{col:n,row:r,offset:i}=this.postionInBoundary(this.props.figureUI,e.key);this.env.model.dispatch(`UPDATE_FIGURE`,{sheetId:this.env.model.getters.getActiveSheetId(),figureId:this.props.figureUI.id,offset:i,col:n,row:r}),e.preventDefault(),e.stopPropagation();break;case`Ctrl+A`:e.preventDefault(),e.stopPropagation();break;case`Ctrl+Y`:case`Ctrl+Z`:t===`Ctrl+Y`?this.env.model.dispatch(`REQUEST_REDO`):t===`Ctrl+Z`&&this.env.model.dispatch(`REQUEST_UNDO`),e.preventDefault(),e.stopPropagation();break}}postionInBoundary(e,t){let n=this.env.model.getters.getActiveSheetId(),{col:r,row:i,offset:a}=e;switch(a={...a},t){case`ArrowUp`:a.y===0?(i--,a.y=this.env.model.getters.getRowSize(n,i)-1):a.y--;break;case`ArrowLeft`:a.x===0?(r--,a.x=this.env.model.getters.getColSize(n,r)-1):a.x--;break;case`ArrowDown`:a.y===this.env.model.getters.getRowSize(n,i)?(i++,a.y=0):a.y++;break;case`ArrowRight`:a.x===this.env.model.getters.getColSize(n,i)?(r++,a.x=0):a.x++}return{col:r,row:i,offset:a}}onContextMenu(e){if(this.env.isDashboard())return;let t=Ep(this.env,e);this.openContextMenu({x:t.clientX,y:t.clientY,width:0,height:0})}showMenu(){this.openContextMenu(ap(this.menuButtonRef))}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.anchorRect=e,this.menuState.menuItems=Bv.get(this.props.figureUI.tag).menuBuilder(this.props.figureUI.id,this.env)}editWrapperStyle(e){if(this.figureWrapperRef.el)for(let t in e)this.figureWrapperRef.el.style.setProperty(t,e[t]||null)}get isFigureResizable(){return this.isSelected&&!this.env.isMobile()&&!this.env.isDashboard()&&!this.env.model.getters.isCurrentSheetLocked()}},Hv=class extends yr{mutators=[`clear`,`hover`];col;row;handle(e){switch(e.type){case`ACTIVATE_SHEET`:this.clear()}}hover(e){if(e.col===this.col&&e.row===this.row)return`noStateChange`;this.col=e.col,this.row=e.row}clear(){if(this.col===void 0&&this.row===void 0)return`noStateChange`;this.col=void 0,this.row=void 0}};let Uv=/(.*?)\((.*?)\)(.*)/,Wv=[`ANY`,`BOOLEAN`,`DATE`,`NUMBER`,`STRING`,`RANGE`,`RANGE<BOOLEAN>`,`RANGE<DATE>`,`RANGE<NUMBER>`,`RANGE<STRING>`,`META`,`RANGE<META>`];function W(e,t=``,n){return Gv(e,t,n)}function Gv(e,t,n){let r=e.match(Uv),i=r[1].trim();if(!i)throw Error(`Function argument definition is missing a name: '${e}'.`);let a=[],o=!1,s=!1,c;for(let e of r[2].split(`,`)){let t=e.trim().toUpperCase(),n=Wv.find(e=>t===e);n?a.push(n):t===`RANGE<ANY>`?a.push(`RANGE`):t===`OPTIONAL`?o=!0:t===`REPEATING`?s=!0:t.startsWith(`DEFAULT=`)&&(c=e.trim().slice(8))}let l={name:i,description:t,type:a};return(a.includes(`ANY`)||a.includes(`RANGE`))&&(l.acceptErrors=!0),o&&(l.optional=!0),s&&(l.repeating=!0),c!==void 0&&(l.default=!0,l.defaultValue=c),a.some(e=>e.startsWith(`RANGE`))&&(l.acceptMatrix=!0),a.every(e=>e.startsWith(`RANGE`))&&(l.acceptMatrixOnly=!0),n&&n.length>0&&(l.proposalValues=n),l}function Kv(e,t){let n=0,r=0,i=0,a=0;for(let e of t.args)n++,!e.optional&&!e.default&&r++,e.repeating&&i++,(e.optional||e.default)&&!e.repeating&&a++;let o=t;return o.minArgRequired=r,o.maxArgPossible=i?1/0:n,o.nbrArgRepeating=i,o.nbrOptionalNonRepeatingArgs=a,o.hidden=t.hidden||!1,o.name=e,o}let qv={};function Jv(e,t){let n=e.name;return qv[n]?.[t]||(qv[n]||(qv[n]={}),qv[n][t]||(qv[n][t]=Yv(e,t)),qv[n][t])}function Yv(e,t){let n={},r=e.nbrArgRepeating?Math.floor((t-e.minArgRequired)/e.nbrArgRepeating):0,i=e.nbrArgRepeating*r,a=t-e.minArgRequired-i,o=0,s=0;for(let t=0;t<e.args.length;t++){let i=e.args[t];if((i.optional||i.default)&&!i.repeating){s<a&&(n[o]={index:t},o++),s++;continue}if(i.repeating){let a=+!i.optional;for(let i=0;i<r+a;i++)for(let r=0;r<e.nbrArgRepeating;r++)n[o]={index:t+r,repeatingGroupIndex:i},o++;t+=e.nbrArgRepeating-1;continue}n[o]={index:t},o++}return e=>n[e]}let Xv=[`META`,`RANGE<META>`];function Zv(e){if(e.nbrArgRepeating&&e.nbrOptionalNonRepeatingArgs>=e.nbrArgRepeating)throw Error(`Function ${e.name} has more optional arguments than repeatable ones.`);let t=!1,n=!1;for(let r of e.args){if(r.type.some(e=>Xv.includes(e))&&r.type.some(e=>!Xv.includes(e)))throw Error(`Function ${e.name} has a mix of META and non-META types in the same argument: ${r.type}.`);if(r.repeating){if(!n&&t)throw Error(`Function ${e.name} has non-consecutive repeating arguments. All repeating arguments must be declared consecutively.`);t=!0,n=!0}else n=!1}}function Qv(e){function t(...t){let i=[],a=Jv(e,t.length);for(let n=0;n<t.length;n++){let r=a(n).index??-1,o=e.args[r],s=t[n];if(!Ta(s)&&o.acceptMatrixOnly)throw new ga(k(`Function %s expects the parameter '%s' to be reference to a cell or range.`,e.name,(n+1).toString()));i.push(!o.acceptMatrix)}return n(Qa(r.bind(this),t,i))}function n(t){return Ta(t)?Xa(t,t=>ty(t,e.name)):ty(t,e.name),t}function r(...t){for(let n=0;n<t.length;n++){let r=t[n],i=Jv(e,t.length);if(!e.args[i(n).index??n].acceptErrors&&!Ta(r)&&M(r?.value))return r}try{return i.apply(this,t)}catch(t){return $v(t,e.name)}}function i(...t){this.debug&&=!1;let n=e.compute.apply(this,t);return Ta(n)?typeof n[0][0]==`object`&&n[0][0]!==null&&`value`in n[0][0]?n:Ya(n,e=>({value:e})):typeof n==`object`&&n&&`value`in n?n:(e.name,{value:n})}return t}function $v(e,t){return ey(e)&&M(e.value)?(ry(e)&&ty(e,t),e):(console.error(e),new j(ny+(ry(e)?` `+e.message:``)))}function ey(e){return e?.value!==void 0&&typeof e.value==`string`}function ty(e,t){e.message?.includes(`[[FUNCTION_NAME]]`)&&(e.message=e.message.replace(`[[FUNCTION_NAME]]`,t))}let ny=k(`An unexpected error occurred. Submit a support ticket at odoo.com/help.`);function ry(e){return e?.message!==void 0&&typeof e.message==`string`}function iy(e,t,n){if(Ta(e)){let r=n.decimalSeparator===`,`?`/`:`,`;return`{${Za(e).map(e=>e.map(e=>ay(e,t,n)).join(r)).join(`;`)}}`}return ay(e,t,n)}function ay(e,t,n){let r=e.value;switch(typeof r){case`number`:return z(r,{locale:n,format:e.format});case`string`:return M(r)?r:`"${r}"`;case`boolean`:return r?`TRUE`:`FALSE`}return t}var oy=l({ARRAYTOTEXT:()=>Fy,ARRAY_CONSTRAIN:()=>ly,ARRAY_LITERAL:()=>uy,ARRAY_ROW:()=>dy,CHOOSECOLS:()=>fy,CHOOSEROWS:()=>py,EXPAND:()=>my,FLATTEN:()=>hy,FREQUENCY:()=>gy,HSTACK:()=>_y,MDETERM:()=>vy,MINVERSE:()=>yy,MMULT:()=>by,SUMPRODUCT:()=>xy,SUMX2MY2:()=>Cy,SUMX2PY2:()=>wy,SUMXMY2:()=>Ty,TOCOL:()=>Oy,TOROW:()=>ky,TRANSPOSE:()=>Ay,VSTACK:()=>jy,WRAPCOLS:()=>My,WRAPROWS:()=>Ny});function sy(e,t){let n=e.map(L),r=n.map(e=>e?.[0]?.length??0),i=Math.max(...r);if(t?.requireSameRowCount){let e=r[0];if(r.some(t=>t!==e))return new j(k(`All ranges in [[FUNCTION_NAME]] must have the same number of columns (got %s).`,r.join(`, `)))}let a=[];for(let e of n)for(let t=0;t<e.length;t++){let n=Array(i).fill({value:null});for(let r=0;r<e[t].length;r++)n[r]=e[t][r];a.push(n)}return a}function cy(e,t){let n=e.map(L),r=n.map(e=>e?.length??0),i=Math.max(...r);if(t?.requireSameColCount){let e=r[0];if(r.some(t=>t!==e))return new j(k(`All ranges in [[FUNCTION_NAME]] must have the same number of columns (got %s).`,r.join(`, `)))}let a=Ja(i,n.reduce((e,t)=>e+(t?.[0]?.length??0),0),()=>({value:null})),o=0;for(let e of n){for(let t=0;t<e.length;t++)for(let n=0;n<e[t].length;n++)a[t][o+n]=e[t][n];o+=e[0]?.length??0}return a}let ly={description:k(`Returns a result array constrained to a specific width and height.`),args:[W(`input_range (any, range<any>)`,k(`The range to constrain.`)),W(`rows (number)`,k(`The number of rows in the constrained array.`)),W(`columns (number)`,k(`The number of columns in the constrained array.`))],compute:function(e,t,n){let r=L(e),i=Fa(t?.value,this.locale),a=Fa(n?.value,this.locale);if(i<=0)return new j(k(`The rows argument (%s) must be strictly positive.`,i.toString()));if(a<=0)return new j(k(`The columns argument (%s) must be strictly positive.`,a.toString()));let o=Math.min(i,r[0].length);return Ja(Math.min(a,r.length),o,(e,t)=>r[e][t])},isExported:!1},uy={description:k(`Appends ranges vertically and in sequence to return a larger array. All ranges must have the same number of columns.`),args:[W(`range (any, range<any>, repeating)`,k(`The range to be appended.`))],compute:function(...e){return cy(e,{requireSameColCount:!0})},isExported:!1,hidden:!0},dy={description:k(`Appends ranges horizontally and in sequence to return a larger array. All ranges must have the same number of rows.`),args:[W(`range (any, range<any>, repeating)`,k(`The range to be appended.`))],compute:function(...e){return sy(e,{requireSameRowCount:!0})},isExported:!1,hidden:!0},fy={description:k(`Creates a new array from the selected columns in the existing range.`),args:[W(`array (any, range<any>)`,k(`The array that contains the columns to be returned.`)),W(`col_num (number, range<number>, repeating)`,k(`The column index of the column to be returned.`))],compute:function(e,...t){let n=L(e),r=uo(t,e=>Fa(e?.value,this.locale)),i=r.filter(e=>e===0||n.length<Math.abs(e));if(i.length!==0)return new j(k(`The columns arguments must be between -%s and %s (got %s), excluding 0.`,n.length.toString(),n.length.toString(),i.join(`,`)));let a=Array(r.length);for(let e=0;e<r.length;e++)r[e]>0?a[e]=n[r[e]-1]:a[e]=n[n.length+r[e]];return a},isExported:!0},py={description:k(`Creates a new array from the selected rows in the existing range.`),args:[W(`array (any, range<any>)`,k(`The array that contains the rows to be returned.`)),W(`row_num (number, range<number>, repeating)`,k(`The row index of the row to be returned.`))],compute:function(e,...t){let n=L(e),r=uo(t,e=>Fa(e?.value,this.locale)),i=n.length,a=r.filter(e=>e===0||n[0].length<Math.abs(e));return a.length===0?Ja(i,r.length,(e,t)=>r[t]>0?n[e][r[t]-1]:n[e][n[e].length+r[t]]):new j(k(`The rows arguments must be between -%s and %s (got %s), excluding 0.`,n[0].length.toString(),n[0].length.toString(),a.join(`,`)))},isExported:!0},my={description:k(`Expands or pads an array to specified row and column dimensions.`),args:[W(`array (any, range<any>)`,k(`The array to expand.`)),W(`rows (number)`,k(`The number of rows in the expanded array. If missing, rows will not be expanded.`)),W(`columns (number, optional)`,k(`The number of columns in the expanded array. If missing, columns will not be expanded.`)),W(`pad_with (any, default=0)`,k(`The value with which to pad.`))],compute:function(e,t,n,r={value:0}){let i=L(e),a=Fa(t?.value,this.locale),o=n===void 0?i.length:Fa(n.value,this.locale);return a<i[0].length?new j(k(`The rows arguments (%s) must be greater or equal than the number of rows of the array.`,a.toString())):o<i.length?new j(k(`The columns arguments (%s) must be greater or equal than the number of columns of the array.`,o.toString())):Ja(o,a,(e,t)=>e>=i.length||t>=i[e].length?r:i[e][t])},isExported:!0},hy={description:k(`Flattens all the values from one or more ranges into a single column.`),args:[W(`range (any, range<any>, repeating)`,k(`The range to flatten.`))],compute:function(...e){return[uo(e,e=>e===void 0?{value:``}:e)]},isExported:!1},gy={description:k(`Calculates the frequency distribution of a range.`),args:[W(`data (range<number>)`,k(`The array of ranges containing the values to be counted.`)),W(`classes (number, range<number>)`,k(`The range containing the set of classes.`))],compute:function(e,t){let n=uo([e],e=>e.value).filter(e=>typeof e==`number`),r=uo([t],e=>e.value).filter(e=>typeof e==`number`).map((e,t)=>({initialIndex:t,value:e,count:0})).sort((e,t)=>e.value-t.value);r.push({initialIndex:r.length,value:1/0,count:0});let i=n.sort((e,t)=>e-t),a=0;for(let e of i){for(;e>r[a].value&&a<r.length-1;)a++;r[a].count++}return[r.sort((e,t)=>e.initialIndex-t.initialIndex).map(e=>e.count)]},isExported:!0},_y={description:k(`Appends ranges horizontally and in sequence to return a larger array.`),args:[W(`range (any, range<any>, repeating)`,k(`The range to be appended.`))],compute:function(...e){return sy(e)},isExported:!0},vy={description:k(`Returns the matrix determinant of a square matrix.`),args:[W(`square_matrix (number, range<number>)`,k(`An range with an equal number of rows and columns representing a matrix whose determinant will be calculated.`))],compute:function(e){let t=Na(e,`square_matrix`);return gm(t)?ym(t).determinant:new j(k(`The argument square_matrix must have the same number of columns and rows.`))},isExported:!0},yy={description:k(`Returns the multiplicative inverse of a square matrix.`),args:[W(`square_matrix (number, range<number>)`,k(`An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated.`))],compute:function(e){let t=Na(e,`square_matrix`);if(!gm(t))return new j(k(`The argument square_matrix must have the same number of columns and rows.`));let{inverted:n}=ym(t);return n||new j(k(`The matrix is not invertible.`))},isExported:!0},by={description:k(`Calculates the matrix product of two matrices.`),args:[W(`matrix1 (number, range<number>)`,k(`The first matrix in the matrix multiplication operation.`)),W(`matrix2 (number, range<number>)`,k(`The second matrix in the matrix multiplication operation.`))],compute:function(e,t){let n=Na(e,`matrix1`),r=Na(t,`matrix2`);return n.length===0||r.length===0?new j(k(`The first and second arguments of [[FUNCTION_NAME]] must be non-empty matrices.`)):n.length===r[0].length?xm(n,r):new j(k(`In [[FUNCTION_NAME]], the number of columns of the first matrix (%s) must be equal to the number of rows of the second matrix (%s).`,n.length.toString(),r[0].length.toString()))},isExported:!0},xy={description:k(`Calculates the sum of the products of corresponding entries in equal-sized ranges.`),args:[W(`range (number, range<number>, repeating)`,k(`The range whose entries will be multiplied with corresponding entries in the other range.`))],compute:function(...e){if(!hm(...e))return new j(k(`All the ranges must have the same dimensions.`));let t=e.map(L),n=0;for(let e=0;e<t[0].length;e++)for(let r=0;r<t[0][e].length;r++){if(!t.every(t=>typeof t[e][r].value==`number`))continue;let i=1;for(let n of t)i*=N(n[e][r],this.locale);n+=i}return n},isExported:!0};function Sy(e,t,n){if(!hm(e,t))return new j(k(`The arguments array_x and array_y must have the same dimensions.`));let r=L(e),i=L(t),a=!1,o=0;for(let e in r)for(let t in r[e]){let s=r[e][t].value,c=i[e][t].value;typeof s!=`number`||typeof c!=`number`||(a=!0,o+=n(s,c))}return a?o:new j(k(`The arguments array_x and array_y must contain at least one pair of numbers.`))}let Cy={description:k(`Calculates the sum of the difference of the squares of the values in two array.`),args:[W(`array_x (number, range<number>)`,k(`The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.`)),W(`array_y (number, range<number>)`,k(`The array or range of values whose squares will be subtracted from the squares of corresponding entries in array_x and added together.`))],compute:function(e,t){return Sy(e,t,(e,t)=>e**2-t**2)},isExported:!0},wy={description:k(`Calculates the sum of the sum of the squares of the values in two array.`),args:[W(`array_x (number, range<number>)`,k(`The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.`)),W(`array_y (number, range<number>)`,k(`The array or range of values whose squares will be added to the squares of corresponding entries in array_x and added together.`))],compute:function(e,t){return Sy(e,t,(e,t)=>e**2+t**2)},isExported:!0},Ty={description:k(`Calculates the sum of squares of the differences of values in two array.`),args:[W(`array_x (number, range<number>)`,k(`The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.`)),W(`array_y (number, range<number>)`,k(`The array or range of values that will be subtracted from corresponding entries in array_x, the result squared, and all such results added together.`))],compute:function(e,t){return Sy(e,t,(e,t)=>(e-t)**2)},isExported:!0},Ey=[W(`array (any, range<any>)`,k(`The array which will be transformed.`)),W(`ignore (number, default=0)`,k(`Whether to ignore certain types of values. By default, no values are ignored.`),[{value:0,label:k(`Keep all values (default)`)},{value:1,label:k(`Ignore blanks`)},{value:2,label:k(`Ignore errors`)},{value:3,label:k(`Ignore blanks and errors`)}]),W(`scan_by_column (number, default=false)`,k(`Scan the array by column. By default, the array is scanned by row.`),[{value:!1,label:k(`Scan by row (default)`)},{value:!0,label:k(`Scan by column`)}])];function Dy(e){let t=Math.trunc(e);if(t===0)return()=>!0;if(t===1)return e=>e.value!==null;if(t===2)return e=>!M(e.value);if(t===3)return e=>e.value!==null&&!M(e.value);throw new j(k(`Argument ignore must be between 0 and 3`))}let Oy={description:k(`Transforms a range of cells into a single column.`),args:Ey,compute:function(e,t={value:0},n={value:!1}){let r=L(e),i=N(t.value,this.locale),a=(F(n.value)?r:Za(r)).flat().filter(Dy(i));return a.length===0?new ya(k(`No results for the given arguments of TOCOL.`)):[a]},isExported:!0},ky={description:k(`Transforms a range of cells into a single row.`),args:Ey,compute:function(e,t={value:0},n={value:!1}){let r=L(e),i=N(t.value,this.locale),a=(F(n.value)?r:Za(r)).flat().filter(Dy(i)).map(e=>[e]);return a.length===0||a[0].length===0?new ya(k(`No results for the given arguments of TOROW.`)):a},isExported:!0},Ay={description:k(`Transposes the rows and columns of a range.`),args:[W(`range (any, range<any>)`,k(`The range to be transposed.`))],compute:function(e){let t=L(e),n=t[0].length,r=t.length;return Ja(n,r,(e,n)=>t[n][e])},isExported:!0},jy={description:k(`Appends ranges vertically and in sequence to return a larger array.`),args:[W(`range (any, range<any>, repeating)`,k(`The range to be appended.`))],compute:function(...e){return cy(e)},isExported:!0},My={description:k(`Wraps the provided row or column of cells by columns after a specified number of elements to form a new array.`),args:[W(`range (any, range<any>)`,k(`The range to wrap.`)),W(`wrap_count (number)`,k(`The maximum number of cells for each column, rounded down to the nearest whole number.`)),W(`pad_with (any, default=0)`,k(`The value with which to fill the extra cells in the range.`))],compute:function(e,t,n={value:0}){let r=L(e),i=Fa(t?.value,this.locale);if(!mm(r))return new j(k(`Argument range must be a single row or column.`));let a=r.flat();return Ja(Math.ceil(a.length/i),i,(e,t)=>{let r=e*i+t;return r<a.length?a[r]:n})},isExported:!0},Ny={description:k(`Wraps the provided row or column of cells by rows after a specified number of elements to form a new array.`),args:[W(`range (any, range<any>)`,k(`The range to wrap.`)),W(`wrap_count (number)`,k(`The maximum number of cells for each row, rounded down to the nearest whole number.`)),W(`pad_with (any, default=0)`,k(`The value with which to fill the extra cells in the range.`))],compute:function(e,t,n={value:0}){let r=L(e),i=Fa(t?.value,this.locale);if(!mm(r))return new j(k(`Argument range must be a single row or column.`));let a=r.flat();return Ja(i,Math.ceil(a.length/i),(e,t)=>{let r=t*i+e;return r<a.length?a[r]:n})},isExported:!0},Py=[{value:0,label:k(`Concise format\xA0(default)`)},{value:1,label:k(`Strict format`)}],Fy={description:k(`returns an array of text values from any specified range. It passes text values unchanged, and converts non-text values to text.`),args:[W(`array (range)`,k(`The array to convert into text`)),W(`format (number, default=0)`,k(`The format of the returned data.`),Py)],compute:function(e,t={value:0}){let n=N(t,this.locale),r=L(e);if(n===1)return iy(r,``,this.locale);if(n===0){let e=this.locale.decimalSeparator===`,`?`/`:`,`;return Za(r).flatMap(e=>e.map(e=>M(e.value)?e.value:P(e))).join(e)}else return new j(k(`Format must be 0 or 1`))},isExported:!0};var Iy=l({ABS:()=>Ry,ACOS:()=>zy,ACOSH:()=>By,ACOT:()=>Vy,ACOTH:()=>Hy,ASIN:()=>Uy,ASINH:()=>Wy,ATAN:()=>Gy,ATAN2:()=>Ky,ATANH:()=>qy,CEILING:()=>Jy,CEILING_MATH:()=>Xy,CEILING_PRECISE:()=>Zy,COS:()=>Qy,COSH:()=>$y,COT:()=>eb,COTH:()=>tb,COUNTBLANK:()=>nb,COUNTIF:()=>rb,COUNTIFS:()=>ib,COUNTUNIQUE:()=>ab,COUNTUNIQUEIFS:()=>ob,CSC:()=>sb,CSCH:()=>cb,DECIMAL:()=>lb,DEGREES:()=>ub,EXP:()=>db,FLOOR:()=>fb,FLOOR_MATH:()=>mb,FLOOR_PRECISE:()=>hb,INT:()=>Zb,ISEVEN:()=>gb,ISODD:()=>vb,ISO_CEILING:()=>_b,LN:()=>yb,LOG:()=>bb,MOD:()=>Sb,MUNIT:()=>Cb,ODD:()=>wb,PI:()=>Tb,POWER:()=>Eb,PRODUCT:()=>Db,RAND:()=>Ob,RANDARRAY:()=>kb,RANDBETWEEN:()=>Ab,ROUND:()=>jb,ROUNDDOWN:()=>Mb,ROUNDUP:()=>Nb,SEC:()=>Pb,SECH:()=>Fb,SEQUENCE:()=>Ib,SIN:()=>Lb,SINH:()=>Rb,SQRT:()=>zb,SUBTOTAL:()=>Ub,SUM:()=>Wb,SUMIF:()=>Gb,SUMIFS:()=>Kb,TAN:()=>qb,TANH:()=>Jb,TRUNC:()=>Xb});let Ly=/^-?[a-z0-9]+$/i,Ry={description:k(`Absolute value of a number.`),args:[W(`value (number)`,k(`The number of which to return the absolute value.`))],compute:function(e){return Math.abs(N(e,this.locale))},isExported:!0},zy={description:k(`Inverse cosine of a value, in radians.`),args:[W(`value (number)`,k(`The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.`))],compute:function(e){let t=N(e,this.locale);return Math.abs(t)>1?new j(k(`The value (%s) must be between -1 and 1 inclusive.`,t)):Math.acos(t)},isExported:!0},By={description:k(`Inverse hyperbolic cosine of a number.`),args:[W(`value (number)`,k(`The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.`))],compute:function(e){let t=N(e,this.locale);return t<1?new j(k(`The value (%s) must be greater than or equal to 1.`,t)):Math.acosh(t)},isExported:!0},Vy={description:k(`Inverse cotangent of a value.`),args:[W(`value (number)`,k(`The value for which to calculate the inverse cotangent.`))],compute:function(e){let t=N(e,this.locale);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},Hy={description:k(`Inverse hyperbolic cotangent of a value.`),args:[W(`value (number)`,k(`The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.`))],compute:function(e){let t=N(e,this.locale);return Math.abs(t)<=1?new j(k(`The value (%s) cannot be between -1 and 1 inclusive.`,t)):Math.log((t+1)/(t-1))/2},isExported:!0},Uy={description:k(`Inverse sine of a value, in radians.`),args:[W(`value (number)`,k(`The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.`))],compute:function(e){let t=N(e,this.locale);return Math.abs(t)>1?new j(k(`The value (%s) must be between -1 and 1 inclusive.`,t)):Math.asin(t)},isExported:!0},Wy={description:k(`Inverse hyperbolic sine of a number.`),args:[W(`value (number)`,k(`The value for which to calculate the inverse hyperbolic sine.`))],compute:function(e){return Math.asinh(N(e,this.locale))},isExported:!0},Gy={description:k(`Inverse tangent of a value, in radians.`),args:[W(`value (number)`,k(`The value for which to calculate the inverse tangent.`))],compute:function(e){return Math.atan(N(e,this.locale))},isExported:!0},Ky={description:k(`Angle from the X axis to a point (x,y), in radians.`),args:[W(`x (number)`,k(`The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.`)),W(`y (number)`,k(`The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.`))],compute:function(e,t){let n=N(e,this.locale),r=N(t,this.locale);return n===0&&r===0?new Sa(k(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):Math.atan2(r,n)},isExported:!0},qy={description:k(`Inverse hyperbolic tangent of a number.`),args:[W(`value (number)`,k(`The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.`))],compute:function(e){let t=N(e,this.locale);return Math.abs(t)>=1?new j(k(`The value (%s) must be between -1 and 1 exclusive.`,t)):Math.atanh(t)},isExported:!0},Jy={description:k(`Rounds number up to nearest multiple of factor.`),args:[W(`value (number)`,k(`The value to round up to the nearest integer multiple of factor.`)),W(`factor (number, default=1)`,k(`The number to whose multiples value will be rounded.`))],compute:function(e,t={value:1}){let n=N(e,this.locale),r=N(t,this.locale);return r<0&&n>0?new j(k(`The factor (%s) must be positive when the value (%s) is positive.`,r,n)):{value:r?Math.ceil(n/r)*r:0,format:e?.format}},isExported:!0};function Yy(e,t,n=0){return t===0?0:(t=Math.abs(t),e>=0?Math.ceil(e/t)*t:n===0?-Math.floor(Math.abs(e)/t)*t:-Math.ceil(Math.abs(e)/t)*t)}let Xy={description:k(`Rounds number up to nearest multiple of factor.`),args:[W(`number (number)`,k(`The value to round up to the nearest integer multiple of significance.`)),W(`significance (number, default=1)`,k(`The number to whose multiples number will be rounded. The sign of significance will be ignored.`)),W(`mode (number, default=0)`,k(`If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero.`))],compute:function(e,t={value:1},n={value:0}){let r=N(t,this.locale);return{value:Yy(N(e,this.locale),r,N(n,this.locale)),format:e?.format}},isExported:!0},Zy={description:k(`Rounds number up to nearest multiple of factor.`),args:[W(`number (number)`,k(`The value to round up to the nearest integer multiple of significance.`)),W(`significance (number, default=1)`,k(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){let n=N(t,this.locale);return{value:Yy(N(e,this.locale),n),format:e?.format}},isExported:!0},Qy={description:k(`Cosine of an angle provided in radians.`),args:[W(`angle (number)`,k(`The angle to find the cosine of, in radians.`))],compute:function(e){return Math.cos(N(e,this.locale))},isExported:!0},$y={description:k(`Hyperbolic cosine of any real number.`),args:[W(`value (number)`,k(`Any real value to calculate the hyperbolic cosine of.`))],compute:function(e){return Math.cosh(N(e,this.locale))},isExported:!0},eb={description:k(`Cotangent of an angle provided in radians.`),args:[W(`angle (number)`,k(`The angle to find the cotangent of, in radians.`))],compute:function(e){let t=N(e,this.locale);return t===0?new Sa(k(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):1/Math.tan(t)},isExported:!0},tb={description:k(`Hyperbolic cotangent of any real number.`),args:[W(`value (number)`,k(`Any real value to calculate the hyperbolic cotangent of.`))],compute:function(e){let t=N(e,this.locale);return t===0?new Sa(k(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):1/Math.tanh(t)},isExported:!0},nb={description:k(`Number of empty values.`),args:[W(`value (any, range, repeating)`,k(`Value or range in which to count the number of blanks.`))],compute:function(...e){return Ga(e,(e,t)=>t===void 0||t.value===null||t.value===``?e+1:e,0)},isExported:!0},rb={description:k(`A conditional count across a range.`),args:[W(`range (range)`,k(`The range that is tested against criterion.`)),W(`criterion (string)`,k(`The pattern or test to apply to range.`))],compute:function(...e){let t=0;return io(e,(e,n)=>{t+=1},this.locale),t},isExported:!0},ib={description:k(`Count values depending on multiple criteria.`),args:[W(`criteria_range (any, range, repeating)`,k(`Range over which to evaluate criteria.`)),W(`criterion (string, repeating)`,k(`Criteria to check.`))],compute:function(...e){let t=0;return io(e,(e,n)=>{t+=1},this.locale),t},isExported:!0},ab={description:k(`Counts number of unique values in a range.`),args:[W(`value (any, range, repeating)`,k(`Value or range to consider for uniqueness.`))],compute:function(...e){return Ym(e)}},ob={description:k(`Counts number of unique values in a range, filtered by a set of criteria.`),args:[W(`range (range)`,k(`The range of cells from which the number of unique values will be counted.`)),W(`criteria_range (any, range, repeating)`,k(`Range over which to evaluate criteria.`)),W(`criterion (string, repeating)`,k(`Criteria to check.`))],compute:function(e,...t){let n=new Set;return io(t,(t,r)=>{let i=e[t]?.[r];fo(i)&&n.add(i.value)},this.locale),n.size}},sb={description:k(`Cosecant of an angle provided in radians.`),args:[W(`angle (number)`,k(`The angle to find the cosecant of, in radians.`))],compute:function(e){let t=N(e,this.locale);return t===0?new Sa(k(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):1/Math.sin(t)},isExported:!0},cb={description:k(`Hyperbolic cosecant of any real number.`),args:[W(`value (number)`,k(`Any real value to calculate the hyperbolic cosecant of.`))],compute:function(e){let t=N(e,this.locale);return t===0?new Sa(k(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):1/Math.sinh(t)},isExported:!0},lb={description:k(`Converts from another base to decimal.`),args:[W(`value (string)`,k(`The number to convert.`)),W(`base (number)`,k(`The base to convert the value from.`))],compute:function(e,t){let n=N(t,this.locale);if(n=Math.floor(n),2>n||n>36)return new j(k(`The base (%s) must be between 2 and 36 inclusive.`,n));let r=P(e);if(r===``)return 0;if(!Ly.test(r))return new j(k(`The value (%s) must be a valid base %s representation.`,r,n));let i=parseInt(r,n);return isNaN(i)?new j(k(`The value (%s) must be a valid base %s representation.`,r,n)):i},isExported:!0},ub={description:k(`Converts an angle value in radians to degrees.`),args:[W(`angle (number)`,k(`The angle to convert from radians to degrees.`))],compute:function(e){return N(e,this.locale)*180/Math.PI},isExported:!0},db={description:k(`Euler's number, e (~2.718) raised to a power.`),args:[W(`value (number)`,k(`The exponent to raise e.`))],compute:function(e){return Math.exp(N(e,this.locale))},isExported:!0},fb={description:k(`Rounds number down to nearest multiple of factor.`),args:[W(`value (number)`,k(`The value to round down to the nearest integer multiple of factor.`)),W(`factor (number, default=1)`,k(`The number to whose multiples value will be rounded.`))],compute:function(e,t={value:1}){let n=N(e,this.locale),r=N(t,this.locale);return r<0&&n>0?new j(k(`The factor (%s) must be positive when the value (%s) is positive.`,r,n)):{value:r?Math.floor(n/r)*r:0,format:e?.format}},isExported:!0};function pb(e,t,n=0){return t===0?0:(t=Math.abs(t),e>=0?Math.floor(e/t)*t:n===0?-Math.ceil(Math.abs(e)/t)*t:-Math.floor(Math.abs(e)/t)*t)}let mb={description:k(`Rounds number down to nearest multiple of factor.`),args:[W(`number (number)`,k(`The value to round down to the nearest integer multiple of significance.`)),W(`significance (number, default=1)`,k(`The number to whose multiples number will be rounded. The sign of significance will be ignored.`)),W(`mode (number, default=0)`,k(`If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero.`))],compute:function(e,t={value:1},n={value:0}){let r=N(t,this.locale);return{value:pb(N(e,this.locale),r,N(n,this.locale)),format:e?.format}},isExported:!0},hb={description:k(`Rounds number down to nearest multiple of factor.`),args:[W(`number (number)`,k(`The value to round down to the nearest integer multiple of significance.`)),W(`significance (number, default=1)`,k(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){let n=N(t,this.locale);return{value:pb(N(e,this.locale),n),format:e?.format}},isExported:!0},gb={description:k(`Whether the provided value is even.`),args:[W(`value (number)`,k(`The value to be verified as even.`))],compute:function(e){let t=Pa(e,this.locale);return!(Math.floor(Math.abs(t))&1)},isExported:!0},_b={description:k(`Rounds number up to nearest multiple of factor.`),args:[W(`number (number)`,k(`The value to round up to the nearest integer multiple of significance.`)),W(`significance (number, default=1)`,k(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){return{value:Yy(N(e,this.locale),N(t,this.locale)),format:e?.format}},isExported:!0},vb={description:k(`Whether the provided value is even.`),args:[W(`value (number)`,k(`The value to be verified as even.`))],compute:function(e){let t=Pa(e,this.locale);return!!(Math.floor(Math.abs(t))&1)},isExported:!0},yb={description:k(`The logarithm of a number, base e (euler's number).`),args:[W(`value (number)`,k(`The value for which to calculate the logarithm, base e.`))],compute:function(e){let t=N(e,this.locale);return t<=0?new j(k(`The value (%s) must be strictly positive.`,t)):Math.log(t)},isExported:!0},bb={description:k(`The logarithm of a number, for a given base.`),args:[W(`value (number)`,k(`The value for which to calculate the logarithm.`)),W(`base (number, default=10)`,k(`The base of the logarithm.`))],compute:function(e,t={value:10}){let n=N(e,this.locale),r=N(t,this.locale);return n<=0?new j(k(`The value (%s) must be strictly positive.`,n)):r<=0?new j(k(`The base (%s) must be strictly positive.`,r)):r===1?new j(k(`The base must be different from 1.`)):Math.log10(n)/Math.log10(r)},isExported:!0};function xb(e,t){pm(t,k(`The divisor must be different from 0.`));let n=e%t;return n>0&&t<0||n<0&&t>0?n+t:n}let Sb={description:k(`Modulo (remainder) operator.`),args:[W(`dividend (number)`,k(`The number to be divided to find the remainder.`)),W(`divisor (number)`,k(`The number to divide by.`))],compute:function(e,t){let n=N(t,this.locale);return{value:xb(N(e,this.locale),n),format:e?.format}},isExported:!0},Cb={description:k(`Returns a n x n unit matrix, where n is the input dimension.`),args:[W(`dimension (number)`,k(`An integer specifying the dimension size of the unit matrix. It must be positive.`))],compute:function(e){let t=Fa(e,this.locale);return t<1?new j(k(`The argument dimension must be positive`)):vm(t)},isExported:!0},wb={description:k(`Rounds a number up to the nearest odd integer.`),args:[W(`value (number)`,k(`The value to round to the next greatest odd number.`))],compute:function(e){let t=N(e,this.locale),n=Math.ceil(Math.abs(t));return n=n&1?n:n+1,{value:t<0?-n:n,format:e?.format}},isExported:!0},Tb={description:k(`The number pi.`),args:[],compute:function(){return Math.PI},isExported:!0},Eb={description:k(`A number raised to a power.`),args:[W(`base (number)`,k(`The number to raise to the exponent power.`)),W(`exponent (number)`,k(`The exponent to raise base to.`))],compute:function(e,t){let n=N(e,this.locale),r=N(t,this.locale);return n<0&&!Number.isInteger(r)?new j(k(`The exponent (%s) must be an integer when the base is negative.`,r)):{value:n**+r,format:e?.format}},isExported:!0},Db={description:k(`Result of multiplying a series of numbers together.`),args:[W(`factor (number, range<number>, repeating)`,k(`Number or range to calculate for the product.`))],compute:function(...e){let t=0,n=1;for(let r of e)if(Ta(r))for(let e of r)for(let r of e){let e=r.value;if(typeof e==`number`&&(n*=e,t+=1),M(e))return r}else r!==void 0&&r.value!==null&&(n*=Pa(r,this.locale),t+=1);return{value:t===0?0:n,format:Da(e[0])}},isExported:!0},Ob={description:k(`A random number between 0 inclusive and 1 exclusive.`),args:[],compute:function(){return Math.random()},isExported:!0},kb={description:k(`Returns a grid of random numbers between 0 inclusive and 1 exclusive.`),args:[W(`rows (number, default=1)`,k(`The number of rows to be returned.`)),W(`columns (number, default=1)`,k(`The number of columns to be returned.`)),W(`min (number, default=0)`,k(`The minimum number you would like returned.`)),W(`max (number, default=1)`,k(`The maximum number you would like returned.`)),W(`whole_number (boolean, default=FALSE)`,k(`Return a whole number or a decimal value.`),[{value:!1,label:k(`Decimal (default)`)},{value:!0,label:k(`Integer`)}])],compute:function(e={value:1},t={value:1},n={value:0},r={value:1},i={value:!1}){let a=Fa(t,this.locale),o=Fa(e,this.locale),s=N(n,this.locale),c=N(r,this.locale),l=F(i);if(a<1)return new j(k(`The number of columns (%s) must be positive.`,a));if(o<1)return new j(k(`The number of rows (%s) must be positive.`,o));if(s>c)return new j(k(`The maximum (%s) must be greater than or equal to the minimum (%s).`,c,s));if(l&&(!Number.isInteger(s)||!Number.isInteger(c)))return new j(k(`The maximum (%s) and minimum (%s) must be integers when whole_number is TRUE.`,c.toString(),s.toString()));let u=Array(a);for(let e=0;e<a;e++){u[e]=Array(o);for(let t=0;t<o;t++)l?u[e][t]=Math.floor(Math.random()*(c-s+1)+s):u[e][t]=s+Math.random()*(c-s)}return u},isExported:!0},Ab={description:k(`Random integer between two values, inclusive.`),args:[W(`low (number)`,k(`The low end of the random range.`)),W(`high (number)`,k(`The high end of the random range.`))],compute:function(e,t){let n=N(e,this.locale);Number.isInteger(n)||(n=Math.ceil(n));let r=N(t,this.locale);return Number.isInteger(r)||(r=Math.floor(r)),n>r?new j(k(`The high (%s) must be greater than or equal to the low (%s).`,r,n)):{value:n+Math.ceil((r-n+1)*Math.random())-1,format:e?.format}},isExported:!0},jb={description:k(`Rounds a number according to standard rules.`),args:[W(`value (number)`,k(`The value to round to places number of places.`)),W(`places (number, default=0)`,k(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=N(e,this.locale),r=N(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.round(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.round(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},Mb={description:k(`Rounds down a number.`),args:[W(`value (number)`,k(`The value to round to places number of places, always rounding down.`)),W(`places (number, default=0)`,k(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=N(e,this.locale),r=N(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.floor(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.floor(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},Nb={description:k(`Rounds up a number.`),args:[W(`value (number)`,k(`The value to round to places number of places, always rounding up.`)),W(`places (number, default=0)`,k(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=N(e,this.locale),r=N(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.ceil(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.ceil(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},Pb={description:k(`Secant of an angle provided in radians.`),args:[W(`angle (number)`,k(`The angle to find the secant of, in radians.`))],compute:function(e){return 1/Math.cos(N(e,this.locale))},isExported:!0},Fb={description:k(`Hyperbolic secant of any real number.`),args:[W(`value (number)`,k(`Any real value to calculate the hyperbolic secant of.`))],compute:function(e){return 1/Math.cosh(N(e,this.locale))},isExported:!0},Ib={description:k(`Returns a sequence of numbers.`),args:[W(`rows (number)`,k(`The number of rows to return`)),W(`columns (number, optional, default=1)`,k(`The number of columns to return`)),W(`start (number, optional, default=1)`,k(`The first number in the sequence`)),W(`step (number, optional, default=1)`,k(`The amount to increment each value in the sequence`))],compute:function(e,t={value:1},n={value:1},r={value:1}){let i=N(n,this.locale),a=N(r,this.locale),o=Fa(e,this.locale),s=Fa(t,this.locale);return s<1?new j(k(`The number of columns (%s) must be positive.`,s)):o<1?new j(k(`The number of rows (%s) must be positive.`,o)):Ja(s,o,(e,t)=>({value:i+t*s*a+e*a}))},isExported:!0},Lb={description:k(`Sine of an angle provided in radians.`),args:[W(`angle (number)`,k(`The angle to find the sine of, in radians.`))],compute:function(e){return Math.sin(N(e,this.locale))},isExported:!0},Rb={description:k(`Hyperbolic sine of any real number.`),args:[W(`value (number)`,k(`Any real value to calculate the hyperbolic sine of.`))],compute:function(e){return Math.sinh(N(e,this.locale))},isExported:!0},zb={description:k(`Positive square root of a positive number.`),args:[W(`value (number)`,k(`The number for which to calculate the positive square root.`))],compute:function(e){let t=N(e,this.locale);return t<0?new j(k(`The value (%s) must be positive or null.`,t)):{value:Math.sqrt(t),format:e?.format}},isExported:!0},Bb={1:`AVERAGE`,2:`COUNT`,3:`COUNTA`,4:`MAX`,5:`MIN`,6:`PRODUCT`,7:`STDEV`,8:`STDEVP`,9:`SUM`,10:`VAR`,11:`VARP`},Vb=Object.entries(Bb).map(([e,t])=>({value:parseInt(e),label:k(`%s (include manually-hidden rows)`,t)})),Hb=Object.entries(Bb).map(([e,t])=>({value:parseInt(e)+100,label:k(`%s (exclude manually-hidden rows)`,t)})),Ub={description:k(`Returns a subtotal for a vertical range of cells using a specified aggregation function.`),args:[W(`function_code (number)`,k(`The function to use in subtotal aggregation.`),[...Vb,...Hb]),W(`ref (meta, range<meta>, repeating)`,k(`Range or reference for which you want the subtotal.`))],compute:function(e,...t){let n=Fa(e,this.locale),r=!0;if(n>100&&(n-=100,r=!1),n<1||n>11)return new j(k(`The function code (%s) must be between 1 to 11 or 101 to 111.`,n));let i=[];for(let e of t){let t=e[0][0],n=zc(t.value).sheetName,a=n?this.getters.getSheetIdByName(n):this.__originSheetId;if(!a)continue;let{top:o,left:s}=mn(t.value),c=s+e.length-1,l=o+e[0].length-1;for(let e=o;e<=l;e++)if(!this.getters.isRowFiltered(a,e)&&!(!r&&this.getters.isRowHiddenByUser(a,e)))for(let t=s;t<=c;t++){let n=this.getters.getCorrespondingFormulaCell({sheetId:a,col:t,row:e});(!n||!Gt(n,`SUBTOTAL`))&&i.push(this.getters.getEvaluatedCell({sheetId:a,col:t,row:e}))}}return this[Bb[n]].apply(this,[[i]])},isExported:!0},Wb={description:k(`Sum of a series of numbers and/or cells.`),args:[W(`value (number, range<number>, repeating)`,k(`Number or range to add together.`))],compute:function(...e){let t=e[0];return{value:Jm(e,this.locale),format:Da(t)}},isExported:!0},Gb={description:k(`A conditional sum across a range.`),args:[W(`criteria_range (range)`,k(`The range which is tested against criterion.`)),W(`criterion (string)`,k(`The pattern or test to apply to range.`)),W(`sum_range (range, default=criteria_range)`,k(`The range to be summed, if different from range.`))],compute:function(e,t,n){n===void 0&&(n=e);let r=0;return io([e,t],(e,t)=>{let i=n[e]?.[t]?.value;typeof i==`number`&&(r+=i)},this.locale),r},isExported:!0},Kb={description:k(`Sums a range depending on multiple criteria.`),args:[W(`sum_range (range)`,k(`The range to sum.`)),W(`criteria_range (any, range, repeating)`,k(`Range to check.`)),W(`criterion (string, repeating)`,k(`Criteria to check.`))],compute:function(e,...t){let n=0;return io(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n+=i)},this.locale),n},isExported:!0},qb={description:k(`Tangent of an angle provided in radians.`),args:[W(`angle (number)`,k(`The angle to find the tangent of, in radians.`))],compute:function(e){return Math.tan(N(e,this.locale))},isExported:!0},Jb={description:k(`Hyperbolic tangent of any real number.`),args:[W(`value (number)`,k(`Any real value to calculate the hyperbolic tangent of.`))],compute:function(e){return Math.tanh(N(e,this.locale))},isExported:!0};function Yb(e,t){return t===0?Math.trunc(e):(Number.isInteger(t)||(t=Math.trunc(t)),Math.trunc(e*10**t)/10**t)}let Xb={description:k(`Truncates a number.`),args:[W(`value (number)`,k(`The value to be truncated.`)),W(`places (number, default=0)`,k(`The number of significant digits to the right of the decimal point to retain.`))],compute:function(e,t={value:0}){return{value:Yb(N(e,this.locale),N(t,this.locale)),format:e?.format}},isExported:!0},Zb={description:k(`Rounds a number down to the nearest integer that is less than or equal to it.`),args:[W(`value (number)`,k(`The number to round down to the nearest integer.`))],compute:function(e){return Math.floor(N(e,this.locale))},isExported:!0};var Qb=l({AVEDEV:()=>cx,AVERAGE:()=>lx,AVERAGEA:()=>px,AVERAGEIF:()=>mx,AVERAGEIFS:()=>hx,AVERAGE_WEIGHTED:()=>fx,CORREL:()=>Lx,COUNT:()=>gx,COUNTA:()=>_x,COVAR:()=>vx,COVARIANCE_P:()=>yx,COVARIANCE_S:()=>bx,FORECAST:()=>xx,GROWTH:()=>Sx,INTERCEPT:()=>Cx,LARGE:()=>wx,LINEST:()=>Tx,LOGEST:()=>Ex,MATTHEWS:()=>Dx,MAX:()=>Ox,MAXA:()=>kx,MAXIFS:()=>Ax,MEDIAN:()=>jx,MIN:()=>Mx,MINA:()=>Nx,MINIFS:()=>Px,PEARSON:()=>Ix,PERCENTILE:()=>Rx,PERCENTILE_EXC:()=>zx,PERCENTILE_INC:()=>Bx,POLYFIT_COEFFS:()=>Vx,POLYFIT_FORECAST:()=>Hx,QUARTILE:()=>Ux,QUARTILE_EXC:()=>Wx,QUARTILE_INC:()=>Gx,RANK:()=>Kx,RSQ:()=>qx,SLOPE:()=>Jx,SMALL:()=>Yx,SPEARMAN:()=>Xx,STDEV:()=>Zx,STDEVA:()=>eS,STDEVP:()=>tS,STDEVPA:()=>nS,STDEV_P:()=>Qx,STDEV_S:()=>$x,STEYX:()=>rS,TREND:()=>iS,VAR:()=>aS,VARA:()=>cS,VARP:()=>lS,VARPA:()=>uS,VAR_P:()=>oS,VAR_S:()=>sS});let $b=[{value:!0,label:k(`b is calculated normally`)},{value:!1,label:k(`b is forced to 1`)}],ex=[{value:!1,label:k(`do not return additional regression statistics`)},{value:!0,label:k(`return additional regression statistics`)}],tx=[{value:1,label:k(`order 1 (Linear)`)},{value:2,label:k(`order 2 (Quadratic)`)},{value:3,label:k(`order 3 (Cubic)`)},{value:4,label:k(`order 4 (Quartic)`)},{value:5,label:k(`order 5 (Quintic)`)},{value:6,label:k(`order 6 (Sextic)`)}],nx=[{value:!0,label:k(`Compute intercept`)},{value:!1,label:k(`Force intercept to 0`)}],rx=[{value:0,label:k(`Minimum value`)},{value:1,label:k(`First quartile (25th percentile)`)},{value:2,label:k(`Median value (50th percentile)`)},{value:3,label:k(`Third quartile (75th percentile)`)},{value:4,label:k(`Maximum value`)}];function ix(e,t){let n=[],r=[],i=0,a=0;Ha([e],e=>{n.push(e),i+=1}),Ha([t],e=>{r.push(e),a+=1}),fm(i===a,k(`[[FUNCTION_NAME]] has mismatched argument count %s vs %s.`,i,a));let o=[],s=[];for(let e=0;e<i;e++){let t=n[e]?.value,i=r[e]?.value;typeof t==`number`&&typeof i==`number`&&(s.push(t),o.push(i))}return{flatDataX:o,flatDataY:s}}function ax(e,t,n){let{flatDataX:r,flatDataY:i}=ix(e,t),a=i.length;pm(a),n&&pm(a-1);let o=0,s=0;for(let e=0;e<a;e++)o+=i[e],s+=r[e];let c=o/a,l=s/a,u=0;for(let e=0;e<a;e++)u+=(i[e]-c)*(r[e]-l);return u/(a-+!!n)}function ox(e,t,n,r){let i=0,a=n?qa:Ka,o=a(e,(e,t)=>(i+=1,e+t),0,r);pm(i),t&&pm(i-1);let s=o/i;return a(e,(e,t)=>e+(t-s)**2,0,r)/(i-+!!t)}function sx(e,t,n,r){let i=N(t,r);fm(n?0<=i&&i<=1:0<i&&i<1,k(`Function [[FUNCTION_NAME]] parameter 2 value is out of range.`));let a=[],o,s=0;return Ha(e,e=>{let t=e?.value;typeof t==`number`&&(o=ao(a,e,`nextSmaller`,`asc`,a.length,(e,t)=>e[t]),a.splice(o+1,0,t),s++)}),fm(s!==0,po),n||fm(1/(s+1)<=i&&i<=s/(s+1),k(`Function [[FUNCTION_NAME]] parameter 2 value is out of range.`)),oa(a,i,n)}let cx={description:k(`Average magnitude of deviations from mean.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the sample.`))],compute:function(...e){let t=0,n=Ka(e,(e,n)=>(t+=1,e+n),0,this.locale);if(t===0)return new Sa(k(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`));let r=n/t;return Ka(e,(e,t)=>e+Math.abs(r-t),0,this.locale)/t},isExported:!0},lx={description:k(`Numerical average value in a dataset, ignoring text.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to consider when calculating the average value.`))],compute:function(...e){return{value:Em(e,this.locale),format:Da(e[0])}},isExported:!0},ux=k(`[[FUNCTION_NAME]] has mismatched range sizes.`),dx=k(`[[FUNCTION_NAME]] expects the weight to be positive or equal to 0.`),fx={description:k(`Weighted average.`),args:[W(`values (number, range<number>, repeating)`,k(`Value to average.`)),W(`weights (number, range<number>, repeating)`,k(`Weight for each corresponding value.`))],compute:function(...e){let t=0,n=0;for(let r=0;r<e.length-1;r+=2){let i=e[r],a=e[r+1];if(!hm(i,a))return new j(ux);if(Ta(i))for(let e=0;e<i.length;e++)for(let r=0;r<i[0].length;r++){let o=i[e][r].value,s=Ta(a)?a?.[e][r].value:N(a,this.locale),c=typeof o==`number`,l=typeof s==`number`;if(c&&l){if(s<0)return new j(dx);t+=o*s,n+=s;continue}if(c!==l)return new j(k(`[[FUNCTION_NAME]] expects number values.`))}else{let e=N(i,this.locale),r=Ta(a)?a?.[0][0].value:N(a,this.locale);if(typeof r==`number`){if(r<0)return new j(dx);t+=e*r,n+=r}}}return n===0?new Sa(k(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:t/n,format:Da(e[0])}}},px={description:k(`Numerical average value in a dataset.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to consider when calculating the average value.`))],compute:function(...e){let t=0,n=qa(e,(e,n)=>(t+=1,e+n),0,this.locale);return t===0?new Sa(k(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:n/t,format:Da(e[0])}},isExported:!0},mx={description:k(`Average of values depending on criteria.`),args:[W(`criteria_range (number, range<number>)`,k(`The range to check against criterion.`)),W(`criterion (string)`,k(`The pattern or test to apply to criteria_range.`)),W(`average_range (number, range<number>, default=criteria_range)`,k(`The range to average. If not included, criteria_range is used for the average instead.`))],compute:function(e,t,n){let r=L(n===void 0?e:n),i=0,a=0;return io([e,t],(e,t)=>{let n=r[e]?.[t]?.value;typeof n==`number`&&(i+=1,a+=n)},this.locale),i===0?new Sa(k(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):a/i},isExported:!0},hx={description:k(`Average of values depending on multiple criteria.`),args:[W(`average_range (range)`,k(`The range to average.`)),W(`criteria_range (any, range, repeating)`,k(`Range to check.`)),W(`criterion (string, repeating)`,k(`Criterion to check.`))],compute:function(e,...t){let n=L(e),r=0,i=0;return io(t,(e,t)=>{let a=n[e]?.[t]?.value;typeof a==`number`&&(r+=1,i+=a)},this.locale),r===0?new Sa(k(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):i/r},isExported:!0},gx={description:k(`The number of numeric values in dataset.`),args:[W(`value (number, any, range<number>, repeating)`,k(`Value or range to consider when counting.`))],compute:function(...e){return Dm(e,this.locale)},isExported:!0},_x={description:k(`The number of values in a dataset.`),args:[W(`value (any, range, repeating)`,k(`Value or range to consider when counting.`))],compute:function(...e){return Om(e)},isExported:!0},vx={description:k(`The covariance of a dataset.`),args:[W(`data_y (any, range)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (any, range)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return ax(e,t,!1)},isExported:!0},yx={description:k(`The covariance of a dataset.`),args:[W(`data_y (any, range)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (any, range)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return ax(e,t,!1)},isExported:!0},bx={description:k(`The sample covariance of a dataset.`),args:[W(`data_y (any, range)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (any, range)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return ax(e,t,!0)},isExported:!0},xx={description:k(`Calculates the expected y-value for a specified x based on a linear regression of a dataset.`),args:[W(`x (number, range<number>)`,k(`The value(s) on the x-axis to forecast.`)),W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t,n){let{flatDataX:r,flatDataY:i}=ix(t,n);return r.length===0||i.length===0?new ya(po):Rm([i],[r],Ya(L(e),e=>N(e,this.locale)),!0)},isExported:!0},Sx={description:k(`Fits points to exponential growth trend.`),args:[W(`known_data_y (range<number>)`,k(`The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.`)),W(`known_data_x (range<number>, default={1;2;3;...})`,k(`The values of the independent variable(s) corresponding with known_data_y.`)),W(`new_data_x (any, range, default=known_data_x)`,k(`The data points to return the y values for on the ideal curve fit.`)),W(`b (boolean, default=TRUE)`,k(`Given a general exponential form of y = b*m^x for a curve fit, calculates b if TRUE or forces b to be 1 and only calculates the m values if FALSE.`),$b)],compute:function(e,t=[[]],n=[[]],r={value:!0}){return e.length===0||e[0].length===0?new j(mo(`known_data_y`)):Im(Rm(Lm(Na(e,`known_data_y`)),Na(t,`known_data_x`),Na(n,`new_data_y`),F(r)))}},Cx={description:k(`Compute the intercept of the linear regression.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=ix(e,t);if(n.length===0||r.length===0)return new ya(po);let[[],[i]]=Mm([n],[r]);return i},isExported:!0},wx={description:k(`Nth largest element from a data set.`),args:[W(`data (any, range)`,k(`Array or range containing the dataset to consider.`)),W(`n (number)`,k(`The rank from largest to smallest of the element to return.`))],compute:function(e,t){let n=Math.trunc(N(t?.value,this.locale)),r=[],i,a=0;Ha([e],e=>{typeof e?.value==`number`&&(i=ao(r,e,`nextSmaller`,`asc`,r.length,(e,t)=>e[t].value),r.splice(i+1,0,e),a++,a>n&&(r.shift(),a--))});let o=r.shift();return o===void 0?new j(po):a<n?new j(k(`Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.`,n)):o},isExported:!0},Tx={description:k(`Given partial data about a linear trend, calculates various parameters about the ideal linear trend using the least-squares method.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>, default={1;2;3;...})`,k(`The range representing the array or matrix of independent data.`)),W(`calculate_b (boolean, default=TRUE)`,k(`A flag specifying whether to compute the slope or not`),$b),W(`verbose (boolean, default=FALSE)`,k(`A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept`),ex)],compute:function(e,t=[[]],n={value:!0},r={value:!1}){return e.length===0||e[0].length===0?new j(mo(`data_y`)):Mm(Na(t,`data_x`),Na(e,`data_y`),F(n),F(r))},isExported:!0},Ex={description:k(`Given partial data about an exponential growth curve, calculates various parameters about the best fit ideal exponential growth curve.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>, optional, default={1;2;3;...})`,k(`The range representing the array or matrix of independent data.`)),W(`calculate_b (boolean, default=TRUE)`,k(`A flag specifying whether to compute the slope or not`),$b),W(`verbose (boolean, default=FALSE)`,k(`A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept`),ex)],compute:function(e,t=[[]],n={value:!0},r={value:!1}){if(e.length===0||e[0].length===0)return new j(mo(`data_y`));let i=Mm(Na(t,`data_x`),Lm(Na(e,`data_y`)),F(n),F(r));for(let e=0;e<i.length;e++)i[e][0]=Math.exp(i[e][0]);return i},isExported:!0},Dx={description:k(`Compute the Matthews correlation coefficient of a dataset.`),args:[W(`data_x (range)`,k(`The range representing the array or matrix of observed data.`)),W(`data_y (range)`,k(`The range representing the array or matrix of predicted data.`))],compute:function(e,t){let n=e.flat(),r=t.flat();if(Tm(n,r),n.length===0||r.length===0)return new ya(po);let i=n.length,a=0,o=0,s=0,c=0;for(let e=0;e<i;++e){let t=F(n[e]);t===F(r[e])?t?o++:a++:t?c++:s++}return(o*a-s*c)/Math.sqrt((o+s)*(o+c)*(a+s)*(a+c))},isExported:!1},Ox={description:k(`Maximum value in a numeric dataset.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to consider when calculating the maximum value.`))],compute:function(...e){return km(e,this.locale)},isExported:!0},kx={description:k(`Maximum numeric value in a dataset.`),args:[W(`value (any, range, repeating)`,k(`Value or range to consider when calculating the maximum value.`))],compute:function(...e){let t=qa(e,(e,t)=>Math.max(t,e),-1/0,this.locale);return{value:t===-1/0?0:t,format:Da(e[0])}},isExported:!0},Ax={description:k(`Returns the maximum value in a range of cells, filtered by a set of criteria.`),args:[W(`range (range)`,k(`The range of cells from which the maximum will be determined.`)),W(`criteria_range (any, range, repeating)`,k(`Range to evaluate criteria.`)),W(`criterion (string, repeating)`,k(`Criteria to check.`))],compute:function(e,...t){let n=-1/0;return io(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n=n<i?i:n)},this.locale),n===-1/0?0:n},isExported:!0},jx={description:k(`Median value in a numeric dataset.`),args:[W(`value (any, range, repeating)`,k(`Value or range to consider when calculating the median value.`))],compute:function(...e){let t=[];return Ua(e,e=>{t.push(e)},this.locale),{value:sx(t,{value:.5},!0,this.locale),format:Da(t[0])}},isExported:!0},Mx={description:k(`Minimum value in a numeric dataset.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to consider when calculating the minimum value.`))],compute:function(...e){return Am(e,this.locale)},isExported:!0},Nx={description:k(`Minimum numeric value in a dataset.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to consider when calculating the minimum value.`))],compute:function(...e){let t=qa(e,(e,t)=>Math.min(t,e),1/0,this.locale);return{value:t===1/0?0:t,format:Da(e[0])}},isExported:!0},Px={description:k(`Returns the minimum value in a range of cells, filtered by a set of criteria.`),args:[W(`range (range)`,k(`The range of cells from which the minimum will be determined.`)),W(`criteria_range (any, range, repeating)`,k(`Range to evaluate criteria.`)),W(`criterion (string, repeating)`,k(`Criterion to check.`))],compute:function(e,...t){let n=1/0;return io(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n=n>i?i:n)},this.locale),n===1/0?0:n},isExported:!0};function Fx(e,t){let{flatDataX:n,flatDataY:r}=ix(e,t);if(n.length===0||r.length===0)return new ya(po);let i=n.length,a=0,o=0,s=0,c=0,l=0;for(let e=0;e<i;e++){let t=n[e],i=r[e];a+=t,o+=i,s+=t*i,c+=t*t,l+=i*i}return(i*s-a*o)/Math.sqrt((i*c-a*a)*(i*l-o*o))}let Ix={description:k(`Compute the Pearson product-moment correlation coefficient of a dataset.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return Fx(e,t)},isExported:!0},Lx=Ix,Rx={description:k(`Value at a given percentile of a dataset.`),args:[W(`data (any, range)`,k(`The array or range containing the dataset to consider.`)),W(`percentile (number)`,k(`The percentile whose value within data will be calculated and returned.`))],compute:function(e,t){return Bx.compute.bind(this)(e,t)},isExported:!0},zx={description:k(`Value at a given percentile of a dataset exclusive of 0 and 1.`),args:[W(`data (any, range)`,k(`The array or range containing the dataset to consider.`)),W(`percentile (number)`,k(`The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.`))],compute:function(e,t){return{value:sx([e],t,!1,this.locale),format:Da(e)}},isExported:!0},Bx={description:k(`Value at a given percentile of a dataset.`),args:[W(`data (any, range)`,k(`The array or range containing the dataset to consider.`)),W(`percentile (number)`,k(`The percentile whose value within data will be calculated and returned.`))],compute:function(e,t){return{value:sx([e],t,!0,this.locale),format:Da(e)}},isExported:!0},Vx={description:k(`Compute the coefficients of polynomial regression of the dataset.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`)),W(`order (number)`,k(`The order of the polynomial to fit the data, between 1 and 6.`),tx),W(`intercept (boolean, default=TRUE)`,k(`A flag specifying whether to compute the intercept or not.`),nx)],compute:function(e,t,n,r={value:!0}){let{flatDataX:i,flatDataY:a}=ix(e,t);return i.length===0||a.length===0?new ya(po):Nm(a,i,N(n,this.locale),F(r))},isExported:!1},Hx={description:k(`Predict value by computing a polynomial regression of the dataset.`),args:[W(`x (number, range<number>)`,k(`The value(s) on the x-axis to forecast.`)),W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`)),W(`order (number)`,k(`The order of the polynomial to fit the data, between 1 and 6.`),tx),W(`intercept (boolean, default=TRUE)`,k(`A flag specifying whether to compute the intercept or not.`),nx)],compute:function(e,t,n,r,i={value:!0}){let a=N(r,this.locale),{flatDataX:o,flatDataY:s}=ix(t,n);if(o.length===0||s.length===0)return new ya(po);let c=Nm(s,o,a,F(i)).flat();return Ya(L(e),e=>Fm(c,N(e,this.locale),a))},isExported:!1},Ux={description:k(`Value nearest to a specific quartile of a dataset.`),args:[W(`data (any, range)`,k(`The array or range containing the dataset to consider.`)),W(`quartile_number (number)`,k(`Which quartile value to return.`),rx)],compute:function(e,t){return Gx.compute.bind(this)(e,t)},isExported:!0},Wx={description:k(`Value nearest to a specific quartile of a dataset exclusive of 0 and 4.`),args:[W(`data (any, range)`,k(`The array or range containing the dataset to consider.`)),W(`quartile_number (number)`,k(`Which quartile value, exclusive of 0 and 4, to return.`),[{value:1,label:k(`First quartile (25th percentile)`)},{value:2,label:k(`Median value (50th percentile)`)},{value:3,label:k(`Third quartile (75th percentile)`)}])],compute:function(e,t){let n={value:.25*Math.trunc(N(t,this.locale))};return{value:sx([e],n,!1,this.locale),format:Da(e)}},isExported:!0},Gx={description:k(`Value nearest to a specific quartile of a dataset.`),args:[W(`data (any, range)`,k(`The array or range containing the dataset to consider.`)),W(`quartile_number (number)`,k(`Which quartile value to return.`),rx)],compute:function(e,t){let n={value:.25*Math.trunc(N(t,this.locale))};return{value:sx([e],n,!0,this.locale),format:Da(e)}},isExported:!0},Kx={description:k(`Returns the rank of a specified value in a dataset.`),args:[W(`value (number)`,k(`The value whose rank will be determined.`)),W(`data (range)`,k(`The range containing the dataset to consider.`)),W(`is_ascending (boolean, default=FALSE)`,k(`Whether to consider the values in data in descending or ascending order.`),[{value:!1,label:k(`Descending`)},{value:!0,label:k(`Ascending`)}])],compute:function(e,t,n={value:!1}){let r=F(n),i=N(e,this.locale),a=1,o=!1;for(let e of t)for(let t of e){if(typeof t.value!=`number`)continue;let e=N(t,this.locale);e===i?o=!0:e>i!==r&&a++}return o?a:new ya(k(`Value not found in the given data.`))},isExported:!0},qx={description:k(`Compute the square of r, the Pearson product-moment correlation coefficient of a dataset.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let n=Fx(e,t);if(n instanceof Error)throw n;return n**2},isExported:!0},Jx={description:k(`Compute the slope of the linear regression.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=ix(e,t);if(n.length===0||r.length===0)return new ya(po);let[[i]]=Mm([n],[r]);return i},isExported:!0},Yx={description:k(`Nth smallest element in a data set.`),args:[W(`data (any, range)`,k(`The array or range containing the dataset to consider.`)),W(`n (number)`,k(`The rank from smallest to largest of the element to return.`))],compute:function(e,t){let n=Math.trunc(N(t?.value,this.locale)),r=[],i,a=0;Ha([e],e=>{typeof e?.value==`number`&&(i=ao(r,e,`nextSmaller`,`asc`,r.length,(e,t)=>e[t].value),r.splice(i+1,0,e),a++,a>n&&(r.pop(),a--))});let o=r.pop();return o===void 0?new j(po):a<n?new j(k(`Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.`,n)):o},isExported:!0},Xx={description:k(`Compute the Spearman rank correlation coefficient of a dataset.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=ix(t,e);if(n.length===0||r.length===0)return new ya(po);let i=n.length,a=n.map((e,t)=>[e,r[t]]);a.sort((e,t)=>e[0]-t[0]);for(let e=0;e<i;++e)a[e][0]=e;a.sort((e,t)=>e[1]-t[1]);let o=0;for(let e=0;e<i;++e)o+=(a[e][0]-e)**2;return 1-6*o/(i**3-i)},isExported:!1},Zx={description:k(`Standard deviation.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the sample.`))],compute:function(...e){return Math.sqrt(aS.compute.bind(this)(...e))},isExported:!0},Qx={description:k(`Standard deviation of entire population.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the population.`))],compute:function(...e){return Math.sqrt(oS.compute.bind(this)(...e))},isExported:!0},$x={description:k(`Standard deviation.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the sample.`))],compute:function(...e){return Math.sqrt(sS.compute.bind(this)(...e))},isExported:!0},eS={description:k(`Standard deviation of sample (text as 0).`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the sample.`))],compute:function(...e){return Math.sqrt(cS.compute.bind(this)(...e))},isExported:!0},tS={description:k(`Standard deviation of entire population.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the population.`))],compute:function(...e){return Math.sqrt(lS.compute.bind(this)(...e))},isExported:!0},nS={description:k(`Standard deviation of entire population (text as 0).`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the population.`))],compute:function(...e){return Math.sqrt(uS.compute.bind(this)(...e))},isExported:!0},rS={description:k(`Calculates the standard error of the predicted y-value for each x in the regression of a dataset.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=ix(e,t);return n.length===0||r.length===0?new ya(po):Mm([n],[r],!0,!0)[1][2]},isExported:!0},iS={description:k(`Fits points to linear trend derived via least-squares.`),args:[W(`known_data_y (number, range<number>)`,k(`The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.`)),W(`known_data_x (number, range<number>, optional, default={1;2;3;...})`,k(`The values of the independent variable(s) corresponding with known_data_y.`)),W(`new_data_x (number, range<number>, optional, default=known_data_x)`,k(`The data points to return the y values for on the ideal curve fit.`)),W(`b (boolean, optional, default=TRUE)`,k(`Given a general linear form of y = m*x+b for a curve fit, calculates b if TRUE or forces b to be 0 and only calculates the m values if FALSE, i.e. forces the curve fit to pass through the origin.`),$b)],compute:function(e,t=[[]],n=[[]],r={value:!0}){return e.length===0||e[0].length===0?new j(mo(`known_data_y`)):Rm(Na(e,`known_data_y`),Na(t,`known_data_x`),Na(n,`new_data_y`),F(r))}},aS={description:k(`Variance.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the sample.`))],compute:function(...e){return ox(e,!0,!1,this.locale)},isExported:!0},oS={description:k(`Variance of entire population.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the population.`))],compute:function(...e){return ox(e,!1,!1,this.locale)},isExported:!0},sS={description:k(`Variance.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the sample.`))],compute:function(...e){return ox(e,!0,!1,this.locale)},isExported:!0},cS={description:k(`Variance of sample (text as 0).`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the sample.`))],compute:function(...e){return ox(e,!0,!0,this.locale)},isExported:!0},lS={description:k(`Variance of entire population.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the population.`))],compute:function(...e){return ox(e,!1,!1,this.locale)},isExported:!0},uS={description:k(`Variance of entire population (text as 0).`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the population.`))],compute:function(...e){return ox(e,!1,!0,this.locale)},isExported:!0};var dS=l({DAVERAGE:()=>mS,DCOUNT:()=>hS,DCOUNTA:()=>gS,DGET:()=>_S,DMAX:()=>vS,DMIN:()=>yS,DPRODUCT:()=>bS,DSTDEV:()=>xS,DSTDEVP:()=>SS,DSUM:()=>CS,DVAR:()=>wS,DVARP:()=>TS});function fS(e,t,n,r){let i=new Map,a=e.length;for(let t=a-1;t>=0;t--)i.set(P(e[t][0]).toUpperCase(),t);let o=t?.value;if(typeof o!=`number`&&typeof o!=`string`)throw new j(k(`The field must be a number or a string`));let s;if(typeof o==`number`){if(s=Math.trunc(o)-1,s<0||a-1<s)throw new j(k(`The field (%(fieldValue)s) must be one of %(dimRowDB)s or must be a number between 1 and %s inclusive.`,{fieldValue:o.toString(),dimRowDB:a.toString()}))}else{let e=P(t).toUpperCase();if(s=i.get(e)??-1,s===-1)throw new j(k(`The field (%s) must be one of %s.`,P(t),[...i.keys()].toString()))}let c=n[0].length;if(c<2)throw new j(k(`The criteria range contains %s row, it must be at least 2 rows.`,c.toString()));let l=new Set,u=e[0].length;for(let t=1;t<c;t++){let a=[],o=!0;for(let r=0;r<n.length;r++){let s=P(n[r][0]).toUpperCase(),c=i.get(s),l=n[r][t];if(l.value!==null)if(c!==void 0)a.push([e[c].slice(1,u)]),a.push(l);else{o=!1;break}}if(o)if(a.length>0)io(a,(e,t)=>{l.add(t)},r,!0);else{l=new Set(Array(u-1).keys());break}}let d=e[s];return[...l].map(e=>d[e+1])}let pS=[W(`database (range)`,k(`The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.`)),W(`field (number, string)`,k(`Indicates which column in database contains the values to be extracted and operated on.`)),W(`criteria (range)`,k(`An array or range containing zero or more criteria to filter the database values by before operating.`))],mS={description:k(`Average of a set of values from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return lx.compute.bind(this)([r])},isExported:!0},hS={description:k(`Counts values from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return gx.compute.bind(this)([r])},isExported:!0},gS={description:k(`Counts values and text from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return _x.compute.bind(this)([r])},isExported:!0},_S={description:k(`Single value from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return r.length===1?r[0]:new j(k(`More than one match found in DGET evaluation.`))},isExported:!0},vS={description:k(`Maximum of values from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return Ox.compute.bind(this)([r])},isExported:!0},yS={description:k(`Minimum of values from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return Mx.compute.bind(this)([r])},isExported:!0},bS={description:k(`Product of values from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return Db.compute.bind(this)([r])},isExported:!0},xS={description:k(`Standard deviation of population sample from table.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return Zx.compute.bind(this)([r])},isExported:!0},SS={description:k(`Standard deviation of entire population from table.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return tS.compute.bind(this)([r])},isExported:!0},CS={description:k(`Sum of values from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return Wb.compute.bind(this)([r])},isExported:!0},wS={description:k(`Variance of population sample from table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return aS.compute.bind(this)([r])},isExported:!0},TS={description:k(`Variance of a population from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return lS.compute.bind(this)([r])},isExported:!0};function ES(e){if(!e||typeof e!=`object`||!(!e.thousandsSeparator||typeof e.thousandsSeparator==`string`))return!1;for(let t of[`code`,`name`,`decimalSeparator`,`dateFormat`,`timeFormat`,`formulaArgSeparator`])if(!e[t]||typeof e[t]!=`string`)return!1;if(e.formulaArgSeparator===e.decimalSeparator||e.thousandsSeparator===e.decimalSeparator)return!1;try{z(1,{locale:e,format:`#,##0.00`}),z(1,{locale:e,format:e.dateFormat}),z(1,{locale:e,format:e.timeFormat})}catch{return!1}return!0}function DS(e,t){return Ut(e)?jS(e,t):PS(e,t)}function OS(e,t){return Ut(e)?jS(e,t):FS(e,t)}function kS(e,t){return e.startsWith(`=`)?MS(e,t):LS(e,t)}function AS(e,t){return Ut(e)?jS(e,t):PS(e,t)}function jS(e,t){return NS(e.startsWith(`+`)?`=`+e.slice(1):e,t,R)}function MS(e,t){return NS(e,R,t)}function NS(e,t,n){if(t.formulaArgSeparator===n.formulaArgSeparator&&t.decimalSeparator===n.decimalSeparator)return e;let r=Tu(e,t),i=``;for(let e of r)e.type===`NUMBER`?i+=e.value.replace(t.decimalSeparator,n.decimalSeparator):e.type===`ARG_SEPARATOR`?i+=n.formulaArgSeparator:e.type===`ARRAY_ROW_SEPARATOR`?i+=n.formulaArgSeparator===`;`?`\\`:`;`:i+=e.value;return i}function PS(e,t){return t.decimalSeparator===`.`||!ra(e,t)?e:(t.thousandsSeparator&&(e=e.replaceAll(t.thousandsSeparator,``)),e.replace(t.decimalSeparator,`.`))}function FS(e,t){if(Ti(e,t)){let n=N(e,t),r=R.dateFormat;return Number.isInteger(n)||(r+=` `+R.timeFormat),z(n,{locale:R,format:r})}return PS(e,t)}function IS(e,t){if(t.decimalSeparator===`.`||!ra(e,R))return e;let n=ls(R);return e.replace(n,e=>e.replace(`.`,t.decimalSeparator))}function LS(e,t){if(Ti(e,R)){let n=N(e,R),r=t.dateFormat;return Number.isInteger(n)||(r+=` `+t.timeFormat),z(n,{locale:t,format:r})}return IS(e,t)}function RS(e,t){return VS(e,e=>OS(e,t))}function zS(e,t){return VS(e,e=>kS(e,t))}function BS(e,t){let n=b(e);return n.criterion.values=n.criterion.values.map(e=>kS(e,t)),n}function VS(e,t){switch(e=b(e),e.type){case`CellIsRule`:switch(e.operator){case`isBetween`:case`isNotBetween`:case`isEqual`:case`isNotEqual`:case`isGreaterThan`:case`isGreaterOrEqualTo`:case`isLessThan`:case`isLessOrEqualTo`:case`customFormula`:case`dateIs`:case`dateIsBefore`:case`dateIsAfter`:case`dateIsOnOrAfter`:case`dateIsOnOrBefore`:case`top10`:return e.values=e.values.map(e=>t(e)),e;case`beginsWithText`:case`containsText`:case`endsWithText`:case`notContainsText`:case`isEmpty`:case`isNotEmpty`:case`uniqueValues`:case`duplicateValues`:return e}case`DataBarRule`:return e;case`ColorScaleRule`:return e.minimum=HS(e.minimum,t),e.maximum=HS(e.maximum,t),e.midpoint&&=HS(e.midpoint,t),e;case`IconSetRule`:return e.lowerInflectionPoint.value=t(e.lowerInflectionPoint.value),e.upperInflectionPoint.value=t(e.upperInflectionPoint.value),e}}function HS(e,t){if(!e?.value)return e;let n=t(e.type===`formula`?`=`+e.value:e.value),r=e.type===`formula`?n.slice(1):n;return{...e,value:r}}function US(e){return e.dateFormat+` `+e.timeFormat}let WS=k(`The cashflow_amounts and cashflow_dates ranges must have the same dimensions.`),GS=k(`There must be both positive and negative values in cashflow_amounts.`),KS=e=>k(`The cost (%s) must be positive or null.`,e),qS=e=>k(`The cost (%s) must be strictly positive.`,e),JS=e=>k(`The frequency (%s) must be one of %s`,e,[1,2,4].toString()),YS=e=>k(`The day_count_convention (%s) must be between 0 and 4 inclusive.`,e),XS=e=>k(`The depreciation factor (%s) must be strictly positive.`,e),ZS=e=>k(`The discount (%s) must be different from -1.`,e),QS=e=>k(`The discount (%s) must be strictly positive.`,e),$S=e=>k(`The discount (%s) must be smaller than 1.`,e),eC=e=>k(`The effective_rate (%s) must be strictly positive.`,e),tC=e=>k(`The end_period (%s) must be positive or null.`,e),nC=(e,t)=>k(`The end_period (%(end)s) must be smaller or equal to the life (%(life)s).`,{end:e,life:t}),rC=e=>k(`All the dates should be greater or equal to the first date in cashflow_dates (%s).`,e),iC=(e,t)=>k(`The first_period (%(first)s) must be smaller or equal to the last_period (%(last)s).`,{first:e,last:t}),aC=e=>k(`The first_period (%s) must be strictly positive.`,e),oC=e=>k(`The future_value (%s) must be strictly positive.`,e),sC=e=>k(`The investment (%s) must be strictly positive.`,e),cC=e=>k(`The issue (%s) must be positive or null.`,e),lC=(e,t)=>k(`The last_period (%(last)s) must be smaller or equal to the number_of_periods (%(nPeriods)s).`,{last:e,nPeriods:t}),uC=e=>k(`The last_period (%s) must be strictly positive.`,e),dC=e=>k(`The life (%s) must be strictly positive.`,e),fC=(e,t)=>k(`The maturity (%(maturity)s) must be strictly greater than the settlement (%(settlement)s).`,{maturity:t,settlement:e}),pC=e=>k(`The month (%s) must be between 1 and 12 inclusive.`,e),mC=e=>k(`The nominal_rate (%s) must be strictly positive.`,e),hC=e=>k(`The number_of_periods (%s) must be different from zero.`,e),gC=e=>k(`The number_of_periods (%s) must be strictly positive.`,e),_C=e=>k(`The period must be between 1 and number_of_periods (%s)`,e),vC=(e,t)=>k(`The period (%(period)s) must be less than or equal to %(lifeLimit)s.`,{period:e,lifeLimit:t}),yC=e=>k(`The period (%s) must be positive or null.`,e),bC=e=>k(`The periods_by_year (%s) must be strictly positive.`,e),xC=(e,t)=>k(`The period (%(period)s) must be less than or equal life (%(life)s).`,{period:e,life:t}),SC=e=>k(`The period (%s) must be strictly positive.`,e),CC=e=>k(`The present_value (%s) must be strictly positive.`,e),wC=e=>k(`The price (%s) must be strictly positive.`,e),TC=(e,t)=>k(`The purchase_date (%(purchaseDate)s) must be before the first_period_end (%(firstPeriodEnd)s).`,{purchaseDate:e,firstPeriodEnd:t}),EC=e=>k(`The purchase_date (%s) must be positive or null.`,e),DC=e=>k(`The rate_guess (%s) must be strictly greater than -1.`,e),OC=e=>k(`The rate (%s) must be positive or null.`,e),kC=e=>k(`The rate (%s) must be strictly positive.`,e),AC=e=>k(`The redemption (%s) must be strictly positive.`,e),jC=e=>k(`The salvage (%s) must be positive or null.`,e),MC=(e,t)=>k(`The salvage (%(salvage)s) must be smaller or equal than the cost (%(cost)s).`,{salvage:e,cost:t}),NC=(e,t)=>k(`The settlement date (%(settlement)s) must be greater or equal to the issue date (%(issue)s).`,{settlement:e,issue:t}),PC=(e,t)=>k(`The settlement date (%(settlement)s) must at most one year after the maturity date (%(maturity)s).`,{settlement:e,maturity:t}),FC=(e,t)=>k(`The settlement date (%(settlement)s) must be strictly greater than the issue date (%(issue)s).`,{settlement:e,issue:t}),IC=e=>k(`The start_period (%s) must be positive or null.`,e),LC=(e,t)=>k(`The start_period (%(start)s) must be smaller or equal to the end_period (%(end)s).`,{start:e,end:t}),RC=e=>k(`The unit (%s) must be strictly positive.`,e),zC=e=>k(`The yield (%s) must be positive or null.`,e);function BC(e){return e.some(e=>e>0)&&e.some(e=>e<0)}function VC(e){return![0,1,2,3,4].includes(e)}function HC(e){return![1,2,4].includes(e)}function UC(e,t,n){let r=I(e,n),i=I(t,n),a=I(e,n);return a.setFullYear(r.getFullYear()+1),i.getTime()<=a.getTime()}let WC=[{value:0,label:k(`US (NASD) 30/360`)},{value:1,label:k(`Actual/Actual`)},{value:2,label:k(`Actual/360`)},{value:3,label:k(`Actual/365`)},{value:4,label:k(`European 30/360`)}];var GC=l({DATE:()=>qC,DATEDIF:()=>JC,DATEVALUE:()=>YC,DAY:()=>XC,DAYS:()=>ZC,DAYS360:()=>QC,EDATE:()=>$C,EOMONTH:()=>ew,HOUR:()=>tw,ISOWEEKNUM:()=>nw,MINUTE:()=>rw,MONTH:()=>iw,MONTH_END:()=>xw,MONTH_START:()=>bw,NETWORKDAYS:()=>aw,NETWORKDAYS_INTL:()=>cw,NOW:()=>lw,QUARTER:()=>Sw,QUARTER_END:()=>ww,QUARTER_START:()=>Cw,SECOND:()=>uw,TIME:()=>dw,TIMEVALUE:()=>fw,TODAY:()=>pw,WEEKDAY:()=>mw,WEEKNUM:()=>hw,WORKDAY:()=>gw,WORKDAY_INTL:()=>_w,YEAR:()=>vw,YEARFRAC:()=>yw,YEAR_END:()=>Ew,YEAR_START:()=>Tw}),KC=function(e){return e.WHOLE_YEARS=`Y`,e.WHOLE_MONTHS=`M`,e.WHOLE_DAYS=`D`,e.DAYS_WITHOUT_WHOLE_MONTHS=`MD`,e.MONTH_WITHOUT_WHOLE_YEARS=`YM`,e.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR=`YD`,e}(KC||{});let qC={description:k(`Converts year/month/day into a date.`),args:[W(`year (number)`,k(`The year component of the date.`)),W(`month (number)`,k(`The month component of the date.`)),W(`day (number)`,k(`The day component of the date.`))],compute:function(e,t,n){let r=Math.trunc(N(e,this.locale)),i=Math.trunc(N(t,this.locale)),a=Math.trunc(N(n,this.locale));if(r<0||r>9999)return new j(k(`The year (%s) must be between 0 and 9999 inclusive.`,r.toString()));r<1900&&(r+=1900);let o=Ri(new O(r,i-1,a));return o<0?new j(k(`The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.`)):{value:o,format:this.locale.dateFormat}},isExported:!0},JC={description:k(`Calculates the number of days, months, or years between two dates.`),args:[W(`start_date (date)`,k(`The start date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.`)),W(`end_date (date)`,k(`The end date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.`)),W(`unit (string)`,k(`A text abbreviation for unit of time.`),[{value:`Y`,label:k(`The number of whole years between start_date and end_date`)},{value:`M`,label:k(`The number of whole months between start_date and end_date`)},{value:`D`,label:k(`The number of days between start_date and end_date`)},{value:`MD`,label:k(`The number of days between start_date and end_date after subtracting whole months`)},{value:`YM`,label:k(`The number of whole months between start_date and end_date after subtracting whole years`)},{value:`YD`,label:k(`The number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart`)}])],compute:function(e,t,n){let r=P(n).toUpperCase();if(!Object.values(KC).includes(r))return new j(ja(Object.values(KC),P(n)));let i=Math.trunc(N(e,this.locale)),a=Math.trunc(N(t,this.locale)),o=Li(i),s=Li(a);if(a<i)return new j(k(`start_date (%s) should be on or before end_date (%s).`,o.toLocaleDateString(),s.toLocaleDateString()));switch(r){case`Y`:return qi(o,s);case`M`:return Gi(o,s);case`D`:return Ki(o,s);case`YM`:return Gi(o,s)-qi(o,s)*12;case`MD`:let e=s.getDate()-o.getDate();return e<0&&(e=Bi(new O(s.getFullYear(),s.getMonth()-1,1))-Math.abs(e)),e;case`YD`:{if(Ji(i,a))return Ki(o,s);let e=new O(o.getFullYear(),s.getMonth(),s.getDate()),t=Ki(o,e);return t<0&&(e.setFullYear(o.getFullYear()+1),t=Ki(o,e)),t}}},isExported:!0},YC={description:k(`Converts a date string to a date value.`),args:[W(`date_string (string)`,k(`The string representing the date.`))],compute:function(e){let t=P(e),n=Di(t,this.locale);return n===null?new j(k(`The date_string (%s) cannot be parsed to date/time.`,t.toString())):Math.trunc(n.value)},isExported:!0},XC={description:k(`Day of the month that a specific date falls on.`),args:[W(`date (string)`,k(`The date from which to extract the day.`))],compute:function(e){return I(e,this.locale).getDate()},isExported:!0},ZC={description:k(`Number of days between two dates.`),args:[W(`end_date (date)`,k(`The end of the date range.`)),W(`start_date (date)`,k(`The start of the date range.`))],compute:function(e,t){let n=I(e,this.locale),r=I(t,this.locale),i=n.getTime()-r.getTime();return Math.round(i/pi)},isExported:!0},QC={description:k(`Number of days between two dates on a 360-day year (months of 30 days).`),args:[W(`start_date (date)`,k(`The start date to consider in the calculation.`)),W(`end_date (date)`,k(`The end date to consider in the calculation.`)),W(`method (boolean, default=false)`,k(`An indicator of what day count method to use.`),[{value:!1,label:k(`U.S. NASD method (default)`)},{value:!0,label:k(`European method`)}])],compute:function(e,t,n={value:!1}){let r=Math.trunc(N(e,this.locale)),i=Math.trunc(N(t,this.locale)),a=Wi(r,i,F(n)?4:0);return Math.sign(i-r)*Math.round(a*360)},isExported:!0},$C={description:k(`Date a number of months before/after another date.`),args:[W(`start_date (date)`,k(`The date from which to calculate the result.`)),W(`months (number)`,k(`The number of months before (negative) or after (positive) 'start_date' to calculate.`))],compute:function(e,t){return{value:Ri(Hi(I(e,this.locale),Math.trunc(N(t,this.locale)),!1)),format:this.locale.dateFormat}},isExported:!0},ew={description:k(`Last day of a month before or after a date.`),args:[W(`start_date (date)`,k(`The date from which to calculate the result.`)),W(`months (number)`,k(`The number of months before (negative) or after (positive) 'start_date' to consider.`))],compute:function(e,t){let n=I(e,this.locale),r=Math.trunc(N(t,this.locale));return{value:Ri(new O(n.getFullYear(),n.getMonth()+r+1,0)),format:this.locale.dateFormat}},isExported:!0},tw={description:k(`Hour component of a specific time.`),args:[W(`time (date)`,k(`The time from which to calculate the hour component.`))],compute:function(e){return I(e,this.locale).getHours()},isExported:!0},nw={description:k(`ISO week number of the year.`),args:[W(`date (date)`,k(`The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.`))],compute:function(e){let t=I(e,this.locale),n=t.getFullYear(),r=1;for(;new O(n,0,r).getDay()!==4;)r+=1;let i=new O(n,0,r-3),a=31;for(;new O(n,11,a).getDay()!==4;)--a;let o=new O(n,11,a+3),s;s=i.getTime()<=t.getTime()?t.getTime()<=o.getTime()?0:1:-1;let c;switch(s){case 0:c=i;break;case 1:c=new O(n,11,a+3+1);break;case-1:let e=1;for(;new O(n-1,0,e).getDay()!==4;)e+=1;c=new O(n-1,0,e-3);break}let l=(t.getTime()-c.getTime())/pi;return Math.floor(l/7)+1},isExported:!0},rw={description:k(`Minute component of a specific time.`),args:[W(`time (date)`,k(`The time from which to calculate the minute component.`))],compute:function(e){return I(e,this.locale).getMinutes()},isExported:!0},iw={description:k(`Month of the year a specific date falls in`),args:[W(`date (date)`,k(`The date from which to extract the month.`))],compute:function(e){return I(e,this.locale).getMonth()+1},isExported:!0},aw={description:k(`Net working days between two provided days.`),args:[W(`start_date (date)`,k(`The start date of the period from which to calculate the number of net working days.`)),W(`end_date (date)`,k(`The end date of the period from which to calculate the number of net working days.`)),W(`holidays (date, range<date>, optional)`,k(`A range or array constant containing the date serial numbers to consider holidays.`))],compute:function(e,t,n){return cw.compute.bind(this)(e,t,{value:1},n)},isExported:!0};function ow(e){let t=e?.value;if(typeof t==`string`){fm(t.length===7&&[...t].every(e=>e===`0`||e===`1`),k(`When weekend is a string (%s) it must be composed of "0" or "1".`,t));let e=[];for(let n=0;n<7;n++)t[n]===`1`&&e.push((n+1)%7);return e}if(typeof t==`number`)return fm(1<=t&&t<=7||11<=t&&t<=17,k(`The weekend (%s) must be a string or a number in the range 1-7 or 11-17.`,t.toString())),t<=7?[t-2==-1?6:t-2,t-1]:[t-11];throw new j(k(`The weekend must be a number or a string.`))}let sw=[{value:1,label:k(`Saturday/Sunday are weekends`)},{value:2,label:k(`Sunday/Monday are weekends`)},{value:3,label:k(`Monday/Tuesday are weekends`)},{value:4,label:k(`Tuesday/Wednesday are weekends`)},{value:5,label:k(`Wednesday/Thursday are weekends`)},{value:6,label:k(`Thursday/Friday are weekends`)},{value:7,label:k(`Friday/Saturday are weekends`)},{value:11,label:k(`Sunday is the only weekend`)},{value:12,label:k(`Monday is the only weekend`)},{value:13,label:k(`Tuesday is the only weekend`)},{value:14,label:k(`Wednesday is the only weekend`)},{value:15,label:k(`Thursday is the only weekend`)},{value:16,label:k(`Friday is the only weekend`)},{value:17,label:k(`Saturday is the only weekend`)}],cw={description:k(`Net working days between two dates (specifying weekends).`),args:[W(`start_date (date)`,k(`The start date of the period from which to calculate the number of net working days.`)),W(`end_date (date)`,k(`The end date of the period from which to calculate the number of net working days.`)),W(`weekend (any, default=1)`,k(`A number or string representing which days of the week are considered weekends.`),sw),W(`holidays (date, range<date>, optional)`,k(`A range or array constant containing the dates to consider as holidays.`))],compute:function(e,t,n={value:1},r){let i=I(e,this.locale),a=I(t,this.locale),o=ow(n),s=new Set;r!==void 0&&Ha([r],e=>{let t=I(e,this.locale);s.add(t.getTime())});let c=i.getTime()>a.getTime(),l=O.fromTimestamp((c?i:a).getTime()),u=O.fromTimestamp((c?a:i).getTime()),d=l.getTime(),f=u.getTime(),p=0;for(;f<=d;)!o.includes(u.getDay())&&!s.has(f)&&(p+=1),u.setDate(u.getDate()+1),f=u.getTime();return c?-p:p},isExported:!0},lw={description:k(`Current date and time as a date value.`),args:[],compute:function(){let e=O.now(),t=e.getTime()-fi.getTime(),n=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return{value:Math.floor(t/pi)+n,format:US(this.locale)}},isExported:!0},uw={description:k(`Minute component of a specific time.`),args:[W(`time (date)`,k(`The time from which to calculate the second component.`))],compute:function(e){return I(e,this.locale).getSeconds()},isExported:!0},dw={description:k(`Converts hour/minute/second into a time.`),args:[W(`hour (number)`,k(`The hour component of the time.`)),W(`minute (number)`,k(`The minute component of the time.`)),W(`second (number)`,k(`The second component of the time.`))],compute:function(e,t,n){let r=Math.trunc(N(e,this.locale)),i=Math.trunc(N(t,this.locale)),a=Math.trunc(N(n,this.locale));return i+=Math.floor(a/60),a=a%60+(a<0?60:0),r+=Math.floor(i/60),i=i%60+(i<0?60:0),r%=24,r<0?new j(k(`The function [[FUNCTION_NAME]] result cannot be negative`)):{value:r/24+i/1440+a/(1440*60),format:this.locale.timeFormat}},isExported:!0},fw={description:k(`Converts a time string into its serial number representation.`),args:[W(`time_string (string)`,k(`The string that holds the time representation.`))],compute:function(e){let t=P(e),n=Di(t,this.locale);if(n===null)return new j(k(`The time_string (%s) cannot be parsed to date/time.`,t));let r=n.value-Math.trunc(n.value);return r<0?1+r:r},isExported:!0},pw={description:k(`Current date as a date value.`),args:[],compute:function(){let e=O.now();return{value:Ri(new O(e.getFullYear(),e.getMonth(),e.getDate())),format:this.locale.dateFormat}},isExported:!0},mw={description:k(`Day of the week of the date provided (as number).`),args:[W(`date (date)`,k(`The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),W(`type (number, default=1)`,k(`A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.`),[{value:1,label:k(`Numbers 1 (Sunday) trough 7 (Saturday)`)},{value:2,label:k(`Numbers 1 (Monday) trough 7 (Sunday)`)},{value:3,label:k(`Numbers 0 (Monday) trough 6 (Sunday)`)},{value:11,label:k(`Numbers 1 (Monday) trough 7 (Sunday)`)},{value:12,label:k(`Numbers 1 (Tuesday) trough 7 (Monday)`)},{value:13,label:k(`Numbers 1 (Wednesday) trough 7 (Tuesday)`)},{value:14,label:k(`Numbers 1 (Thursday) trough 7 (Wednesday)`)},{value:15,label:k(`Numbers 1 (Friday) trough 7 (Thursday)`)},{value:16,label:k(`Numbers 1 (Saturday) trough 7 (Friday)`)},{value:17,label:k(`Numbers 1 (Sunday) trough 7 (Saturday)`)}])],compute:function(e,t={value:1}){let n=I(e,this.locale),r=Math.round(N(t,this.locale)),i=n.getDay();if(!(1<=r&&r<=3)&&!(11<=r&&r<=17))return new j(k(`The type (%s) must be between 1 and 3 or between 11 and 17.`,r));switch(r){case 1:return i+1;case 2:return i===0?7:i;case 3:return i===0?6:i-1}let a=r-10,o=(i+1-a+7)%7;return o===0?7:o},isExported:!0},hw={description:k(`Week number of the year.`),args:[W(`date (date)`,k(`The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),W(`type (number, default=1)`,k(`A number representing the day that a week starts on. Sunday = 1.`),[{value:1,label:k(`Sunday`)},{value:2,label:k(`Monday`)},{value:11,label:k(`Monday`)},{value:12,label:k(`Tuesday`)},{value:13,label:k(`Wednesday`)},{value:14,label:k(`Thursday`)},{value:15,label:k(`Friday`)},{value:16,label:k(`Saturday`)},{value:17,label:k(`Sunday`)},{value:21,label:k(`ISO week number (Monday as first day of the week)`)}])],compute:function(e,t={value:1}){let n=I(e,this.locale),r=Math.round(N(t,this.locale));if(![1,2,11,12,13,14,15,16,17,21].includes(r))return new j(k(`The type (%s) is out of range.`,r.toString()));if(r===21)return nw.compute.bind(this)(e);let i;i=r===1||r===2?r-1:r-10==7?0:r-10;let a=n.getFullYear(),o=1,s=new O(a,0,o);for(;s.getDay()!==i;)o+=1,s=new O(a,0,o);let c=(n.getTime()-s.getTime())/pi;return c<0?1:Math.floor(c/7)+(o===1?1:2)},isExported:!0},gw={description:k(`Date after a number of workdays.`),args:[W(`start_date (date)`,k(`The date from which to begin counting.`)),W(`num_days (number)`,k(`The number of working days to advance from start_date. If negative, counts backwards.`)),W(`holidays (date, range<date>, optional)`,k(`A range or array constant containing the dates to consider holidays.`))],compute:function(e,t,n={value:null}){return _w.compute.bind(this)(e,t,{value:1},n)},isExported:!0},_w={description:k(`Date after a number of workdays (specifying weekends).`),args:[W(`start_date (date)`,k(`The date from which to begin counting.`)),W(`num_days (number)`,k(`The number of working days to advance from start_date. If negative, counts backwards.`)),W(`weekend (any, default=1)`,k(`A number or string representing which days of the week are considered weekends.`),sw),W(`holidays (date, range<date>, optional)`,k(`A range or array constant containing the dates to consider holidays.`))],compute:function(e,t,n={value:1},r){let i=I(e,this.locale),a=Math.trunc(N(t,this.locale));if(n.value===`1111111`)return new j(k(`The weekend must be different from '1111111'.`));let o=ow(n),s=new Set;r!==void 0&&Ha([r],e=>{let t=I(e,this.locale);s.add(t.getTime())});let c=O.fromTimestamp(i.getTime()),l=c.getTime(),u=Math.sign(a),d=Math.abs(a);for(;d>0;)c.setDate(c.getDate()+u),l=c.getTime(),!o.includes(c.getDay())&&!s.has(l)&&--d;let f=l-fi.getTime();return{value:Math.round(f/pi),format:this.locale.dateFormat}},isExported:!0},vw={description:k(`Year specified by a given date.`),args:[W(`date (date)`,k(`The date from which to extract the year.`))],compute:function(e){return I(e,this.locale).getFullYear()},isExported:!0},yw={description:k(`Exact number of years between two dates.`),args:[W(`start_date (date)`,k(`The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),W(`end_date (date)`,k(`The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),W(`day_count_convention (number, default=0)`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n={value:0}){let r=Math.trunc(N(e,this.locale)),i=Math.trunc(N(t,this.locale)),a=Math.trunc(N(n,this.locale));return r<0?new j(k(`The start_date (%s) must be positive or null.`,r)):i<0?new j(k(`The end_date (%s) must be positive or null.`,i)):0>a||a>4?new j(k(`The day_count_convention (%s) must be between 0 and 4 inclusive.`,a)):Wi(r,i,a)}},bw={description:k(`First day of the month preceding a date.`),args:[W(`date (date)`,k(`The date from which to calculate the result.`))],compute:function(e){let t=I(e,this.locale);return{value:Ri(new O(t.getFullYear(),t.getMonth(),1)),format:this.locale.dateFormat}}},xw={description:k(`Last day of the month following a date.`),args:[W(`date (date)`,k(`The date from which to calculate the result.`))],compute:function(e){return ew.compute.bind(this)(e,{value:0})}},Sw={description:k(`Quarter of the year a specific date falls in`),args:[W(`date (date)`,k(`The date from which to extract the quarter.`))],compute:function(e){return Math.ceil((I(e,this.locale).getMonth()+1)/3)}},Cw={description:k(`First day of the quarter of the year a specific date falls in.`),args:[W(`date (date)`,k(`The date from which to calculate the start of quarter.`))],compute:function(e){let t=Sw.compute.bind(this)(e);return{value:Ri(new O(vw.compute.bind(this)(e),(t-1)*3,1)),format:this.locale.dateFormat}}},ww={description:k(`Last day of the quarter of the year a specific date falls in.`),args:[W(`date (date)`,k(`The date from which to calculate the end of quarter.`))],compute:function(e){let t=Sw.compute.bind(this)(e);return{value:Ri(new O(vw.compute.bind(this)(e),t*3,0)),format:this.locale.dateFormat}}},Tw={description:k(`First day of the year a specific date falls in.`),args:[W(`date (date)`,k(`The date from which to calculate the start of the year.`))],compute:function(e){return{value:Ri(new O(vw.compute.bind(this)(e),0,1)),format:this.locale.dateFormat}}},Ew={description:k(`Last day of the year a specific date falls in.`),args:[W(`date (date)`,k(`The date from which to calculate the end of the year.`))],compute:function(e){return{value:Ri(new O(vw.compute.bind(this)(e)+1,0,0)),format:this.locale.dateFormat}}};var Dw=l({DELTA:()=>Ow});let Ow={description:k(`Compare two numeric values, returning 1 if they're equal.`),args:[W(`number1 (number)`,k(`The first number to compare.`)),W(`number2 (number, default=0)`,k(`The second number to compare.`))],compute:function(e,t={value:0}){return+(N(e,this.locale)===N(t,this.locale))},isExported:!0},kw=[`number`,`error`,`text`,`boolean`];function Aw(e){let t=e===`asc`?1:-1;return(e,n)=>{if(e.type===`empty`)return n.type===`empty`?0:1;if(n.type===`empty`)return-1;let r=kw.indexOf(e.type)-kw.indexOf(n.type);return r===0&&(r=e.type===`text`||e.type===`error`?e.value.localeCompare(n.value):e.value-n.value),t*r}}function jw(e,t,n){let r=e.map((e,t)=>({index:t,type:e.type,value:e.value}));return(n?r.map(e=>e.type===`empty`?{...e,type:`number`,value:0}:e):r).sort(Aw(t))}var Mw=l({FILTER:()=>Pw,SORT:()=>Fw,SORTN:()=>Iw,UNIQUE:()=>Lw});function Nw(e,t,...n){for(let e=0;e<n.length;e++){let t=e%2==0?`sort_column`:`is_ascending`;fm(n[e]!==void 0,k(`Value for parameter %s is missing in [[FUNCTION_NAME]].`,t))}let r=[],i=[],a=e.length;for(let o=0;o<n.length;o+=2){r.push(F(Sm(n[o+1])?.value)?`asc`:`desc`);let s=n[o];if(Ta(s)&&(s.length>1||s[0].length>1))fm(s.length===1&&s[0].length===a,k(`Wrong size for %s. Expected a range of size 1x%s. Got %sx%s.`,`sort_column${o+1}`,a,s.length,s[0].length)),i.push(s.flat().map(e=>e.value));else{let n=N(Sm(s)?.value,t);if(n<1||n>e[0].length)return e;i.push(e.map(e=>e[n-1].value))}}if(i.length===0)for(let t=0;t<e[0].length;t++)i.push(e.map(e=>e[t].value)),r.push(`asc`);let o={desc:Aw(`desc`),asc:Aw(`asc`)},s=S(0,e.length);return s.sort((e,t)=>{for(let[n,a]of i.entries()){let i=a[e],s=a[t],c={value:i,type:i===null?`empty`:typeof i==`string`?`text`:typeof i},l={value:s,type:s===null?`empty`:typeof s==`string`?`text`:typeof s},u=o[r[n]](c,l);if(u!==0)return u}return 0}),s.map(t=>e[t])}let Pw={description:k(`Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions.`),args:[W(`range (any, range<any>)`,k(`The data to be filtered.`)),W(`condition (boolean, range<boolean>, repeating)`,k(`Column or row containing true or false values corresponding to the range.`))],compute:function(e,...t){let n=L(e),r=t.map(e=>Ya(L(e),e=>e.value));for(let e of r)if(!mm(e))return new j(k(`The arguments condition must be a single column or row.`));if(!hm(...t))return new j(k(`The arguments conditions must have the same dimensions.`));let i=r.map(e=>e.flat()),a=r[0].length===1?`row`:`col`;if(n=a===`row`?Za(n):n,i.some(e=>e.length!==n.length))return new j(k(`FILTER has mismatched sizes on the range and conditions.`));let o=[];for(let e=0;e<n.length;e++){let t=n[e];i.every(t=>(typeof t[e]==`boolean`||typeof t[e]==`number`)&&t[e])&&o.push(t)}return o.length?a===`row`?Za(o):o:new ya(k(`No match found in FILTER evaluation`))},isExported:!1},Fw={description:k(`Sorts the rows of a given array or range by the values in one or more columns.`),args:[W(`range (range)`,k(`The data to be sorted.`)),W(`sort_column (any, range<number>, repeating, optional)`,k(`The index of the column in range or a range outside of range containing the value by which to sort.`)),W(`is_ascending (boolean, repeating, optional)`,k(`TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.`),[{value:!0,label:k(`Ascending`)},{value:!1,label:k(`Descending`)}])],compute:function(e,...t){return Za(Nw(Za(e),this.locale,...t))},isExported:!0},Iw={description:k(`Returns the first n items in a data set after performing a sort.`),args:[W(`range (range)`,k(`The data to be sorted.`)),W(`n (number)`,k(`The number of items to return.`)),W(`display_ties_mode (number, default=0)`,k(`A number representing the way to display ties.`)),W(`sort_column (number, range<number>, repeating, optional)`,k(`The index of the column in range or a range outside of range containing the value by which to sort.`)),W(`is_ascending (boolean, repeating, optional)`,k(`TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.`),[{value:!0,label:k(`Ascending`)},{value:!1,label:k(`Descending`)}])],compute:function(e,t,...n){let r=N(t?.value??1,this.locale),i=n.length%2==0?0:N(n[0]?.value,this.locale),a=n.length%2==0?n:n.slice(1);if(r<0)return new j(k(`Wrong value of 'n'. Expected a positive number. Got %s.`,r));if(i<0||i>3)return new j(k(`Wrong value of 'display_ties_mode'. Expected a positive number between 0 and 3. Got %s.`,i));let o=Nw(Za(e),this.locale,...a),s=(e,t)=>JSON.stringify(o[e].map(e=>e.value))===JSON.stringify(o[t].map(e=>e.value));switch(i){case 0:return Za(o.slice(0,r));case 1:for(let e=r;e<o.length;e++)if(!s(e,r-1))return Za(o.slice(0,e));return Za(o);case 2:{let e=[o[0]];for(let t=1;t<o.length;t++)for(let n=0;n<t&&!s(t,n);n++)n===t-1&&e.push(o[t]);return Za(e.slice(0,r))}case 3:{let e=[o[0]],t=1;for(let n=1;n<o.length&&(s(n,n-1)||t++,!(t>r));n++)e.push(o[n]);return Za(e)}}},isExported:!1},Lw={description:k(`Unique rows in the provided source range.`),args:[W(`range (any, range<any>)`,k(`The data to filter by unique entries.`)),W(`by_column (boolean, default=FALSE)`,k(`Whether to filter the data by columns or by rows.`),[{value:!0,label:k(`Return unique columns`)},{value:!1,label:k(`Return unique rows`)}]),W(`exactly_once (boolean, default=FALSE)`,k(`Whether to return only entries with no duplicates.`),[{value:!0,label:k(`Return items that appear exactly once`)},{value:!1,label:k(`Return every distinct item`)}])],compute:function(e={value:``},t,n){if(!Ta(e))return[[e]];let r=F(t?.value)||!1,i=F(n?.value)||!1;r||(e=Za(e));let a=new Map;for(let t of e){let e=JSON.stringify(t.map(e=>e.value)),n=a.get(e);n?n.count++:a.set(e,{data:t,count:1})}let o=[];for(let e of a.values())i&&e.count>1||o.push(e.data);return o.length?r?o:Za(o):new j(k(`No unique values found`))},isExported:!0};var Rw=l({ACCRINTM:()=>Uw,AMORLINC:()=>Ww,COUPDAYBS:()=>Kw,COUPDAYS:()=>Gw,COUPDAYSNC:()=>qw,COUPNCD:()=>Jw,COUPNUM:()=>Yw,COUPPCD:()=>Xw,CUMIPMT:()=>Zw,CUMPRINC:()=>Qw,DB:()=>$w,DDB:()=>tT,DISC:()=>nT,DOLLARDE:()=>rT,DOLLARFR:()=>iT,DURATION:()=>aT,EFFECT:()=>oT,FV:()=>cT,FVSCHEDULE:()=>lT,INTRATE:()=>uT,IPMT:()=>fT,IRR:()=>mT,ISPMT:()=>hT,MDURATION:()=>gT,MIRR:()=>_T,NOMINAL:()=>vT,NPER:()=>yT,NPV:()=>xT,PDURATION:()=>ST,PMT:()=>wT,PPMT:()=>ET,PRICE:()=>OT,PRICEDISC:()=>kT,PRICEMAT:()=>AT,PV:()=>DT,RATE:()=>MT,RECEIVED:()=>NT,RRI:()=>PT,SLN:()=>FT,SYD:()=>IT,TBILLEQ:()=>zT,TBILLPRICE:()=>RT,TBILLYIELD:()=>BT,VDB:()=>VT,XIRR:()=>HT,XNPV:()=>UT,YIELD:()=>WT,YIELDDISC:()=>GT,YIELDMAT:()=>KT});let zw=[{value:1,label:k(`Annual`)},{value:2,label:k(`Semi-annual`)},{value:4,label:k(`Quarterly`)}],Bw=[{value:0,label:k(`End of period (default)`)},{value:1,label:k(`Beginning of period`)}],Vw=[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`frequency (number)`,k(`The number of interest or coupon payments per year (1, 2, or 4).`),zw),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)];function Hw(e,t,n,r,i=1e-10,a){let o=n,s,c,l,u=!1,d=0,f;do{if(l=e(o),isNaN(l)){fm(d<r&&a!==void 0,k(`Function [[FUNCTION_NAME]] didn't find any result.`)),d++,o=a(f),f=o;continue}s=o-l/t(o),c=Math.abs(s-o),o=s,u=c<i||Math.abs(l)<i,fm(d<r,k(`Function [[FUNCTION_NAME]] didn't find any result.`)),d++}while(!u);return o}let Uw={description:k(`Accrued interest of security paying at maturity.`),args:[W(`issue (date)`,k(`The date the security was initially issued.`)),W(`maturity (date)`,k(`The maturity date of the security.`)),W(`rate (number)`,k(`The annualized rate of interest.`)),W(`redemption (number)`,k(`The redemption amount per 100 face value, or par.`)),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i={value:0}){let a=Math.trunc(N(e,this.locale)),o=Math.trunc(N(t,this.locale)),s=N(r,this.locale),c=N(n,this.locale),l=Math.trunc(N(i,this.locale));if(a<0)return new j(cC(a));if(a>=o)return new j(fC(a,o));if(VC(l))return new j(YS(l));if(s<=0)return new j(AC(s));if(c<=0)return new j(kC(c));let u=Wi(a,o,l);return s*c*u},isExported:!0},Ww={description:k(`Depreciation for an accounting period.`),args:[W(`cost (number)`,k(`The initial cost of the asset.`)),W(`purchase_date (date)`,k(`The date the asset was purchased.`)),W(`first_period_end (date)`,k(`The date the first period ended.`)),W(`salvage (number)`,k(`The value of the asset at the end of depreciation.`)),W(`period (number)`,k(`The single period within life for which to calculate depreciation.`)),W(`rate (number)`,k(`The deprecation rate.`)),W(`day_count_convention (number, optional)`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=N(e,this.locale),c=Math.trunc(N(t,this.locale)),l=Math.trunc(N(n,this.locale)),u=N(r,this.locale),d=N(i,this.locale),f=N(a,this.locale),p=Math.trunc(N(o,this.locale));if(s<=0)return new j(qS(s));if(c<0)return new j(EC(c));if(u<0)return new j(jC(u));if(u>s)return new j(MC(u,s));if(d<0)return new j(yC(d));if(f<=0)return new j(kC(f));if(VC(p))return new j(YS(p));if(c>l)return new j(TC(c,l));let m=d<1&&d>0?1:Math.trunc(d),h=s*f,g=Wi(c,l,p),_=c===l?h:h*g,v=s-_-h*m;return v>=u?m===0?_:h:u-v<h?h-(u-v):0},isExported:!0},Gw={description:k(`Days in coupon period containing settlement date.`),args:Vw,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(N(e,this.locale)),a=Math.trunc(N(t,this.locale)),o=Math.trunc(N(n,this.locale)),s=Math.trunc(N(r,this.locale));if(i>=a)return new j(fC(i,a));if(HC(o))return new j(JS(o));if(VC(s))return new j(YS(s));if(s===1){let i=Xw.compute.bind(this)(e,t,n,r).value,a=Jw.compute.bind(this)(e,t,n,r).value;return N(a,this.locale)-N(i,this.locale)}return(s===3?365:360)/o},isExported:!0},Kw={description:k(`Days from settlement until next coupon.`),args:Vw,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(N(e,this.locale)),a=Math.trunc(N(t,this.locale)),o=Math.trunc(N(n,this.locale)),s=Math.trunc(N(r,this.locale));if(i>=a)return new j(fC(i,a));if(HC(o))return new j(JS(o));if(VC(s))return new j(YS(s));let c=Xw.compute.bind(this)(e,t,n,r).value,l=N(c,this.locale);if([1,2,3].includes(s))return i-l;if(s===4){let e=Wi(l,i,s);return Math.round(e*360)}let u=I(i,this.locale),d=I(l,this.locale),f=d.getFullYear(),p=u.getFullYear(),m=d.getMonth()+1,h=u.getMonth()+1,g=d.getDate(),_=u.getDate();return m===2&&h===2&&Vi(d)&&Vi(u)&&(_=30),_===31&&(g===30||g===31)&&(_=30),m===2&&Vi(d)&&(g=30),g===31&&(g=30),(p-f)*360+(h-m)*30+(_-g)},isExported:!0},qw={description:k(`Days from settlement until next coupon.`),args:Vw,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(N(e,this.locale)),a=Math.trunc(N(t,this.locale)),o=Math.trunc(N(n,this.locale)),s=Math.trunc(N(r,this.locale));if(i>=a)return new j(fC(i,a));if(HC(o))return new j(JS(o));if(VC(s))return new j(YS(s));let c=Jw.compute.bind(this)(e,t,n,r).value,l=N(c,this.locale);if([1,2,3].includes(s))return l-i;if(s===4){let e=Wi(i,l,s);return Math.round(e*360)}let u=Kw.compute.bind(this)(e,t,n,r);return N(Gw.compute.bind(this)(e,t,n,r),this.locale)-N(u,this.locale)},isExported:!0},Jw={description:k(`Next coupon date after the settlement date.`),args:Vw,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(N(e,this.locale)),a=Math.trunc(N(t,this.locale)),o=Math.trunc(N(n,this.locale)),s=Math.trunc(N(r,this.locale));if(i>=a)return new j(fC(i,a));if(HC(o))return new j(JS(o));if(VC(s))return new j(YS(s));let c=12/o,l=Yw.compute.bind(this)(e,t,n,r);return{value:Ri(Hi(I(a,this.locale),-(N(l,this.locale)-1)*c,!0)),format:this.locale.dateFormat}},isExported:!0},Yw={description:k(`Number of coupons between settlement and maturity.`),args:Vw,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(N(e,this.locale)),a=Math.trunc(N(t,this.locale)),o=Math.trunc(N(n,this.locale)),s=Math.trunc(N(r,this.locale));if(i>=a)return new j(fC(i,a));if(HC(o))return new j(JS(o));if(VC(s))return new j(YS(s));let c=1,l=a,u=12/o;for(;l>i;)l=Ri(Hi(I(l,this.locale),-u,!1)),c++;return c-1},isExported:!0},Xw={description:k(`Last coupon date prior to or on the settlement date.`),args:Vw,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(N(e,this.locale)),a=Math.trunc(N(t,this.locale)),o=Math.trunc(N(n,this.locale)),s=Math.trunc(N(r,this.locale));if(i>=a)return new j(fC(i,a));if(HC(o))return new j(JS(o));if(VC(s))return new j(YS(s));let c=12/o,l=Yw.compute.bind(this)(e,t,n,r);return{value:Ri(Hi(I(a,this.locale),-l*c,!0)),format:this.locale.dateFormat}},isExported:!0},Zw={description:k(`Cumulative interest paid over a set of periods.`),args:[W(`rate (number)`,k(`The interest rate.`)),W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`present_value (number)`,k(`The current value of the annuity.`)),W(`first_period (number)`,k(`The number of the payment period to begin the cumulative calculation.`)),W(`last_period (number)`,k(`The number of the payment period to end the cumulative calculation.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw)],compute:function(e,t,n,r,i,a={value:0}){let o=N(r,this.locale),s=N(i,this.locale),c=N(e,this.locale),l=N(n,this.locale),u=N(t,this.locale),d=+!!F(a);if(u<=0)return new j(gC(u));if(o<=0)return new j(aC(o));if(s<=0)return new j(uC(s));if(o>s)return new j(iC(o,s));if(s>u)return new j(lC(s,u));if(c<=0)return new j(kC(c));if(l<=0)return new j(CC(l));let f=0;for(let e=o;e<=s;e++)f+=dT(c,e,u,l,0,d);return f},isExported:!0},Qw={description:k(`Cumulative principal paid over a set of periods.`),args:[W(`rate (number)`,k(`The interest rate.`)),W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`present_value (number)`,k(`The current value of the annuity.`)),W(`first_period (number)`,k(`The number of the payment period to begin the cumulative calculation.`)),W(`last_period (number)`,k(`The number of the payment period to end the cumulative calculation.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw)],compute:function(e,t,n,r,i,a={value:0}){let o=N(r,this.locale),s=N(i,this.locale),c=N(e,this.locale),l=N(n,this.locale),u=N(t,this.locale),d=+!!F(a);if(u<=0)return new j(gC(u));if(o<=0)return new j(aC(o));if(s<=0)return new j(uC(s));if(o>s)return new j(iC(o,s));if(s>u)return new j(lC(s,u));if(c<=0)return new j(kC(c));if(l<=0)return new j(CC(l));let f=0;for(let e=o;e<=s;e++)f+=TT(c,e,u,l,0,d);return f},isExported:!0},$w={description:k(`Depreciation via declining balance method.`),args:[W(`cost (number)`,k(`The initial cost of the asset.`)),W(`salvage (number)`,k(`The value of the asset at the end of depreciation.`)),W(`life (number)`,k(`The number of periods over which the asset is depreciated.`)),W(`period (number)`,k(`The single period within life for which to calculate depreciation.`)),W(`month (number, optional)`,k(`The number of months in the first year of depreciation.`))],compute:function(e,t,n,r,...i){let a=N(e,this.locale),o=N(t,this.locale),s=N(n,this.locale),c=Math.trunc(N(r,this.locale)),l=i.length?Math.trunc(N(i[0],this.locale)):12,u=s+(l===12?0:1);if(a<0)return new j(KS(a));if(o<0)return new j(jC(o));if(c<=0)return new j(SC(c));if(s<=0)return new j(dC(s));if(1>l||l>12)return new j(pC(l));if(c>u)return new j(vC(c,u));let d=l/12,f=1-(o/a)**(1/s);f=Math.round(f*1e3)/1e3;let p=a,m=a*(1-f*d);for(let e=1;e<c;e++)p=m,m=p*(1-f),e===s&&(m=p*(1-f*(1-d)));return{value:p-m,format:`#,##0.00`}},isExported:!0},eT=`#,##0.00`,tT={description:k(`Depreciation via double-declining balance method.`),args:[W(`cost (number)`,k(`The initial cost of the asset.`)),W(`salvage (number)`,k(`The value of the asset at the end of depreciation.`)),W(`life (number)`,k(`The number of periods over which the asset is depreciated.`)),W(`period (number)`,k(`The single period within life for which to calculate depreciation.`)),W(`factor (number, default=2)`,k(`The factor by which depreciation decreases.`))],compute:function(e,t,n,r,i={value:2}){let a=N(e,this.locale),o=N(t,this.locale),s=N(n,this.locale),c=N(r,this.locale),l=N(i,this.locale);if(a<0)return new j(KS(a));if(o<0)return new j(jC(o));if(c<=0)return new j(SC(c));if(s<=0)return new j(dC(s));if(c>s)return new j(xC(c,s));if(l<=0)return new j(XS(l));if(a===0||o>=a)return{value:0,format:eT};let u=l/s;if(u>1)return{value:c===1?a-o:0,format:eT};if(c<=1)return{value:a*u,format:eT};let d=a*(1-u)**(c-1),f=a*(1-u)**c,p=f<o?d-o:d-f;return{value:Math.max(p,0),format:eT}},isExported:!0},nT={description:k(`Discount rate of a security based on price.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`price (number)`,k(`The price at which the security is bought per 100 face value.`)),W(`redemption (number)`,k(`The redemption amount per 100 face value, or par.`)),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(N(e,this.locale)),o=Math.trunc(N(t,this.locale)),s=N(n,this.locale),c=N(r,this.locale),l=Math.trunc(N(i,this.locale));if(a>=o)return new j(fC(a,o));if(VC(l))return new j(YS(l));if(s<=0)return new j(wC(s));if(c<=0)return new j(AC(c));let u=Wi(a,o,l);return(c-s)/c/u},isExported:!0},rT={description:k(`Convert a decimal fraction to decimal value.`),args:[W(`fractional_price (number)`,k(`The price quotation given using fractional decimal conventions.`)),W(`unit (number)`,k(`The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.`))],compute:function(e,t){let n=N(e,this.locale),r=Math.trunc(N(t,this.locale));if(r<=0)return new j(RC(r));let i=Math.trunc(n);return i+(n-i)*(10**Math.ceil(Math.log10(r))/r)},isExported:!0},iT={description:k(`Convert a decimal value to decimal fraction.`),args:[W(`decimal_price (number)`,k(`The price quotation given as a decimal value.`)),W(`unit (number)`,k(`The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.`))],compute:function(e,t){let n=N(e,this.locale),r=Math.trunc(N(t,this.locale));if(r<=0)return new j(RC(r));let i=Math.trunc(n);return i+(n-i)*(r/10**Math.ceil(Math.log10(r)))},isExported:!0},aT={description:k(`Number of periods for an investment to reach a value.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`rate (number)`,k(`The annualized rate of interest.`)),W(`yield (number)`,k(`The expected annual yield of the security.`)),W(`frequency (number)`,k(`The number of interest or coupon payments per year (1, 2, or 4).`),zw),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i,a={value:0}){let o=Math.trunc(N(e,this.locale)),s=Math.trunc(N(t,this.locale)),c=N(n,this.locale),l=N(r,this.locale),u=Math.trunc(N(i,this.locale)),d=Math.trunc(N(a,this.locale));if(o>=s)return new j(fC(o,s));if(HC(u))return new j(JS(u));if(VC(d))return new j(YS(d));if(c<0)return new j(OC(c));if(l<0)return new j(zC(l));let f=Wi(o,s,d),p=f-Math.trunc(f)||1/u,m=Math.ceil(f*u),h=c/u,g=l/u,_=0,v=0;for(let e=1;e<=m;e++){let t=(h+ +(e===m))/(1+g)**e;v+=(p+(e-1)/u)*t,_+=t}return _===0?0:v/_},isExported:!0},oT={description:k(`Annual effective interest rate.`),args:[W(`nominal_rate (number)`,k(`The nominal interest rate per year.`)),W(`periods_per_year (number)`,k(`The number of compounding periods per year.`))],compute:function(e,t){let n=N(e,this.locale),r=Math.trunc(N(t,this.locale));return n<=0?new j(mC(n)):r<=0?new j(bC(r)):(1+n/r)**+r-1},isExported:!0};function sT(e,t,n,r,i){return e===0?-(r+n*t):-r*(1+e)**t-n*(1+e*i)*((1+e)**t-1)/e}let cT={description:k(`Future value of an annuity investment.`),args:[W(`rate (number)`,k(`The interest rate.`)),W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`payment_amount (number)`,k(`The amount per period to be paid.`)),W(`present_value (number, default=0)`,k(`The current value of the annuity.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw)],compute:function(e,t,n,r={value:0},i={value:0}){return r||=0,i||=0,{value:sT(N(e,this.locale),N(t,this.locale),N(n,this.locale),N(r,this.locale),+!!F(i)),format:`#,##0.00`}},isExported:!0},lT={description:k(`Future value of principal from series of rates.`),args:[W(`principal (number)`,k(`The amount of initial capital or value to compound against.`)),W(`rate_schedule (number, range<number>)`,k(`A series of interest rates to compound against the principal.`))],compute:function(e,t){let n=N(e,this.locale);return Ga([t],(e,t)=>e*(1+N(t,this.locale)),n)},isExported:!0},uT={description:k(`Calculates effective interest rate.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`investment (number)`,k(`The amount invested in the security.`)),W(`redemption (number)`,k(`The amount to be received at maturity.`)),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i={value:0}){let a=Math.trunc(N(e,this.locale)),o=Math.trunc(N(t,this.locale)),s=N(r,this.locale),c=N(n,this.locale),l=Math.trunc(N(i,this.locale));if(a>=o)return new j(fC(a,o));if(c<=0)return new j(sC(c));if(s<=0)return new j(AC(s));if(VC(l))return new j(YS(l));let u=Wi(a,o,l);return(s-c)/c/u},isExported:!0};function dT(e,t,n,r,i,a){return CT(e,n,r,i,a)-TT(e,t,n,r,i,a)}let fT={description:k(`Payment on the principal of an investment.`),args:[W(`rate (number)`,k(`The annualized rate of interest.`)),W(`period (number)`,k(`The amortization period, in terms of number of periods.`)),W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`present_value (number)`,k(`The current value of the annuity.`)),W(`future_value (number, default=0)`,k(`The future value remaining after the final payment has been made.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw)],compute:function(e,t,n,r,i={value:0},a={value:0}){return{value:dT(N(e,this.locale),N(t,this.locale),N(n,this.locale),N(r,this.locale),N(i,this.locale),+!!F(a)),format:`#,##0.00`}},isExported:!0},pT=.1,mT={description:k(`Internal rate of return given periodic cashflows.`),args:[W(`cashflow_amounts (number, range<number>)`,k(`An array or range containing the income or payments associated with the investment.`)),W(`rate_guess (number, default=${pT})`,k(`An estimate for what the internal rate of return will be.`))],compute:function(e,t={value:pT}){let n=N(t,this.locale);if(n<=-1)return new j(DC(n));let r=!1,i=!1,a=[];if(Ua([e],({value:e})=>{e>0&&(r=!0),e<0&&(i=!0),a.push(e)},this.locale),!r||!i)return new j(GS);let o=a.shift();function s(e,t,n){let r=n.length,i=0;return n.reduce((t,n)=>(i++,t+n*e**(r-i)),t*e**r)}function c(e,t,n){let r=n.length,i=0;return n.reduce((t,n)=>(i++,t+n*(r-i)*e**(r-i-1)),t*r*e**(r-1))}function l(e){return s(e,o,a)}function u(e){return c(e,o,a)}return{value:Hw(l,u,n+1,20,1e-5)-1,format:`0%`}},isExported:!0},hT={description:k(`Returns the interest paid at a particular period of an investment.`),args:[W(`rate (number)`,k(`The interest rate.`)),W(`period (number)`,k(`The period for which you want to view the interest payment.`)),W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`present_value (number)`,k(`The current value of the annuity.`))],compute:function(e,t,n,r){let i=N(e,this.locale),a=N(t,this.locale),o=N(n,this.locale),s=N(r,this.locale);return o===0?new j(hC(o)):-1*(s-a/o*s)*i},isExported:!0},gT={description:k(`Modified Macaulay duration.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`rate (number)`,k(`The annualized rate of interest.`)),W(`yield (number)`,k(`The expected annual yield of the security.`)),W(`frequency (number)`,k(`The number of interest or coupon payments per year (1, 2, or 4).`),zw),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`))],compute:function(e,t,n,r,i,a={value:0}){let o=aT.compute.bind(this)(e,t,n,r,i,a),s=N(r,this.locale),c=Math.trunc(N(i,this.locale));return N(o,this.locale)/(1+s/c)},isExported:!0},_T={description:k(`Modified internal rate of return.`),args:[W(`cashflow_amounts (range<number>)`,k(`A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.`)),W(`financing_rate (number)`,k(`The interest rate paid on funds invested.`)),W(`reinvestment_return_rate (number)`,k(`The return (as a percentage) earned on reinvestment of income received from the investment.`))],compute:function(e,t,n){let r=N(t,this.locale),i=N(n,this.locale),a=Za(e).flat().filter(e=>e.value!==null).map(e=>N(e,this.locale)),o=a.length,s=0,c=0;for(let e of S(0,o)){let t=a[e];t>=0?s+=t*(i+1)**(o-e-1):c+=t/(r+1)**e}if(c===0||s===0)return new j(GS);let l=1/(o-1);return(-s/c)**l-1},isExported:!0},vT={description:k(`Annual nominal interest rate.`),args:[W(`effective_rate (number)`,k(`The effective interest rate per year.`)),W(`periods_per_year (number)`,k(`The number of compounding periods per year.`))],compute:function(e,t){let n=N(e,this.locale),r=Math.trunc(N(t,this.locale));return n<=0?new j(eC(n)):r<=0?new j(bC(r)):((n+1)**(1/r)-1)*r},isExported:!0},yT={description:k(`Number of payment periods for an investment.`),args:[W(`rate (number)`,k(`The interest rate.`)),W(`payment_amount (number)`,k(`The amount of each payment made.`)),W(`present_value (number)`,k(`The current value of the annuity.`)),W(`future_value (number, default=0)`,k(`The future value remaining after the final payment has been made.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw)],compute:function(e,t,n,r={value:0},i={value:0}){r||=0,i||=0;let a=N(e,this.locale),o=N(t,this.locale),s=N(n,this.locale),c=N(r,this.locale),l=+!!F(i);if(a===0)return-(c+s)/o;let u=o*(1+a*l)/a;return Math.log((u-c)/(s+u))/Math.log(1+a)},isExported:!0};function bT(e,t,n,r){let i=0;return Ka(n,(t,n)=>(i++,t+n/(1+e)**i),t,r)}let xT={description:k(`The net present value of an investment based on a series of periodic cash flows and a discount rate.`),args:[W(`discount (number)`,k(`The discount rate of the investment over one period.`)),W(`cashflow (number, range<number>, repeating)`,k(`The future cash flows.`))],compute:function(e,...t){let n=N(e,this.locale);return n===-1?new j(ZS(n)):{value:bT(n,0,t,this.locale),format:`#,##0.00`}},isExported:!0},ST={description:k(`Computes the number of periods needed for an investment to reach a value.`),args:[W(`rate (number)`,k(`The rate at which the investment grows each period.`)),W(`present_value (number)`,k(`The investment's current value.`)),W(`future_value (number)`,k(`The investment's desired future value.`))],compute:function(e,t,n){let r=N(e,this.locale),i=N(t,this.locale),a=N(n,this.locale);return r<=0?new j(kC(r)):i<=0?new j(CC(i)):a<=0?new j(oC(a)):(Math.log(a)-Math.log(i))/Math.log(1+r)},isExported:!0};function CT(e,t,n,r,i){if(t<=0)throw new j(gC(t));if(e===0)return-(r+n)/t;let a=-(n*(1+e)**t+r);return a=a*e/((1+e*i)*((1+e)**t-1)),a}let wT={description:k(`Periodic payment for an annuity investment.`),args:[W(`rate (number)`,k(`The annualized rate of interest.`)),W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`present_value (number)`,k(`The current value of the annuity.`)),W(`future_value (number, default=0)`,k(`The future value remaining after the final payment has been made.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw)],compute:function(e,t,n,r={value:0},i={value:0}){let a=N(t,this.locale),o=N(e,this.locale),s=+!!F(i),c=N(r,this.locale);return{value:CT(o,a,N(n,this.locale),c,s),format:`#,##0.00`}},isExported:!0};function TT(e,t,n,r,i,a){if(n<=0)throw new j(gC(n));if(t<=0||t>n)throw new j(_C(n));let o=CT(e,n,r,i,a);return a===1&&t===1?o:o+-sT(e,a===0?t-1:t-2,o,r+o*a,0)*e}let ET={description:k(`Payment on the principal of an investment.`),args:[W(`rate (number)`,k(`The annualized rate of interest.`)),W(`period (number)`,k(`The amortization period, in terms of number of periods.`)),W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`present_value (number)`,k(`The current value of the annuity.`)),W(`future_value (number, default=0)`,k(`The future value remaining after the final payment has been made.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw)],compute:function(e,t,n,r,i={value:0},a={value:0}){let o=N(n,this.locale),s=N(e,this.locale),c=N(t,this.locale),l=+!!F(a),u=N(i,this.locale);return{value:TT(s,c,o,N(r,this.locale),u,l),format:`#,##0.00`}},isExported:!0},DT={description:k(`Present value of an annuity investment.`),args:[W(`rate (number)`,k(`The interest rate.`)),W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`payment_amount (number)`,k(`The amount per period to be paid.`)),W(`future_value (number, default=0)`,k(`The future value remaining after the final payment has been made.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw)],compute:function(e,t,n,r={value:0},i={value:0}){r||=0,i||=0;let a=N(e,this.locale),o=N(t,this.locale),s=N(n,this.locale),c=N(r,this.locale),l=+!!F(i);return{value:a?-(s*(1+a*l)*((1+a)**o-1)/a+c)/(1+a)**o:-(c+s*o),format:`#,##0.00`}},isExported:!0},OT={description:k(`Price of a security paying periodic interest.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`rate (number)`,k(`The annualized rate of interest.`)),W(`yield (number)`,k(`The expected annual yield of the security.`)),W(`redemption (number)`,k(`The redemption amount per 100 face value, or par.`)),W(`frequency (number)`,k(`The number of interest or coupon payments per year (1, 2, or 4).`),zw),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=Math.trunc(N(e,this.locale)),c=Math.trunc(N(t,this.locale)),l=N(n,this.locale),u=N(r,this.locale),d=N(i,this.locale),f=Math.trunc(N(a,this.locale)),p=Math.trunc(N(o,this.locale));if(s>=c)return new j(fC(s,c));if(HC(f))return new j(JS(f));if(VC(p))return new j(YS(p));if(l<0)return new j(OC(l));if(u<0)return new j(zC(u));if(d<=0)return new j(AC(d));let m=Wi(s,c,p)*f,h=Math.ceil(m),g=m-Math.floor(m)||1,_=1+u/f,v=100*l/f;if(h===1)return(v+d)/(g*u/f+1)-v*(1-g);let y=0;for(let e=1;e<=h;e++)y+=v/_**(e-1+g);return d/_**(h-1+g)+y-v*(1-g)},isExported:!0},kT={description:k(`Price of a discount security.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`discount (number)`,k(`The discount rate of the security at time of purchase.`)),W(`redemption (number)`,k(`The redemption amount per 100 face value, or par.`)),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(N(e,this.locale)),o=Math.trunc(N(t,this.locale)),s=N(n,this.locale),c=N(r,this.locale),l=Math.trunc(N(i,this.locale));if(a>=o)return new j(fC(a,o));if(VC(l))return new j(YS(l));if(s<=0)return new j(QS(s));if(c<=0)return new j(AC(c));let u=Wi(a,o,l);return c-s*c*u},isExported:!0},AT={description:k(`Calculates the price of a security paying interest at maturity, based on expected yield.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`issue (date)`,k(`The date the security was initially issued.`)),W(`rate (number)`,k(`The annualized rate of interest.`)),W(`yield (number)`,k(`The expected annual yield of the security.`)),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i,a={value:0}){a||=0;let o=Math.trunc(N(e,this.locale)),s=Math.trunc(N(t,this.locale)),c=Math.trunc(N(n,this.locale)),l=N(r,this.locale),u=N(i,this.locale),d=Math.trunc(N(a,this.locale));if(o<=c)return new j(FC(o,c));if(o>=s)return new j(fC(o,s));if(VC(d))return new j(YS(d));if(l<0)return new j(OC(l));if(u<0)return new j(zC(u));let f=Wi(o,s,d),p=Wi(o,c,d),m=100+Wi(c,s,d)*l*100,h=1+f*u,g=p*l*100;return m/h-g},isExported:!0},jT=.1,MT={description:k(`Interest rate of an annuity investment.`),args:[W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`payment_per_period (number)`,k(`The amount per period to be paid.`)),W(`present_value (number)`,k(`The current value of the annuity.`)),W(`future_value (number, default=0)`,k(`The future value remaining after the final payment has been made.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw),W(`rate_guess (number, default=${jT})`,k(`An estimate for what the interest rate will be.`))],compute:function(e,t,n,r={value:0},i={value:0},a={value:jT}){let o=N(e,this.locale),s=N(t,this.locale),c=+!!F(i),l=N(a,this.locale)||jT,u=N(r,this.locale),d=N(n,this.locale);return o<=0?new j(gC(o)):BC([s,d,u])?l<=-1?new j(DC(l)):(u-=s*c,d+=s*c,{value:Hw(e=>{let t=(1+e)**+o,n=(t-1)/e;return u+d*t+s*n},e=>{let t=(1+e)**(o-1),n=((1+e)**+o-1)/e,r=o*t/e-n/e;return d*o*t+s*r},l,40,1e-5),format:`0%`}):new j(k(`There must be both positive and negative values in [payment_amount, present_value, future_value].`))},isExported:!0},NT={description:k(`Amount received at maturity for a security.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`investment (number)`,k(`The amount invested (irrespective of face value of each security).`)),W(`discount (number)`,k(`The discount rate of the security invested in.`)),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(N(e,this.locale)),o=Math.trunc(N(t,this.locale)),s=N(n,this.locale),c=N(r,this.locale),l=Math.trunc(N(i,this.locale));return a>=o?new j(fC(a,o)):VC(l)?new j(YS(l)):s<=0?new j(sC(s)):c<=0?new j(QS(c)):s/(1-c*Wi(a,o,l))},isExported:!0},PT={description:k(`Computes the rate needed for an investment to reach a specific value within a specific number of periods.`),args:[W(`number_of_periods (number)`,k(`The number of periods.`)),W(`present_value (number)`,k(`The present value of the investment.`)),W(`future_value (number)`,k(`The future value of the investment.`))],compute:function(e,t,n){let r=N(e,this.locale),i=N(t,this.locale),a=N(n,this.locale);return r<=0?new j(gC(r)):(a/i)**(1/r)-1},isExported:!0},FT={description:k(`Depreciation of an asset using the straight-line method.`),args:[W(`cost (number)`,k(`The initial cost of the asset.`)),W(`salvage (number)`,k(`The value of the asset at the end of depreciation.`)),W(`life (number)`,k(`The number of periods over which the asset is depreciated.`))],compute:function(e,t,n){let r=N(e,this.locale),i=N(t,this.locale),a=N(n,this.locale);return{value:(r-i)/a,format:`#,##0.00`}},isExported:!0},IT={description:k(`Depreciation via sum of years digit method.`),args:[W(`cost (number)`,k(`The initial cost of the asset.`)),W(`salvage (number)`,k(`The value of the asset at the end of depreciation.`)),W(`life (number)`,k(`The number of periods over which the asset is depreciated.`)),W(`period (number)`,k(`The single period within life for which to calculate depreciation.`))],compute:function(e,t,n,r){let i=N(e,this.locale),a=N(t,this.locale),o=N(n,this.locale),s=N(r,this.locale);if(s<=0)return new j(SC(s));if(o<=0)return new j(dC(o));if(s>o)return new j(xC(s,o));let c=o*(o+1)/2,l=o-s+1;return{value:(i-a)*(l/c),format:`#,##0.00`}},isExported:!0};function LT(e,t,n){return 100*(1-n*Wi(e,t,2))}let RT={description:k(`Price of a US Treasury bill.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`discount (number)`,k(`The discount rate of the bill at time of purchase.`))],compute:function(e,t,n){let r=Math.trunc(N(e,this.locale)),i=Math.trunc(N(t,this.locale)),a=N(n,this.locale);return r>=i?new j(fC(r,i)):UC(r,i,this.locale)?a<=0?new j(QS(a)):a>=1?new j($S(a)):LT(r,i,a):new j(PC(r,i))},isExported:!0},zT={description:k(`Equivalent rate of return for a US Treasury bill.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`discount (number)`,k(`The discount rate of the bill at time of purchase.`))],compute:function(e,t,n){let r=Math.trunc(N(e,this.locale)),i=Math.trunc(N(t,this.locale)),a=N(n,this.locale);if(r>=i)return new j(fC(r,i));if(!UC(r,i,this.locale))return new j(PC(r,i));if(a<=0)return new j(QS(a));if(a>=1)return new j($S(a));let o=ZC.compute.bind(this)({value:i},{value:r});if(o<=182)return 365*a/(360-a*o);let s=LT(r,i,a)/100,c=o/(o===366?366:365);return(-2*c+2*Math.sqrt(c**2-(2*c-1)*(1-1/s)))/(2*c-1)},isExported:!0},BT={description:k(`The yield of a US Treasury bill based on price.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`price (number)`,k(`The price at which the security is bought per 100 face value.`))],compute:function(e,t,n){let r=Math.trunc(N(e,this.locale)),i=Math.trunc(N(t,this.locale)),a=N(n,this.locale);if(r>=i)return new j(fC(r,i));if(!UC(r,i,this.locale))return new j(PC(r,i));if(a<=0)return new j(wC(a));let o=Wi(r,i,2);return(100-a)/a*(1/o)},isExported:!0},VT={description:k(`Variable declining balance. WARNING : does not handle decimal periods.`),args:[W(`cost (number)`,k(`The initial cost of the asset.`)),W(`salvage (number)`,k(`The value of the asset at the end of depreciation.`)),W(`life (number)`,k(`The number of periods over which the asset is depreciated.`)),W(`start (number)`,k(`Starting period to calculate depreciation.`)),W(`end (number)`,k(`Ending period to calculate depreciation.`)),W(`factor (number, default=2)`,k(`The number of months in the first year of depreciation.`)),W(`no_switch (number, default=false)`,k(`Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.`),[{value:!1,label:k(`Switch to straight-line depreciation`)},{value:!0,label:k(`Do not switch to straight-line depreciation`)}])],compute:function(e,t,n,r,i,a={value:2},o={value:!1}){a||=0;let s=N(e,this.locale),c=N(t,this.locale),l=N(n,this.locale),u=Math.trunc(N(r,this.locale)),d=Math.trunc(N(i,this.locale)),f=N(a,this.locale),p=F(o);if(s<0)return new j(KS(s));if(c<0)return new j(jC(c));if(l<=0)return new j(dC(l));if(u<0)return new j(IC(u));if(d<0)return new j(tC(d));if(u>d)return new j(LC(u,d));if(d>l)return new j(nC(d,l));if(f<=0)return new j(XS(f));if(s===0)return 0;if(c>=s)return u<1?s-c:0;let m=f/l;if(m>=1)return u<1?s-c:0;let h=s,g=0,_=0,v=!1;for(let e=0;e<d;e++){if(!v||p){let t=h*m,n=l-e,r=(h-c)/n;!p&&r>t?(v=!0,g=r):g=t}let t=Math.max(h-g,c);e>=u&&(_+=h-t),h=t}return _},isExported:!0},HT={description:k(`Internal rate of return given non-periodic cash flows.`),args:[W(`cashflow_amounts (range<number>)`,k(`An range containing the income or payments associated with the investment.`)),W(`cashflow_dates (range<number>)`,k(`An range with dates corresponding to the cash flows in cashflow_amounts.`)),W(`rate_guess (number, default=${jT})`,k(`An estimate for what the internal rate of return will be.`))],compute:function(e,t,n={value:jT}){let r=N(n,this.locale);if(!hm(e,t))return new j(WS);let i=e.flat().map(e=>N(e,this.locale)),a=t.flat().map(e=>N(e,this.locale));if(!BC(i))return new j(GS);if(a.some(e=>e<a[0]))return new j(rC(a[0]));if(r<=-1)return new j(DC(r));let o=new Map;for(let e of S(0,a.length)){let t=a[e];o.has(t)?o.set(t,o.get(t)+i[e]):o.set(t,i[e])}let s=Array.from(o.keys()),c=s.map(e=>o.get(e));return Hw(e=>{let t=c[0];for(let n of S(1,c.length)){let r=(s[0]-s[n])/365;t+=c[n]*(1+e)**r}return t},e=>{let t=0;for(let n of S(1,c.length)){let r=(s[0]-s[n])/365;t+=r*c[n]*(1+e)**(r-1)}return t},r,40,1e-5,e=>e?e/10-.9:-.9)},isExported:!0},UT={description:k(`Net present value given to non-periodic cash flows..`),args:[W(`discount (number)`,k(`The discount rate of the investment over one period.`)),W(`cashflow_amounts (number, range<number>)`,k(`An range containing the income or payments associated with the investment.`)),W(`cashflow_dates (number, range<number>)`,k(`An range with dates corresponding to the cash flows in cashflow_amounts.`))],compute:function(e,t,n){let r=N(e,this.locale);if(!hm(t,n))return new j(WS);let i=L(t).flat().map(e=>Pa(e,this.locale)),a=L(n).flat().map(e=>Pa(e,this.locale));if(a.some(e=>e<a[0]))return new j(rC(a[0]));if(r<=0)return new j(kC(r));if(i.length===1)return i[0];let o=new Map;for(let e of S(0,a.length)){let t=a[e];o.has(t)?o.set(t,o.get(t)+i[e]):o.set(t,i[e])}let s=Array.from(o.keys()),c=s.map(e=>o.get(e)),l=c[0];for(let e of S(1,c.length)){let t=(s[0]-s[e])/365;l+=c[e]*(1+r)**t}return l},isExported:!0},WT={description:k(`Annual yield of a security paying periodic interest.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`rate (number)`,k(`The annualized rate of interest.`)),W(`price (number)`,k(`The price at which the security is bought per 100 face value.`)),W(`redemption (number)`,k(`The redemption amount per 100 face value, or par.`)),W(`frequency (number)`,k(`The number of interest or coupon payments per year (1, 2, or 4).`),zw),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=Math.trunc(N(e,this.locale)),c=Math.trunc(N(t,this.locale)),l=N(n,this.locale),u=N(r,this.locale),d=N(i,this.locale),f=Math.trunc(N(a,this.locale)),p=Math.trunc(N(o,this.locale));if(s>=c)return new j(fC(s,c));if(HC(f))return new j(JS(f));if(VC(p))return new j(YS(p));if(l<0)return new j(OC(l));if(u<=0)return new j(wC(u));if(d<=0)return new j(AC(d));let m=Wi(s,c,p)*f,h=Math.ceil(m),g=m-Math.floor(m)||1,_=100*l/f;if(h===1){let e=u+_*(1-g);return(d+_-e)*f*(1/g)/e}function v(e,t,n,r,i,a){let o=a-(e+i*(1-t))*r**(n-1+t);for(let e=1;e<=n;e++)o+=i*r**(e-1);return o}function y(e,t,n,r,i){let a=-(e+i*(1-t))*(n-1+t)*r**(n-2+t);for(let e=1;e<=n;e++)a+=i*(e-1)*r**(e-2);return a}function ee(e){return v(u,g,h,e,_,d)}function te(e){return y(u,g,h,e,_)}return(Hw(ee,te,1+(l+1)/f,100,1e-5)-1)*f},isExported:!0},GT={description:k(`Annual yield of a discount security.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`price (number)`,k(`The price at which the security is bought per 100 face value.`)),W(`redemption (number)`,k(`The redemption amount per 100 face value, or par.`)),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(N(e,this.locale)),o=Math.trunc(N(t,this.locale)),s=N(n,this.locale),c=N(r,this.locale),l=Math.trunc(N(i,this.locale));if(a>=o)return new j(fC(a,o));if(VC(l))return new j(YS(l));if(s<=0)return new j(wC(s));if(c<=0)return new j(AC(c));let u=Wi(a,o,l);return(c/s-1)/u},isExported:!0},KT={description:k(`Annual yield of a security paying interest at maturity.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`issue (date)`,k(`The date the security was initially issued.`)),W(`rate (number)`,k(`The annualized rate of interest.`)),W(`price (number)`,k(`The price at which the security is bought.`)),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i,a={value:0}){a||=0;let o=Math.trunc(N(e,this.locale)),s=Math.trunc(N(t,this.locale)),c=Math.trunc(N(n,this.locale)),l=N(r,this.locale),u=N(i,this.locale),d=Math.trunc(N(a,this.locale));if(o>=s)return new j(fC(o,s));if(VC(d))return new j(YS(d));if(o<c)return new j(NC(o,c));if(l<0)return new j(OC(l));if(u<=0)return new j(wC(u));let f=Wi(c,s,d),p=Wi(c,o,d),m=Wi(o,s,d);return(100*(1+l*f)/(u+100*l*p)-1)/m},isExported:!0};var qT=l({CELL:()=>YT,ISBLANK:()=>rE,ISERR:()=>XT,ISERROR:()=>ZT,ISFORMULA:()=>aE,ISLOGICAL:()=>QT,ISNA:()=>$T,ISNONTEXT:()=>eE,ISNUMBER:()=>tE,ISTEXT:()=>nE,NA:()=>iE});let JT=[{value:`address`,label:k(`Returns an absolute reference as plain text of the top left cell in reference.`)},{value:`col`,label:k(`Returns the column number of the cell in reference.`)},{value:`contents`,label:k(`Returns the value contained in the top left cell in reference.`)},{value:`format`,label:k(`Returns the format of the top left cell in reference.`)},{value:`row`,label:k(`Returns the row number of the top left cell in reference.`)},{value:`type`,label:k(`Returns the type of data in the cell in reference. The following values are returned: "b" for a blank cell, "l" (for label) if the cell contains plain text, and "v" (for value) if the cell contains any other type of data.`)}],YT={description:k(`Gets information about a cell.`),args:[W(`info_type (string)`,k(`The type of information requested.`),JT),W(`reference (meta, range<meta>)`,k(`The reference to the cell.`))],compute:function(e,t){let n=P(e).toLowerCase();if(!JT.map(e=>e.value).includes(n))return new j(k(`The info_type should be one of %s.`,JT.join(`, `)));let r=this.__originSheetId,i=t[0][0].value,{sheetName:a,xc:o}=zc(i);a=a===this.getters.getSheetName(r)?void 0:a;let s=Bc(a,Uc(o,`colrow`)),c=this.getters.getRangeFromSheetXC(r,s);switch(n){case`address`:return this.getters.getRangeString(c,r);case`col`:return c.zone.left+1;case`contents`:{let e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top};return this.getters.getEvaluatedCell(e).value}case`format`:{let e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top};return this.getters.getEvaluatedCell(e).format||``}case`row`:return c.zone.top+1;case`type`:{let e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top},t=this.getters.getEvaluatedCell(e).type;return t===`empty`?`b`:t===`text`?`l`:`v`}}return``},isExported:!0},XT={description:k(`Whether a value is an error other than #N/A.`),args:[W(`value (any)`,k(`The value to be verified as an error type.`))],compute:function(e){let t=e?.value;return M(t)&&t!==A.NotAvailable},isExported:!0},ZT={description:k(`Whether a value is an error.`),args:[W(`value (any)`,k(`The value to be verified as an error type.`))],compute:function(e){let t=e?.value;return M(t)},isExported:!0},QT={description:k("Whether a value is `true` or `false`."),args:[W(`value (any)`,k(`The value to be verified as a logical TRUE or FALSE.`))],compute:function(e){return typeof e?.value==`boolean`},isExported:!0},$T={description:k(`Whether a value is the error #N/A.`),args:[W(`value (any)`,k(`The value to be verified as an error type.`))],compute:function(e){return e?.value===A.NotAvailable},isExported:!0},eE={description:k(`Whether a value is non-textual.`),args:[W(`value (any)`,k(`The value to be checked.`))],compute:function(e){return!nE.compute.bind(this)(e)},isExported:!0},tE={description:k(`Whether a value is a number.`),args:[W(`value (any)`,k(`The value to be verified as a number.`))],compute:function(e){return typeof e?.value==`number`},isExported:!0},nE={description:k(`Whether a value is text.`),args:[W(`value (any)`,k(`The value to be verified as text.`))],compute:function(e){return typeof e?.value==`string`&&M(e?.value)===!1},isExported:!0},rE={description:k(`Whether the referenced cell is empty`),args:[W(`value (any)`,k(`Reference to the cell that will be checked for emptiness.`))],compute:function(e){return e?.value===null},isExported:!0},iE={description:k(`Returns the error value #N/A.`),args:[],compute:function(){return{value:A.NotAvailable}},isExported:!0},aE={description:k(`Checks whether there is a reference to a cell that contains a formula, and returns TRUE or FALSE.`),args:[W(`cell_reference (meta)`,k(`A reference to a cell.`))],compute:function(e){let{sheetName:t,xc:n}=zc(e.value),{col:r,row:i}=tn(n),a=(t&&this.getters.getSheetIdByName(t))??this.__originSheetId;return this.getters.getCell({sheetId:a,col:r,row:i})?.isFormula??!1},isExported:!0};var oE=l({AND:()=>sE,FALSE:()=>cE,IF:()=>lE,IFERROR:()=>uE,IFNA:()=>dE,IFS:()=>fE,NOT:()=>pE,OR:()=>mE,SWITCH:()=>hE,TRUE:()=>gE,XOR:()=>_E});let sE={description:k("Logical `and` operator."),args:[W(`logical_expression (boolean, range<boolean>, repeating)`,k(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let{result:t,foundBoolean:n}=Km(e);return n?t:new j(po)},isExported:!0},cE={description:k("Logical value `false`."),args:[],compute:function(){return!1},isExported:!0},lE={description:k(`Returns value depending on logical expression.`),args:[W(`logical_expression (boolean, range<boolean>)`,k(`An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.`)),W(`value_if_true (any, range)`,k(`The value the function returns if logical_expression is TRUE.`)),W(`value_if_false (any, range, default=FALSE)`,k(`The value the function returns if logical_expression is FALSE.`))],compute:function(e,t,n){return wm(e)?Qa(lE.compute,[e,t,n]):(F(Sm(e))?t:n)??{value:0}},isExported:!0},uE={description:k(`Value if it is not an error, otherwise 2nd argument.`),args:[W(`value (any, range)`,k(`The value to return if value itself is not an error.`)),W(`value_if_error (any, range, default="empty")`,k(`The value the function returns if value is an error.`))],compute:function(e,t){return wm(e)?Qa(uE.compute,[e,t]):(M(Sm(e)?.value)?t:e)??{value:0}},isExported:!0},dE={description:k(`Value if it is not an #N/A error, otherwise 2nd argument.`),args:[W(`value (any, range)`,k(`The value to return if value itself is not #N/A an error.`)),W(`value_if_error (any, range, default="empty")`,k(`The value the function returns if value is an #N/A error.`))],compute:function(e,t){return wm(e)?Qa(dE.compute,[e,t]):(Sm(e)?.value===A.NotAvailable?t:e)??{value:0}},isExported:!0},fE={description:k(`Returns a value depending on multiple logical expressions.`),args:[W(`condition (any, range, repeating)`,k(`The condition to be evaluated. It can be a boolean, a number, an array, or a reference to any of those.`)),W(`value (any, range, repeating)`,k(`The value to be returned if its corresponding condition is TRUE.`))],compute:function(...e){if(e.length%2!=0)return new j(k(`Wrong number of arguments. Expected an even number of arguments.`));for(;e.length>0;){if(wm(e[0]))return Qa(fE.compute,e);let t=F(Sm(e.shift())),n=e.shift();if(t)return n??{value:0}}return new j(k(`No match.`))},isExported:!0},pE={description:k(`Returns opposite of provided logical value.`),args:[W(`logical_expression (boolean)`,k(`An expression or reference to a cell holding an expression that represents some logical value.`))],compute:function(e){return!F(e)},isExported:!0},mE={description:k("Logical `or` operator."),args:[W(`logical_expression (boolean, range<boolean>, repeating)`,k(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let{result:t,foundBoolean:n}=qm(e);return n?t:new j(po)},isExported:!0},hE={description:k(`Returns a value by comparing cases to an expression.`),args:[W(`expression (number, boolean, string)`,k(`The value to be checked.`)),W(`case (any, repeating)`,k(`Case to be checked against expression.`)),W(`value (any, repeating)`,k(`Value to be returned if its corresponding case matches expression.`)),W(`default (any, default="empty")`,k(`An optional default value to be returned if none of the cases match expression.`))],compute:function(e,...t){let n=t.length%2==0?Oa(e):t.pop();for(let n=0;n<t.length;n+=2){let r=t[n];if(r&&M(r.value))return r;if(e?.value===r?.value)return t[n+1]||{value:0}}return n||{value:0}},isExported:!0},gE={description:k("Logical value `true`."),args:[],compute:function(){return!0},isExported:!0},_E={description:k("Logical `xor` operator."),args:[W(`logical_expression (boolean, range<boolean>, repeating)`,k(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let t=!1,n=!1;return eo(e,e=>(t=!0,n=n?!e:e,!0)),t?n:new j(po)},isExported:!0};function vE(e,t){let n=t.getPivotId(e);if(!n)throw new j(k(`There is no pivot with id "%s"`,e));return n}function yE(e,t,n){let{measures:r}=n.getPivotCoreDefinition(e);if(!r.find(e=>e.id===t))throw new j(k(`The argument %s is not a valid measure. Here are the measures: %s`,t,`(${r.map(e=>e.id).join(`, `)})`))}function bE(e){if(e.length%2!=0)throw new j(k(`Function PIVOT takes an even number of arguments.`))}function xE(e,t,n){let r=[],i=e.getters.getPivotCoreDefinition(t);if(i.type===`SPREADSHEET`&&i.dataSet){let{sheetId:t,zone:n}=i.dataSet,a=yn(n),o=e.getters.getRangeFromSheetXC(t,a);if(o===void 0||o.invalidXc||o.invalidSheetName)throw new va;if(e.__originCellPosition&&o.sheetId===e.__originSheetId&&jn(E(e.__originCellPosition),n))throw new _a;r.push(o)}for(let i of n)i.computedBy&&r.push(...e.getters.getMeasureFullDependencies(t,i));let a=e.__originCellPosition;a&&r.length&&(e.updateDependencies?.(a),e.addDependencies?.(a,r))}var SE=l({ADDRESS:()=>TE,CHOOSE:()=>HE,COLUMN:()=>EE,COLUMNS:()=>DE,DROP:()=>UE,FORMULATEXT:()=>GE,HLOOKUP:()=>OE,INDEX:()=>kE,INDIRECT:()=>AE,LOOKUP:()=>jE,MATCH:()=>ME,OFFSET:()=>VE,PIVOT:()=>BE,PIVOT_HEADER:()=>zE,PIVOT_VALUE:()=>RE,ROW:()=>NE,ROWS:()=>PE,TAKE:()=>WE,VLOOKUP:()=>FE,XLOOKUP:()=>LE});let CE=[{value:!0,label:k(`A1 style (default)`)},{value:!1,label:k(`R1C1 style`)}],wE=[{value:!0,label:k(`Approximate match (default)`)},{value:!1,label:k(`Exact match`)}],TE={description:k(`Returns a cell reference as a string. `),args:[W(`row (number)`,k(`The row number of the cell reference. `)),W(`column (number)`,k(`The column number (not name) of the cell reference. A is column number 1. `)),W(`absolute_relative_mode (number, default=1)`,k(`An indicator of whether the reference is row/column absolute.`),[{value:1,label:k(`Absolute row and column (e.g. $A$1)`)},{value:2,label:k(`Absolute row, relative column (e.g. A$1)`)},{value:3,label:k(`Relative row, absolute column (e.g. $A1)`)},{value:4,label:k(`Relative row and column (e.g. A1)`)}]),W(`use_a1_notation (boolean, default=TRUE)`,k(`A boolean indicating whether to use A1 style notation or R1C1 style notation.`),CE),W(`sheet (string, optional)`,k(`A string indicating the name of the sheet into which the address points.`))],compute:function(e,t,n={value:1},r={value:!0},i){let a=Ia(e,this.locale),o=Ia(t,this.locale);if(a<1)return new j(_m(a));if(o<1)return new j(_m(o));let s=Ia(n,this.locale);if(![1,2,3,4].includes(s))return new j(Aa(1,4,s));let c=F(r),l;if(c){let e={rowFixed:[1,2].includes(s),colFixed:[1,3].includes(s)};l=T(o-1,a-1,e)}else l=([1,2].includes(s)?`R${a}`:`R[${a}]`)+([1,3].includes(s)?`C${o}`:`C[${o}]`);return i===void 0?l:Bc(P(i),l)},isExported:!0},EE={description:k(`Column number of a specified cell.`),args:[W(`cell_reference (meta, range<meta>, default='this cell')`,k(`The cell whose column number will be returned. Column A corresponds to 1. By default, the function use the cell in which the formula is entered.`))],compute:function(e){if(e===void 0)return this.__originCellPosition?.col===void 0?new j(k(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):this.__originCellPosition.col+1;if(e[0][0]===void 0)return new j(k(`The range is out of bounds.`));if(e[0][0].value===A.InvalidReference)return e[0][0];let t=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),e[0][0].value).zone.left;return e.length===1?t+1:Ja(e.length,1,(e,n)=>({value:t+e+1}))},isExported:!0},DE={description:k(`Number of columns in a specified array or range.`),args:[W(`range (any, range<any>)`,k(`The range whose column count will be returned.`))],compute:function(e){let t=L(e);return t[0][0]===void 0?new j(k(`The range is out of bounds.`)):t[0][0].value===A.InvalidReference?t[0][0]:t.length},isExported:!0},OE={description:k(`Horizontal lookup`),args:[W(`search_key (string, number, boolean)`,k(`The value to search for. For example, 42, 'Cats', or I24.`)),W(`range (any, range)`,k(`The range to consider for the search. The first row in the range is searched for the key specified in search_key.`)),W(`index (number)`,k(`The row index of the value to be returned, where the first row in range is numbered 1.`)),W(`is_sorted (boolean, default=true)`,k(`Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned.`),wE)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(N(n?.value,this.locale)),a=L(t);if(1>i||i>a[0].length)return new j(k(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[t][0].value,s=a[F(r.value)?ao(a,e,`nextSmaller`,`asc`,a.length,o):oo(a,e,`wildcard`,a.length,o,this.lookupCaches)];return s===void 0?Oa(e):s[i-1]},isExported:!0},kE={description:k(`Returns the content of a cell, specified by row and column offset.`),args:[W(`reference (any, range)`,k(`The range of cells from which the values are returned.`)),W(`row (number, default=0)`,k(`The index of the row to be returned from within the reference range of cells.`)),W(`column (number, default=0)`,k(`The index of the column to be returned from within the reference range of cells.`))],compute:function(e,t={value:0},n={value:0}){let r=L(e),i=N(t.value,this.locale),a=N(n.value,this.locale);return a<0||a-1>=r.length||i<0||i-1>=r[0].length?new j(k(`Index out of range.`)):i===0&&a===0?r:i===0?[r[a-1]]:a===0?r.map(e=>[e[i-1]]):r[a-1][i-1]},isExported:!0},AE={description:k(`Returns the content of a cell, specified by a string.`),args:[W(`reference (string)`,k(`The range of cells from which the values are returned.`)),W(`use_a1_notation (boolean, default=TRUE)`,k(`A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).`),CE)],compute:function(e,t={value:!0}){let n=e?.value?.toString();if(!n)return new va(k(`Reference should be defined.`));if(!F(t))return new j(k(`R1C1 notation is not supported.`));let r=this.__originSheetId,i=this.__originCellPosition;i&&this.updateDependencies?.(i);let a=this.getters.getRangeFromSheetXC(r,n);if(a===void 0||a.invalidXc||a.invalidSheetName)return new va;i&&this.addDependencies?.(i,[a]);let o=[];for(let e=a.zone.left;e<=a.zone.right;e++){let t=[];for(let n=a.zone.top;n<=a.zone.bottom;n++){let r={sheetId:a.sheetId,col:e,row:n};t.push(this.getters.getEvaluatedCell(r))}o.push(t)}return o.length===1&&o[0].length===1?o[0][0]:o},isExported:!0},jE={description:k(`Look up a value.`),args:[W(`search_key (string, number, boolean)`,k(`The value to search for. For example, 42, 'Cats', or I24.`)),W(`search_array (any, range)`,k(`One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.`)),W(`result_range (any, range, optional)`,k(`The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method.`))],compute:function(e,t,n){let r=L(t),i=L(n),a=r.length,o=r[0].length,s=o>=a,c=ao(r,e,`nextSmaller`,`asc`,s?o:a,s?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value);return c===-1||s&&r[0][c]===void 0||!s&&r[c][o-1]===void 0?Oa(e):i[0].length===0?s?r[a-1][c]:r[c][o-1]:(a=i.length,o=i[0].length,a!==1&&o!==1?new j(k(`The result_range must be a single row or a single column.`)):a>1?c>a-1?new j(k(`[[FUNCTION_NAME]] evaluates to an out of range row value %s.`,c+1)):i[c][0]:c>o-1?new j(k(`[[FUNCTION_NAME]] evaluates to an out of range column value %s.`,c+1)):i[0][c])},isExported:!0},ME={description:k(`Position of item in range that matches value.`),args:[W(`search_key (string, number, boolean)`,k(`The value to search for. For example, 42, 'Cats', or I24.`)),W(`range (any, range)`,k(`The one-dimensional array to be searched.`)),W(`search_type (number, default=1)`,k(`The search method is a number 1, 0 or -1 indicating which value to return. 1 finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order.`),[{value:1,label:k(`Ascending order (default)`)},{value:0,label:k(`Exact match`)},{value:-1,label:k(`Descending order`)}])],compute:function(e,t,n={value:1}){let r=N(n,this.locale),i=L(t),a=i.length,o=i[0].length;if(a!==1&&o!==1)return new j(k(`The range must be a single row or a single column.`));let s=-1,c=a===1?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,l=a===1?i[0].length:i.length;switch(r=Math.sign(r),r){case 1:s=ao(i,e,`nextSmaller`,`asc`,l,c);break;case 0:s=oo(i,e,`wildcard`,l,c,this.lookupCaches);break;case-1:s=ao(i,e,`nextGreater`,`desc`,l,c);break}return a===1&&i[0][s]===void 0||a!==1&&i[s]===void 0?Oa(e):s+1},isExported:!0},NE={description:k(`Row number of a specified cell.`),args:[W(`cell_reference (meta, range<meta>, default='this cell')`,k(`The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered.`))],compute:function(e){if(e===void 0)return this.__originCellPosition?.row===void 0?new j(k(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):this.__originCellPosition.row+1;if(e[0][0]===void 0)return new j(k(`The range is out of bounds.`));if(e[0][0].value===A.InvalidReference)return e[0][0];let t=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),e[0][0].value).zone.top;return e[0].length===1?t+1:Ja(1,e[0].length,(e,n)=>({value:t+n+1}))},isExported:!0},PE={description:k(`Number of rows in a specified array or range.`),args:[W(`range (any, range<any>)`,k(`The range whose row count will be returned.`))],compute:function(e){let t=L(e);return t[0][0]===void 0?new j(k(`The range is out of bounds.`)):t[0][0].value===A.InvalidReference?t[0][0]:t[0].length},isExported:!0},FE={description:k(`Vertical lookup.`),args:[W(`search_key (string, number, boolean)`,k(`The value to search for. For example, 42, 'Cats', or I24.`)),W(`range (any, range)`,k(`The range to consider for the search. The first column in the range is searched for the key specified in search_key.`)),W(`index (number)`,k(`The column index of the value to be returned, where the first column in range is numbered 1.`)),W(`is_sorted (boolean, default=true)`,k(`Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned.`),wE)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(N(n?.value,this.locale)),a=L(t);if(1>i||i>a.length)return new j(k(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[0][t].value,s=F(r.value)?ao(a,e,`nextSmaller`,`asc`,a[0].length,o):oo(a,e,`wildcard`,a[0].length,o,this.lookupCaches),c=a[i-1][s];return c===void 0?Oa(e):c},isExported:!0},IE={0:`strict`,1:`nextGreater`,"-1":`nextSmaller`,2:`wildcard`},LE={description:k(`Search a range for a match and return the corresponding item from a second range.`),args:[W(`search_key (string,number,boolean)`,k(`The value to search for.`)),W(`lookup_range (any, range)`,k(`The range to consider for the search. Should be a single column or a single row.`)),W(`return_range (any, range)`,k(`The range containing the return value. Should have the same dimensions as lookup_range.`)),W(`if_not_found (any, optional)`,k(`If a valid match is not found, return this value.`)),W(`match_mode (any, default=0)`,k(`Specifies how to match search_key with the items in lookup_range. `),[{value:0,label:k(`Exact match (default)`)},{value:-1,label:k(`Exact match or next smaller item`)},{value:1,label:k(`Exact match or next larger item`)},{value:2,label:k(`Wildcard character match`)}]),W(`search_mode (any, default=1)`,k(`Specifies the search mode to use. By default, a first to last search will be used.`),[{value:1,label:k(`Search first to last (default)`)},{value:-1,label:k(`Search last to first`)},{value:2,label:k(`Binary search (sorted ascending order)`)},{value:-2,label:k(`Binary search (sorted descending order)`)}])],compute:function(e,t,n,r,i={value:0},a={value:1}){let o=Math.trunc(N(i.value,this.locale)),s=Math.trunc(N(a.value,this.locale)),c=L(t),l=L(n);if(c.length!==1&&c[0].length!==1)return new j(k(`lookup_range should be either a single row or single column.`));if(![1,-1,2,-2].includes(s))return new j(k(`search_mode should be a value in [-1, 1, -2, 2].`));if(![-1,0,1,2].includes(o))return new j(k(`match_mode should be a value in [-1, 0, 1, 2].`));let u=c.length===1?`col`:`row`;if(o===2&&[-2,2].includes(s))return new j(k(`The search and match mode combination is not supported for XLOOKUP evaluation.`));if(u===`col`?l[0].length!==c[0].length:l.length!==c.length)return new j(k(`return_range should have the same dimensions as lookup_range.`));let d=u===`col`?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,f=u===`col`?c[0].length:c.length,p=IE[o],m=s===-1,h=s===2||s===-2?ao(c,e,p,s===2?`asc`:`desc`,f,d):oo(c,e,p,f,d,this.lookupCaches,m);return h===-1?r===void 0?Oa(e):[[r]]:u===`col`?l.map(e=>[e[h]]):[l[h]]},isExported:!0},RE={description:k(`Get the value from a pivot.`),args:[W(`pivot_id (number,string)`,k(`ID of the pivot.`)),W(`measure_name (string)`,k(`Name of the measure.`)),W(`domain_field_name (string,repeating,optional)`,k(`Field name.`)),W(`domain_value (number,string,boolean,repeating,optional)`,k(`Value.`))],compute:function(e,t,...n){let r=P(e),i=P(t),a=vE(r,this.getters);yE(a,i,this.getters),bE(n);let o=this.getters.getPivot(a),s=this.getters.getPivotCoreDefinition(a);xE(this,a,s.measures.filter(e=>e.id===i)),o.init({reload:o.needsReevaluation});let c=o.assertIsValid({throwOnError:!1});if(c)return c;if(!o.areDomainArgsFieldsValid(n)){let e=k(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${r})`);return{value:A.GenericError,message:k(`Dimensions don't match the pivot definition`)+`. `+e}}let l=o.parseArgsToPivotDomain(n);return this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(a)?.trackValue(i,l),o.getPivotCellValueAndFormat(i,l)}},zE={description:k(`Get the header of a pivot.`),args:[W(`pivot_id (number,string)`,k(`ID of the pivot.`)),W(`domain_field_name (string,repeating,optional)`,k(`Field name.`)),W(`domain_value (number,string,value,repeating,optional)`,k(`Value.`))],compute:function(e,...t){let n=P(e),r=vE(n,this.getters);bE(t);let i=this.getters.getPivot(r);xE(this,r,[]),i.init({reload:i.needsReevaluation});let a=i.assertIsValid({throwOnError:!1});if(a)return a;if(!i.areDomainArgsFieldsValid(t)){let e=k(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${n})`);return{value:A.GenericError,message:k(`Dimensions don't match the pivot definition`)+`. `+e}}let o=i.parseArgsToPivotDomain(t);this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(r)?.trackHeader(o);let s=o.at(-1);if(s?.field===`measure`)return i.getPivotMeasureValue(P(s.value),o);let{value:c,format:l}=i.getPivotHeaderValueAndFormat(o);return{value:c,format:!s||s.field===`measure`||s.value===`false`?void 0:l}}},BE={description:k(`Get a pivot table.`),args:[W(`pivot_id (string)`,k(`ID of the pivot.`)),W(`row_count (number, optional)`,k(`number of rows`)),W(`include_total (boolean, default=TRUE)`,k(`Whether to include total/sub-totals or not.`)),W(`include_column_titles (boolean, default=TRUE)`,k(`Whether to include the column titles or not.`)),W(`column_count (number, optional)`,k(`number of columns`)),W(`include_measure_titles (boolean, default=TRUE)`,k(`Whether to include the measure titles row or not.`))],compute:function(e,t,n,r,i,a){let o=vE(P(e),this.getters),s=this.getters.getPivot(o),c=this.getters.getPivotCoreDefinition(o),l=Vh(c,t,n,r,i,a,this.locale);if(l.numberOfRows<0)return new j(k(`The number of rows must be positive.`));if(l.numberOfColumns<0)return new j(k(`The number of columns must be positive.`));xE(this,o,c.measures),s.init({reload:s.needsReevaluation});let u=s.assertIsValid({throwOnError:!1});if(u)return u;let d=s.getCollapsedTableStructure();if(d.numberOfCells>5e5)return new j(dm(d.numberOfCells,this.locale));let f=d.getPivotCells(l),p=0;l.displayColumnHeaders&&(p=d.columns.length-1),l.displayMeasuresRow&&p++;let m=this.getters.getPivotName(o),{numberOfCols:h,numberOfRows:g}=d.getPivotTableDimensions(l);if(g===0)return[[{value:m}]];let _=[];for(let e of S(0,h)){_[e]=[];for(let t of S(0,g)){let n=f[e][t];switch(n.type){case`EMPTY`:_[e].push({value:``});break;case`HEADER`:let t=s.getPivotHeaderValueAndFormat(n.domain);_[e].push(Mh(n.domain,t));break;case`MEASURE_HEADER`:_[e].push(s.getPivotMeasureValue(n.measure,n.domain));break;case`VALUE`:_[e].push(s.getPivotCellValueAndFormat(n.measure,n.domain));break}}}return(l.displayColumnHeaders||l.displayMeasuresRow)&&(_[0][0]={value:m}),_}},VE={description:k(`Returns a range reference shifted by a specified number of rows and columns from a starting cell reference.`),args:[W(`cell_reference (meta, range<meta>)`,k(`The starting point from which to count the offset rows and columns.`)),W(`offset_rows (number)`,k(`The number of rows to offset by.`)),W(`offset_columns (number)`,k(`The number of columns to offset by.`)),W(`height (number, default='height of cell_reference')`,k(`The number of rows of the range to return starting at the offset target.`)),W(`width (number, default='width of cell_reference')`,k(`The number of columns of the range to return starting at the offset target.`))],compute:function(e,t,n,r,i){if(M(e[0][0].value))return e[0][0];let a=e[0][0].value;if(!a)return new j(`In this context, the function OFFSET needs to have a cell or range in parameter.`);let o=mn(a),s=e[0].length,c=e.length;if(r){let e=N(r,this.locale);if(e<1)return new j(k(`Height value is %(_height)s. It should be greater than or equal to 1.`,{_height:e}));s=e}if(i){let e=N(i,this.locale);if(e<1)return new j(k(`Width value is %(_width)s. It should be greater than or equal to 1.`,{_width:e}));c=e}let{sheetName:l}=zc(a),u=l&&this.getters.getSheetIdByName(l)||this.getters.getActiveSheetId(),d=N(t,this.locale),f=N(n,this.locale),p=this.__originCellPosition;p&&this.updateDependencies?.(p);let m=o.left+f,h=o.top+d;if(m<0||h<0)return new va(k(`OFFSET evaluates to an out of bounds range.`));let g={left:m,top:h,right:m+c-1,bottom:h+s-1},_=this.getters.getRangeFromZone(u,g);return _.invalidXc||_.invalidSheetName?new va:(p&&this.addDependencies?.(p,[_]),Ja(c,s,(e,t)=>this.getters.getEvaluatedCell({sheetId:u,col:m+e,row:h+t})))}},HE={description:k(`Returns an element from a list of choices based on index.`),args:[W(`index (number)`,k(`Which choice to return.`)),W(`choice (any, range<any>, repeating)`,k(`A potential value to return. May be a reference to a cell or an individual value.`))],compute:function(e,...t){let n=Math.floor(N(e,this.locale))-1;return n<0||n>=t.length?new j(k(`Index for CHOOSE is invalid. Valid values are between 1 and %(choices)s inclusive.`,{choices:t.length})):t[n]??new j(k(`Choice is undefined.`))},isExported:!0},UE={description:k(`Excludes a specified number of rows or columns from the start or end of an array.`),args:[W(`array (range)`,k(`The array from which to drop rows or columns`)),W(`rows (number)`,k(`The number of rows to drop. A negative value drops from the end of the array.`)),W(`columns (number, optional)`,k(`The number of columns to exclude. A negative value drops from the end of the array.`))],compute:function(e,t,n){let r=N(t,this.locale),i=N(n,this.locale),a=e;if(Math.abs(i)>=e.length||Math.abs(r)>=e[0].length)return new j(k(`The number of rows or column to exclude must be smaller than the number of elements in the array.`));a=i>=0?a.slice(i):a.slice(0,a.length+i);for(let e=0;e<a.length;e++)r>=0?a[e]=a[e].slice(r):a[e]=a[e].slice(0,a[e].length+r);return a},isExported:!0},WE={description:k(`Returns a specified number of contiguous rows or columns from the start or end of an array.`),args:[W(`array (range)`,k(`The array from which to take rows or columns.`)),W(`rows (number)`,k(`The number of rows to take. A negative value takes from the end of the array.`)),W(`columns (number, optional)`,k(`The number of columns to take. A negative value takes from the end of the array.`))],compute:function(e,t,n){let r=t?N(t,this.locale):e[0].length,i=N(n,this.locale),a=e;if((Math.abs(i)>=e.length||i===0)&&(i=e.length),Math.abs(r)>=e[0].length&&(r=e[0].length),a=i>=0?a.slice(0,i):a.slice(a.length+i,a.length),r===0)return new j(k(`The number of rows can not be zero.`));for(let e=0;e<a.length;e++)r>0?a[e]=a[e].slice(0,r):a[e]=a[e].slice(a[e].length+r,a[e].length);return a},isExported:!0},GE={description:k(`Returns a formula as a string.`),args:[W(`cell_reference (meta)`,k(`A reference to a cell.`))],compute:function(e){let{sheetName:t,xc:n}=zc(e.value),{col:r,row:i}=tn(n),a=(t&&this.getters.getSheetIdByName(t))??this.__originSheetId,o=this.getters.getCell({sheetId:a,col:r,row:i});return o?.isFormula?o.compiledFormula.toFormulaString(this.getters):new ya(k(`The cell does not contain a formula.`))},isExported:!0};var KE=l({ADD:()=>qE,CONCAT:()=>JE,DIVIDE:()=>YE,EQ:()=>$E,GT:()=>tD,GTE:()=>nD,LT:()=>rD,LTE:()=>iD,MINUS:()=>aD,MULTIPLY:()=>oD,NE:()=>sD,POW:()=>cD,SPILLED_RANGE:()=>lD,UMINUS:()=>uD,UNARY_PERCENT:()=>dD,UPLUS:()=>fD});let qE={description:k(`Sum of two numbers.`),args:[W(`value1 (number)`,k(`The first addend.`)),W(`value2 (number)`,k(`The second addend.`))],compute:function(e,t){return{value:N(e,this.locale)+N(t,this.locale),format:e?.format||t?.format}}},JE={description:k(`Concatenation of two values.`),args:[W(`value1 (string)`,k(`The value to which value2 will be appended.`)),W(`value2 (string)`,k(`The value to append to value1.`))],compute:function(e,t){return P(e)+P(t)},isExported:!0},YE={description:k(`One number divided by another.`),args:[W(`dividend (number)`,k(`The number to be divided.`)),W(`divisor (number)`,k(`The number to divide by.`))],compute:function(e,t){let n=N(t,this.locale);return n===0?new Sa(k(`The divisor must be different from zero.`)):{value:N(e,this.locale)/n,format:e?.format||t?.format}}};function XE(e){return e===void 0||e.value===null}let ZE={number:0,string:``,boolean:!1};function QE(e,t,n=2e-16){return Math.abs(e-t)<n}let $E={description:k(`Equal.`),args:[W(`value1 (string, number, boolean)`,k(`The first value.`)),W(`value2 (string, number, boolean)`,k(`The value to test against value1 for equality.`))],compute:function(e,t){if(M(e?.value))return e;if(M(t?.value))return t;let n=XE(e)?ZE[typeof t?.value]:e?.value,r=XE(t)?ZE[typeof e?.value]:t?.value;return typeof n==`string`&&(n=n.toUpperCase()),typeof r==`string`&&(r=r.toUpperCase()),typeof n==`number`&&typeof r==`number`?{value:QE(n,r)}:{value:n===r}}};function eD(e,t,n){if(M(e?.value))return e;if(M(t?.value))return t;let r=XE(e)?ZE[typeof t?.value]:e?.value,i=XE(t)?ZE[typeof e?.value]:t?.value;typeof r!=`number`&&(r=P(r).toUpperCase()),typeof i!=`number`&&(i=P(i).toUpperCase());let a=typeof r,o=typeof i;return a===`string`&&o===`number`?{value:!0}:o===`string`&&a===`number`?{value:!1}:{value:n(r,i)}}let tD={description:k(`Strictly greater than.`),args:[W(`value1 (number, string, boolean)`,k(`The value to test as being greater than value2.`)),W(`value2 (number, string, boolean)`,k(`The second value.`))],compute:function(e,t){return eD(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?!QE(e,t)&&e>t:e>t)}},nD={description:k(`Greater than or equal to.`),args:[W(`value1 (number, string, boolean)`,k(`The value to test as being greater than or equal to value2.`)),W(`value2 (number, string, boolean)`,k(`The second value.`))],compute:function(e,t){return eD(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?QE(e,t)||e>t:e>=t)}},rD={description:k(`Less than.`),args:[W(`value1 (number, string, boolean)`,k(`The value to test as being less than value2.`)),W(`value2 (number, string, boolean)`,k(`The second value.`))],compute:function(e,t){let n=nD.compute.bind(this)(e,t);return M(n.value)?n:{value:!n.value}}},iD={description:k(`Less than or equal to.`),args:[W(`value1 (number, string, boolean)`,k(`The value to test as being less than or equal to value2.`)),W(`value2 (number, string, boolean)`,k(`The second value.`))],compute:function(e,t){let n=tD.compute.bind(this)(e,t);return M(n.value)?n:{value:!n.value}}},aD={description:k(`Difference of two numbers.`),args:[W(`value1 (number)`,k(`The minuend, or number to be subtracted from.`)),W(`value2 (number)`,k(`The subtrahend, or number to subtract from value1.`))],compute:function(e,t){return{value:N(e,this.locale)-N(t,this.locale),format:e?.format||t?.format}}},oD={description:k(`Product of two numbers`),args:[W(`factor1 (number)`,k(`The first multiplicand.`)),W(`factor2 (number)`,k(`The second multiplicand.`))],compute:function(e,t){return{value:N(e,this.locale)*N(t,this.locale),format:e?.format||t?.format}}},sD={description:k(`Not equal.`),args:[W(`value1 (string, number, boolean)`,k(`The first value.`)),W(`value2 (string, number, boolean)`,k(`The value to test against value1 for inequality.`))],compute:function(e,t){let n=$E.compute.bind(this)(e,t);return M(n.value)?n:{value:!n.value}}},cD={description:k(`A number raised to a power.`),args:[W(`base (number)`,k(`The number to raise to the exponent power.`)),W(`exponent (number)`,k(`The exponent to raise base to.`))],compute:function(e,t){return Eb.compute.bind(this)(e,t)}},lD={description:k(`Gets the spilled range of an array formula.`),args:[W(`ref (meta , range<meta>)`,k(`The reference to get the spilled range from.`))],compute:function(e){if(e===void 0)return new j(k(`The range is out of bounds.`));if(e.length!==1||e[0].length!==1)return new j(k(`Only single-cell references are allowed to get the spilled range.`));let t=e[0][0];if(M(t.value))return t;let n=this.getters.getRangeFromSheetXC(this.__originSheetId,t.value),r={col:n.zone.left,row:n.zone.top,sheetId:n.sheetId},i=this.__originCellPosition;i&&this.updateDependencies?.(i);let a=this.getters.getSpreadZone(r);if(a===void 0)return new va;let o=this.getters.getRangeFromZone(n.sheetId,a);return i&&this.addDependencies?.(i,[o]),Ja(a.right-a.left+1,a.bottom-a.top+1,(e,t)=>this.getters.getEvaluatedCell({sheetId:o.sheetId,col:a.left+e,row:a.top+t}))},hidden:!0},uD={description:k(`A number with the sign reversed.`),args:[W(`value (number)`,k(`The number to have its sign reversed. Equivalently, the number to multiply by -1.`))],compute:function(e){return{value:-N(e,this.locale),format:e?.format}}},dD={description:k(`Value interpreted as a percentage.`),args:[W(`percentage (number)`,k(`The value to interpret as a percentage.`))],compute:function(e){return N(e,this.locale)/100}},fD={description:k(`A specified number, unchanged.`),args:[W(`value (any)`,k(`The number to return.`))],compute:function(e={value:null}){return e}},G=e=>({transform:t=>t*e,inverseTransform:t=>t/e}),pD={transform:e=>e,inverseTransform:e=>e},mD=1e-10,hD=.0254,gD=hD/72,_D=.3048,vD=.9144,yD=1609.34,bD=1852,xD=946073047258e4,SD={g:{...pD,category:`weight`},u:{...G(166053e-29),category:`weight`},grain:{...G(.0647989),category:`weight`},ozm:{...G(28.3495),category:`weight`},lbm:{...G(453.592),category:`weight`},stone:{...G(6350.29),category:`weight`},sg:{...G(14593.90294),category:`weight`},cwt:{...G(45359.237),category:`weight`},uk_cwt:{...G(50802.3),category:`weight`},ton:{...G(907184.74),category:`weight`},uk_ton:{...G(1016046.9),category:`weight`},m:{...pD,category:`distance`},km:{...G(1e3),category:`distance`},ang:{...G(mD),category:`distance`},Picapt:{...G(gD),category:`distance`},pica:{...G(hD/6),category:`distance`},in:{...G(hD),category:`distance`},ft:{...G(_D),category:`distance`},yd:{...G(vD),category:`distance`},ell:{...G(1.143),category:`distance`},mi:{...G(yD),category:`distance`},survey_mi:{...G(1609.34),category:`distance`},Nmi:{...G(bD),category:`distance`},ly:{...G(xD),category:`distance`},parsec:{...G(0x6da012f95c9fd0),category:`distance`},sec:{...pD,category:`time`},min:{...G(60),category:`time`},hr:{...G(3600),category:`time`},day:{...G(86400),category:`time`},yr:{...G(31556952),category:`time`},Pa:{...pD,category:`pressure`},bar:{...G(1e5),category:`pressure`},mmHg:{...G(133.322),category:`pressure`},Torr:{...G(133.322),category:`pressure`},psi:{...G(6894.76),category:`pressure`},atm:{...G(101325),category:`pressure`},N:{...pD,category:`force`},dyn:{...G(1e-5),category:`force`},pond:{...G(.00980665),category:`force`},lbf:{...G(4.44822),category:`force`},J:{...pD,category:`energy`},eV:{...G(160218e-24),category:`energy`},e:{...G(1e-7),category:`energy`},flb:{...G(1.3558179483),category:`energy`},c:{...G(4.184),category:`energy`},cal:{...G(4.1868),category:`energy`},BTU:{...G(1055.06),category:`energy`},Wh:{...G(3600),category:`energy`},HPh:{...G(2684520),category:`energy`},W:{...pD,category:`power`},PS:{...G(735.499),category:`power`},HP:{...G(745.7),category:`power`},T:{...pD,category:`magnetism`},ga:{...G(1e-4),category:`magnetism`},K:{...pD,category:`temperature`},C:{transform:e=>e+273.15,inverseTransform:e=>e-273.15,category:`temperature`},F:{transform:e=>(e-32)*5/9+273.15,inverseTransform:e=>(e-273.15)*9/5+32,category:`temperature`},Rank:{...G(5/9),category:`temperature`},Reau:{transform:e=>e*1.25+273.15,inverseTransform:e=>(e-273.15)/1.25,category:`temperature`},"m^3":{...pD,category:`volume`,order:3},"ang^3":{...G(mD**3),category:`volume`,order:3},"Picapt^3":{...G(gD**3),category:`volume`,order:3},tsp:{...G(492892e-11),category:`volume`},tspm:{...G(5e-6),category:`volume`},tbs:{...G(14786764825785619e-21),category:`volume`},"in^3":{...G(hD**3),category:`volume`,order:3},oz:{...G(295735295625e-16),category:`volume`},cup:{...G(237e-6),category:`volume`},pt:{...G(.0004731765),category:`volume`},uk_pt:{...G(568261e-9),category:`volume`},qt:{...G(.0009463529),category:`volume`},l:{...G(.001),category:`volume`},uk_qt:{...G(.0011365225),category:`volume`},gal:{...G(.0037854118),category:`volume`},uk_gal:{...G(.00454609),category:`volume`},"ft^3":{...G(_D**3),category:`volume`,order:3},bushel:{...G(.0352390704),category:`volume`},barrel:{...G(.158987295),category:`volume`},"yd^3":{...G(vD**3),category:`volume`,order:3},MTON:{...G(1.13267386368),category:`volume`},GRT:{...G(2.83168),category:`volume`},"mi^3":{...G(yD**3),category:`volume`,order:3},"Nmi^3":{...G(bD**3),category:`volume`,order:3},"ly^3":{...G(xD**3),category:`volume`,order:3},"m^2":{...pD,category:`area`,order:2},"ang^2":{...G(mD**2),category:`area`,order:2},"Picapt^2":{...G(gD**2),category:`area`,order:2},"in^2":{...G(hD**2),category:`area`,order:2},"ft^2":{...G(_D**2),category:`area`,order:2},"yd^2":{...G(vD**2),category:`area`,order:2},ar:{...G(100),category:`area`},Morgen:{...G(2500),category:`area`},uk_acre:{...G(4046.8564224),category:`area`},us_acre:{...G(4046.8726098743),category:`area`},ha:{...G(1e4),category:`area`},"mi^2":{...G(yD**2),category:`area`,order:2},"Nmi^2":{...G(bD**2),category:`area`,order:2},"ly^2":{...G(xD**2),category:`area`,order:2},bit:{...pD,category:`information`},byte:{...G(8),category:`information`},"m/s":{...pD,category:`speed`},"m/hr":{...G(1/3600),category:`speed`},"km/hr":{...G(1/3.6),category:`speed`},mph:{...G(.44704),category:`speed`},kn:{...G(.5144444444),category:`speed`},admkn:{...G(.5147733333),category:`speed`}},CD={shweight:`cwt`,lcwt:`uk_cwt`,hweight:`uk_cwt`,LTON:`uk_ton`,brton:`uk_ton`,pc:`parsec`,Pica:`Picapt`,d:`day`,mn:`min`,s:`sec`,p:`Pa`,at:`atm`,dy:`dyn`,ev:`eV`,hh:`HPh`,wh:`Wh`,btu:`BTU`,h:`HP`,cel:`C`,fah:`F`,kel:`K`,us_pt:`pt`,L:`l`,lt:`l`,ang3:`ang^3`,ft3:`ft^3`,in3:`in^3`,ly3:`ly^3`,m3:`m^3`,mi3:`mi^3`,yd3:`yd^3`,Nmi3:`Nmi^3`,Picapt3:`Picapt^3`,"Pica^3":`Picapt^3`,Pica3:`Picapt^3`,regton:`GRT`,ang2:`ang^2`,ft2:`ft^2`,in2:`in^2`,ly2:`ly^2`,m2:`m^2`,mi2:`mi^2`,Nmi2:`Nmi^2`,Picapt2:`Picapt^2`,"Pica^2":`Picapt^2`,Pica2:`Picapt^2`,yd2:`yd^2`,"m/h":`m/hr`,"m/sec":`m/s`},wD={"":1,Y:1e24,Z:1e21,E:0xde0b6b3a7640000,P:0x38d7ea4c68000,T:0xe8d4a51000,G:1e9,M:1e6,k:1e3,h:100,da:10,e:10,d:.1,c:.01,m:.001,u:1e-6,n:1e-9,p:1e-12,f:1e-15,a:1e-18,z:1e-21,y:1e-21,Yi:2**80,Zi:2**70,Ei:2**60,Pi:2**50,Ti:2**40,Gi:2**30,Mi:2**20,ki:2**10},TD={weight:k(`Weight`),distance:k(`Distance`),time:k(`Time`),pressure:k(`Pressure`),force:k(`Force`),energy:k(`Energy`),power:k(`Power`),magnetism:k(`Magnetism`),temperature:k(`Temperature`),volume:k(`Volume`),area:k(`Area`),information:k(`Information`),speed:k(`Speed`)},ED=Object.entries(SD).map(([e,t])=>({value:e,label:DD(t.category)}));function DD(e){return TD[e]??``}function OD(e){for(let[t,n]of Object.entries(wD)){if(t&&!e.startsWith(t))continue;let r=e.slice(t.length),i=SD[r];if(!i&&CD[r]&&(i=SD[CD[r]]),i)return{...i,factor:i.order?n**+i.order:n}}}var kD=l({CONVERT:()=>AD});let AD={description:k(`Converts a numeric value to a different unit of measure.`),args:[W(`value (number)`,k(`the numeric value in start_unit to convert to end_unit`)),W(`start_unit (string)`,k(`The starting unit, the unit currently assigned to value`),ED),W(`end_unit (string)`,k(`The unit of measure into which to convert value`),ED)],compute:function(e,t,n){let r=N(e,this.locale),i=P(t),a=P(n),o=OD(i),s=OD(a);return o?s?o.category===s.category?{value:s.inverseTransform(o.factor*o.transform(r))/s.factor,format:e?.format}:{value:A.GenericError,message:k(`Incompatible units of measure ('%s' vs '%s')`,DD(o.category),DD(s.category))}:{value:A.GenericError,message:k(`Invalid units of measure ('%s')`,a)}:{value:A.GenericError,message:k(`Invalid units of measure ('%s')`,i)}},isExported:!0};var jD=l({CHAR:()=>FD,CLEAN:()=>ID,CONCATENATE:()=>LD,EXACT:()=>RD,FIND:()=>zD,FORMAT_LARGE_NUMBER:()=>BD,JOIN:()=>VD,LEFT:()=>HD,LEN:()=>UD,LOWER:()=>WD,MID:()=>GD,PROPER:()=>KD,REGEXEXTRACT:()=>JD,REGEXREPLACE:()=>YD,REGEXTEST:()=>qD,REPLACE:()=>XD,RIGHT:()=>ZD,SEARCH:()=>QD,SPLIT:()=>$D,SUBSTITUTE:()=>eO,TEXT:()=>aO,TEXTAFTER:()=>sO,TEXTBEFORE:()=>cO,TEXTJOIN:()=>tO,TEXTSPLIT:()=>nO,TRIM:()=>rO,UPPER:()=>iO,VALUE:()=>oO});let MD=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,ND=[{value:0,label:k(`Case-sensitive (default)`)},{value:1,label:k(`Case-insensitive`)}],PD=[{value:0,label:k(`Don't match to end (default)`)},{value:1,label:k(`Match to end`)}],FD={description:k(`Gets character associated with number.`),args:[W(`table_number (number)`,k(`The number of the character to look up from the current Unicode table in decimal format.`))],compute:function(e){let t=Math.trunc(N(e,this.locale));return t<1?new j(k(`The table_number (%s) is out of range.`,t)):String.fromCharCode(t)},isExported:!0},ID={description:k(`Remove non-printable characters from a piece of text.`),args:[W(`text (string)`,k(`The text whose non-printable characters are to be removed.`))],compute:function(e){let t=P(e),n=``;for(let e of t)e&&e.charCodeAt(0)>31&&(n+=e);return n},isExported:!0},LD={description:k(`Appends strings to one another.`),args:[W(`string (string, range<string>, repeating)`,k(`String to append in sequence.`))],compute:function(...e){return Ga(e,(e,t)=>e+P(t),``)},isExported:!0},RD={description:k(`Tests whether two strings are identical.`),args:[W(`string1 (string)`,k(`The first string to compare.`)),W(`string2 (string)`,k(`The second string to compare.`))],compute:function(e,t){return P(e)===P(t)},isExported:!0},zD={description:k(`First position of string found in text, case-sensitive.`),args:[W(`search_for (string)`,k(`The string to look for within text_to_search.`)),W(`text_to_search (string)`,k(`The text to search for the first occurrence of search_for.`)),W(`starting_at (number, default=1)`,k(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=P(e),i=P(t),a=N(n,this.locale);if(i===``)return new j(k(`The text_to_search must be non-empty.`));if(a<1)return new j(k(`The starting_at (%s) must be greater than or equal to 1.`,a));let o=i.indexOf(r,a-1);return o===-1?new j(k(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)):o+1},isExported:!0},BD={description:k(`Apply a large number format`),args:[W(`value (number)`,k(`The number.`)),W(`unit (string, optional)`,k(`The formatting unit. Use 'k', 'm', or 'b' to force the unit`),[{value:`k`,label:k(`Thousand`)},{value:`m`,label:k(`Million`)},{value:`b`,label:k(`Billion`)}])],compute:function(e,t){return{value:N(e,this.locale),format:bs(e,t,this.locale)}}},VD={description:k(`Concatenates elements of arrays with delimiter.`),args:[W(`delimiter (string)`,k(`The character or string to place between each concatenated value.`)),W(`value_or_array (string, range<string>, repeating)`,k(`Value to be appended using delimiter.`))],compute:function(e,...t){let n=P(e);return Ga(t,(e,t)=>(e?e+n:``)+P(t),``)}},HD={description:k(`Substring from beginning of specified string.`),args:[W(`text (string)`,k(`The string from which the left portion will be returned.`)),W(`number_of_characters (number, optional)`,k(`The number of characters to return from the left side of string.`))],compute:function(e,...t){let n=t.length?N(t[0],this.locale):1;return n<0?new j(k(`The number_of_characters (%s) must be positive or null.`,n)):P(e).substring(0,n)},isExported:!0},UD={description:k(`Length of a string.`),args:[W(`text (string)`,k(`The string whose length will be returned.`))],compute:function(e){return P(e).length},isExported:!0},WD={description:k(`Converts a specified string to lowercase.`),args:[W(`text (string)`,k(`The string to convert to lowercase.`))],compute:function(e){return P(e).toLowerCase()},isExported:!0},GD={description:k(`A segment of a string.`),args:[W(`text (string)`,k(`The string to extract a segment from.`)),W(`starting_at (number)`,k(`The index from the left of string from which to begin extracting. The first character in string has the index 1.`)),W(`extract_length (number)`,k(`The length of the segment to extract.`))],compute:function(e,t,n){let r=P(e),i=N(t,this.locale),a=N(n,this.locale);return i<1?new j(k(`The starting_at argument (%s) must be positive greater than one.`,i.toString())):a<0?new j(k(`The extract_length argument (%s) must be positive or null.`,a)):r.slice(i-1,i+a-1)},isExported:!0},KD={description:k(`Capitalizes each word in a specified string.`),args:[W(`text_to_capitalize (string)`,k(`The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase.`))],compute:function(e){return P(e).replace(MD,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())},isExported:!0},qD={description:k(`Checks whether a string matches the supplied regular expression.`),args:[W(`text (string)`,k(`The string to test.`)),W(`pattern (string)`,k(`The regular expression pattern to match against the text.`)),W(`case_sensitivity (number, default=0)`,k(`Whether the match is case-sensitive.`),[{value:0,label:k(`Case-sensitive`)},{value:1,label:k(`Case-insensitive`)}])],compute:function(e,t,n={value:0}){let r=P(e),i=P(t),a=N(n,this.locale);if(i===``)return!0;if(r===``)return!1;if(a!==0&&a!==1)return new j(k(`The case_sensitivity (%s) must be 0 or 1.`,a));let o=a===1?`gi`:`g`,s;try{s=new RegExp(i,o)}catch{return new j(k(`Invalid regular expression`))}return s.test(r)},isExported:!0},JD={description:k(`Extract text from a string based on the supplied regular expression.`),args:[W(`text (string)`,k(`The string on which you want to extract text.`)),W(`pattern (string)`,k(`The regular expression pattern to match against the text.`)),W(`return_mode (number, default=0)`,k(`0 = first match, 1 = all matches as an array, 2 = capturing groups from the first match as an array.`),[{value:0,label:k(`First match`)},{value:1,label:k(`All matches`)},{value:2,label:k(`Capture groups of first match`)}]),W(`case_sensitivity (number, default=0)`,k(`Whether the match is case-sensitive.`),[{value:0,label:k(`Case-sensitive`)},{value:1,label:k(`Case-insensitive`)}])],compute:function(e,t,n={value:0},r={value:0}){let i=P(e),a=P(t),o=N(n,this.locale),s=N(r,this.locale);if(i===``||a===``)return{value:``};if(o<0||o>2)return new j(k(`The return_mode (%s) must be 0, 1 or 2.`,o));if(s!==0&&s!==1)return new j(k(`The case_sensitivity (%s) must be 0 or 1.`,s));let c=s===1?`gi`:`g`,l;try{l=new RegExp(a,c)}catch{return new j(k(`Invalid regular expression`))}let u=[...i.matchAll(l)];return u.length===0?{value:A.NotAvailable,message:k(`No matches found.`)}:o===0?u[0][0]:o===1?u.map(e=>[e[0]]):u[0].length<2?new j(k(`No capturing groups found.`)):u[0].slice(1).map(e=>[e])},isExported:!0},YD={description:k(`Replace text in a string based on the supplied regular expression.`),args:[W(`text (string)`,k(`The string in which you want to replace text.`)),W(`pattern (string)`,k(`The regular expression pattern to match against the text.`)),W(`replacement (string)`,k(`The text to use as the replacement.`)),W(`occurrence (number, default=0)`,k(`0 = replace all matches. A negative number counts from the end.`)),W(`case_sensitivity (number, default=0)`,k(`Whether the match is case-sensitive.`),[{value:0,label:k(`Case-sensitive`)},{value:1,label:k(`Case-insensitive`)}])],compute:function(e,t,n,r={value:0},i={value:0}){let a=P(e),o=P(t),s=P(n),c=N(r,this.locale),l=N(i,this.locale);if(l!==0&&l!==1)return new j(k(`The case_sensitivity (%s) must be 0 or 1.`,l));let u=l===1?`gi`:`g`,d;try{d=new RegExp(o,u)}catch{return new j(k(`Invalid regular expression`))}if(c!==0){let e=[...a.matchAll(d)];if(e.length===0||Math.abs(c)>e.length)return a;let t=c>0?c-1:e.length+c,n=e[t][0].length,r=e[t].index;return a.substring(0,r)+s+a.substring(r+n)}return a.replace(d,s)},isExported:!0},XD={description:k(`Replaces part of a text string with different text.`),args:[W(`text (string)`,k(`The text, a part of which will be replaced.`)),W(`position (number)`,k(`The position where the replacement will begin (starting from 1).`)),W(`length (number)`,k(`The number of characters in the text to be replaced.`)),W(`new_text (string)`,k(`The text which will be inserted into the original text.`))],compute:function(e,t,n,r){let i=N(t,this.locale);if(i<1)return new j(k(`The position (%s) must be greater than or equal to 1.`,i));let a=P(e),o=N(n,this.locale),s=P(r);return a.substring(0,i-1)+s+a.substring(i-1+o)},isExported:!0},ZD={description:k(`A substring from the end of a specified string.`),args:[W(`text (string)`,k(`The string from which the right portion will be returned.`)),W(`number_of_characters (number, optional)`,k(`The number of characters to return from the right side of string.`))],compute:function(e,...t){let n=t.length?N(t[0],this.locale):1;if(n<0)return new j(k(`The number_of_characters (%s) must be positive or null.`,n));let r=P(e),i=r.length;return r.substring(i-n,i)},isExported:!0},QD={description:k(`First position of string found in text, ignoring case.`),args:[W(`search_for (string)`,k(`The string to look for within text_to_search.`)),W(`text_to_search (string)`,k(`The text to search for the first occurrence of search_for.`)),W(`starting_at (number, default=1)`,k(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=P(e).toLowerCase(),i=P(t).toLowerCase(),a=N(n,this.locale);if(i===``)return{value:A.GenericError,message:k(`The text_to_search must be non-empty.`)};if(a<1)return{value:A.GenericError,message:k(`The starting_at (%s) must be greater than or equal to 1.`,a)};let o=i.indexOf(r,a-1);return o===-1?{value:A.GenericError,message:k(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)}:{value:o+1}},isExported:!0},$D={description:k(`Split text by specific character delimiter(s).`),args:[W(`text (string)`,k(`The text to divide.`)),W(`delimiter (string)`,k(`The character or characters to use to split text.`)),W(`split_by_each (boolean, default=true})`,k(`Whether or not to divide text around each character contained in delimiter.`)),W(`remove_empty_text (boolean, default=true)`,k(`Whether or not to remove empty text messages from the split results. The default behavior is to treat consecutive delimiters as one (if TRUE). If FALSE, empty cells values are added between consecutive delimiters.`))],compute:function(e,t,n={value:!0},r={value:!0}){let i=P(e),a=qe(P(t)),o=F(n),s=F(r);if(a.length<=0)return new j(k(`The delimiter (%s) must be not be empty.`,a));let c=o?RegExp(`[${a}]`,`g`):new RegExp(a,`g`),l=i.split(c);return s&&(l=l.filter(e=>e!==``)),Za([l])},isExported:!1},eO={description:k(`Replaces existing text with new text in a string.`),args:[W(`text_to_search (string)`,k(`The text within which to search and replace.`)),W(`search_for (string)`,k(`The string to search for within text_to_search.`)),W(`replace_with (string)`,k(`The string that will replace search_for.`)),W(`occurrence_number (number, optional)`,k(`The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced.`))],compute:function(e,t,n,r){let i=N(r,this.locale);if(i<0)return new j(k(`The occurrenceNumber (%s) must be positive or null.`,i));let a=P(e),o=P(t);if(o===``)return a;let s=P(n),c=new RegExp(qe(o),`g`);if(i===0)return a.replace(c,s);let l=0;return a.replace(c,e=>++l===i?s:e)},isExported:!0},tO={description:k(`Combines text from multiple strings and/or arrays.`),args:[W(`delimiter (string)`,k(`A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.`)),W(`ignore_empty (boolean)`,k(`A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.`),[{value:!0,label:k(`Ignore empty cells`)},{value:!1,label:k(`Include empty cells (default)`)}]),W(`texts (string, range<string>, repeating)`,k(`Text item to join.`))],compute:function(e,t={value:!0},...n){let r=P(e),i=F(t),a=0;return Ga(n,(e,t)=>i&&P(t)===``?e:(a++?e+r:``)+P(t),``)},isExported:!0},nO={description:k(`Splits text into rows or columns using specified column and row delimiters.`),args:[W(`text (string)`,k(`The text to split.`)),W(`col_delimiter (string, range<string>)`,k(`Character or string to split columns by.`)),W(`row_delimiter (string, range<string>, optional)`,k(`Character or string to split rows by.`)),W(`ignore_empty (boolean, default=false)`,k(`Whether to ignore empty cells.`),[{value:!1,label:k(`Include empty cells (default)`)},{value:!0,label:k(`Ignore empty cells`)}]),W(`match_mode (number, default=0)`,k(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),ND),W(`pad_with (string, default="${A.NotAvailable}")`,k(`The value to use for padding empty cells.`))],compute:function(e,t,n,r={value:!1},i={value:0},a=new ya){let o=P(e);if(o.length<=0)return new j(k(`No text to split.`));if(t===void 0&&n===void 0)return new j(k(`At least one delimiter must be provided.`));let s=L(t).flat().map(e=>qe(P(e))),c=L(n).flat().map(e=>qe(P(e)));if(s.some(e=>e===``)||c.some(e=>e===``))return new j(k(`The delimiters cannot be empty values.`));let l=F(r),u=N(i,this.locale);if(![0,1].includes(u))return new j(k(`match_mode should be a value of 0 or 1.`));let d=[],f=u===1?`gi`:`g`,p=c.filter(e=>!s.includes(e)),m=p.length?o.split(new RegExp(p.join(`|`),f)):[o];l&&(m=m.filter(e=>e!==``));let h=new RegExp(s.join(`|`),f);for(let e of m){let t=s.length?e.split(h):[e];l&&(t=t.filter(e=>e!==``)),d.push(t.map(e=>({value:e})))}let g=Math.max(...d.map(e=>e.length));for(let e of d)for(;e.length<g;)e.push(a);return Za(d)},isExported:!0},rO={description:k(`Removes space characters.`),args:[W(`text (string)`,k(`The text or reference to a cell containing text to be trimmed.`))],compute:function(e){return Pt(P(e))},isExported:!0},iO={description:k(`Converts a specified string to uppercase.`),args:[W(`text (string)`,k(`The string to convert to uppercase.`))],compute:function(e){return P(e).toUpperCase()},isExported:!0},aO={description:k(`Converts a number to text according to a specified format.`),args:[W(`number (number)`,k(`The number, date or time to format.`)),W(`format (string)`,k(`The case-sensitive format of the result, enclosed in quotation marks. Examples: "0.00" rounded to 2 decimal places, "hh:mm:ss" for hour:minutes:seconds.`))],compute:function(e,t){return z(N(e,this.locale),{format:P(t),locale:this.locale})},isExported:!0},oO={description:k(`Converts a string to a numeric value.`),args:[W(`value (number)`,k(`the string to be converted`))],compute:function(e){return N(e,this.locale)},isExported:!0},sO={description:k(`Returns text that occurs after a given substring or delimiter.`),args:[W(`text (string)`,k(`The source text.`)),W(`delimiter (string)`,k(`The substring after which text will be returned.`)),W(`instance_num (number, default=1)`,k(`The desired instance of the delimiter after which we extract the text. A negative number searches from the end.`)),W(`match_mode (number, default=0)`,k(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),ND),W(`match_end (number, default=0))`,k(`Whether to treat the end of text as a delimiter.`),PD),W(`if_not_found (string, default="${A.NotAvailable}")`,k(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new ya){let o=P(e),s=N(n,this.locale),c=N(r,this.locale),l=N(i,this.locale);if(s===0)return new j(k(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new j(k(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new j(k(`match_end should have a value of 0 or 1.`));let u=P(t);if(u===``)return Math.sign(s)>0?{value:o}:{value:``};let d=c===1?`gi`:`g`,f=qe(u),p=new RegExp(f,d),m=[...o.matchAll(p)].map(e=>e.index+f.length);if(s<0&&(m=m.reverse()),l&&Math.abs(s)===m.length+1)return Math.sign(s)>0?{value:``}:{value:o};let h=m[Math.abs(s)-1];return h===void 0?a:{value:o.substring(h)}},isExported:!0},cO={description:k(`Returns text that occurs before a given substring or delimiter.`),args:[W(`text (string)`,k(`The source text.`)),W(`delimiter (string)`,k(`The substring after which text will be returned.`)),W(`instance_num (number, default=1)`,k(`The desired instance of the delimiter before which we extract the text. A negative number searches from the end.`)),W(`match_mode (number, default=0)`,k(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),ND),W(`match_end (number, default=0))`,k(`Whether to match a delimiter against the end of the text.`),PD),W(`if_not_found (string, default="${A.NotAvailable}")`,k(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new ya){let o=P(e),s=N(n,this.locale),c=N(r,this.locale),l=N(i,this.locale);if(s===0)return new j(k(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new j(k(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new j(k(`match_end should have a value of 0 or 1.`));let u=P(t);if(u===``)return Math.sign(s)>0?{value:``}:{value:o};let d=c===1?`gi`:`g`,f=qe(u),p=new RegExp(f,d),m=[...o.matchAll(p)].map(e=>e.index+f.length);if(s<0&&(m=m.reverse()),l&&Math.abs(s)===m.length+1)return Math.sign(s)>0?{value:o}:{value:``};let h=m[Math.abs(s)-1];return h===void 0?a:{value:o.substring(0,h-u.length)}},isExported:!0};var lO=l({HYPERLINK:()=>uO});let uO={description:k(`Creates a hyperlink in a cell.`),args:[W(`url (string)`,k(`The full URL of the link enclosed in quotation marks.`)),W(`link_label (string, optional)`,k(`The text to display in the cell, enclosed in quotation marks.`))],compute:function(e,t){let n=P(e).trim(),r=P(t)||n;return n===``?r:ot(r,n)},isExported:!0},dO=/^[A-Z0-9\_\.]+$/,fO=new class extends B{mapping={};add(e,t){if(e=e.toUpperCase(),e in this.content)throw Error(`${e} is already present in this registry!`);return this.replace(e,t)}replace(e,t){if(e=e.toUpperCase(),!dO.test(e))throw Error(k(`Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)`,e));let n=Kv(e,t);return Zv(n),this.mapping[e]=Qv(n),super.replace(e,n),this}},pO=[{name:k(`Array`),functions:oy},{name:k(`Database`),functions:dS},{name:k(`Date`),functions:GC},{name:k(`Filter`),functions:Mw},{name:k(`Financial`),functions:Rw},{name:k(`Info`),functions:qT},{name:k(`Lookup`),functions:SE},{name:k(`Logical`),functions:oE},{name:k(`Math`),functions:Iy},{name:k(`Operator`),functions:KE},{name:k(`Statistical`),functions:Qb},{name:k(`Text`),functions:jD},{name:k(`Engineering`),functions:Dw},{name:k(`Web`),functions:lO},{name:k(`Parser`),functions:kD}];for(let e of pO){let t=e.functions;for(let n in t){let r=t[n];r.category=r.category||e.name,n=n.replace(/_/g,`.`),fO.add(n,{isExported:!1,...r})}}var mO=class{xmlString;constructor(e){this.xmlString=e}toString(){return this.xmlString}};let hO=[`areaChart`,`area3DChart`,`lineChart`,`line3DChart`,`stockChart`,`radarChart`,`scatterChart`,`pieChart`,`pie3DChart`,`doughnutChart`,`barChart`,`bar3DChart`,`ofPieChart`,`surfaceChart`,`surface3DChart`,`bubbleChart`,`comboChart`,`radarChart`],gO={name:`ARROW_DOWN`,width:448,height:512,paths:[{fillColor:`#E06666`,path:`M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z`}]},_O={name:`ARROW_UP`,width:448,height:512,paths:[{fillColor:`#6AA84F`,path:`M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z`}]},vO={name:`ARROW_RIGHT`,width:448,height:512,paths:[{fillColor:`#F0AD4E`,path:`M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z`}]},yO={name:`SMILE`,width:496,height:512,paths:[{fillColor:`#6AA84F`,path:`M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm4 72.6c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.7-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.1-8.4-25.3-7.1-33.8 3.1z`}]},bO={name:`MEH`,width:496,height:512,paths:[{fillColor:`#F0AD4E`,path:`M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm8 144H160c-13.2 0-24 10.8-24 24s10.8 24 24 24h176c13.2 0 24-10.8 24-24s-10.8-24-24-24z`}]},xO={name:`FROWN`,width:496,height:512,paths:[{fillColor:`#E06666`,path:`M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-80 128c-40.2 0-78 17.7-103.8 48.6-8.5 10.2-7.1 25.3 3.1 33.8 10.2 8.4 25.3 7.1 33.8-3.1 16.6-19.9 41-31.4 66.9-31.4s50.3 11.4 66.9 31.4c8.1 9.7 23.1 11.9 33.8 3.1 10.2-8.5 11.5-23.6 3.1-33.8C326 321.7 288.2 304 248 304z`}]},SO=`M256 9 a247 247 0 1 0.1 0 0`,CO={name:`GREEN_DOT`,width:512,height:512,paths:[{fillColor:`#6AA84F`,path:SO}]},wO={name:`YELLOW_DOT`,width:512,height:512,paths:[{fillColor:`#F0AD4E`,path:SO}]},TO={name:`RED_DOT`,width:512,height:512,paths:[{fillColor:`#E06666`,path:SO}]},EO=`M40 160 h320 l-160 160`;function DO(e){return{name:`CARET_DOWN`,width:512,height:512,paths:[{fillColor:e.textColor||`#374151C2`,path:EO}]}}function OO(e){return{name:`CARET_UP`,width:512,height:512,paths:[{fillColor:e.textColor||`#374151C2`,path:`M40 320 h320 l-160 -160`}]}}function kO(e){return{name:`CARET_DOWN`,width:512,height:512,paths:[{fillColor:e.textColor||`#374151C2`,path:`M200 32a200 200 0 1 1 0 400 200 200 0 1 1 0-400`},{fillColor:e.fillColor||`#fff`,path:EO}]}}let AO={name:`CHECKBOX_UNCHECKED`,width:512,height:512,paths:[{fillColor:fe,path:`M45,45 h422 v422 h-422 v-422 m30,30 v362 h362 v-362`}]},jO={name:`CHECKBOX_UNCHECKED`,width:512,height:512,paths:[{fillColor:me,path:`M45,45 h422 v422 h-422 v-422 m30,30 v362 h362 v-362`}]},MO={name:`CHECKBOX_CHECKED`,width:512,height:512,paths:[{fillColor:me,path:`M45,45 h422 v422 h-422 v-422`},{fillColor:`#FFF`,path:`M165,240 l45,45 l135,-135 h60 l-195,195 l-105,-105`}]};function NO(e,t){return{name:`PIVOT_ICON`,width:512,height:512,paths:[{path:`M21,21 h469 v469 h-469`,fillColor:t?de:`#777`},{path:`M64,64 v384 h384 v-384`,fillColor:t?`#E7E9ED`:`#eee`},{path:e?`M149,235 h213 v43 h-213 M235,149 h43 v213 h-43`:`M149,235 h213 v43 h-213`,fillColor:t?de:`#777`}]}}function PO(e,t,n){let r=e?`M18.6 3.5H4.29c-.7 0-1.06.85-.56 1.35l6.1 6.1v6.8c0 .26.13.5.34.65l2.64 1.85a.79.79 0 0 0 1.25-.65v-8.64l6.1-6.1a.79.79 0 0 0-.56-1.35`:`M 339.667 681 L 510.333 681 L 510.333 595.667 L 339.667 595.667 L 339.667 681 Z M 41 169 L 41 254.333 L 809 254.333 L 809 169 L 41 169 Z M 169 467.667 L 681 467.667 L 681 382.333 L 169 382.333 L 169 467.667 Z`,i=e?`M0,0 h24 v24 h-24`:`M0,0 h850 v850 h-850`,a={iconColor:ce,hoverBackgroundColor:ce};return n&&!t?a.iconColor=`#fff`:!n&&t?a.iconColor=`#defade`:n&&t&&(a.iconColor=ce,a.hoverBackgroundColor=`#fff`),{name:`DATA_FILTER_ICON`,width:e?24:850,height:e?24:850,paths:[n?{path:i,fillColor:a.hoverBackgroundColor}:void 0,{path:r,fillColor:a.iconColor}].filter(C)}}let FO={arrowGood:{template:`ARROW_UP`,svg:_O},arrowNeutral:{template:`ARROW_RIGHT`,svg:vO},arrowBad:{template:`ARROW_DOWN`,svg:gO},smileyGood:{template:`SMILE`,svg:yO},smileyNeutral:{template:`MEH`,svg:bO},smileyBad:{template:`FROWN`,svg:xO},dotGood:{template:`GREEN_DOT`,svg:CO},dotNeutral:{template:`YELLOW_DOT`,svg:wO},dotBad:{template:`RED_DOT`,svg:TO}},IO={arrows:{good:`arrowGood`,neutral:`arrowNeutral`,bad:`arrowBad`},smiley:{good:`smileyGood`,neutral:`smileyNeutral`,bad:`smileyBad`},dots:{good:`dotGood`,neutral:`dotNeutral`,bad:`dotBad`}},LO={};function RO(e){if(LO[e])return LO[e];let t=new Path2D(e);return LO[e]=t,t}function zO(e,t){let n=e.split(`/`),r=t.split(`/`),i=``,a=0;for(let e=0;e<n.length-1;e++)n[e]===r[e]?a++:i+=`../`;return i+=r.slice(a).join(`/`),i}function BO(e,t=0){let n={};for(let r=0;r<e.length;r++)e[r]&&(n[r+t]=e[r]);return n}function VO(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,(e,t)=>String.fromCharCode(parseInt(t,16)))}function HO(e,t,n){return t===`COL`?(e.cols[n]||(e.cols[n]={}),e.cols[n]):(e.rows[n]||(e.rows[n]={}),e.rows[n])}function UO(e){if(e[0]===`=`)return e;let t=Tu(e);return t.length===1&&t[0].type!==`REFERENCE`?e:`=`+e}var WO=class{_parsingWarnings=new Set;_conversionWarnings=new Set;addParsingWarning(e){this._parsingWarnings.add(e)}addConversionWarning(e){this._conversionWarnings.add(e)}get warnings(){return[...this._parsingWarnings,...this._conversionWarnings]}generateNotSupportedWarning(e,t,n){let r=`${e} ${t?`"`+t+`" is`:`are`} not yet supported. `;n&&(r+=`Only ${n.join(`, `)} are currently supported.`),this._conversionWarnings.has(r)||this._conversionWarnings.add(r)}};let GO=[`thin`,`medium`,`thick`,`dashed`,`dotted`],KO=[`general`,`left`,`center`,`right`],qO=[`top`,`center`,`bottom`],JO=[`Arial`],YO=[`solid`,`none`],XO=[`expression`,`cellIs`,`colorScale`,`iconSet`,`containsText`,`notContainsText`,`beginsWith`,`endsWithText`,`containsBlanks`,`notContainsBlanks`],ZO={b:`boolean`,d:`date`,e:`error`,inlineStr:`inlineStr`,n:`number`,s:`sharedString`,str:`str`},QO={dashDot:`thin`,dashDotDot:`thin`,dashed:`dashed`,dotted:`dotted`,double:`thin`,hair:`thin`,medium:`medium`,mediumDashDot:`thin`,mediumDashDotDot:`thin`,mediumDashed:`thin`,none:void 0,slantDashDot:`thin`,thick:`thick`,thin:`thin`},$O={general:void 0,left:`left`,center:`center`,right:`right`,fill:`left`,justify:`left`,centerContinuous:`center`,distributed:`center`},ek={top:`top`,center:`middle`,bottom:`bottom`,justify:`middle`,distributed:`middle`},tk={top:`top`,middle:`center`,bottom:`bottom`},nk={beginsWith:`beginsWithText`,endsWith:`endsWithText`,containsText:`containsText`,notContains:`notContainsText`,between:`isBetween`,notBetween:`isNotBetween`,equal:`isEqual`,notEqual:`isNotEqual`,greaterThan:`isGreaterThan`,greaterThanOrEqual:`isGreaterOrEqualTo`,lessThan:`isLessThan`,lessThanOrEqual:`isLessOrEqualTo`},rk={aboveAverage:void 0,expression:`customFormula`,cellIs:void 0,colorScale:void 0,dataBar:void 0,iconSet:void 0,top10:`top10`,uniqueValues:`uniqueValues`,duplicateValues:`duplicateValues`,containsText:`containsText`,notContainsText:`notContainsText`,beginsWith:`beginsWithText`,endsWith:`endsWithText`,containsBlanks:`isEmpty`,notContainsBlanks:`isNotEmpty`,containsErrors:void 0,notContainsErrors:void 0,timePeriod:void 0},ik={num:`number`,percent:`percentage`,max:`value`,min:`value`,percentile:`percentile`,formula:`formula`},ak={NoIcons:void 0,"3Arrows":`arrows`,"3ArrowsGray":`arrows`,"3Symbols":`smiley`,"3Symbols2":`smiley`,"3Signs":`dots`,"3Flags":`dots`,"3TrafficLights1":`dots`,"3TrafficLights2":`dots`,"4Arrows":`arrows`,"4ArrowsGray":`arrows`,"4RedToBlack":`dots`,"4Rating":`smiley`,"4TrafficLights":`dots`,"5Arrows":`arrows`,"5ArrowsGray":`arrows`,"5Rating":`smiley`,"5Quarters":`dots`,"3Stars":`smiley`,"3Triangles":`arrows`,"5Boxes":`dots`},ok={none:`none`,b:`bottom`,t:`top`,l:`left`,r:`right`,tr:`right`},sk={areaChart:void 0,area3DChart:void 0,lineChart:`line`,line3DChart:void 0,stockChart:void 0,radarChart:`radar`,scatterChart:`scatter`,pieChart:`pie`,pie3DChart:void 0,doughnutChart:`pie`,barChart:`bar`,bar3DChart:void 0,ofPieChart:void 0,surfaceChart:void 0,surface3DChart:void 0,bubbleChart:void 0,comboChart:`combo`},ck={exp:`exponential`,log:`logarithmic`,poly:`polynomial`,movingAvg:`trailingMovingAverage`},lk={1:`AVERAGE`,2:`COUNT`,3:`COUNTA`,4:`MAX`,5:`MIN`,6:`PRODUCT`,7:`STDEV`,8:`STDEVP`,9:`SUM`,10:`VAR`,11:`VARP`,101:`AVERAGE`,102:`COUNT`,103:`COUNTA`,104:`MAX`,105:`MIN`,106:`PRODUCT`,107:`STDEV`,108:`STDEVP`,109:`SUM`,110:`VAR`,111:`VARP`},uk={0:`General`,1:`0`,2:`0.00`,3:`#,#00`,4:`#,##0.00`,9:`0%`,10:`0.00%`,11:void 0,12:void 0,13:void 0,14:`m/d/yyyy`,15:`m/d/yyyy`,16:`m/d/yyyy`,17:`m/d/yyyy`,18:`hh:mm:ss a`,19:`hh:mm:ss a`,20:`hhhh:mm:ss`,21:`hhhh:mm:ss`,22:`m/d/yy h:mm`,37:void 0,38:void 0,39:void 0,40:void 0,45:`hhhh:mm:ss`,46:`hhhh:mm:ss`,47:`hhhh:mm:ss`,48:void 0,49:`@`},dk={0:1,"0.00":2,"#,#00":3,"#,##0.00":4,"0%":9,"0.00%":10,"0.00E+00":11,"# ?/?":12,"# ??/??":13,"mm-dd-yy":14,"d-mm-yy":15,"mm-yy":16,"mmm-yy":17,"h:mm AM/PM":18,"h:mm:ss AM/PM":19,"h:mm":20,"h:mm:ss":21,"m/d/yy h:mm":22,"#,##0 ;(#,##0)":37,"#,##0 ;[Red](#,##0)":38,"#,##0.00;(#,##0.00)":39,"#,##0.00;[Red](#,##0.00)":40,"mm:ss":45,"[h]:mm:ss":46,"mmss.0":47,"##0.0E+0":48,"@":49,"hh:mm:ss a":19},fk={0:`000000`,1:`FFFFFF`,2:`FF0000`,3:`00FF00`,4:`0000FF`,5:`FFFF00`,6:`FF00FF`,7:`00FFFF`,8:`000000`,9:`FFFFFF`,10:`FF0000`,11:`00FF00`,12:`0000FF`,13:`FFFF00`,14:`FF00FF`,15:`00FFFF`,16:`800000`,17:`008000`,18:`000080`,19:`808000`,20:`800080`,21:`008080`,22:`C0C0C0`,23:`808080`,24:`9999FF`,25:`993366`,26:`FFFFCC`,27:`CCFFFF`,28:`660066`,29:`FF8080`,30:`0066CC`,31:`CCCCFF`,32:`000080`,33:`FF00FF`,34:`FFFF00`,35:`00FFFF`,36:`800080`,37:`800000`,38:`008080`,39:`0000FF`,40:`00CCFF`,41:`CCFFFF`,42:`CCFFCC`,43:`FFFF99`,44:`99CCFF`,45:`FF99CC`,46:`CC99FF`,47:`FFCC99`,48:`3366FF`,49:`33CCCC`,50:`99CC00`,51:`FFCC00`,52:`FF9900`,53:`FF6600`,54:`666699`,55:`969696`,56:`003366`,57:`339966`,58:`003300`,59:`333300`,60:`993300`,61:`993366`,62:`333399`,63:`333333`,64:`000000`,65:`FFFFFF`},pk={"image/avif":`avif`,"image/bmp":`bmp`,"image/gif":`gif`,"image/vnd.microsoft.icon":`ico`,"image/jpeg":`jpeg`,"image/png":`png`,"image/tiff":`tiff`,"image/webp":`webp`},mk={avif:`image/avif`,bmp:`image/bmp`,gif:`image/gif`,ico:`image/vnd.microsoft.icon`,jpeg:`image/jpeg`,png:`image/png`,tiff:`image/tiff`,webp:`image/webp`,jpg:`image/jpeg`},hk={between:`isBetween`,notBetween:`isNotBetween`,equal:`isEqual`,notEqual:`isNotEqual`,greaterThan:`isGreaterThan`,greaterThanOrEqual:`isGreaterOrEqualTo`,lessThan:`isLessThan`,lessThanOrEqual:`isLessOrEqualTo`},gk={between:`dateIsBetween`,notBetween:`dateIsNotBetween`,equal:`dateIs`,greaterThan:`dateIsAfter`,greaterThanOrEqual:`dateIsOnOrAfter`,lessThan:`dateIsBefore`,lessThanOrEqual:`dateIsOnOrBefore`};function _k(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=lu;else if(e.indexed)t=fk[e.indexed];else return;return t=vk(t),e.tint&&(t=yk(t,e.tint)),t=t.toUpperCase(),t.length===9&&t.endsWith(`FF`)&&(t=t.slice(0,7)),t}function vk(e){return e.length===6?`#`+e+`FF`:`#`+e.slice(2)+e.slice(0,2)}function yk(e,t){let n=Rr(Ir(e));return t<0&&(n.l*=1+t),t>0&&(n.l=n.l*(1-t)+(100-100*(1-t))),Fr(Lr(n))}function bk(e){return e.length===9&&(e=e.slice(0,7)),parseInt(e.replace(`#`,``),16)}function xk(e){switch(e){case`isNotEmpty`:return`notContainsBlanks`;case`isEmpty`:return`containsBlanks`;case`notContainsText`:return`notContainsBlanks`;case`containsText`:return`containsText`;case`beginsWithText`:return`beginsWith`;case`endsWithText`:return`endsWith`;case`isGreaterThan`:return`greaterThan`;case`isGreaterOrEqualTo`:return`greaterThanOrEqual`;case`isLessThan`:return`lessThan`;case`isLessOrEqualTo`:return`lessThanOrEqual`;case`isBetween`:return`between`;case`isNotBetween`:return`notBetween`;case`isEqual`:return`equal`;case`isNotEqual`:return`notEqual`;case`customFormula`:return``;case`dateIs`:return``;case`dateIsBefore`:return`lessThan`;case`dateIsAfter`:return`greaterThan`;case`dateIsOnOrAfter`:return`greaterThanOrEqual`;case`dateIsOnOrBefore`:return`lessThanOrEqual`;case`top10`:return`top10`;case`uniqueValues`:return`uniqueValues`;case`duplicateValues`:return`duplicateValues`}}function Sk(e){switch(typeof e){case`boolean`:return`b`;case`string`:return`str`;case`number`:return`n`;default:return}}function Ck(e){return Math.round(_u*e*100)/100}function wk(e){return Math.round(vu*e*100)/100}function Tk(e){return e&&Math.round(e/_u*100)/100}function Ek(e){return e&&Math.round(e/vu*100)/100}function Dk(e,t,n,r,i){let a=n?e.styles[n]:{},o=r?e.formats[r]:void 0,s={font:{size:a?.fontSize||we,color:{rgb:a?.textColor?a.textColor:`000000`},family:2,name:`Arial`},fill:a?.fillColor?{fgColor:{rgb:a.fillColor}}:{reservedAttribute:`none`},numFmt:o?{format:o,id:0}:void 0,border:i||0,alignment:{horizontal:a.align,vertical:a.verticalAlign?tk[a.verticalAlign]:void 0,wrapText:a.wrapping===`wrap`||t?.includes(`
|
|
65
|
+
`);return!!(n&&r&&(n!==r||gv(t,e)))},updateAnimation:function(e,t,n,r){let i=pv[this.easingFn](e),a=r.y+(i-1)*r.height,o=r.y+i*r.height,s=gv(r,n),c={id:r.id+`-text-slide-in`,x:r.x,y:a,width:r.width,height:r.height,style:{...r.style,hideGridLines:!0},content:r.content?{...r.content}:void 0,clipRect:r.clipRect||{...r,x:Math.max(0,r.x-(r.content?.width||0)),width:r.width+(r.content?.width||0)*2},icons:s?hv(r.icons,r):mv(r.icons)},l={id:n.id+`-text-slide-out`,x:r.x,y:o,width:r.width,height:r.height,style:{...n.style,hideGridLines:!0},content:n.content?{...n.content}:void 0,clipRect:n.clipRect||{...r,x:Math.max(0,r.x-(n.content?.width||0)),width:r.width+(n.content?.width||0)*2},icons:s?hv(n.icons,r):mv(n.icons)};if(r.content&&n.content&&c.content&&l.content){let e=r.content.y+(i-1)*r.height,t=r.content.y+i*r.height;c.content.y=e,l.content.y=t}return l.style.fillColor=c.style.fillColor=void 0,t.content=void 0,t.icons=s?{}:t.icons,{newBoxes:[c,l]}}}),fv.add(`borderFadeIn`,{id:`borderFadeIn`,easingFn:`easeInCubic`,hasAnimation:(e,t)=>!!(!e?.border?.bottom&&t?.border?.bottom||!e?.border?.top&&t?.border?.top||!e?.border?.left&&t?.border?.left||!e?.border?.right&&t?.border?.right),updateAnimation:function(e,t,n,r){let i=pv[this.easingFn](e);t.border?.top&&r.border?.top&&!n.border?.top&&(t.border.top.opacity=i),t.border?.bottom&&r.border?.bottom&&!n.border?.bottom&&(t.border.bottom.opacity=i),t.border?.left&&r.border?.left&&!n.border?.left&&(t.border.left.opacity=i),t.border?.right&&r.border?.right&&!n.border?.right&&(t.border.right.opacity=i)}}),fv.add(`borderFadeOut`,{id:`borderFadeOut`,easingFn:`easeOutCubic`,hasAnimation:(e,t)=>!!(e?.border?.bottom&&!t?.border?.bottom||e?.border?.top&&!t?.border?.top||e?.border?.left&&!t?.border?.left||e?.border?.right&&!t?.border?.right),updateAnimation:function(e,t,n,r){let i=1-pv[this.easingFn](e);t.border||={},n.border?.top&&!r.border?.top&&(t.border.top={...n.border.top,opacity:i}),n.border?.bottom&&!r.border?.bottom&&(t.border.bottom={...n.border.bottom,opacity:i}),n.border?.left&&!r.border?.left&&(t.border.left={...n.border.left,opacity:i}),n.border?.right&&!r.border?.right&&(t.border.right={...n.border.right,opacity:i})}}),fv.add(`borderColorChange`,{id:`borderColorChange`,easingFn:`easeOutCubic`,hasAnimation:(e,t)=>{let n=e?.border,r=t?.border;return!n||!r?!1:n.bottom?.color!==r.bottom?.color||n.top?.color!==r.top?.color||n.left?.color!==r.left?.color||n.right?.color!==r.right?.color},updateAnimation:function(e,t,n,r){let i=i=>{let a=n?.border?.[i],o=r?.border?.[i],s=t.border?.[i];a&&o&&s&&(s.color=li([{value:0,color:a.color||`#000000`},{value:1,color:o.color||`#000000`}])(pv[this.easingFn](e)))};i(`top`),i(`bottom`),i(`left`),i(`right`)}}),fv.add(`iconChange`,{id:`iconChange`,easingFn:`easeOutCubic`,hasAnimation:(e,t)=>!gv(t,e)&&(e?.icons?.center?.svg?.name!==t?.icons?.center?.svg?.name||e?.icons?.left?.svg?.name!==t?.icons?.left?.svg?.name||e?.icons?.right?.svg?.name!==t?.icons?.right?.svg?.name),updateAnimation:function(e,t,n,r){let i=pv[this.easingFn](e),a=r.y+(i-1)*r.height,o=r.y+i*r.height,s=[],c=e=>{let i=n.icons?.[e],c=r.icons?.[e],l={id:`${r.id}-icon-${e}-slide-in`,style:{verticalAlign:r.style.verticalAlign,hideGridLines:!0},x:r.x,y:a,width:r.width,height:r.height,icons:{[e]:{...c,clipRect:r}}},u={id:`${r.id}-icon-${e}-slide-out`,style:{verticalAlign:n.style.verticalAlign,hideGridLines:!0},x:r.x,y:o,width:r.width,height:r.height,icons:{[e]:{...i,clipRect:r}}};t.icons[e]=mv(r.icons)[e],s.push(l,u)};return c(`left`),c(`right`),c(`center`),{newBoxes:s}}});let pv={linear:e=>e,easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeOutQuart:e=>-(--e*e*e*e-1)};function mv(e){return{left:e.left?{...e.left,svg:void 0}:void 0,right:e.right?{...e.right,svg:void 0}:void 0,center:e.center?{...e.center,svg:void 0}:void 0}}function hv(e,t){return{left:e.left?{...e.left,clipRect:t}:void 0,right:e.right?{...e.right,clipRect:t}:void 0,center:e.center?{...e.center,clipRect:t}:void 0}}function gv(e,t){let n=(e,t)=>t&&e?!!(e.horizontalAlign!==t.horizontalAlign||e.size!==t.size||e.margin!==t.margin||e.svg&&!t.svg||!e.svg&&t.svg):!!(e&&!t||!e&&t);return n(e?.icons.left,t?.icons.left)||n(e?.icons.right,t?.icons.right)||n(e?.icons.center,t?.icons.center)}var _v=class extends t.Component{static template=`o-spreadsheet-GaugeChartComponent`;static props={chartId:String,isFullScreen:{type:Boolean,optional:!0}};canvas=(0,t.useRef)(`chartContainer`);animationStore;get runtime(){return this.env.model.getters.getChartRuntime(this.props.chartId)}setup(){this.env.model.getters.isDashboard()&&(this.animationStore=D(tu));let e=null,n;(0,t.useEffect)(()=>{if(this.env.isDashboard()&&n===void 0&&this.animationStore?.animationPlayed[this.animationChartId]!==`gauge`)e=this.drawGaugeWithAnimation(),this.animationStore?.disableAnimationForChart(this.animationChartId,`gauge`);else if(this.env.isDashboard()&&n!==void 0&&!w(this.runtime,n))e=this.drawGaugeWithAnimation(),this.animationStore?.disableAnimationForChart(this.animationChartId,`gauge`);else{let e=this.env.model.getters.getViewportZoomLevel();Mp(this.canvasEl,this.runtime,e)}return n=this.runtime,()=>e?.stop()},()=>{let e=this.canvasEl.getBoundingClientRect();return[e.width,e.height,this.runtime,this.canvas.el,window.devicePixelRatio]})}drawGaugeWithAnimation(){Mp(this.canvasEl,{...this.runtime,animationValue:0},void 0);let e=this.runtime.gaugeValue?.value||0,t=this.runtime.maxValue.value,n=Math.sign(e)*Math.min(Math.abs(e),Math.abs(t));if(n===0)return null;let r=this.runtime.minValue.value,i=new vv(r,n,1e3,e=>Mp(this.canvasEl,{...this.runtime,animationValue:e},void 0));return i.start(),i}get canvasEl(){return this.canvas.el}get animationChartId(){return this.props.isFullScreen?this.props.chartId+`-fullscreen`:this.props.chartId}},vv=class{startValue;endValue;duration;callback;startTime=void 0;animationFrameId=null;constructor(e,t,n,r){this.startValue=e,this.endValue=t,this.duration=n,this.callback=r}start(){this.animationFrameId=requestAnimationFrame(this.animate.bind(this))}stop(){this.animationFrameId&&=(cancelAnimationFrame(this.animationFrameId),null)}animate(e){this.startTime||=e;let t=e-this.startTime,n=Math.min(t/this.duration,1),r=this.startValue+(this.endValue-this.startValue)*pv.easeOutQuart(n);this.callback(r),n<1?this.animationFrameId=requestAnimationFrame(this.animate.bind(this)):this.stop()}};let yv=new B;yv.add(`line`,dv),yv.add(`bar`,dv),yv.add(`combo`,dv),yv.add(`pie`,Pf),yv.add(`gauge`,_v),yv.add(`scatter`,Pf),yv.add(`scorecard`,Ap),yv.add(`waterfall`,dv),yv.add(`pyramid`,Pf),yv.add(`radar`,Pf),yv.add(`geo`,Pf),yv.add(`funnel`,Pf),yv.add(`sunburst`,Pf),yv.add(`treemap`,Pf),yv.add(`calendar`,Pf);var bv=class extends yr{mutators=[`toggleFullScreenFigure`];fullScreenFigure=void 0;toggleFullScreenFigure(e){this.fullScreenFigure?.id===e?this.fullScreenFigure=void 0:this.makeFullScreen(e)}makeFullScreen(e){let t=this.getters.getActiveSheetId(),n=this.getters.getFigure(t,e);n&&(this.fullScreenFigure={...n,x:0,y:0,width:0,height:0})}};function xv(e,n){let r,{setInterval:i,clearInterval:a}=window,o=()=>{a(r),r=void 0},s=()=>{try{e()}catch(e){throw o(),e}};return(0,t.useEffect)(()=>(r=i(s,n),()=>a(r)),()=>[n]),{pause:o,resume:()=>{r===void 0&&(r=i(s,n))}}}function Sv(){let e;function n(){e!==void 0&&(clearTimeout(e),e=void 0)}function r(t,r){n(),e=setTimeout(t,r)}return(0,t.onWillUnmount)(n),{clear:n,schedule:r}}var Cv=class extends t.Component{static template=`o-spreadsheet-Menu`;static props={menuItems:Array,onClose:Function,onClickMenu:{type:Function,optional:!0},onMouseEnter:{type:Function,optional:!0},onMouseOver:{type:Function,optional:!0},onMouseLeave:{type:Function,optional:!0},width:{type:Number,optional:!0},isActive:{type:Function,optional:!0},onScroll:{type:Function,optional:!0}};static components={};static defaultProps={};hoveredMenu=void 0;setup(){(0,t.onWillUnmount)(()=>{this.hoveredMenu?.onStopHover?.(this.env)})}get childrenHaveIcon(){return this.props.menuItems.some(e=>e!==`separator`&&!!this.getIconName(e))}getIconName(e){return e.icon(this.env)?e.icon(this.env):e.isActive?.(this.env)?`o-spreadsheet-Icon.CHECK`:``}getColor(e){return U({color:e.textColor})}getIconColor(e){return U({color:e.iconColor})}getName(e){return e.name(this.env)}isRoot(e){return _(e)}isEnabled(e){let t=e.children?.(this.env);if(t.length)return t.some(e=>this.isEnabled(e));if(e.isEnabled(this.env)){let t=e.isEnabledOnLockedSheet||!this.env.model.getters.isCurrentSheetLocked();return this.env.model.getters.isReadonly()?e.isReadonlyAllowed:t}return!1}get menuStyle(){return this.props.width?U({width:this.props.width+`px`}):``}onMouseEnter(e,t){this.hoveredMenu=e,e.onStartHover?.(this.env),this.props.onMouseEnter?.(e,t)}onMouseLeave(e,t){this.hoveredMenu=void 0,e.onStopHover?.(this.env),this.props.onMouseLeave?.(e,t)}onClickMenu(e,t){this.isEnabled(e)&&this.props.onClickMenu?.(e,t)}};function wv(e,t){return Dv(En(Ev(e),Ev(t)))}function Tv(...e){return Dv(wn(...e.map(Ev)))}function Ev(e){return{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height}}function Dv(e){if(e)return{x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top}}function Ov(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function kv(){let e=(0,t.useState)({x:0,y:0,width:0,height:0}),n=null;function r(){if(n||=document.querySelector(`.o-spreadsheet`),n){let{top:t,left:r,width:i,height:a}=n.getBoundingClientRect();e.x=r,e.y=t,e.width=i,e.height=a}}return(0,t.onMounted)(r),(0,t.onPatched)(r),e}function Av(){let e=(0,t.useState)({x:0,y:0,width:0,height:0}),n=(0,t.useComponent)(),r=kv();function i(){let t=n.env,i=`getPopoverContainerRect`in t&&t.getPopoverContainerRect?t.getPopoverContainerRect():r;e.x=i.x,e.y=i.y,e.width=i.width,e.height=i.height}return i(),(0,t.onMounted)(i),(0,t.onPatched)(i),e}var jv=class extends t.Component{static template=`o-spreadsheet-Popover`;static props={anchorRect:Object,containerRect:{type:Object,optional:!0},positioning:{type:String,optional:!0},maxWidth:{type:Number,optional:!0},maxHeight:{type:Number,optional:!0},verticalOffset:{type:Number,optional:!0},onMouseWheel:{type:Function,optional:!0},onPopoverHidden:{type:Function,optional:!0},onPopoverMoved:{type:Function,optional:!0},zIndex:{type:Number,optional:!0},class:{type:String,optional:!0},slots:Object};static defaultProps={positioning:`bottom-left`,verticalOffset:0,onMouseWheel:()=>{},onPopoverMoved:()=>{},onPopoverHidden:()=>{}};popoverRef=(0,t.useRef)(`popover`);popoverContentRef=(0,t.useRef)(`popoverContent`);currentPosition=void 0;currentDisplayValue=void 0;spreadsheetRect=kv();containerRect;setup(){this.containerRect=Av();let e=new ResizeObserver(this.computePopoverPosition.bind(this));(0,t.onMounted)(()=>{e.observe(this.popoverContentRef.el)}),(0,t.onWillUnmount)(()=>{e.disconnect()}),(0,t.useEffect)(this.computePopoverPosition.bind(this))}computePopoverPosition(){if(!this.containerRect)throw Error(`Popover container is not defined`);let e=this.popoverRef.el,t=this.popoverContentRef.el,n=wv(this.props.anchorRect,this.containerRect),r=n?`block`:`none`;if(this.currentDisplayValue!==`none`&&r===`none`&&this.props.onPopoverHidden?.(),e.style.display=r,this.currentDisplayValue=r,!n)return;let i={width:this.props.maxWidth,height:this.props.maxHeight},a={width:t.getBoundingClientRect().width,height:t.getBoundingClientRect().height},o=this.spreadsheetRect,s=this.props.positioning===`bottom-left`?new Nv(n,this.containerRect,i,o,this.currentPosition):new Pv(n,this.containerRect,i,o,this.currentPosition);e.style[`max-height`]=s.getMaxHeight(a.height)+`px`,e.style[`max-width`]=s.getMaxWidth(a.width)+`px`,a={width:e.getBoundingClientRect().width,height:e.getBoundingClientRect().height};let c=s.getCss(a,this.props.verticalOffset);for(let t of Object.keys(c))e.style[t]=c[t];let l=s.getCurrentPosition(a);this.currentPosition&&l!==this.currentPosition&&this.props.onPopoverMoved?.(),this.currentPosition=l}},Mv=class{anchorRect;containerRect;propsMaxSize;spreadsheetOffset;lastPosition;constructor(e,t,n,r,i){this.anchorRect=e,this.containerRect=t,this.propsMaxSize=n,this.spreadsheetOffset=r,this.lastPosition=i}shouldRenderAtBottom(e){return this.lastPosition===`top-left`||this.lastPosition===`top-right`?!(e<=this.availableHeightUp||this.availableHeightUp>=this.availableHeightDown):e<=this.availableHeightDown||this.availableHeightDown>=this.availableHeightUp}shouldRenderAtRight(e){return this.lastPosition===`bottom-left`||this.lastPosition===`top-left`?!(e<=this.availableWidthLeft||this.availableWidthLeft>=this.availableWidthRight):e<=this.availableWidthRight||this.availableWidthRight>=this.availableWidthLeft}getMaxHeight(e){let t=this.shouldRenderAtBottom(e)?this.availableHeightDown:this.availableHeightUp;return this.propsMaxSize.height?Math.min(t,this.propsMaxSize.height):t}getMaxWidth(e){let t=this.shouldRenderAtRight(e)?this.availableWidthRight:this.availableWidthLeft;return this.propsMaxSize.width?Math.min(t,this.propsMaxSize.width):t}getCss(e,t){let n=this.getMaxHeight(e.height),r=this.getMaxWidth(e.width),i=Math.min(n,e.height),a=Math.min(r,e.width),o=this.shouldRenderAtBottom(e.height),s=this.shouldRenderAtRight(e.width);return t=o?t:-t,{top:this.getTopCoordinate(i,o)-this.spreadsheetOffset.y-t+`px`,left:this.getLeftCoordinate(a,s)-this.spreadsheetOffset.x+`px`}}getCurrentPosition(e){let t=this.shouldRenderAtBottom(e.height),n=this.shouldRenderAtRight(e.width);return t&&n?`bottom-right`:t&&!n?`bottom-left`:!t&&n?`top-right`:`top-left`}},Nv=class extends Mv{get availableHeightUp(){return this.anchorRect.y-this.containerRect.y}get availableHeightDown(){return this.containerRect.height-this.availableHeightUp-this.anchorRect.height}get availableWidthRight(){return this.containerRect.x+this.containerRect.width-this.anchorRect.x}get availableWidthLeft(){return this.anchorRect.x+this.anchorRect.width-this.containerRect.x}getTopCoordinate(e,t){return t?this.anchorRect.y+this.anchorRect.height:this.anchorRect.y-e}getLeftCoordinate(e,t){return t?this.anchorRect.x:this.anchorRect.x+this.anchorRect.width-e}},Pv=class extends Mv{get availableHeightUp(){return this.anchorRect.y+this.anchorRect.height-this.containerRect.y}get availableHeightDown(){return this.containerRect.y+this.containerRect.height-this.anchorRect.y}get availableWidthRight(){return this.containerRect.width-this.anchorRect.width-this.availableWidthLeft}get availableWidthLeft(){return this.anchorRect.x-this.containerRect.x}getTopCoordinate(e,t){return t?this.anchorRect.y:this.anchorRect.y+this.anchorRect.height-e}getLeftCoordinate(e,t){return t?this.anchorRect.x+this.anchorRect.width:this.anchorRect.x-e}},Fv=class e extends t.Component{static template=`o-spreadsheet-Menu-Popover`;static props={anchorRect:Object,popoverPositioning:{type:String,optional:!0},menuItems:Array,depth:{type:Number,optional:!0},maxHeight:{type:Number,optional:!0},onClose:Function,onMenuClicked:{type:Function,optional:!0},menuId:{type:String,optional:!0},onMouseOver:{type:Function,optional:!0},width:{type:Number,optional:!0}};static components={MenuPopover:e,Menu:Cv,Popover:jv};static defaultProps={depth:1,popoverPositioning:`top-right`};subMenu=(0,t.useState)({isOpen:!1,anchorRect:null,scrollOffset:0,menuItems:[],isHoveringChild:!1});menuRef=(0,t.useRef)(`menu`);hoveredMenu=void 0;openingTimeOut=Sv();setup(){(0,t.useExternalListener)(window,`click`,this.onExternalClick,{capture:!0}),(0,t.useExternalListener)(window,`contextmenu`,this.onExternalClick,{capture:!0}),(0,t.onWillUpdateProps)(e=>{e.menuItems!==this.props.menuItems&&this.closeSubMenu()}),(0,t.onWillUnmount)(()=>{this.hoveredMenu?.onStopHover?.(this.env)})}get menuProps(){return{menuItems:this.menuItems,onClose:this.close.bind(this),onClickMenu:this.onClickMenu.bind(this),onMouseOver:this.onMouseOver.bind(this),onMouseLeave:this.onMouseLeave.bind(this),width:this.props.width||250,isActive:this.isActive.bind(this),onScroll:this.onScroll.bind(this)}}get subMenuAnchorRect(){let e=Object.assign({},this.subMenu.anchorRect);return e.y-=this.subMenu.scrollOffset||0,e}get popoverProps(){let e=this.props.depth===1;return{anchorRect:{x:this.props.anchorRect.x,y:this.props.anchorRect.y,width:e?this.props.anchorRect.width:this.props.width||250,height:e?this.props.anchorRect.height:26},positioning:this.props.popoverPositioning,verticalOffset:e?0:6,onPopoverHidden:()=>this.closeSubMenu(),onPopoverMoved:()=>this.closeSubMenu(),maxHeight:this.props.maxHeight}}get childrenHaveIcon(){return this.props.menuItems.some(e=>!!this.getIconName(e))}getIconName(e){return e.icon(this.env)?e.icon(this.env):e.isActive?.(this.env)?`o-spreadsheet-Icon.CHECK`:``}getColor(e){return U({color:e.textColor})}getIconColor(e){return U({color:e.iconColor})}async activateMenu(e,t){let n=await e.execute?.(this.env,t);this.close(),this.props.onMenuClicked?.({detail:n})}close(){this.closeSubMenu(),this.props.onClose()}onExternalClick(e){this.menuRef.el&&cp().some(t=>np(t,e))||(e.closedMenuId=this.props.menuId,this.close())}get menuItems(){return g(this.env,this.props.menuItems)}getName(e){return e.name(this.env)}isRoot(e){return!e.execute}isEnabled(e){return e.isEnabled(this.env)?this.env.model.getters.isReadonly()?e.isReadonlyAllowed:!0:!1}isActive(e){return(this.subMenu?.isHoveringChild||!1)&&this.isParentMenu(this.subMenu,e)}onScroll(e){this.subMenu.scrollOffset=e.target.scrollTop}openSubMenu(e,t){if(!t)return;let n=t.getBoundingClientRect().top;this.subMenu.anchorRect={x:ap(this.menuRef).x,y:n-(this.subMenu.scrollOffset||0),width:this.props.width||250,height:26},this.subMenu.menuItems=e.children(this.env),this.subMenu.isOpen=!0,this.subMenu.parentMenu=e}isParentMenu(e,t){return e.parentMenu?.id===t.id}closeSubMenu(){this.subMenu.isHoveringChild||(this.subMenu.isOpen=!1,this.subMenu.parentMenu=void 0)}onClickMenu(e,t){this.isRoot(e)?this.openSubMenu(e,t.currentTarget):this.activateMenu(e,gp(t))}onMouseOver(e,t){if(this.isParentMenu(this.subMenu,e)){this.openingTimeOut.clear();return}let n=t.currentTarget;this.isRoot(e)&&this.openingTimeOut.schedule(()=>{this.openSubMenu(e,n)},250)}onMouseOverMainMenu(){this.props.onMouseOver?.(),this.subMenu.isHoveringChild=!1}onMouseOverChildMenu(){this.subMenu.isHoveringChild=!0,this.openingTimeOut.clear()}onMouseLeave(e){this.openingTimeOut.schedule(this.closeSubMenu.bind(this),250)}get menuStyle(){return this.props.width?U({width:this.props.width+`px`}):``}},Iv=class extends t.Component{static template=`o-spreadsheet-ChartDashboardMenu`;static components={MenuPopover:Fv};static props={chartId:String,hasFullScreenButton:{type:Boolean,optional:!0}};static defaultProps={hasFullScreenButton:!0};fullScreenFigureStore;menuState=(0,t.useState)({isOpen:!1,anchorRect:null,menuItems:[]});setup(){super.setup(),this.fullScreenFigureStore=D(bv)}getMenuItems(){return[this.fullScreenMenuItem].filter(C)}get backgroundColor(){return`background-color: `+(this.env.model.getters.getChartDefinition(this.props.chartId).background||`#FFFFFF`)}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.anchorRect=op(e.currentTarget);let t=this.env.model.getters.getFigureIdFromChartId(this.props.chartId);this.menuState.menuItems=K_(t,this.env)}get fullScreenMenuItem(){if(!this.props.hasFullScreenButton)return;let e=this.env.model.getters.getChartDefinition(this.props.chartId),t=this.env.model.getters.getFigureIdFromChartId(this.props.chartId);if(e.type===`scorecard`)return;let n=t===this.fullScreenFigureStore.fullScreenFigure?.id;return{id:`fullScreenChart`,label:k(n?`Exit Full Screen`:`Full Screen`),class:`text-muted fa ${n?`fa-compress`:`fa-expand`}`,onClick:()=>{this.fullScreenFigureStore.toggleFullScreenFigure(t)}}}},Lv=class extends t.Component{static template=`o-spreadsheet-CarouselFigure`;static props={figureUI:Object,editFigureStyle:{type:Function,optional:!0},isFullScreen:{type:Boolean,optional:!0},openContextMenu:{type:Function,optional:!0}};static components={ChartDashboardMenu:Iv,MenuPopover:Fv};carouselTabsRef=(0,t.useRef)(`carouselTabs`);carouselTabsDropdownRef=(0,t.useRef)(`carouselTabsDropdown`);menuState=(0,t.useState)({isOpen:!1,anchorRect:null,menuItems:[]});hiddenItems=[];animationStore;fullScreenFigureStore;setup(){this.animationStore=D(tu),this.fullScreenFigureStore=D(bv),(0,t.useEffect)(()=>{this.selectedCarouselItem?.type===`carouselDataView`?this.props.editFigureStyle?.({"pointer-events":`none`}):this.props.editFigureStyle?.({"pointer-events":`auto`}),this.updateTabsVisibility()})}get carousel(){return this.env.model.getters.getCarousel(this.props.figureUI.id)}get selectedCarouselItem(){return this.env.model.getters.getSelectedCarouselItem(this.props.figureUI.id)}get chartComponent(){let e=this.selectedCarouselItem;if(e?.type!==`chart`)throw Error(`Selected item is not a chart`);let t=this.env.model.getters.getChartType(e.chartId),n=yv.get(t);if(!n)throw Error(`Component is not defined for type ${t}`);return n}onCarouselDoubleClick(){this.env.model.dispatch(`SELECT_FIGURE`,{figureId:this.props.figureUI.id}),this.env.openSidePanel(`CarouselPanel`,{figureId:this.props.figureUI.id})}isItemSelected(e){let t=this.selectedCarouselItem;return w(t,e)}getItemTitle(e){return rv(this.env.model.getters,e)}onCarouselTabClick(e){if(this.env.model.dispatch(`UPDATE_CAROUSEL_ACTIVE_ITEM`,{figureId:this.props.figureUI.id,sheetId:this.env.model.getters.getActiveSheetId(),item:e}),e.type===`chart`){let t=e.chartId+(this.props.isFullScreen?`-fullscreen`:``);this.animationStore?.enableAnimationForChart(t)}}get headerStyle(){let e={};if(this.selectedCarouselItem?.type===`chart`){let t=this.env.model.getters.getChartRuntime(this.selectedCarouselItem.chartId);`background`in t&&t.background?e[`background-color`]=t.background:`chartJsConfig`in t&&(e[`background-color`]=t.chartJsConfig.options?.plugins?.background?.color||`#FFFFFF`)}else e[`background-color`]=oe;return U(e)}get title(){return this.carousel.title?.text??``}get titleStyle(){return U(ov(Wt({...Ve,...this.carousel.title})))}updateTabsVisibility(){let e=this.carouselTabsRef.el,t=this.carouselTabsDropdownRef.el;if(!e||!t)return;this.hiddenItems=[];let n=op(e),r=Array.from(e.children);for(let e of r)e.style.display=`block`;let i=r.map(e=>op(e).width),a=0;for(let e=0;e<r.length;e++){let t=a+i[e]>n.width;a+=i[e],t&&(r[e].style.display=`none`,this.hiddenItems.push(this.carousel.items[e]))}t.style.display=this.hiddenItems.length?`block`:`none`}get menuId(){return`carousel-tabs-menu-`}toggleMenu(e){if(e.closedMenuId===this.menuId){this.menuState.isOpen=!1;return}let t=ap(this.carouselTabsDropdownRef),n=this.hiddenItems.map(e=>({name:this.getItemTitle(e),execute:()=>this.onCarouselTabClick(e),isActive:()=>this.isItemSelected(e),isReadonlyAllowed:!0}));this.menuState.isOpen=!0,this.menuState.anchorRect=t,this.menuState.menuItems=p(n)}toggleFullScreen(){this.selectedCarouselItem?.type===`chart`&&this.fullScreenFigureStore.toggleFullScreenFigure(this.props.figureUI.id)}get fullScreenButtonTitle(){return this.props.isFullScreen?k(`Exit Full Screen`):k(`Full Screen`)}get visibleCarouselItems(){return this.carousel.items.filter(e=>!(e.type===`carouselDataView`&&this.props.isFullScreen))}openContextMenu(e){let t=e.currentTarget;t&&this.props.openContextMenu?.(op(t))}},Rv=class extends t.Component{static template=`o-spreadsheet-ChartFigure`;static props={figureUI:Object,editFigureStyle:{type:Function,optional:!0},isFullScreen:{type:Boolean,optional:!0},openContextMenu:{type:Function,optional:!0}};static components={ChartDashboardMenu:Iv};onDoubleClick(){this.env.model.dispatch(`SELECT_FIGURE`,{figureId:this.props.figureUI.id}),this.env.openSidePanel(`ChartPanel`)}get chartType(){return this.env.model.getters.getChartType(this.chartId)}get chartId(){let e=this.env.model.getters.getChartIdFromFigureId(this.props.figureUI.id);if(!e)throw Error(`No chart found for figure ID: ${this.props.figureUI.id}`);return e}get chartComponent(){let e=this.chartType,t=yv.get(e);if(!t)throw Error(`Component is not defined for type ${e}`);return t}},zv=class extends t.Component{static template=`o-spreadsheet-ImageFigure`;static props={figureUI:Object,editFigureStyle:{type:Function,optional:!0},openContextMenu:{type:Function,optional:!0}};static components={};get figureId(){return this.props.figureUI.id}get getImagePath(){return this.env.model.getters.getImagePath(this.figureId)}};let Bv=new B;Bv.add(`chart`,{Component:Rv,SidePanelComponent:`ChartPanel`,menuBuilder:K_}),Bv.add(`image`,{Component:zv,keepRatio:!0,minFigSize:20,borderWidth:0,menuBuilder:q_}),Bv.add(`carousel`,{Component:Lv,menuBuilder:J_});var Vv=class extends t.Component{static template=`o-spreadsheet-FigureComponent`;static props={figureUI:Object,style:{type:String,optional:!0},class:{type:String,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}};static components={MenuPopover:Fv};static defaultProps={onMouseDown:()=>{},onClickAnchor:()=>{}};menuState=(0,t.useState)({isOpen:!1,anchorRect:null,menuItems:[]});figureRef=(0,t.useRef)(`figure`);figureWrapperRef=(0,t.useRef)(`figureWrapper`);menuButtonRef=(0,t.useRef)(`menuButton`);borderWidth;get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figureUI.id}get figureRegistry(){return Bv}getBorderWidth(){return this.env.isDashboard()?0:this.isSelected?2:this.borderWidth}getBorderStyle(e){return`border-${e}-width: ${this.getBorderWidth()}px;`}get wrapperStyle(){let{x:e,y:t,width:n,height:r}=this.props.figureUI;return U({left:`${e}px`,top:`${t}px`,width:`${n}px`,height:`${r}px`})}getResizerPosition(e){let t={};return e.includes(`top`)?t.top=`-3px`:e.includes(`bottom`)?t.bottom=`-3px`:t.bottom=`calc(50% - 3px)`,e.includes(`left`)?t.left=`-3px`:e.includes(`right`)?t.right=`-3px`:t.right=`calc(50% - 3px)`,U(t)}setup(){let e=Bv.get(this.props.figureUI.tag).borderWidth;this.borderWidth=e===void 0?1:e,(0,t.useEffect)((e,t,n)=>{e===t&&n?.focus({preventScroll:!0})},()=>[this.env.model.getters.getSelectedFigureId(),this.props.figureUI.id,this.figureRef.el])}clickAnchor(e,t,n){this.props.onClickAnchor(e,t,n)}onMouseDown(e){this.env.isMobile()||this.props.onMouseDown(e)}onClick(e){this.env.isMobile()&&this.props.onMouseDown(e)}onKeyDown(e){let t=pp(e);switch(t){case`Delete`:case`Backspace`:this.env.model.dispatch(`DELETE_FIGURE`,{sheetId:this.env.model.getters.getActiveSheetId(),figureId:this.props.figureUI.id}),e.preventDefault(),e.stopPropagation();break;case`ArrowDown`:case`ArrowLeft`:case`ArrowRight`:case`ArrowUp`:let{col:n,row:r,offset:i}=this.postionInBoundary(this.env.model.getters.getActiveSheetId(),this.props.figureUI,e.key);this.env.model.dispatch(`UPDATE_FIGURE`,{sheetId:this.env.model.getters.getActiveSheetId(),figureId:this.props.figureUI.id,offset:i,col:n,row:r}),e.preventDefault(),e.stopPropagation();break;case`Ctrl+A`:e.preventDefault(),e.stopPropagation();break;case`Ctrl+Y`:case`Ctrl+Z`:t===`Ctrl+Y`?this.env.model.dispatch(`REQUEST_REDO`):t===`Ctrl+Z`&&this.env.model.dispatch(`REQUEST_UNDO`),e.preventDefault(),e.stopPropagation();break}}postionInBoundary(e,t,n){let{col:r,row:i,offset:a}=t;a={...a};let o=this.env.model.getters.getMaxAnchorOffset(e,t.height,t.width);switch(n){case`ArrowUp`:if(a.y===0){for(i--;i>0&&this.env.model.getters.isRowHiddenByUser(e,i);)i--;a.y=this.env.model.getters.getRowSize(e,i)-1}else a.y--;break;case`ArrowLeft`:if(a.x===0){for(r--;r>0&&this.env.model.getters.isColHiddenByUser(e,r);)r--;a.x=this.env.model.getters.getColSize(e,r)-1}else a.x--;break;case`ArrowDown`:if(a.y===this.env.model.getters.getRowSize(e,i)){for(i++;i<=o.row&&this.env.model.getters.isRowHiddenByUser(e,i);)i++;a.y=0}else a.y++;break;case`ArrowRight`:if(a.x===this.env.model.getters.getColSize(e,i)){for(r++;r<=o.col&&this.env.model.getters.isColHiddenByUser(e,r);)r++;a.x=0}else a.x++}return r<0?(r=0,a.x=0):(r>o.col||r===o.col&&a.x>o.offset.x)&&(r=o.col,a.x=o.offset.x),i<0?(i=0,a.y=0):(i>o.row||i===o.row&&a.y>o.offset.y)&&(i=o.row,a.y=o.offset.y),{col:r,row:i,offset:a}}onContextMenu(e){if(this.env.isDashboard())return;let t=Ep(this.env,e);this.openContextMenu({x:t.clientX,y:t.clientY,width:0,height:0})}showMenu(){this.openContextMenu(ap(this.menuButtonRef))}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.anchorRect=e,this.menuState.menuItems=Bv.get(this.props.figureUI.tag).menuBuilder(this.props.figureUI.id,this.env)}editWrapperStyle(e){if(this.figureWrapperRef.el)for(let t in e)this.figureWrapperRef.el.style.setProperty(t,e[t]||null)}get isFigureResizable(){return this.isSelected&&!this.env.isMobile()&&!this.env.isDashboard()&&!this.env.model.getters.isCurrentSheetLocked()}},Hv=class extends yr{mutators=[`clear`,`hover`];col;row;handle(e){switch(e.type){case`ACTIVATE_SHEET`:this.clear()}}hover(e){if(e.col===this.col&&e.row===this.row)return`noStateChange`;this.col=e.col,this.row=e.row}clear(){if(this.col===void 0&&this.row===void 0)return`noStateChange`;this.col=void 0,this.row=void 0}};let Uv=/(.*?)\((.*?)\)(.*)/,Wv=[`ANY`,`BOOLEAN`,`DATE`,`NUMBER`,`STRING`,`RANGE`,`RANGE<BOOLEAN>`,`RANGE<DATE>`,`RANGE<NUMBER>`,`RANGE<STRING>`,`META`,`RANGE<META>`];function W(e,t=``,n){return Gv(e,t,n)}function Gv(e,t,n){let r=e.match(Uv),i=r[1].trim();if(!i)throw Error(`Function argument definition is missing a name: '${e}'.`);let a=[],o=!1,s=!1,c;for(let e of r[2].split(`,`)){let t=e.trim().toUpperCase(),n=Wv.find(e=>t===e);n?a.push(n):t===`RANGE<ANY>`?a.push(`RANGE`):t===`OPTIONAL`?o=!0:t===`REPEATING`?s=!0:t.startsWith(`DEFAULT=`)&&(c=e.trim().slice(8))}let l={name:i,description:t,type:a};return(a.includes(`ANY`)||a.includes(`RANGE`))&&(l.acceptErrors=!0),o&&(l.optional=!0),s&&(l.repeating=!0),c!==void 0&&(l.default=!0,l.defaultValue=c),a.some(e=>e.startsWith(`RANGE`))&&(l.acceptMatrix=!0),a.every(e=>e.startsWith(`RANGE`))&&(l.acceptMatrixOnly=!0),n&&n.length>0&&(l.proposalValues=n),l}function Kv(e,t){let n=0,r=0,i=0,a=0;for(let e of t.args)n++,!e.optional&&!e.default&&r++,e.repeating&&i++,(e.optional||e.default)&&!e.repeating&&a++;let o=t;return o.minArgRequired=r,o.maxArgPossible=i?1/0:n,o.nbrArgRepeating=i,o.nbrOptionalNonRepeatingArgs=a,o.hidden=t.hidden||!1,o.name=e,o}let qv={};function Jv(e,t){let n=e.name;return qv[n]?.[t]||(qv[n]||(qv[n]={}),qv[n][t]||(qv[n][t]=Yv(e,t)),qv[n][t])}function Yv(e,t){let n={},r=e.nbrArgRepeating?Math.floor((t-e.minArgRequired)/e.nbrArgRepeating):0,i=e.nbrArgRepeating*r,a=t-e.minArgRequired-i,o=0,s=0;for(let t=0;t<e.args.length;t++){let i=e.args[t];if((i.optional||i.default)&&!i.repeating){s<a&&(n[o]={index:t},o++),s++;continue}if(i.repeating){let a=+!i.optional;for(let i=0;i<r+a;i++)for(let r=0;r<e.nbrArgRepeating;r++)n[o]={index:t+r,repeatingGroupIndex:i},o++;t+=e.nbrArgRepeating-1;continue}n[o]={index:t},o++}return e=>n[e]}let Xv=[`META`,`RANGE<META>`];function Zv(e){if(e.nbrArgRepeating&&e.nbrOptionalNonRepeatingArgs>=e.nbrArgRepeating)throw Error(`Function ${e.name} has more optional arguments than repeatable ones.`);let t=!1,n=!1;for(let r of e.args){if(r.type.some(e=>Xv.includes(e))&&r.type.some(e=>!Xv.includes(e)))throw Error(`Function ${e.name} has a mix of META and non-META types in the same argument: ${r.type}.`);if(r.repeating){if(!n&&t)throw Error(`Function ${e.name} has non-consecutive repeating arguments. All repeating arguments must be declared consecutively.`);t=!0,n=!0}else n=!1}}function Qv(e){let t=[];function n(...n){let a=[];t=Array(n.length);let o=Jv(e,n.length);for(let r=0;r<n.length;r++){let i=o(r).index??-1,s=e.args[i];t[r]=s;let c=n[r];if(!Ta(c)&&s.acceptMatrixOnly)throw new ga(k(`Function %s expects the parameter '%s' to be reference to a cell or range.`,e.name,(r+1).toString()));a.push(!s.acceptMatrix)}return r(Qa(i.bind(this),n,a))}function r(t){return Ta(t)?Xa(t,t=>ty(t,e.name)):ty(t,e.name),t}function i(...n){for(let e=0;e<n.length;e++){let r=n[e];if(!t[e].acceptErrors&&!Ta(r)&&M(r?.value))return r}try{return a.apply(this,n)}catch(t){return $v(t,e.name)}}function a(...t){this.debug&&=!1;let n=e.compute.apply(this,t);return Ta(n)?typeof n[0][0]==`object`&&n[0][0]!==null&&`value`in n[0][0]?n:Ya(n,e=>({value:e})):typeof n==`object`&&n&&`value`in n?n:(e.name,{value:n})}return n}function $v(e,t){return ey(e)&&M(e.value)?(ry(e)&&ty(e,t),e):(console.error(e),new j(ny+(ry(e)?` `+e.message:``)))}function ey(e){return e?.value!==void 0&&typeof e.value==`string`}function ty(e,t){e.message?.includes(`[[FUNCTION_NAME]]`)&&(e.message=e.message.replace(`[[FUNCTION_NAME]]`,t))}let ny=k(`An unexpected error occurred. Submit a support ticket at odoo.com/help.`);function ry(e){return e?.message!==void 0&&typeof e.message==`string`}function iy(e,t,n){if(Ta(e)){let r=n.decimalSeparator===`,`?`/`:`,`;return`{${Za(e).map(e=>e.map(e=>ay(e,t,n)).join(r)).join(`;`)}}`}return ay(e,t,n)}function ay(e,t,n){let r=e.value;switch(typeof r){case`number`:return z(r,{locale:n,format:e.format});case`string`:return M(r)?r:`"${r}"`;case`boolean`:return r?`TRUE`:`FALSE`}return t}var oy=l({ARRAYTOTEXT:()=>Fy,ARRAY_CONSTRAIN:()=>ly,ARRAY_LITERAL:()=>uy,ARRAY_ROW:()=>dy,CHOOSECOLS:()=>fy,CHOOSEROWS:()=>py,EXPAND:()=>my,FLATTEN:()=>hy,FREQUENCY:()=>gy,HSTACK:()=>_y,MDETERM:()=>vy,MINVERSE:()=>yy,MMULT:()=>by,SUMPRODUCT:()=>xy,SUMX2MY2:()=>Cy,SUMX2PY2:()=>wy,SUMXMY2:()=>Ty,TOCOL:()=>Oy,TOROW:()=>ky,TRANSPOSE:()=>Ay,VSTACK:()=>jy,WRAPCOLS:()=>My,WRAPROWS:()=>Ny});function sy(e,t){let n=e.map(L),r=n.map(e=>e?.[0]?.length??0),i=Math.max(...r);if(t?.requireSameRowCount){let e=r[0];if(r.some(t=>t!==e))return new j(k(`All ranges in [[FUNCTION_NAME]] must have the same number of columns (got %s).`,r.join(`, `)))}let a=[];for(let e of n)for(let t=0;t<e.length;t++){let n=Array(i).fill({value:null});for(let r=0;r<e[t].length;r++)n[r]=e[t][r];a.push(n)}return a}function cy(e,t){let n=e.map(L),r=n.map(e=>e?.length??0),i=Math.max(...r);if(t?.requireSameColCount){let e=r[0];if(r.some(t=>t!==e))return new j(k(`All ranges in [[FUNCTION_NAME]] must have the same number of columns (got %s).`,r.join(`, `)))}let a=Ja(i,n.reduce((e,t)=>e+(t?.[0]?.length??0),0),()=>({value:null})),o=0;for(let e of n){for(let t=0;t<e.length;t++)for(let n=0;n<e[t].length;n++)a[t][o+n]=e[t][n];o+=e[0]?.length??0}return a}let ly={description:k(`Returns a result array constrained to a specific width and height.`),args:[W(`input_range (any, range<any>)`,k(`The range to constrain.`)),W(`rows (number)`,k(`The number of rows in the constrained array.`)),W(`columns (number)`,k(`The number of columns in the constrained array.`))],compute:function(e,t,n){let r=L(e),i=Fa(t?.value,this.locale),a=Fa(n?.value,this.locale);if(i<=0)return new j(k(`The rows argument (%s) must be strictly positive.`,i.toString()));if(a<=0)return new j(k(`The columns argument (%s) must be strictly positive.`,a.toString()));let o=Math.min(i,r[0].length);return Ja(Math.min(a,r.length),o,(e,t)=>r[e][t])},isExported:!1},uy={description:k(`Appends ranges vertically and in sequence to return a larger array. All ranges must have the same number of columns.`),args:[W(`range (any, range<any>, repeating)`,k(`The range to be appended.`))],compute:function(...e){return cy(e,{requireSameColCount:!0})},isExported:!1,hidden:!0},dy={description:k(`Appends ranges horizontally and in sequence to return a larger array. All ranges must have the same number of rows.`),args:[W(`range (any, range<any>, repeating)`,k(`The range to be appended.`))],compute:function(...e){return sy(e,{requireSameRowCount:!0})},isExported:!1,hidden:!0},fy={description:k(`Creates a new array from the selected columns in the existing range.`),args:[W(`array (any, range<any>)`,k(`The array that contains the columns to be returned.`)),W(`col_num (number, range<number>, repeating)`,k(`The column index of the column to be returned.`))],compute:function(e,...t){let n=L(e),r=uo(t,e=>Fa(e?.value,this.locale)),i=r.filter(e=>e===0||n.length<Math.abs(e));if(i.length!==0)return new j(k(`The columns arguments must be between -%s and %s (got %s), excluding 0.`,n.length.toString(),n.length.toString(),i.join(`,`)));let a=Array(r.length);for(let e=0;e<r.length;e++)r[e]>0?a[e]=n[r[e]-1]:a[e]=n[n.length+r[e]];return a},isExported:!0},py={description:k(`Creates a new array from the selected rows in the existing range.`),args:[W(`array (any, range<any>)`,k(`The array that contains the rows to be returned.`)),W(`row_num (number, range<number>, repeating)`,k(`The row index of the row to be returned.`))],compute:function(e,...t){let n=L(e),r=uo(t,e=>Fa(e?.value,this.locale)),i=n.length,a=r.filter(e=>e===0||n[0].length<Math.abs(e));return a.length===0?Ja(i,r.length,(e,t)=>r[t]>0?n[e][r[t]-1]:n[e][n[e].length+r[t]]):new j(k(`The rows arguments must be between -%s and %s (got %s), excluding 0.`,n[0].length.toString(),n[0].length.toString(),a.join(`,`)))},isExported:!0},my={description:k(`Expands or pads an array to specified row and column dimensions.`),args:[W(`array (any, range<any>)`,k(`The array to expand.`)),W(`rows (number)`,k(`The number of rows in the expanded array. If missing, rows will not be expanded.`)),W(`columns (number, optional)`,k(`The number of columns in the expanded array. If missing, columns will not be expanded.`)),W(`pad_with (any, default=0)`,k(`The value with which to pad.`))],compute:function(e,t,n,r={value:0}){let i=L(e),a=Fa(t?.value,this.locale),o=n===void 0?i.length:Fa(n.value,this.locale);return a<i[0].length?new j(k(`The rows arguments (%s) must be greater or equal than the number of rows of the array.`,a.toString())):o<i.length?new j(k(`The columns arguments (%s) must be greater or equal than the number of columns of the array.`,o.toString())):Ja(o,a,(e,t)=>e>=i.length||t>=i[e].length?r:i[e][t])},isExported:!0},hy={description:k(`Flattens all the values from one or more ranges into a single column.`),args:[W(`range (any, range<any>, repeating)`,k(`The range to flatten.`))],compute:function(...e){return[uo(e,e=>e===void 0?{value:``}:e)]},isExported:!1},gy={description:k(`Calculates the frequency distribution of a range.`),args:[W(`data (range<number>)`,k(`The array of ranges containing the values to be counted.`)),W(`classes (number, range<number>)`,k(`The range containing the set of classes.`))],compute:function(e,t){let n=uo([e],e=>e.value).filter(e=>typeof e==`number`),r=uo([t],e=>e.value).filter(e=>typeof e==`number`).map((e,t)=>({initialIndex:t,value:e,count:0})).sort((e,t)=>e.value-t.value);r.push({initialIndex:r.length,value:1/0,count:0});let i=n.sort((e,t)=>e-t),a=0;for(let e of i){for(;e>r[a].value&&a<r.length-1;)a++;r[a].count++}return[r.sort((e,t)=>e.initialIndex-t.initialIndex).map(e=>e.count)]},isExported:!0},_y={description:k(`Appends ranges horizontally and in sequence to return a larger array.`),args:[W(`range (any, range<any>, repeating)`,k(`The range to be appended.`))],compute:function(...e){return sy(e)},isExported:!0},vy={description:k(`Returns the matrix determinant of a square matrix.`),args:[W(`square_matrix (number, range<number>)`,k(`An range with an equal number of rows and columns representing a matrix whose determinant will be calculated.`))],compute:function(e){let t=Na(e,`square_matrix`);return gm(t)?ym(t).determinant:new j(k(`The argument square_matrix must have the same number of columns and rows.`))},isExported:!0},yy={description:k(`Returns the multiplicative inverse of a square matrix.`),args:[W(`square_matrix (number, range<number>)`,k(`An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated.`))],compute:function(e){let t=Na(e,`square_matrix`);if(!gm(t))return new j(k(`The argument square_matrix must have the same number of columns and rows.`));let{inverted:n}=ym(t);return n||new j(k(`The matrix is not invertible.`))},isExported:!0},by={description:k(`Calculates the matrix product of two matrices.`),args:[W(`matrix1 (number, range<number>)`,k(`The first matrix in the matrix multiplication operation.`)),W(`matrix2 (number, range<number>)`,k(`The second matrix in the matrix multiplication operation.`))],compute:function(e,t){let n=Na(e,`matrix1`),r=Na(t,`matrix2`);return n.length===0||r.length===0?new j(k(`The first and second arguments of [[FUNCTION_NAME]] must be non-empty matrices.`)):n.length===r[0].length?xm(n,r):new j(k(`In [[FUNCTION_NAME]], the number of columns of the first matrix (%s) must be equal to the number of rows of the second matrix (%s).`,n.length.toString(),r[0].length.toString()))},isExported:!0},xy={description:k(`Calculates the sum of the products of corresponding entries in equal-sized ranges.`),args:[W(`range (number, range<number>, repeating)`,k(`The range whose entries will be multiplied with corresponding entries in the other range.`))],compute:function(...e){if(!hm(...e))return new j(k(`All the ranges must have the same dimensions.`));let t=e.map(L),n=0;for(let e=0;e<t[0].length;e++)for(let r=0;r<t[0][e].length;r++){if(!t.every(t=>typeof t[e][r].value==`number`))continue;let i=1;for(let n of t)i*=N(n[e][r],this.locale);n+=i}return n},isExported:!0};function Sy(e,t,n){if(!hm(e,t))return new j(k(`The arguments array_x and array_y must have the same dimensions.`));let r=L(e),i=L(t),a=!1,o=0;for(let e in r)for(let t in r[e]){let s=r[e][t].value,c=i[e][t].value;typeof s!=`number`||typeof c!=`number`||(a=!0,o+=n(s,c))}return a?o:new j(k(`The arguments array_x and array_y must contain at least one pair of numbers.`))}let Cy={description:k(`Calculates the sum of the difference of the squares of the values in two array.`),args:[W(`array_x (number, range<number>)`,k(`The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.`)),W(`array_y (number, range<number>)`,k(`The array or range of values whose squares will be subtracted from the squares of corresponding entries in array_x and added together.`))],compute:function(e,t){return Sy(e,t,(e,t)=>e**2-t**2)},isExported:!0},wy={description:k(`Calculates the sum of the sum of the squares of the values in two array.`),args:[W(`array_x (number, range<number>)`,k(`The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.`)),W(`array_y (number, range<number>)`,k(`The array or range of values whose squares will be added to the squares of corresponding entries in array_x and added together.`))],compute:function(e,t){return Sy(e,t,(e,t)=>e**2+t**2)},isExported:!0},Ty={description:k(`Calculates the sum of squares of the differences of values in two array.`),args:[W(`array_x (number, range<number>)`,k(`The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.`)),W(`array_y (number, range<number>)`,k(`The array or range of values that will be subtracted from corresponding entries in array_x, the result squared, and all such results added together.`))],compute:function(e,t){return Sy(e,t,(e,t)=>(e-t)**2)},isExported:!0},Ey=[W(`array (any, range<any>)`,k(`The array which will be transformed.`)),W(`ignore (number, default=0)`,k(`Whether to ignore certain types of values. By default, no values are ignored.`),[{value:0,label:k(`Keep all values (default)`)},{value:1,label:k(`Ignore blanks`)},{value:2,label:k(`Ignore errors`)},{value:3,label:k(`Ignore blanks and errors`)}]),W(`scan_by_column (number, default=false)`,k(`Scan the array by column. By default, the array is scanned by row.`),[{value:!1,label:k(`Scan by row (default)`)},{value:!0,label:k(`Scan by column`)}])];function Dy(e){let t=Math.trunc(e);if(t===0)return()=>!0;if(t===1)return e=>e.value!==null;if(t===2)return e=>!M(e.value);if(t===3)return e=>e.value!==null&&!M(e.value);throw new j(k(`Argument ignore must be between 0 and 3`))}let Oy={description:k(`Transforms a range of cells into a single column.`),args:Ey,compute:function(e,t={value:0},n={value:!1}){let r=L(e),i=N(t.value,this.locale),a=(F(n.value)?r:Za(r)).flat().filter(Dy(i));return a.length===0?new ya(k(`No results for the given arguments of TOCOL.`)):[a]},isExported:!0},ky={description:k(`Transforms a range of cells into a single row.`),args:Ey,compute:function(e,t={value:0},n={value:!1}){let r=L(e),i=N(t.value,this.locale),a=(F(n.value)?r:Za(r)).flat().filter(Dy(i)).map(e=>[e]);return a.length===0||a[0].length===0?new ya(k(`No results for the given arguments of TOROW.`)):a},isExported:!0},Ay={description:k(`Transposes the rows and columns of a range.`),args:[W(`range (any, range<any>)`,k(`The range to be transposed.`))],compute:function(e){let t=L(e),n=t[0].length,r=t.length;return Ja(n,r,(e,n)=>t[n][e])},isExported:!0},jy={description:k(`Appends ranges vertically and in sequence to return a larger array.`),args:[W(`range (any, range<any>, repeating)`,k(`The range to be appended.`))],compute:function(...e){return cy(e)},isExported:!0},My={description:k(`Wraps the provided row or column of cells by columns after a specified number of elements to form a new array.`),args:[W(`range (any, range<any>)`,k(`The range to wrap.`)),W(`wrap_count (number)`,k(`The maximum number of cells for each column, rounded down to the nearest whole number.`)),W(`pad_with (any, default=0)`,k(`The value with which to fill the extra cells in the range.`))],compute:function(e,t,n={value:0}){let r=L(e),i=Fa(t?.value,this.locale);if(!mm(r))return new j(k(`Argument range must be a single row or column.`));let a=r.flat();return Ja(Math.ceil(a.length/i),i,(e,t)=>{let r=e*i+t;return r<a.length?a[r]:n})},isExported:!0},Ny={description:k(`Wraps the provided row or column of cells by rows after a specified number of elements to form a new array.`),args:[W(`range (any, range<any>)`,k(`The range to wrap.`)),W(`wrap_count (number)`,k(`The maximum number of cells for each row, rounded down to the nearest whole number.`)),W(`pad_with (any, default=0)`,k(`The value with which to fill the extra cells in the range.`))],compute:function(e,t,n={value:0}){let r=L(e),i=Fa(t?.value,this.locale);if(!mm(r))return new j(k(`Argument range must be a single row or column.`));let a=r.flat();return Ja(i,Math.ceil(a.length/i),(e,t)=>{let r=t*i+e;return r<a.length?a[r]:n})},isExported:!0},Py=[{value:0,label:k(`Concise format\xA0(default)`)},{value:1,label:k(`Strict format`)}],Fy={description:k(`returns an array of text values from any specified range. It passes text values unchanged, and converts non-text values to text.`),args:[W(`array (range)`,k(`The array to convert into text`)),W(`format (number, default=0)`,k(`The format of the returned data.`),Py)],compute:function(e,t={value:0}){let n=N(t,this.locale),r=L(e);if(n===1)return iy(r,``,this.locale);if(n===0){let e=this.locale.decimalSeparator===`,`?`/`:`,`;return Za(r).flatMap(e=>e.map(e=>M(e.value)?e.value:P(e))).join(e)}else return new j(k(`Format must be 0 or 1`))},isExported:!0};var Iy=l({ABS:()=>Ry,ACOS:()=>zy,ACOSH:()=>By,ACOT:()=>Vy,ACOTH:()=>Hy,ASIN:()=>Uy,ASINH:()=>Wy,ATAN:()=>Gy,ATAN2:()=>Ky,ATANH:()=>qy,CEILING:()=>Jy,CEILING_MATH:()=>Xy,CEILING_PRECISE:()=>Zy,COS:()=>Qy,COSH:()=>$y,COT:()=>eb,COTH:()=>tb,COUNTBLANK:()=>nb,COUNTIF:()=>rb,COUNTIFS:()=>ib,COUNTUNIQUE:()=>ab,COUNTUNIQUEIFS:()=>ob,CSC:()=>sb,CSCH:()=>cb,DECIMAL:()=>lb,DEGREES:()=>ub,EXP:()=>db,FLOOR:()=>fb,FLOOR_MATH:()=>mb,FLOOR_PRECISE:()=>hb,INT:()=>Zb,ISEVEN:()=>gb,ISODD:()=>vb,ISO_CEILING:()=>_b,LN:()=>yb,LOG:()=>bb,MOD:()=>Sb,MUNIT:()=>Cb,ODD:()=>wb,PI:()=>Tb,POWER:()=>Eb,PRODUCT:()=>Db,RAND:()=>Ob,RANDARRAY:()=>kb,RANDBETWEEN:()=>Ab,ROUND:()=>jb,ROUNDDOWN:()=>Mb,ROUNDUP:()=>Nb,SEC:()=>Pb,SECH:()=>Fb,SEQUENCE:()=>Ib,SIN:()=>Lb,SINH:()=>Rb,SQRT:()=>zb,SUBTOTAL:()=>Ub,SUM:()=>Wb,SUMIF:()=>Gb,SUMIFS:()=>Kb,TAN:()=>qb,TANH:()=>Jb,TRUNC:()=>Xb});let Ly=/^-?[a-z0-9]+$/i,Ry={description:k(`Absolute value of a number.`),args:[W(`value (number)`,k(`The number of which to return the absolute value.`))],compute:function(e){return Math.abs(N(e,this.locale))},isExported:!0},zy={description:k(`Inverse cosine of a value, in radians.`),args:[W(`value (number)`,k(`The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.`))],compute:function(e){let t=N(e,this.locale);return Math.abs(t)>1?new j(k(`The value (%s) must be between -1 and 1 inclusive.`,t)):Math.acos(t)},isExported:!0},By={description:k(`Inverse hyperbolic cosine of a number.`),args:[W(`value (number)`,k(`The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.`))],compute:function(e){let t=N(e,this.locale);return t<1?new j(k(`The value (%s) must be greater than or equal to 1.`,t)):Math.acosh(t)},isExported:!0},Vy={description:k(`Inverse cotangent of a value.`),args:[W(`value (number)`,k(`The value for which to calculate the inverse cotangent.`))],compute:function(e){let t=N(e,this.locale);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},Hy={description:k(`Inverse hyperbolic cotangent of a value.`),args:[W(`value (number)`,k(`The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.`))],compute:function(e){let t=N(e,this.locale);return Math.abs(t)<=1?new j(k(`The value (%s) cannot be between -1 and 1 inclusive.`,t)):Math.log((t+1)/(t-1))/2},isExported:!0},Uy={description:k(`Inverse sine of a value, in radians.`),args:[W(`value (number)`,k(`The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.`))],compute:function(e){let t=N(e,this.locale);return Math.abs(t)>1?new j(k(`The value (%s) must be between -1 and 1 inclusive.`,t)):Math.asin(t)},isExported:!0},Wy={description:k(`Inverse hyperbolic sine of a number.`),args:[W(`value (number)`,k(`The value for which to calculate the inverse hyperbolic sine.`))],compute:function(e){return Math.asinh(N(e,this.locale))},isExported:!0},Gy={description:k(`Inverse tangent of a value, in radians.`),args:[W(`value (number)`,k(`The value for which to calculate the inverse tangent.`))],compute:function(e){return Math.atan(N(e,this.locale))},isExported:!0},Ky={description:k(`Angle from the X axis to a point (x,y), in radians.`),args:[W(`x (number)`,k(`The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.`)),W(`y (number)`,k(`The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.`))],compute:function(e,t){let n=N(e,this.locale),r=N(t,this.locale);return n===0&&r===0?new Sa(k(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):Math.atan2(r,n)},isExported:!0},qy={description:k(`Inverse hyperbolic tangent of a number.`),args:[W(`value (number)`,k(`The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.`))],compute:function(e){let t=N(e,this.locale);return Math.abs(t)>=1?new j(k(`The value (%s) must be between -1 and 1 exclusive.`,t)):Math.atanh(t)},isExported:!0},Jy={description:k(`Rounds number up to nearest multiple of factor.`),args:[W(`value (number)`,k(`The value to round up to the nearest integer multiple of factor.`)),W(`factor (number, default=1)`,k(`The number to whose multiples value will be rounded.`))],compute:function(e,t={value:1}){let n=N(e,this.locale),r=N(t,this.locale);return r<0&&n>0?new j(k(`The factor (%s) must be positive when the value (%s) is positive.`,r,n)):{value:r?Math.ceil(n/r)*r:0,format:e?.format}},isExported:!0};function Yy(e,t,n=0){return t===0?0:(t=Math.abs(t),e>=0?Math.ceil(e/t)*t:n===0?-Math.floor(Math.abs(e)/t)*t:-Math.ceil(Math.abs(e)/t)*t)}let Xy={description:k(`Rounds number up to nearest multiple of factor.`),args:[W(`number (number)`,k(`The value to round up to the nearest integer multiple of significance.`)),W(`significance (number, default=1)`,k(`The number to whose multiples number will be rounded. The sign of significance will be ignored.`)),W(`mode (number, default=0)`,k(`If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero.`))],compute:function(e,t={value:1},n={value:0}){let r=N(t,this.locale);return{value:Yy(N(e,this.locale),r,N(n,this.locale)),format:e?.format}},isExported:!0},Zy={description:k(`Rounds number up to nearest multiple of factor.`),args:[W(`number (number)`,k(`The value to round up to the nearest integer multiple of significance.`)),W(`significance (number, default=1)`,k(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){let n=N(t,this.locale);return{value:Yy(N(e,this.locale),n),format:e?.format}},isExported:!0},Qy={description:k(`Cosine of an angle provided in radians.`),args:[W(`angle (number)`,k(`The angle to find the cosine of, in radians.`))],compute:function(e){return Math.cos(N(e,this.locale))},isExported:!0},$y={description:k(`Hyperbolic cosine of any real number.`),args:[W(`value (number)`,k(`Any real value to calculate the hyperbolic cosine of.`))],compute:function(e){return Math.cosh(N(e,this.locale))},isExported:!0},eb={description:k(`Cotangent of an angle provided in radians.`),args:[W(`angle (number)`,k(`The angle to find the cotangent of, in radians.`))],compute:function(e){let t=N(e,this.locale);return t===0?new Sa(k(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):1/Math.tan(t)},isExported:!0},tb={description:k(`Hyperbolic cotangent of any real number.`),args:[W(`value (number)`,k(`Any real value to calculate the hyperbolic cotangent of.`))],compute:function(e){let t=N(e,this.locale);return t===0?new Sa(k(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):1/Math.tanh(t)},isExported:!0},nb={description:k(`Number of empty values.`),args:[W(`value (any, range, repeating)`,k(`Value or range in which to count the number of blanks.`))],compute:function(...e){return Ga(e,(e,t)=>t===void 0||t.value===null||t.value===``?e+1:e,0)},isExported:!0},rb={description:k(`A conditional count across a range.`),args:[W(`range (range)`,k(`The range that is tested against criterion.`)),W(`criterion (string)`,k(`The pattern or test to apply to range.`))],compute:function(...e){let t=0;return io(e,(e,n)=>{t+=1},this.locale),t},isExported:!0},ib={description:k(`Count values depending on multiple criteria.`),args:[W(`criteria_range (any, range, repeating)`,k(`Range over which to evaluate criteria.`)),W(`criterion (string, repeating)`,k(`Criteria to check.`))],compute:function(...e){let t=0;return io(e,(e,n)=>{t+=1},this.locale),t},isExported:!0},ab={description:k(`Counts number of unique values in a range.`),args:[W(`value (any, range, repeating)`,k(`Value or range to consider for uniqueness.`))],compute:function(...e){return Ym(e)}},ob={description:k(`Counts number of unique values in a range, filtered by a set of criteria.`),args:[W(`range (range)`,k(`The range of cells from which the number of unique values will be counted.`)),W(`criteria_range (any, range, repeating)`,k(`Range over which to evaluate criteria.`)),W(`criterion (string, repeating)`,k(`Criteria to check.`))],compute:function(e,...t){let n=new Set;return io(t,(t,r)=>{let i=e[t]?.[r];fo(i)&&n.add(i.value)},this.locale),n.size}},sb={description:k(`Cosecant of an angle provided in radians.`),args:[W(`angle (number)`,k(`The angle to find the cosecant of, in radians.`))],compute:function(e){let t=N(e,this.locale);return t===0?new Sa(k(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):1/Math.sin(t)},isExported:!0},cb={description:k(`Hyperbolic cosecant of any real number.`),args:[W(`value (number)`,k(`Any real value to calculate the hyperbolic cosecant of.`))],compute:function(e){let t=N(e,this.locale);return t===0?new Sa(k(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):1/Math.sinh(t)},isExported:!0},lb={description:k(`Converts from another base to decimal.`),args:[W(`value (string)`,k(`The number to convert.`)),W(`base (number)`,k(`The base to convert the value from.`))],compute:function(e,t){let n=N(t,this.locale);if(n=Math.floor(n),2>n||n>36)return new j(k(`The base (%s) must be between 2 and 36 inclusive.`,n));let r=P(e);if(r===``)return 0;if(!Ly.test(r))return new j(k(`The value (%s) must be a valid base %s representation.`,r,n));let i=parseInt(r,n);return isNaN(i)?new j(k(`The value (%s) must be a valid base %s representation.`,r,n)):i},isExported:!0},ub={description:k(`Converts an angle value in radians to degrees.`),args:[W(`angle (number)`,k(`The angle to convert from radians to degrees.`))],compute:function(e){return N(e,this.locale)*180/Math.PI},isExported:!0},db={description:k(`Euler's number, e (~2.718) raised to a power.`),args:[W(`value (number)`,k(`The exponent to raise e.`))],compute:function(e){return Math.exp(N(e,this.locale))},isExported:!0},fb={description:k(`Rounds number down to nearest multiple of factor.`),args:[W(`value (number)`,k(`The value to round down to the nearest integer multiple of factor.`)),W(`factor (number, default=1)`,k(`The number to whose multiples value will be rounded.`))],compute:function(e,t={value:1}){let n=N(e,this.locale),r=N(t,this.locale);return r<0&&n>0?new j(k(`The factor (%s) must be positive when the value (%s) is positive.`,r,n)):{value:r?Math.floor(n/r)*r:0,format:e?.format}},isExported:!0};function pb(e,t,n=0){return t===0?0:(t=Math.abs(t),e>=0?Math.floor(e/t)*t:n===0?-Math.ceil(Math.abs(e)/t)*t:-Math.floor(Math.abs(e)/t)*t)}let mb={description:k(`Rounds number down to nearest multiple of factor.`),args:[W(`number (number)`,k(`The value to round down to the nearest integer multiple of significance.`)),W(`significance (number, default=1)`,k(`The number to whose multiples number will be rounded. The sign of significance will be ignored.`)),W(`mode (number, default=0)`,k(`If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero.`))],compute:function(e,t={value:1},n={value:0}){let r=N(t,this.locale);return{value:pb(N(e,this.locale),r,N(n,this.locale)),format:e?.format}},isExported:!0},hb={description:k(`Rounds number down to nearest multiple of factor.`),args:[W(`number (number)`,k(`The value to round down to the nearest integer multiple of significance.`)),W(`significance (number, default=1)`,k(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){let n=N(t,this.locale);return{value:pb(N(e,this.locale),n),format:e?.format}},isExported:!0},gb={description:k(`Whether the provided value is even.`),args:[W(`value (number)`,k(`The value to be verified as even.`))],compute:function(e){let t=Pa(e,this.locale);return!(Math.floor(Math.abs(t))&1)},isExported:!0},_b={description:k(`Rounds number up to nearest multiple of factor.`),args:[W(`number (number)`,k(`The value to round up to the nearest integer multiple of significance.`)),W(`significance (number, default=1)`,k(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){return{value:Yy(N(e,this.locale),N(t,this.locale)),format:e?.format}},isExported:!0},vb={description:k(`Whether the provided value is even.`),args:[W(`value (number)`,k(`The value to be verified as even.`))],compute:function(e){let t=Pa(e,this.locale);return!!(Math.floor(Math.abs(t))&1)},isExported:!0},yb={description:k(`The logarithm of a number, base e (euler's number).`),args:[W(`value (number)`,k(`The value for which to calculate the logarithm, base e.`))],compute:function(e){let t=N(e,this.locale);return t<=0?new j(k(`The value (%s) must be strictly positive.`,t)):Math.log(t)},isExported:!0},bb={description:k(`The logarithm of a number, for a given base.`),args:[W(`value (number)`,k(`The value for which to calculate the logarithm.`)),W(`base (number, default=10)`,k(`The base of the logarithm.`))],compute:function(e,t={value:10}){let n=N(e,this.locale),r=N(t,this.locale);return n<=0?new j(k(`The value (%s) must be strictly positive.`,n)):r<=0?new j(k(`The base (%s) must be strictly positive.`,r)):r===1?new j(k(`The base must be different from 1.`)):Math.log10(n)/Math.log10(r)},isExported:!0};function xb(e,t){pm(t,k(`The divisor must be different from 0.`));let n=e%t;return n>0&&t<0||n<0&&t>0?n+t:n}let Sb={description:k(`Modulo (remainder) operator.`),args:[W(`dividend (number)`,k(`The number to be divided to find the remainder.`)),W(`divisor (number)`,k(`The number to divide by.`))],compute:function(e,t){let n=N(t,this.locale);return{value:xb(N(e,this.locale),n),format:e?.format}},isExported:!0},Cb={description:k(`Returns a n x n unit matrix, where n is the input dimension.`),args:[W(`dimension (number)`,k(`An integer specifying the dimension size of the unit matrix. It must be positive.`))],compute:function(e){let t=Fa(e,this.locale);return t<1?new j(k(`The argument dimension must be positive`)):vm(t)},isExported:!0},wb={description:k(`Rounds a number up to the nearest odd integer.`),args:[W(`value (number)`,k(`The value to round to the next greatest odd number.`))],compute:function(e){let t=N(e,this.locale),n=Math.ceil(Math.abs(t));return n=n&1?n:n+1,{value:t<0?-n:n,format:e?.format}},isExported:!0},Tb={description:k(`The number pi.`),args:[],compute:function(){return Math.PI},isExported:!0},Eb={description:k(`A number raised to a power.`),args:[W(`base (number)`,k(`The number to raise to the exponent power.`)),W(`exponent (number)`,k(`The exponent to raise base to.`))],compute:function(e,t){let n=N(e,this.locale),r=N(t,this.locale);return n<0&&!Number.isInteger(r)?new j(k(`The exponent (%s) must be an integer when the base is negative.`,r)):{value:n**+r,format:e?.format}},isExported:!0},Db={description:k(`Result of multiplying a series of numbers together.`),args:[W(`factor (number, range<number>, repeating)`,k(`Number or range to calculate for the product.`))],compute:function(...e){let t=0,n=1;for(let r of e)if(Ta(r))for(let e of r)for(let r of e){let e=r.value;if(typeof e==`number`&&(n*=e,t+=1),M(e))return r}else r!==void 0&&r.value!==null&&(n*=Pa(r,this.locale),t+=1);return{value:t===0?0:n,format:Da(e[0])}},isExported:!0},Ob={description:k(`A random number between 0 inclusive and 1 exclusive.`),args:[],compute:function(){return Math.random()},isExported:!0},kb={description:k(`Returns a grid of random numbers between 0 inclusive and 1 exclusive.`),args:[W(`rows (number, default=1)`,k(`The number of rows to be returned.`)),W(`columns (number, default=1)`,k(`The number of columns to be returned.`)),W(`min (number, default=0)`,k(`The minimum number you would like returned.`)),W(`max (number, default=1)`,k(`The maximum number you would like returned.`)),W(`whole_number (boolean, default=FALSE)`,k(`Return a whole number or a decimal value.`),[{value:!1,label:k(`Decimal (default)`)},{value:!0,label:k(`Integer`)}])],compute:function(e={value:1},t={value:1},n={value:0},r={value:1},i={value:!1}){let a=Fa(t,this.locale),o=Fa(e,this.locale),s=N(n,this.locale),c=N(r,this.locale),l=F(i);if(a<1)return new j(k(`The number of columns (%s) must be positive.`,a));if(o<1)return new j(k(`The number of rows (%s) must be positive.`,o));if(s>c)return new j(k(`The maximum (%s) must be greater than or equal to the minimum (%s).`,c,s));if(l&&(!Number.isInteger(s)||!Number.isInteger(c)))return new j(k(`The maximum (%s) and minimum (%s) must be integers when whole_number is TRUE.`,c.toString(),s.toString()));let u=Array(a);for(let e=0;e<a;e++){u[e]=Array(o);for(let t=0;t<o;t++)l?u[e][t]=Math.floor(Math.random()*(c-s+1)+s):u[e][t]=s+Math.random()*(c-s)}return u},isExported:!0},Ab={description:k(`Random integer between two values, inclusive.`),args:[W(`low (number)`,k(`The low end of the random range.`)),W(`high (number)`,k(`The high end of the random range.`))],compute:function(e,t){let n=N(e,this.locale);Number.isInteger(n)||(n=Math.ceil(n));let r=N(t,this.locale);return Number.isInteger(r)||(r=Math.floor(r)),n>r?new j(k(`The high (%s) must be greater than or equal to the low (%s).`,r,n)):{value:n+Math.ceil((r-n+1)*Math.random())-1,format:e?.format}},isExported:!0},jb={description:k(`Rounds a number according to standard rules.`),args:[W(`value (number)`,k(`The value to round to places number of places.`)),W(`places (number, default=0)`,k(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=N(e,this.locale),r=N(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.round(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.round(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},Mb={description:k(`Rounds down a number.`),args:[W(`value (number)`,k(`The value to round to places number of places, always rounding down.`)),W(`places (number, default=0)`,k(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=N(e,this.locale),r=N(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.floor(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.floor(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},Nb={description:k(`Rounds up a number.`),args:[W(`value (number)`,k(`The value to round to places number of places, always rounding up.`)),W(`places (number, default=0)`,k(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=N(e,this.locale),r=N(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.ceil(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.ceil(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},Pb={description:k(`Secant of an angle provided in radians.`),args:[W(`angle (number)`,k(`The angle to find the secant of, in radians.`))],compute:function(e){return 1/Math.cos(N(e,this.locale))},isExported:!0},Fb={description:k(`Hyperbolic secant of any real number.`),args:[W(`value (number)`,k(`Any real value to calculate the hyperbolic secant of.`))],compute:function(e){return 1/Math.cosh(N(e,this.locale))},isExported:!0},Ib={description:k(`Returns a sequence of numbers.`),args:[W(`rows (number)`,k(`The number of rows to return`)),W(`columns (number, optional, default=1)`,k(`The number of columns to return`)),W(`start (number, optional, default=1)`,k(`The first number in the sequence`)),W(`step (number, optional, default=1)`,k(`The amount to increment each value in the sequence`))],compute:function(e,t={value:1},n={value:1},r={value:1}){let i=N(n,this.locale),a=N(r,this.locale),o=Fa(e,this.locale),s=Fa(t,this.locale);return s<1?new j(k(`The number of columns (%s) must be positive.`,s)):o<1?new j(k(`The number of rows (%s) must be positive.`,o)):Ja(s,o,(e,t)=>({value:i+t*s*a+e*a}))},isExported:!0},Lb={description:k(`Sine of an angle provided in radians.`),args:[W(`angle (number)`,k(`The angle to find the sine of, in radians.`))],compute:function(e){return Math.sin(N(e,this.locale))},isExported:!0},Rb={description:k(`Hyperbolic sine of any real number.`),args:[W(`value (number)`,k(`Any real value to calculate the hyperbolic sine of.`))],compute:function(e){return Math.sinh(N(e,this.locale))},isExported:!0},zb={description:k(`Positive square root of a positive number.`),args:[W(`value (number)`,k(`The number for which to calculate the positive square root.`))],compute:function(e){let t=N(e,this.locale);return t<0?new j(k(`The value (%s) must be positive or null.`,t)):{value:Math.sqrt(t),format:e?.format}},isExported:!0},Bb={1:`AVERAGE`,2:`COUNT`,3:`COUNTA`,4:`MAX`,5:`MIN`,6:`PRODUCT`,7:`STDEV`,8:`STDEVP`,9:`SUM`,10:`VAR`,11:`VARP`},Vb=Object.entries(Bb).map(([e,t])=>({value:parseInt(e),label:k(`%s (include manually-hidden rows)`,t)})),Hb=Object.entries(Bb).map(([e,t])=>({value:parseInt(e)+100,label:k(`%s (exclude manually-hidden rows)`,t)})),Ub={description:k(`Returns a subtotal for a vertical range of cells using a specified aggregation function.`),args:[W(`function_code (number)`,k(`The function to use in subtotal aggregation.`),[...Vb,...Hb]),W(`ref (meta, range<meta>, repeating)`,k(`Range or reference for which you want the subtotal.`))],compute:function(e,...t){let n=Fa(e,this.locale),r=!0;if(n>100&&(n-=100,r=!1),n<1||n>11)return new j(k(`The function code (%s) must be between 1 to 11 or 101 to 111.`,n));let i=[];for(let e of t){let t=e[0][0],n=zc(t.value).sheetName,a=n?this.getters.getSheetIdByName(n):this.__originSheetId;if(!a)continue;let{top:o,left:s}=mn(t.value),c=s+e.length-1,l=o+e[0].length-1;for(let e=o;e<=l;e++)if(!this.getters.isRowFiltered(a,e)&&!(!r&&this.getters.isRowHiddenByUser(a,e)))for(let t=s;t<=c;t++){let n=this.getters.getCorrespondingFormulaCell({sheetId:a,col:t,row:e});(!n||!Gt(n,`SUBTOTAL`))&&i.push(this.getters.getEvaluatedCell({sheetId:a,col:t,row:e}))}}return this[Bb[n]].apply(this,[[i]])},isExported:!0},Wb={description:k(`Sum of a series of numbers and/or cells.`),args:[W(`value (number, range<number>, repeating)`,k(`Number or range to add together.`))],compute:function(...e){let t=e[0];return{value:Jm(e,this.locale),format:Da(t)}},isExported:!0},Gb={description:k(`A conditional sum across a range.`),args:[W(`criteria_range (range)`,k(`The range which is tested against criterion.`)),W(`criterion (string)`,k(`The pattern or test to apply to range.`)),W(`sum_range (range, default=criteria_range)`,k(`The range to be summed, if different from range.`))],compute:function(e,t,n){n===void 0&&(n=e);let r=0;return io([e,t],(e,t)=>{let i=n[e]?.[t]?.value;typeof i==`number`&&(r+=i)},this.locale),r},isExported:!0},Kb={description:k(`Sums a range depending on multiple criteria.`),args:[W(`sum_range (range)`,k(`The range to sum.`)),W(`criteria_range (any, range, repeating)`,k(`Range to check.`)),W(`criterion (string, repeating)`,k(`Criteria to check.`))],compute:function(e,...t){let n=0;return io(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n+=i)},this.locale),n},isExported:!0},qb={description:k(`Tangent of an angle provided in radians.`),args:[W(`angle (number)`,k(`The angle to find the tangent of, in radians.`))],compute:function(e){return Math.tan(N(e,this.locale))},isExported:!0},Jb={description:k(`Hyperbolic tangent of any real number.`),args:[W(`value (number)`,k(`Any real value to calculate the hyperbolic tangent of.`))],compute:function(e){return Math.tanh(N(e,this.locale))},isExported:!0};function Yb(e,t){return t===0?Math.trunc(e):(Number.isInteger(t)||(t=Math.trunc(t)),Math.trunc(e*10**t)/10**t)}let Xb={description:k(`Truncates a number.`),args:[W(`value (number)`,k(`The value to be truncated.`)),W(`places (number, default=0)`,k(`The number of significant digits to the right of the decimal point to retain.`))],compute:function(e,t={value:0}){return{value:Yb(N(e,this.locale),N(t,this.locale)),format:e?.format}},isExported:!0},Zb={description:k(`Rounds a number down to the nearest integer that is less than or equal to it.`),args:[W(`value (number)`,k(`The number to round down to the nearest integer.`))],compute:function(e){return Math.floor(N(e,this.locale))},isExported:!0};var Qb=l({AVEDEV:()=>cx,AVERAGE:()=>lx,AVERAGEA:()=>px,AVERAGEIF:()=>mx,AVERAGEIFS:()=>hx,AVERAGE_WEIGHTED:()=>fx,CORREL:()=>Lx,COUNT:()=>gx,COUNTA:()=>_x,COVAR:()=>vx,COVARIANCE_P:()=>yx,COVARIANCE_S:()=>bx,FORECAST:()=>xx,GROWTH:()=>Sx,INTERCEPT:()=>Cx,LARGE:()=>wx,LINEST:()=>Tx,LOGEST:()=>Ex,MATTHEWS:()=>Dx,MAX:()=>Ox,MAXA:()=>kx,MAXIFS:()=>Ax,MEDIAN:()=>jx,MIN:()=>Mx,MINA:()=>Nx,MINIFS:()=>Px,PEARSON:()=>Ix,PERCENTILE:()=>Rx,PERCENTILE_EXC:()=>zx,PERCENTILE_INC:()=>Bx,POLYFIT_COEFFS:()=>Vx,POLYFIT_FORECAST:()=>Hx,QUARTILE:()=>Ux,QUARTILE_EXC:()=>Wx,QUARTILE_INC:()=>Gx,RANK:()=>Kx,RSQ:()=>qx,SLOPE:()=>Jx,SMALL:()=>Yx,SPEARMAN:()=>Xx,STDEV:()=>Zx,STDEVA:()=>eS,STDEVP:()=>tS,STDEVPA:()=>nS,STDEV_P:()=>Qx,STDEV_S:()=>$x,STEYX:()=>rS,TREND:()=>iS,VAR:()=>aS,VARA:()=>cS,VARP:()=>lS,VARPA:()=>uS,VAR_P:()=>oS,VAR_S:()=>sS});let $b=[{value:!0,label:k(`b is calculated normally`)},{value:!1,label:k(`b is forced to 1`)}],ex=[{value:!1,label:k(`do not return additional regression statistics`)},{value:!0,label:k(`return additional regression statistics`)}],tx=[{value:1,label:k(`order 1 (Linear)`)},{value:2,label:k(`order 2 (Quadratic)`)},{value:3,label:k(`order 3 (Cubic)`)},{value:4,label:k(`order 4 (Quartic)`)},{value:5,label:k(`order 5 (Quintic)`)},{value:6,label:k(`order 6 (Sextic)`)}],nx=[{value:!0,label:k(`Compute intercept`)},{value:!1,label:k(`Force intercept to 0`)}],rx=[{value:0,label:k(`Minimum value`)},{value:1,label:k(`First quartile (25th percentile)`)},{value:2,label:k(`Median value (50th percentile)`)},{value:3,label:k(`Third quartile (75th percentile)`)},{value:4,label:k(`Maximum value`)}];function ix(e,t){let n=[],r=[],i=0,a=0;Ha([e],e=>{n.push(e),i+=1}),Ha([t],e=>{r.push(e),a+=1}),fm(i===a,k(`[[FUNCTION_NAME]] has mismatched argument count %s vs %s.`,i,a));let o=[],s=[];for(let e=0;e<i;e++){let t=n[e]?.value,i=r[e]?.value;typeof t==`number`&&typeof i==`number`&&(s.push(t),o.push(i))}return{flatDataX:o,flatDataY:s}}function ax(e,t,n){let{flatDataX:r,flatDataY:i}=ix(e,t),a=i.length;pm(a),n&&pm(a-1);let o=0,s=0;for(let e=0;e<a;e++)o+=i[e],s+=r[e];let c=o/a,l=s/a,u=0;for(let e=0;e<a;e++)u+=(i[e]-c)*(r[e]-l);return u/(a-+!!n)}function ox(e,t,n,r){let i=0,a=n?qa:Ka,o=a(e,(e,t)=>(i+=1,e+t),0,r);pm(i),t&&pm(i-1);let s=o/i;return a(e,(e,t)=>e+(t-s)**2,0,r)/(i-+!!t)}function sx(e,t,n,r){let i=N(t,r);fm(n?0<=i&&i<=1:0<i&&i<1,k(`Function [[FUNCTION_NAME]] parameter 2 value is out of range.`));let a=[],o,s=0;return Ha(e,e=>{let t=e?.value;typeof t==`number`&&(o=ao(a,e,`nextSmaller`,`asc`,a.length,(e,t)=>e[t]),a.splice(o+1,0,t),s++)}),fm(s!==0,po),n||fm(1/(s+1)<=i&&i<=s/(s+1),k(`Function [[FUNCTION_NAME]] parameter 2 value is out of range.`)),oa(a,i,n)}let cx={description:k(`Average magnitude of deviations from mean.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the sample.`))],compute:function(...e){let t=0,n=Ka(e,(e,n)=>(t+=1,e+n),0,this.locale);if(t===0)return new Sa(k(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`));let r=n/t;return Ka(e,(e,t)=>e+Math.abs(r-t),0,this.locale)/t},isExported:!0},lx={description:k(`Numerical average value in a dataset, ignoring text.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to consider when calculating the average value.`))],compute:function(...e){return{value:Em(e,this.locale),format:Da(e[0])}},isExported:!0},ux=k(`[[FUNCTION_NAME]] has mismatched range sizes.`),dx=k(`[[FUNCTION_NAME]] expects the weight to be positive or equal to 0.`),fx={description:k(`Weighted average.`),args:[W(`values (number, range<number>, repeating)`,k(`Value to average.`)),W(`weights (number, range<number>, repeating)`,k(`Weight for each corresponding value.`))],compute:function(...e){let t=0,n=0;for(let r=0;r<e.length-1;r+=2){let i=e[r],a=e[r+1];if(!hm(i,a))return new j(ux);if(Ta(i))for(let e=0;e<i.length;e++)for(let r=0;r<i[0].length;r++){let o=i[e][r].value,s=Ta(a)?a?.[e][r].value:N(a,this.locale),c=typeof o==`number`,l=typeof s==`number`;if(c&&l){if(s<0)return new j(dx);t+=o*s,n+=s;continue}if(c!==l)return new j(k(`[[FUNCTION_NAME]] expects number values.`))}else{let e=N(i,this.locale),r=Ta(a)?a?.[0][0].value:N(a,this.locale);if(typeof r==`number`){if(r<0)return new j(dx);t+=e*r,n+=r}}}return n===0?new Sa(k(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:t/n,format:Da(e[0])}}},px={description:k(`Numerical average value in a dataset.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to consider when calculating the average value.`))],compute:function(...e){let t=0,n=qa(e,(e,n)=>(t+=1,e+n),0,this.locale);return t===0?new Sa(k(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:n/t,format:Da(e[0])}},isExported:!0},mx={description:k(`Average of values depending on criteria.`),args:[W(`criteria_range (number, range<number>)`,k(`The range to check against criterion.`)),W(`criterion (string)`,k(`The pattern or test to apply to criteria_range.`)),W(`average_range (number, range<number>, default=criteria_range)`,k(`The range to average. If not included, criteria_range is used for the average instead.`))],compute:function(e,t,n){let r=L(n===void 0?e:n),i=0,a=0;return io([e,t],(e,t)=>{let n=r[e]?.[t]?.value;typeof n==`number`&&(i+=1,a+=n)},this.locale),i===0?new Sa(k(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):a/i},isExported:!0},hx={description:k(`Average of values depending on multiple criteria.`),args:[W(`average_range (range)`,k(`The range to average.`)),W(`criteria_range (any, range, repeating)`,k(`Range to check.`)),W(`criterion (string, repeating)`,k(`Criterion to check.`))],compute:function(e,...t){let n=L(e),r=0,i=0;return io(t,(e,t)=>{let a=n[e]?.[t]?.value;typeof a==`number`&&(r+=1,i+=a)},this.locale),r===0?new Sa(k(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):i/r},isExported:!0},gx={description:k(`The number of numeric values in dataset.`),args:[W(`value (number, any, range<number>, repeating)`,k(`Value or range to consider when counting.`))],compute:function(...e){return Dm(e,this.locale)},isExported:!0},_x={description:k(`The number of values in a dataset.`),args:[W(`value (any, range, repeating)`,k(`Value or range to consider when counting.`))],compute:function(...e){return Om(e)},isExported:!0},vx={description:k(`The covariance of a dataset.`),args:[W(`data_y (any, range)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (any, range)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return ax(e,t,!1)},isExported:!0},yx={description:k(`The covariance of a dataset.`),args:[W(`data_y (any, range)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (any, range)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return ax(e,t,!1)},isExported:!0},bx={description:k(`The sample covariance of a dataset.`),args:[W(`data_y (any, range)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (any, range)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return ax(e,t,!0)},isExported:!0},xx={description:k(`Calculates the expected y-value for a specified x based on a linear regression of a dataset.`),args:[W(`x (number, range<number>)`,k(`The value(s) on the x-axis to forecast.`)),W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t,n){let{flatDataX:r,flatDataY:i}=ix(t,n);return r.length===0||i.length===0?new ya(po):Rm([i],[r],Ya(L(e),e=>N(e,this.locale)),!0)},isExported:!0},Sx={description:k(`Fits points to exponential growth trend.`),args:[W(`known_data_y (range<number>)`,k(`The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.`)),W(`known_data_x (range<number>, default={1;2;3;...})`,k(`The values of the independent variable(s) corresponding with known_data_y.`)),W(`new_data_x (any, range, default=known_data_x)`,k(`The data points to return the y values for on the ideal curve fit.`)),W(`b (boolean, default=TRUE)`,k(`Given a general exponential form of y = b*m^x for a curve fit, calculates b if TRUE or forces b to be 1 and only calculates the m values if FALSE.`),$b)],compute:function(e,t=[[]],n=[[]],r={value:!0}){return e.length===0||e[0].length===0?new j(mo(`known_data_y`)):Im(Rm(Lm(Na(e,`known_data_y`)),Na(t,`known_data_x`),Na(n,`new_data_y`),F(r)))}},Cx={description:k(`Compute the intercept of the linear regression.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=ix(e,t);if(n.length===0||r.length===0)return new ya(po);let[[],[i]]=Mm([n],[r]);return i},isExported:!0},wx={description:k(`Nth largest element from a data set.`),args:[W(`data (any, range)`,k(`Array or range containing the dataset to consider.`)),W(`n (number)`,k(`The rank from largest to smallest of the element to return.`))],compute:function(e,t){let n=Math.trunc(N(t?.value,this.locale)),r=[],i,a=0;Ha([e],e=>{typeof e?.value==`number`&&(i=ao(r,e,`nextSmaller`,`asc`,r.length,(e,t)=>e[t].value),r.splice(i+1,0,e),a++,a>n&&(r.shift(),a--))});let o=r.shift();return o===void 0?new j(po):a<n?new j(k(`Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.`,n)):o},isExported:!0},Tx={description:k(`Given partial data about a linear trend, calculates various parameters about the ideal linear trend using the least-squares method.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>, default={1;2;3;...})`,k(`The range representing the array or matrix of independent data.`)),W(`calculate_b (boolean, default=TRUE)`,k(`A flag specifying whether to compute the slope or not`),$b),W(`verbose (boolean, default=FALSE)`,k(`A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept`),ex)],compute:function(e,t=[[]],n={value:!0},r={value:!1}){return e.length===0||e[0].length===0?new j(mo(`data_y`)):Mm(Na(t,`data_x`),Na(e,`data_y`),F(n),F(r))},isExported:!0},Ex={description:k(`Given partial data about an exponential growth curve, calculates various parameters about the best fit ideal exponential growth curve.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>, optional, default={1;2;3;...})`,k(`The range representing the array or matrix of independent data.`)),W(`calculate_b (boolean, default=TRUE)`,k(`A flag specifying whether to compute the slope or not`),$b),W(`verbose (boolean, default=FALSE)`,k(`A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept`),ex)],compute:function(e,t=[[]],n={value:!0},r={value:!1}){if(e.length===0||e[0].length===0)return new j(mo(`data_y`));let i=Mm(Na(t,`data_x`),Lm(Na(e,`data_y`)),F(n),F(r));for(let e=0;e<i.length;e++)i[e][0]=Math.exp(i[e][0]);return i},isExported:!0},Dx={description:k(`Compute the Matthews correlation coefficient of a dataset.`),args:[W(`data_x (range)`,k(`The range representing the array or matrix of observed data.`)),W(`data_y (range)`,k(`The range representing the array or matrix of predicted data.`))],compute:function(e,t){let n=e.flat(),r=t.flat();if(Tm(n,r),n.length===0||r.length===0)return new ya(po);let i=n.length,a=0,o=0,s=0,c=0;for(let e=0;e<i;++e){let t=F(n[e]);t===F(r[e])?t?o++:a++:t?c++:s++}return(o*a-s*c)/Math.sqrt((o+s)*(o+c)*(a+s)*(a+c))},isExported:!1},Ox={description:k(`Maximum value in a numeric dataset.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to consider when calculating the maximum value.`))],compute:function(...e){return km(e,this.locale)},isExported:!0},kx={description:k(`Maximum numeric value in a dataset.`),args:[W(`value (any, range, repeating)`,k(`Value or range to consider when calculating the maximum value.`))],compute:function(...e){let t=qa(e,(e,t)=>Math.max(t,e),-1/0,this.locale);return{value:t===-1/0?0:t,format:Da(e[0])}},isExported:!0},Ax={description:k(`Returns the maximum value in a range of cells, filtered by a set of criteria.`),args:[W(`range (range)`,k(`The range of cells from which the maximum will be determined.`)),W(`criteria_range (any, range, repeating)`,k(`Range to evaluate criteria.`)),W(`criterion (string, repeating)`,k(`Criteria to check.`))],compute:function(e,...t){let n=-1/0;return io(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n=n<i?i:n)},this.locale),n===-1/0?0:n},isExported:!0},jx={description:k(`Median value in a numeric dataset.`),args:[W(`value (any, range, repeating)`,k(`Value or range to consider when calculating the median value.`))],compute:function(...e){let t=[];return Ua(e,e=>{t.push(e)},this.locale),{value:sx(t,{value:.5},!0,this.locale),format:Da(t[0])}},isExported:!0},Mx={description:k(`Minimum value in a numeric dataset.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to consider when calculating the minimum value.`))],compute:function(...e){return Am(e,this.locale)},isExported:!0},Nx={description:k(`Minimum numeric value in a dataset.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to consider when calculating the minimum value.`))],compute:function(...e){let t=qa(e,(e,t)=>Math.min(t,e),1/0,this.locale);return{value:t===1/0?0:t,format:Da(e[0])}},isExported:!0},Px={description:k(`Returns the minimum value in a range of cells, filtered by a set of criteria.`),args:[W(`range (range)`,k(`The range of cells from which the minimum will be determined.`)),W(`criteria_range (any, range, repeating)`,k(`Range to evaluate criteria.`)),W(`criterion (string, repeating)`,k(`Criterion to check.`))],compute:function(e,...t){let n=1/0;return io(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n=n>i?i:n)},this.locale),n===1/0?0:n},isExported:!0};function Fx(e,t){let{flatDataX:n,flatDataY:r}=ix(e,t);if(n.length===0||r.length===0)return new ya(po);let i=n.length,a=0,o=0,s=0,c=0,l=0;for(let e=0;e<i;e++){let t=n[e],i=r[e];a+=t,o+=i,s+=t*i,c+=t*t,l+=i*i}return(i*s-a*o)/Math.sqrt((i*c-a*a)*(i*l-o*o))}let Ix={description:k(`Compute the Pearson product-moment correlation coefficient of a dataset.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return Fx(e,t)},isExported:!0},Lx=Ix,Rx={description:k(`Value at a given percentile of a dataset.`),args:[W(`data (any, range)`,k(`The array or range containing the dataset to consider.`)),W(`percentile (number)`,k(`The percentile whose value within data will be calculated and returned.`))],compute:function(e,t){return Bx.compute.bind(this)(e,t)},isExported:!0},zx={description:k(`Value at a given percentile of a dataset exclusive of 0 and 1.`),args:[W(`data (any, range)`,k(`The array or range containing the dataset to consider.`)),W(`percentile (number)`,k(`The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.`))],compute:function(e,t){return{value:sx([e],t,!1,this.locale),format:Da(e)}},isExported:!0},Bx={description:k(`Value at a given percentile of a dataset.`),args:[W(`data (any, range)`,k(`The array or range containing the dataset to consider.`)),W(`percentile (number)`,k(`The percentile whose value within data will be calculated and returned.`))],compute:function(e,t){return{value:sx([e],t,!0,this.locale),format:Da(e)}},isExported:!0},Vx={description:k(`Compute the coefficients of polynomial regression of the dataset.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`)),W(`order (number)`,k(`The order of the polynomial to fit the data, between 1 and 6.`),tx),W(`intercept (boolean, default=TRUE)`,k(`A flag specifying whether to compute the intercept or not.`),nx)],compute:function(e,t,n,r={value:!0}){let{flatDataX:i,flatDataY:a}=ix(e,t);return i.length===0||a.length===0?new ya(po):Nm(a,i,N(n,this.locale),F(r))},isExported:!1},Hx={description:k(`Predict value by computing a polynomial regression of the dataset.`),args:[W(`x (number, range<number>)`,k(`The value(s) on the x-axis to forecast.`)),W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`)),W(`order (number)`,k(`The order of the polynomial to fit the data, between 1 and 6.`),tx),W(`intercept (boolean, default=TRUE)`,k(`A flag specifying whether to compute the intercept or not.`),nx)],compute:function(e,t,n,r,i={value:!0}){let a=N(r,this.locale),{flatDataX:o,flatDataY:s}=ix(t,n);if(o.length===0||s.length===0)return new ya(po);let c=Nm(s,o,a,F(i)).flat();return Ya(L(e),e=>Fm(c,N(e,this.locale),a))},isExported:!1},Ux={description:k(`Value nearest to a specific quartile of a dataset.`),args:[W(`data (any, range)`,k(`The array or range containing the dataset to consider.`)),W(`quartile_number (number)`,k(`Which quartile value to return.`),rx)],compute:function(e,t){return Gx.compute.bind(this)(e,t)},isExported:!0},Wx={description:k(`Value nearest to a specific quartile of a dataset exclusive of 0 and 4.`),args:[W(`data (any, range)`,k(`The array or range containing the dataset to consider.`)),W(`quartile_number (number)`,k(`Which quartile value, exclusive of 0 and 4, to return.`),[{value:1,label:k(`First quartile (25th percentile)`)},{value:2,label:k(`Median value (50th percentile)`)},{value:3,label:k(`Third quartile (75th percentile)`)}])],compute:function(e,t){let n={value:.25*Math.trunc(N(t,this.locale))};return{value:sx([e],n,!1,this.locale),format:Da(e)}},isExported:!0},Gx={description:k(`Value nearest to a specific quartile of a dataset.`),args:[W(`data (any, range)`,k(`The array or range containing the dataset to consider.`)),W(`quartile_number (number)`,k(`Which quartile value to return.`),rx)],compute:function(e,t){let n={value:.25*Math.trunc(N(t,this.locale))};return{value:sx([e],n,!0,this.locale),format:Da(e)}},isExported:!0},Kx={description:k(`Returns the rank of a specified value in a dataset.`),args:[W(`value (number)`,k(`The value whose rank will be determined.`)),W(`data (range)`,k(`The range containing the dataset to consider.`)),W(`is_ascending (boolean, default=FALSE)`,k(`Whether to consider the values in data in descending or ascending order.`),[{value:!1,label:k(`Descending`)},{value:!0,label:k(`Ascending`)}])],compute:function(e,t,n={value:!1}){let r=F(n),i=N(e,this.locale),a=1,o=!1;for(let e of t)for(let t of e){if(typeof t.value!=`number`)continue;let e=N(t,this.locale);e===i?o=!0:e>i!==r&&a++}return o?a:new ya(k(`Value not found in the given data.`))},isExported:!0},qx={description:k(`Compute the square of r, the Pearson product-moment correlation coefficient of a dataset.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let n=Fx(e,t);if(n instanceof Error)throw n;return n**2},isExported:!0},Jx={description:k(`Compute the slope of the linear regression.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=ix(e,t);if(n.length===0||r.length===0)return new ya(po);let[[i]]=Mm([n],[r]);return i},isExported:!0},Yx={description:k(`Nth smallest element in a data set.`),args:[W(`data (any, range)`,k(`The array or range containing the dataset to consider.`)),W(`n (number)`,k(`The rank from smallest to largest of the element to return.`))],compute:function(e,t){let n=Math.trunc(N(t?.value,this.locale)),r=[],i,a=0;Ha([e],e=>{typeof e?.value==`number`&&(i=ao(r,e,`nextSmaller`,`asc`,r.length,(e,t)=>e[t].value),r.splice(i+1,0,e),a++,a>n&&(r.pop(),a--))});let o=r.pop();return o===void 0?new j(po):a<n?new j(k(`Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.`,n)):o},isExported:!0},Xx={description:k(`Compute the Spearman rank correlation coefficient of a dataset.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=ix(t,e);if(n.length===0||r.length===0)return new ya(po);let i=n.length,a=n.map((e,t)=>[e,r[t]]);a.sort((e,t)=>e[0]-t[0]);for(let e=0;e<i;++e)a[e][0]=e;a.sort((e,t)=>e[1]-t[1]);let o=0;for(let e=0;e<i;++e)o+=(a[e][0]-e)**2;return 1-6*o/(i**3-i)},isExported:!1},Zx={description:k(`Standard deviation.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the sample.`))],compute:function(...e){return Math.sqrt(aS.compute.bind(this)(...e))},isExported:!0},Qx={description:k(`Standard deviation of entire population.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the population.`))],compute:function(...e){return Math.sqrt(oS.compute.bind(this)(...e))},isExported:!0},$x={description:k(`Standard deviation.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the sample.`))],compute:function(...e){return Math.sqrt(sS.compute.bind(this)(...e))},isExported:!0},eS={description:k(`Standard deviation of sample (text as 0).`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the sample.`))],compute:function(...e){return Math.sqrt(cS.compute.bind(this)(...e))},isExported:!0},tS={description:k(`Standard deviation of entire population.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the population.`))],compute:function(...e){return Math.sqrt(lS.compute.bind(this)(...e))},isExported:!0},nS={description:k(`Standard deviation of entire population (text as 0).`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the population.`))],compute:function(...e){return Math.sqrt(uS.compute.bind(this)(...e))},isExported:!0},rS={description:k(`Calculates the standard error of the predicted y-value for each x in the regression of a dataset.`),args:[W(`data_y (range<number>)`,k(`The range representing the array or matrix of dependent data.`)),W(`data_x (range<number>)`,k(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=ix(e,t);return n.length===0||r.length===0?new ya(po):Mm([n],[r],!0,!0)[1][2]},isExported:!0},iS={description:k(`Fits points to linear trend derived via least-squares.`),args:[W(`known_data_y (number, range<number>)`,k(`The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.`)),W(`known_data_x (number, range<number>, optional, default={1;2;3;...})`,k(`The values of the independent variable(s) corresponding with known_data_y.`)),W(`new_data_x (number, range<number>, optional, default=known_data_x)`,k(`The data points to return the y values for on the ideal curve fit.`)),W(`b (boolean, optional, default=TRUE)`,k(`Given a general linear form of y = m*x+b for a curve fit, calculates b if TRUE or forces b to be 0 and only calculates the m values if FALSE, i.e. forces the curve fit to pass through the origin.`),$b)],compute:function(e,t=[[]],n=[[]],r={value:!0}){return e.length===0||e[0].length===0?new j(mo(`known_data_y`)):Rm(Na(e,`known_data_y`),Na(t,`known_data_x`),Na(n,`new_data_y`),F(r))}},aS={description:k(`Variance.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the sample.`))],compute:function(...e){return ox(e,!0,!1,this.locale)},isExported:!0},oS={description:k(`Variance of entire population.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the population.`))],compute:function(...e){return ox(e,!1,!1,this.locale)},isExported:!0},sS={description:k(`Variance.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the sample.`))],compute:function(...e){return ox(e,!0,!1,this.locale)},isExported:!0},cS={description:k(`Variance of sample (text as 0).`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the sample.`))],compute:function(...e){return ox(e,!0,!0,this.locale)},isExported:!0},lS={description:k(`Variance of entire population.`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the population.`))],compute:function(...e){return ox(e,!1,!1,this.locale)},isExported:!0},uS={description:k(`Variance of entire population (text as 0).`),args:[W(`value (number, range<number>, repeating)`,k(`Value or range to include in the population.`))],compute:function(...e){return ox(e,!1,!0,this.locale)},isExported:!0};var dS=l({DAVERAGE:()=>mS,DCOUNT:()=>hS,DCOUNTA:()=>gS,DGET:()=>_S,DMAX:()=>vS,DMIN:()=>yS,DPRODUCT:()=>bS,DSTDEV:()=>xS,DSTDEVP:()=>SS,DSUM:()=>CS,DVAR:()=>wS,DVARP:()=>TS});function fS(e,t,n,r){let i=new Map,a=e.length;for(let t=a-1;t>=0;t--)i.set(P(e[t][0]).toUpperCase(),t);let o=t?.value;if(typeof o!=`number`&&typeof o!=`string`)throw new j(k(`The field must be a number or a string`));let s;if(typeof o==`number`){if(s=Math.trunc(o)-1,s<0||a-1<s)throw new j(k(`The field (%(fieldValue)s) must be one of %(dimRowDB)s or must be a number between 1 and %s inclusive.`,{fieldValue:o.toString(),dimRowDB:a.toString()}))}else{let e=P(t).toUpperCase();if(s=i.get(e)??-1,s===-1)throw new j(k(`The field (%s) must be one of %s.`,P(t),[...i.keys()].toString()))}let c=n[0].length;if(c<2)throw new j(k(`The criteria range contains %s row, it must be at least 2 rows.`,c.toString()));let l=new Set,u=e[0].length;for(let t=1;t<c;t++){let a=[],o=!0;for(let r=0;r<n.length;r++){let s=P(n[r][0]).toUpperCase(),c=i.get(s),l=n[r][t];if(l.value!==null)if(c!==void 0)a.push([e[c].slice(1,u)]),a.push(l);else{o=!1;break}}if(o)if(a.length>0)io(a,(e,t)=>{l.add(t)},r,!0);else{l=new Set(Array(u-1).keys());break}}let d=e[s];return[...l].map(e=>d[e+1])}let pS=[W(`database (range)`,k(`The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.`)),W(`field (number, string)`,k(`Indicates which column in database contains the values to be extracted and operated on.`)),W(`criteria (range)`,k(`An array or range containing zero or more criteria to filter the database values by before operating.`))],mS={description:k(`Average of a set of values from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return lx.compute.bind(this)([r])},isExported:!0},hS={description:k(`Counts values from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return gx.compute.bind(this)([r])},isExported:!0},gS={description:k(`Counts values and text from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return _x.compute.bind(this)([r])},isExported:!0},_S={description:k(`Single value from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return r.length===1?r[0]:new j(k(`More than one match found in DGET evaluation.`))},isExported:!0},vS={description:k(`Maximum of values from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return Ox.compute.bind(this)([r])},isExported:!0},yS={description:k(`Minimum of values from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return Mx.compute.bind(this)([r])},isExported:!0},bS={description:k(`Product of values from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return Db.compute.bind(this)([r])},isExported:!0},xS={description:k(`Standard deviation of population sample from table.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return Zx.compute.bind(this)([r])},isExported:!0},SS={description:k(`Standard deviation of entire population from table.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return tS.compute.bind(this)([r])},isExported:!0},CS={description:k(`Sum of values from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return Wb.compute.bind(this)([r])},isExported:!0},wS={description:k(`Variance of population sample from table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return aS.compute.bind(this)([r])},isExported:!0},TS={description:k(`Variance of a population from a table-like range.`),args:pS,compute:function(e,t,n){let r=fS(e,t,n,this.locale);return lS.compute.bind(this)([r])},isExported:!0};function ES(e){if(!e||typeof e!=`object`||!(!e.thousandsSeparator||typeof e.thousandsSeparator==`string`))return!1;for(let t of[`code`,`name`,`decimalSeparator`,`dateFormat`,`timeFormat`,`formulaArgSeparator`])if(!e[t]||typeof e[t]!=`string`)return!1;if(e.formulaArgSeparator===e.decimalSeparator||e.thousandsSeparator===e.decimalSeparator)return!1;try{z(1,{locale:e,format:`#,##0.00`}),z(1,{locale:e,format:e.dateFormat}),z(1,{locale:e,format:e.timeFormat})}catch{return!1}return!0}function DS(e,t){return Ut(e)?jS(e,t):PS(e,t)}function OS(e,t){return Ut(e)?jS(e,t):FS(e,t)}function kS(e,t){return e.startsWith(`=`)?MS(e,t):LS(e,t)}function AS(e,t){return Ut(e)?jS(e,t):PS(e,t)}function jS(e,t){return NS(e.startsWith(`+`)?`=`+e.slice(1):e,t,R)}function MS(e,t){return NS(e,R,t)}function NS(e,t,n){if(t.formulaArgSeparator===n.formulaArgSeparator&&t.decimalSeparator===n.decimalSeparator)return e;let r=Tu(e,t),i=``;for(let e of r)e.type===`NUMBER`?i+=e.value.replace(t.decimalSeparator,n.decimalSeparator):e.type===`ARG_SEPARATOR`?i+=n.formulaArgSeparator:e.type===`ARRAY_ROW_SEPARATOR`?i+=n.formulaArgSeparator===`;`?`\\`:`;`:i+=e.value;return i}function PS(e,t){return t.decimalSeparator===`.`||!ra(e,t)?e:(t.thousandsSeparator&&(e=e.replaceAll(t.thousandsSeparator,``)),e.replace(t.decimalSeparator,`.`))}function FS(e,t){if(Ti(e,t)){let n=N(e,t),r=R.dateFormat;return Number.isInteger(n)||(r+=` `+R.timeFormat),z(n,{locale:R,format:r})}return PS(e,t)}function IS(e,t){if(t.decimalSeparator===`.`||!ra(e,R))return e;let n=ls(R);return e.replace(n,e=>e.replace(`.`,t.decimalSeparator))}function LS(e,t){if(Ti(e,R)){let n=N(e,R),r=t.dateFormat;return Number.isInteger(n)||(r+=` `+t.timeFormat),z(n,{locale:t,format:r})}return IS(e,t)}function RS(e,t){return VS(e,e=>OS(e,t))}function zS(e,t){return VS(e,e=>kS(e,t))}function BS(e,t){let n=b(e);return n.criterion.values=n.criterion.values.map(e=>kS(e,t)),n}function VS(e,t){switch(e=b(e),e.type){case`CellIsRule`:switch(e.operator){case`isBetween`:case`isNotBetween`:case`isEqual`:case`isNotEqual`:case`isGreaterThan`:case`isGreaterOrEqualTo`:case`isLessThan`:case`isLessOrEqualTo`:case`customFormula`:case`dateIs`:case`dateIsBefore`:case`dateIsAfter`:case`dateIsOnOrAfter`:case`dateIsOnOrBefore`:case`top10`:return e.values=e.values.map(e=>t(e)),e;case`beginsWithText`:case`containsText`:case`endsWithText`:case`notContainsText`:case`isEmpty`:case`isNotEmpty`:case`uniqueValues`:case`duplicateValues`:return e}case`DataBarRule`:return e;case`ColorScaleRule`:return e.minimum=HS(e.minimum,t),e.maximum=HS(e.maximum,t),e.midpoint&&=HS(e.midpoint,t),e;case`IconSetRule`:return e.lowerInflectionPoint.value=t(e.lowerInflectionPoint.value),e.upperInflectionPoint.value=t(e.upperInflectionPoint.value),e}}function HS(e,t){if(!e?.value)return e;let n=t(e.type===`formula`?`=`+e.value:e.value),r=e.type===`formula`?n.slice(1):n;return{...e,value:r}}function US(e){return e.dateFormat+` `+e.timeFormat}let WS=k(`The cashflow_amounts and cashflow_dates ranges must have the same dimensions.`),GS=k(`There must be both positive and negative values in cashflow_amounts.`),KS=e=>k(`The cost (%s) must be positive or null.`,e),qS=e=>k(`The cost (%s) must be strictly positive.`,e),JS=e=>k(`The frequency (%s) must be one of %s`,e,[1,2,4].toString()),YS=e=>k(`The day_count_convention (%s) must be between 0 and 4 inclusive.`,e),XS=e=>k(`The depreciation factor (%s) must be strictly positive.`,e),ZS=e=>k(`The discount (%s) must be different from -1.`,e),QS=e=>k(`The discount (%s) must be strictly positive.`,e),$S=e=>k(`The discount (%s) must be smaller than 1.`,e),eC=e=>k(`The effective_rate (%s) must be strictly positive.`,e),tC=e=>k(`The end_period (%s) must be positive or null.`,e),nC=(e,t)=>k(`The end_period (%(end)s) must be smaller or equal to the life (%(life)s).`,{end:e,life:t}),rC=e=>k(`All the dates should be greater or equal to the first date in cashflow_dates (%s).`,e),iC=(e,t)=>k(`The first_period (%(first)s) must be smaller or equal to the last_period (%(last)s).`,{first:e,last:t}),aC=e=>k(`The first_period (%s) must be strictly positive.`,e),oC=e=>k(`The future_value (%s) must be strictly positive.`,e),sC=e=>k(`The investment (%s) must be strictly positive.`,e),cC=e=>k(`The issue (%s) must be positive or null.`,e),lC=(e,t)=>k(`The last_period (%(last)s) must be smaller or equal to the number_of_periods (%(nPeriods)s).`,{last:e,nPeriods:t}),uC=e=>k(`The last_period (%s) must be strictly positive.`,e),dC=e=>k(`The life (%s) must be strictly positive.`,e),fC=(e,t)=>k(`The maturity (%(maturity)s) must be strictly greater than the settlement (%(settlement)s).`,{maturity:t,settlement:e}),pC=e=>k(`The month (%s) must be between 1 and 12 inclusive.`,e),mC=e=>k(`The nominal_rate (%s) must be strictly positive.`,e),hC=e=>k(`The number_of_periods (%s) must be different from zero.`,e),gC=e=>k(`The number_of_periods (%s) must be strictly positive.`,e),_C=e=>k(`The period must be between 1 and number_of_periods (%s)`,e),vC=(e,t)=>k(`The period (%(period)s) must be less than or equal to %(lifeLimit)s.`,{period:e,lifeLimit:t}),yC=e=>k(`The period (%s) must be positive or null.`,e),bC=e=>k(`The periods_by_year (%s) must be strictly positive.`,e),xC=(e,t)=>k(`The period (%(period)s) must be less than or equal life (%(life)s).`,{period:e,life:t}),SC=e=>k(`The period (%s) must be strictly positive.`,e),CC=e=>k(`The present_value (%s) must be strictly positive.`,e),wC=e=>k(`The price (%s) must be strictly positive.`,e),TC=(e,t)=>k(`The purchase_date (%(purchaseDate)s) must be before the first_period_end (%(firstPeriodEnd)s).`,{purchaseDate:e,firstPeriodEnd:t}),EC=e=>k(`The purchase_date (%s) must be positive or null.`,e),DC=e=>k(`The rate_guess (%s) must be strictly greater than -1.`,e),OC=e=>k(`The rate (%s) must be positive or null.`,e),kC=e=>k(`The rate (%s) must be strictly positive.`,e),AC=e=>k(`The redemption (%s) must be strictly positive.`,e),jC=e=>k(`The salvage (%s) must be positive or null.`,e),MC=(e,t)=>k(`The salvage (%(salvage)s) must be smaller or equal than the cost (%(cost)s).`,{salvage:e,cost:t}),NC=(e,t)=>k(`The settlement date (%(settlement)s) must be greater or equal to the issue date (%(issue)s).`,{settlement:e,issue:t}),PC=(e,t)=>k(`The settlement date (%(settlement)s) must at most one year after the maturity date (%(maturity)s).`,{settlement:e,maturity:t}),FC=(e,t)=>k(`The settlement date (%(settlement)s) must be strictly greater than the issue date (%(issue)s).`,{settlement:e,issue:t}),IC=e=>k(`The start_period (%s) must be positive or null.`,e),LC=(e,t)=>k(`The start_period (%(start)s) must be smaller or equal to the end_period (%(end)s).`,{start:e,end:t}),RC=e=>k(`The unit (%s) must be strictly positive.`,e),zC=e=>k(`The yield (%s) must be positive or null.`,e);function BC(e){return e.some(e=>e>0)&&e.some(e=>e<0)}function VC(e){return![0,1,2,3,4].includes(e)}function HC(e){return![1,2,4].includes(e)}function UC(e,t,n){let r=I(e,n),i=I(t,n),a=I(e,n);return a.setFullYear(r.getFullYear()+1),i.getTime()<=a.getTime()}let WC=[{value:0,label:k(`US (NASD) 30/360`)},{value:1,label:k(`Actual/Actual`)},{value:2,label:k(`Actual/360`)},{value:3,label:k(`Actual/365`)},{value:4,label:k(`European 30/360`)}];var GC=l({DATE:()=>qC,DATEDIF:()=>JC,DATEVALUE:()=>YC,DAY:()=>XC,DAYS:()=>ZC,DAYS360:()=>QC,EDATE:()=>$C,EOMONTH:()=>ew,HOUR:()=>tw,ISOWEEKNUM:()=>nw,MINUTE:()=>rw,MONTH:()=>iw,MONTH_END:()=>xw,MONTH_START:()=>bw,NETWORKDAYS:()=>aw,NETWORKDAYS_INTL:()=>cw,NOW:()=>lw,QUARTER:()=>Sw,QUARTER_END:()=>ww,QUARTER_START:()=>Cw,SECOND:()=>uw,TIME:()=>dw,TIMEVALUE:()=>fw,TODAY:()=>pw,WEEKDAY:()=>mw,WEEKNUM:()=>hw,WORKDAY:()=>gw,WORKDAY_INTL:()=>_w,YEAR:()=>vw,YEARFRAC:()=>yw,YEAR_END:()=>Ew,YEAR_START:()=>Tw}),KC=function(e){return e.WHOLE_YEARS=`Y`,e.WHOLE_MONTHS=`M`,e.WHOLE_DAYS=`D`,e.DAYS_WITHOUT_WHOLE_MONTHS=`MD`,e.MONTH_WITHOUT_WHOLE_YEARS=`YM`,e.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR=`YD`,e}(KC||{});let qC={description:k(`Converts year/month/day into a date.`),args:[W(`year (number)`,k(`The year component of the date.`)),W(`month (number)`,k(`The month component of the date.`)),W(`day (number)`,k(`The day component of the date.`))],compute:function(e,t,n){let r=Math.trunc(N(e,this.locale)),i=Math.trunc(N(t,this.locale)),a=Math.trunc(N(n,this.locale));if(r<0||r>9999)return new j(k(`The year (%s) must be between 0 and 9999 inclusive.`,r.toString()));r<1900&&(r+=1900);let o=Ri(new O(r,i-1,a));return o<0?new j(k(`The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.`)):{value:o,format:this.locale.dateFormat}},isExported:!0},JC={description:k(`Calculates the number of days, months, or years between two dates.`),args:[W(`start_date (date)`,k(`The start date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.`)),W(`end_date (date)`,k(`The end date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.`)),W(`unit (string)`,k(`A text abbreviation for unit of time.`),[{value:`Y`,label:k(`The number of whole years between start_date and end_date`)},{value:`M`,label:k(`The number of whole months between start_date and end_date`)},{value:`D`,label:k(`The number of days between start_date and end_date`)},{value:`MD`,label:k(`The number of days between start_date and end_date after subtracting whole months`)},{value:`YM`,label:k(`The number of whole months between start_date and end_date after subtracting whole years`)},{value:`YD`,label:k(`The number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart`)}])],compute:function(e,t,n){let r=P(n).toUpperCase();if(!Object.values(KC).includes(r))return new j(ja(Object.values(KC),P(n)));let i=Math.trunc(N(e,this.locale)),a=Math.trunc(N(t,this.locale)),o=Li(i),s=Li(a);if(a<i)return new j(k(`start_date (%s) should be on or before end_date (%s).`,o.toLocaleDateString(),s.toLocaleDateString()));switch(r){case`Y`:return qi(o,s);case`M`:return Gi(o,s);case`D`:return Ki(o,s);case`YM`:return Gi(o,s)-qi(o,s)*12;case`MD`:let e=s.getDate()-o.getDate();return e<0&&(e=Bi(new O(s.getFullYear(),s.getMonth()-1,1))-Math.abs(e)),e;case`YD`:{if(Ji(i,a))return Ki(o,s);let e=new O(o.getFullYear(),s.getMonth(),s.getDate()),t=Ki(o,e);return t<0&&(e.setFullYear(o.getFullYear()+1),t=Ki(o,e)),t}}},isExported:!0},YC={description:k(`Converts a date string to a date value.`),args:[W(`date_string (string)`,k(`The string representing the date.`))],compute:function(e){let t=P(e),n=Di(t,this.locale);return n===null?new j(k(`The date_string (%s) cannot be parsed to date/time.`,t.toString())):Math.trunc(n.value)},isExported:!0},XC={description:k(`Day of the month that a specific date falls on.`),args:[W(`date (string)`,k(`The date from which to extract the day.`))],compute:function(e){return I(e,this.locale).getDate()},isExported:!0},ZC={description:k(`Number of days between two dates.`),args:[W(`end_date (date)`,k(`The end of the date range.`)),W(`start_date (date)`,k(`The start of the date range.`))],compute:function(e,t){let n=I(e,this.locale),r=I(t,this.locale),i=n.getTime()-r.getTime();return Math.round(i/pi)},isExported:!0},QC={description:k(`Number of days between two dates on a 360-day year (months of 30 days).`),args:[W(`start_date (date)`,k(`The start date to consider in the calculation.`)),W(`end_date (date)`,k(`The end date to consider in the calculation.`)),W(`method (boolean, default=false)`,k(`An indicator of what day count method to use.`),[{value:!1,label:k(`U.S. NASD method (default)`)},{value:!0,label:k(`European method`)}])],compute:function(e,t,n={value:!1}){let r=Math.trunc(N(e,this.locale)),i=Math.trunc(N(t,this.locale)),a=Wi(r,i,F(n)?4:0);return Math.sign(i-r)*Math.round(a*360)},isExported:!0},$C={description:k(`Date a number of months before/after another date.`),args:[W(`start_date (date)`,k(`The date from which to calculate the result.`)),W(`months (number)`,k(`The number of months before (negative) or after (positive) 'start_date' to calculate.`))],compute:function(e,t){return{value:Ri(Hi(I(e,this.locale),Math.trunc(N(t,this.locale)),!1)),format:this.locale.dateFormat}},isExported:!0},ew={description:k(`Last day of a month before or after a date.`),args:[W(`start_date (date)`,k(`The date from which to calculate the result.`)),W(`months (number)`,k(`The number of months before (negative) or after (positive) 'start_date' to consider.`))],compute:function(e,t){let n=I(e,this.locale),r=Math.trunc(N(t,this.locale));return{value:Ri(new O(n.getFullYear(),n.getMonth()+r+1,0)),format:this.locale.dateFormat}},isExported:!0},tw={description:k(`Hour component of a specific time.`),args:[W(`time (date)`,k(`The time from which to calculate the hour component.`))],compute:function(e){return I(e,this.locale).getHours()},isExported:!0},nw={description:k(`ISO week number of the year.`),args:[W(`date (date)`,k(`The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.`))],compute:function(e){let t=I(e,this.locale),n=t.getFullYear(),r=1;for(;new O(n,0,r).getDay()!==4;)r+=1;let i=new O(n,0,r-3),a=31;for(;new O(n,11,a).getDay()!==4;)--a;let o=new O(n,11,a+3),s;s=i.getTime()<=t.getTime()?t.getTime()<=o.getTime()?0:1:-1;let c;switch(s){case 0:c=i;break;case 1:c=new O(n,11,a+3+1);break;case-1:let e=1;for(;new O(n-1,0,e).getDay()!==4;)e+=1;c=new O(n-1,0,e-3);break}let l=(t.getTime()-c.getTime())/pi;return Math.floor(l/7)+1},isExported:!0},rw={description:k(`Minute component of a specific time.`),args:[W(`time (date)`,k(`The time from which to calculate the minute component.`))],compute:function(e){return I(e,this.locale).getMinutes()},isExported:!0},iw={description:k(`Month of the year a specific date falls in`),args:[W(`date (date)`,k(`The date from which to extract the month.`))],compute:function(e){return I(e,this.locale).getMonth()+1},isExported:!0},aw={description:k(`Net working days between two provided days.`),args:[W(`start_date (date)`,k(`The start date of the period from which to calculate the number of net working days.`)),W(`end_date (date)`,k(`The end date of the period from which to calculate the number of net working days.`)),W(`holidays (date, range<date>, optional)`,k(`A range or array constant containing the date serial numbers to consider holidays.`))],compute:function(e,t,n){return cw.compute.bind(this)(e,t,{value:1},n)},isExported:!0};function ow(e){let t=e?.value;if(typeof t==`string`){fm(t.length===7&&[...t].every(e=>e===`0`||e===`1`),k(`When weekend is a string (%s) it must be composed of "0" or "1".`,t));let e=[];for(let n=0;n<7;n++)t[n]===`1`&&e.push((n+1)%7);return e}if(typeof t==`number`)return fm(1<=t&&t<=7||11<=t&&t<=17,k(`The weekend (%s) must be a string or a number in the range 1-7 or 11-17.`,t.toString())),t<=7?[t-2==-1?6:t-2,t-1]:[t-11];throw new j(k(`The weekend must be a number or a string.`))}let sw=[{value:1,label:k(`Saturday/Sunday are weekends`)},{value:2,label:k(`Sunday/Monday are weekends`)},{value:3,label:k(`Monday/Tuesday are weekends`)},{value:4,label:k(`Tuesday/Wednesday are weekends`)},{value:5,label:k(`Wednesday/Thursday are weekends`)},{value:6,label:k(`Thursday/Friday are weekends`)},{value:7,label:k(`Friday/Saturday are weekends`)},{value:11,label:k(`Sunday is the only weekend`)},{value:12,label:k(`Monday is the only weekend`)},{value:13,label:k(`Tuesday is the only weekend`)},{value:14,label:k(`Wednesday is the only weekend`)},{value:15,label:k(`Thursday is the only weekend`)},{value:16,label:k(`Friday is the only weekend`)},{value:17,label:k(`Saturday is the only weekend`)}],cw={description:k(`Net working days between two dates (specifying weekends).`),args:[W(`start_date (date)`,k(`The start date of the period from which to calculate the number of net working days.`)),W(`end_date (date)`,k(`The end date of the period from which to calculate the number of net working days.`)),W(`weekend (any, default=1)`,k(`A number or string representing which days of the week are considered weekends.`),sw),W(`holidays (date, range<date>, optional)`,k(`A range or array constant containing the dates to consider as holidays.`))],compute:function(e,t,n={value:1},r){let i=I(e,this.locale),a=I(t,this.locale),o=ow(n),s=new Set;r!==void 0&&Ha([r],e=>{let t=I(e,this.locale);s.add(t.getTime())});let c=i.getTime()>a.getTime(),l=O.fromTimestamp((c?i:a).getTime()),u=O.fromTimestamp((c?a:i).getTime()),d=l.getTime(),f=u.getTime(),p=0;for(;f<=d;)!o.includes(u.getDay())&&!s.has(f)&&(p+=1),u.setDate(u.getDate()+1),f=u.getTime();return c?-p:p},isExported:!0},lw={description:k(`Current date and time as a date value.`),args:[],compute:function(){let e=O.now(),t=e.getTime()-fi.getTime(),n=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return{value:Math.floor(t/pi)+n,format:US(this.locale)}},isExported:!0},uw={description:k(`Minute component of a specific time.`),args:[W(`time (date)`,k(`The time from which to calculate the second component.`))],compute:function(e){return I(e,this.locale).getSeconds()},isExported:!0},dw={description:k(`Converts hour/minute/second into a time.`),args:[W(`hour (number)`,k(`The hour component of the time.`)),W(`minute (number)`,k(`The minute component of the time.`)),W(`second (number)`,k(`The second component of the time.`))],compute:function(e,t,n){let r=Math.trunc(N(e,this.locale)),i=Math.trunc(N(t,this.locale)),a=Math.trunc(N(n,this.locale));return i+=Math.floor(a/60),a=a%60+(a<0?60:0),r+=Math.floor(i/60),i=i%60+(i<0?60:0),r%=24,r<0?new j(k(`The function [[FUNCTION_NAME]] result cannot be negative`)):{value:r/24+i/1440+a/(1440*60),format:this.locale.timeFormat}},isExported:!0},fw={description:k(`Converts a time string into its serial number representation.`),args:[W(`time_string (string)`,k(`The string that holds the time representation.`))],compute:function(e){let t=P(e),n=Di(t,this.locale);if(n===null)return new j(k(`The time_string (%s) cannot be parsed to date/time.`,t));let r=n.value-Math.trunc(n.value);return r<0?1+r:r},isExported:!0},pw={description:k(`Current date as a date value.`),args:[],compute:function(){let e=O.now();return{value:Ri(new O(e.getFullYear(),e.getMonth(),e.getDate())),format:this.locale.dateFormat}},isExported:!0},mw={description:k(`Day of the week of the date provided (as number).`),args:[W(`date (date)`,k(`The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),W(`type (number, default=1)`,k(`A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.`),[{value:1,label:k(`Numbers 1 (Sunday) trough 7 (Saturday)`)},{value:2,label:k(`Numbers 1 (Monday) trough 7 (Sunday)`)},{value:3,label:k(`Numbers 0 (Monday) trough 6 (Sunday)`)},{value:11,label:k(`Numbers 1 (Monday) trough 7 (Sunday)`)},{value:12,label:k(`Numbers 1 (Tuesday) trough 7 (Monday)`)},{value:13,label:k(`Numbers 1 (Wednesday) trough 7 (Tuesday)`)},{value:14,label:k(`Numbers 1 (Thursday) trough 7 (Wednesday)`)},{value:15,label:k(`Numbers 1 (Friday) trough 7 (Thursday)`)},{value:16,label:k(`Numbers 1 (Saturday) trough 7 (Friday)`)},{value:17,label:k(`Numbers 1 (Sunday) trough 7 (Saturday)`)}])],compute:function(e,t={value:1}){let n=I(e,this.locale),r=Math.round(N(t,this.locale)),i=n.getDay();if(!(1<=r&&r<=3)&&!(11<=r&&r<=17))return new j(k(`The type (%s) must be between 1 and 3 or between 11 and 17.`,r));switch(r){case 1:return i+1;case 2:return i===0?7:i;case 3:return i===0?6:i-1}let a=r-10,o=(i+1-a+7)%7;return o===0?7:o},isExported:!0},hw={description:k(`Week number of the year.`),args:[W(`date (date)`,k(`The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),W(`type (number, default=1)`,k(`A number representing the day that a week starts on. Sunday = 1.`),[{value:1,label:k(`Sunday`)},{value:2,label:k(`Monday`)},{value:11,label:k(`Monday`)},{value:12,label:k(`Tuesday`)},{value:13,label:k(`Wednesday`)},{value:14,label:k(`Thursday`)},{value:15,label:k(`Friday`)},{value:16,label:k(`Saturday`)},{value:17,label:k(`Sunday`)},{value:21,label:k(`ISO week number (Monday as first day of the week)`)}])],compute:function(e,t={value:1}){let n=I(e,this.locale),r=Math.round(N(t,this.locale));if(![1,2,11,12,13,14,15,16,17,21].includes(r))return new j(k(`The type (%s) is out of range.`,r.toString()));if(r===21)return nw.compute.bind(this)(e);let i;i=r===1||r===2?r-1:r-10==7?0:r-10;let a=n.getFullYear(),o=1,s=new O(a,0,o);for(;s.getDay()!==i;)o+=1,s=new O(a,0,o);let c=(n.getTime()-s.getTime())/pi;return c<0?1:Math.floor(c/7)+(o===1?1:2)},isExported:!0},gw={description:k(`Date after a number of workdays.`),args:[W(`start_date (date)`,k(`The date from which to begin counting.`)),W(`num_days (number)`,k(`The number of working days to advance from start_date. If negative, counts backwards.`)),W(`holidays (date, range<date>, optional)`,k(`A range or array constant containing the dates to consider holidays.`))],compute:function(e,t,n={value:null}){return _w.compute.bind(this)(e,t,{value:1},n)},isExported:!0},_w={description:k(`Date after a number of workdays (specifying weekends).`),args:[W(`start_date (date)`,k(`The date from which to begin counting.`)),W(`num_days (number)`,k(`The number of working days to advance from start_date. If negative, counts backwards.`)),W(`weekend (any, default=1)`,k(`A number or string representing which days of the week are considered weekends.`),sw),W(`holidays (date, range<date>, optional)`,k(`A range or array constant containing the dates to consider holidays.`))],compute:function(e,t,n={value:1},r){let i=I(e,this.locale),a=Math.trunc(N(t,this.locale));if(n.value===`1111111`)return new j(k(`The weekend must be different from '1111111'.`));let o=ow(n),s=new Set;r!==void 0&&Ha([r],e=>{let t=I(e,this.locale);s.add(t.getTime())});let c=O.fromTimestamp(i.getTime()),l=c.getTime(),u=Math.sign(a),d=Math.abs(a);for(;d>0;)c.setDate(c.getDate()+u),l=c.getTime(),!o.includes(c.getDay())&&!s.has(l)&&--d;let f=l-fi.getTime();return{value:Math.round(f/pi),format:this.locale.dateFormat}},isExported:!0},vw={description:k(`Year specified by a given date.`),args:[W(`date (date)`,k(`The date from which to extract the year.`))],compute:function(e){return I(e,this.locale).getFullYear()},isExported:!0},yw={description:k(`Exact number of years between two dates.`),args:[W(`start_date (date)`,k(`The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),W(`end_date (date)`,k(`The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),W(`day_count_convention (number, default=0)`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n={value:0}){let r=Math.trunc(N(e,this.locale)),i=Math.trunc(N(t,this.locale)),a=Math.trunc(N(n,this.locale));return r<0?new j(k(`The start_date (%s) must be positive or null.`,r)):i<0?new j(k(`The end_date (%s) must be positive or null.`,i)):0>a||a>4?new j(k(`The day_count_convention (%s) must be between 0 and 4 inclusive.`,a)):Wi(r,i,a)}},bw={description:k(`First day of the month preceding a date.`),args:[W(`date (date)`,k(`The date from which to calculate the result.`))],compute:function(e){let t=I(e,this.locale);return{value:Ri(new O(t.getFullYear(),t.getMonth(),1)),format:this.locale.dateFormat}}},xw={description:k(`Last day of the month following a date.`),args:[W(`date (date)`,k(`The date from which to calculate the result.`))],compute:function(e){return ew.compute.bind(this)(e,{value:0})}},Sw={description:k(`Quarter of the year a specific date falls in`),args:[W(`date (date)`,k(`The date from which to extract the quarter.`))],compute:function(e){return Math.ceil((I(e,this.locale).getMonth()+1)/3)}},Cw={description:k(`First day of the quarter of the year a specific date falls in.`),args:[W(`date (date)`,k(`The date from which to calculate the start of quarter.`))],compute:function(e){let t=Sw.compute.bind(this)(e);return{value:Ri(new O(vw.compute.bind(this)(e),(t-1)*3,1)),format:this.locale.dateFormat}}},ww={description:k(`Last day of the quarter of the year a specific date falls in.`),args:[W(`date (date)`,k(`The date from which to calculate the end of quarter.`))],compute:function(e){let t=Sw.compute.bind(this)(e);return{value:Ri(new O(vw.compute.bind(this)(e),t*3,0)),format:this.locale.dateFormat}}},Tw={description:k(`First day of the year a specific date falls in.`),args:[W(`date (date)`,k(`The date from which to calculate the start of the year.`))],compute:function(e){return{value:Ri(new O(vw.compute.bind(this)(e),0,1)),format:this.locale.dateFormat}}},Ew={description:k(`Last day of the year a specific date falls in.`),args:[W(`date (date)`,k(`The date from which to calculate the end of the year.`))],compute:function(e){return{value:Ri(new O(vw.compute.bind(this)(e)+1,0,0)),format:this.locale.dateFormat}}};var Dw=l({DELTA:()=>Ow});let Ow={description:k(`Compare two numeric values, returning 1 if they're equal.`),args:[W(`number1 (number)`,k(`The first number to compare.`)),W(`number2 (number, default=0)`,k(`The second number to compare.`))],compute:function(e,t={value:0}){return+(N(e,this.locale)===N(t,this.locale))},isExported:!0},kw=[`number`,`error`,`text`,`boolean`];function Aw(e){let t=e===`asc`?1:-1;return(e,n)=>{if(e.type===`empty`)return n.type===`empty`?0:1;if(n.type===`empty`)return-1;let r=kw.indexOf(e.type)-kw.indexOf(n.type);return r===0&&(r=e.type===`text`||e.type===`error`?e.value.localeCompare(n.value):e.value-n.value),t*r}}function jw(e,t,n){let r=e.map((e,t)=>({index:t,type:e.type,value:e.value}));return(n?r.map(e=>e.type===`empty`?{...e,type:`number`,value:0}:e):r).sort(Aw(t))}var Mw=l({FILTER:()=>Pw,SORT:()=>Fw,SORTN:()=>Iw,UNIQUE:()=>Lw});function Nw(e,t,...n){for(let e=0;e<n.length;e++){let t=e%2==0?`sort_column`:`is_ascending`;fm(n[e]!==void 0,k(`Value for parameter %s is missing in [[FUNCTION_NAME]].`,t))}let r=[],i=[],a=e.length;for(let o=0;o<n.length;o+=2){r.push(F(Sm(n[o+1])?.value)?`asc`:`desc`);let s=n[o];if(Ta(s)&&(s.length>1||s[0].length>1))fm(s.length===1&&s[0].length===a,k(`Wrong size for %s. Expected a range of size 1x%s. Got %sx%s.`,`sort_column${o+1}`,a,s.length,s[0].length)),i.push(s.flat().map(e=>e.value));else{let n=N(Sm(s)?.value,t);if(n<1||n>e[0].length)return e;i.push(e.map(e=>e[n-1].value))}}if(i.length===0)for(let t=0;t<e[0].length;t++)i.push(e.map(e=>e[t].value)),r.push(`asc`);let o={desc:Aw(`desc`),asc:Aw(`asc`)},s=S(0,e.length);return s.sort((e,t)=>{for(let[n,a]of i.entries()){let i=a[e],s=a[t],c={value:i,type:i===null?`empty`:typeof i==`string`?`text`:typeof i},l={value:s,type:s===null?`empty`:typeof s==`string`?`text`:typeof s},u=o[r[n]](c,l);if(u!==0)return u}return 0}),s.map(t=>e[t])}let Pw={description:k(`Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions.`),args:[W(`range (any, range<any>)`,k(`The data to be filtered.`)),W(`condition (boolean, range<boolean>, repeating)`,k(`Column or row containing true or false values corresponding to the range.`))],compute:function(e,...t){let n=L(e),r=t.map(e=>Ya(L(e),e=>e.value));for(let e of r)if(!mm(e))return new j(k(`The arguments condition must be a single column or row.`));if(!hm(...t))return new j(k(`The arguments conditions must have the same dimensions.`));let i=r.map(e=>e.flat()),a=r[0].length===1?`row`:`col`;if(n=a===`row`?Za(n):n,i.some(e=>e.length!==n.length))return new j(k(`FILTER has mismatched sizes on the range and conditions.`));let o=[];for(let e=0;e<n.length;e++){let t=n[e];i.every(t=>(typeof t[e]==`boolean`||typeof t[e]==`number`)&&t[e])&&o.push(t)}return o.length?a===`row`?Za(o):o:new ya(k(`No match found in FILTER evaluation`))},isExported:!1},Fw={description:k(`Sorts the rows of a given array or range by the values in one or more columns.`),args:[W(`range (range)`,k(`The data to be sorted.`)),W(`sort_column (any, range<number>, repeating, optional)`,k(`The index of the column in range or a range outside of range containing the value by which to sort.`)),W(`is_ascending (boolean, repeating, optional)`,k(`TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.`),[{value:!0,label:k(`Ascending`)},{value:!1,label:k(`Descending`)}])],compute:function(e,...t){return Za(Nw(Za(e),this.locale,...t))},isExported:!0},Iw={description:k(`Returns the first n items in a data set after performing a sort.`),args:[W(`range (range)`,k(`The data to be sorted.`)),W(`n (number)`,k(`The number of items to return.`)),W(`display_ties_mode (number, default=0)`,k(`A number representing the way to display ties.`)),W(`sort_column (number, range<number>, repeating, optional)`,k(`The index of the column in range or a range outside of range containing the value by which to sort.`)),W(`is_ascending (boolean, repeating, optional)`,k(`TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.`),[{value:!0,label:k(`Ascending`)},{value:!1,label:k(`Descending`)}])],compute:function(e,t,...n){let r=N(t?.value??1,this.locale),i=n.length%2==0?0:N(n[0]?.value,this.locale),a=n.length%2==0?n:n.slice(1);if(r<0)return new j(k(`Wrong value of 'n'. Expected a positive number. Got %s.`,r));if(i<0||i>3)return new j(k(`Wrong value of 'display_ties_mode'. Expected a positive number between 0 and 3. Got %s.`,i));let o=Nw(Za(e),this.locale,...a),s=(e,t)=>JSON.stringify(o[e].map(e=>e.value))===JSON.stringify(o[t].map(e=>e.value));switch(i){case 0:return Za(o.slice(0,r));case 1:for(let e=r;e<o.length;e++)if(!s(e,r-1))return Za(o.slice(0,e));return Za(o);case 2:{let e=[o[0]];for(let t=1;t<o.length;t++)for(let n=0;n<t&&!s(t,n);n++)n===t-1&&e.push(o[t]);return Za(e.slice(0,r))}case 3:{let e=[o[0]],t=1;for(let n=1;n<o.length&&(s(n,n-1)||t++,!(t>r));n++)e.push(o[n]);return Za(e)}}},isExported:!1},Lw={description:k(`Unique rows in the provided source range.`),args:[W(`range (any, range<any>)`,k(`The data to filter by unique entries.`)),W(`by_column (boolean, default=FALSE)`,k(`Whether to filter the data by columns or by rows.`),[{value:!0,label:k(`Return unique columns`)},{value:!1,label:k(`Return unique rows`)}]),W(`exactly_once (boolean, default=FALSE)`,k(`Whether to return only entries with no duplicates.`),[{value:!0,label:k(`Return items that appear exactly once`)},{value:!1,label:k(`Return every distinct item`)}])],compute:function(e={value:``},t,n){if(!Ta(e))return[[e]];let r=F(t?.value)||!1,i=F(n?.value)||!1;r||(e=Za(e));let a=new Map;for(let t of e){let e=JSON.stringify(t.map(e=>e.value)),n=a.get(e);n?n.count++:a.set(e,{data:t,count:1})}let o=[];for(let e of a.values())i&&e.count>1||o.push(e.data);return o.length?r?o:Za(o):new j(k(`No unique values found`))},isExported:!0};var Rw=l({ACCRINTM:()=>Uw,AMORLINC:()=>Ww,COUPDAYBS:()=>Kw,COUPDAYS:()=>Gw,COUPDAYSNC:()=>qw,COUPNCD:()=>Jw,COUPNUM:()=>Yw,COUPPCD:()=>Xw,CUMIPMT:()=>Zw,CUMPRINC:()=>Qw,DB:()=>$w,DDB:()=>tT,DISC:()=>nT,DOLLARDE:()=>rT,DOLLARFR:()=>iT,DURATION:()=>aT,EFFECT:()=>oT,FV:()=>cT,FVSCHEDULE:()=>lT,INTRATE:()=>uT,IPMT:()=>fT,IRR:()=>mT,ISPMT:()=>hT,MDURATION:()=>gT,MIRR:()=>_T,NOMINAL:()=>vT,NPER:()=>yT,NPV:()=>xT,PDURATION:()=>ST,PMT:()=>wT,PPMT:()=>ET,PRICE:()=>OT,PRICEDISC:()=>kT,PRICEMAT:()=>AT,PV:()=>DT,RATE:()=>MT,RECEIVED:()=>NT,RRI:()=>PT,SLN:()=>FT,SYD:()=>IT,TBILLEQ:()=>zT,TBILLPRICE:()=>RT,TBILLYIELD:()=>BT,VDB:()=>VT,XIRR:()=>HT,XNPV:()=>UT,YIELD:()=>WT,YIELDDISC:()=>GT,YIELDMAT:()=>KT});let zw=[{value:1,label:k(`Annual`)},{value:2,label:k(`Semi-annual`)},{value:4,label:k(`Quarterly`)}],Bw=[{value:0,label:k(`End of period (default)`)},{value:1,label:k(`Beginning of period`)}],Vw=[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`frequency (number)`,k(`The number of interest or coupon payments per year (1, 2, or 4).`),zw),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)];function Hw(e,t,n,r,i=1e-10,a){let o=n,s,c,l,u=!1,d=0,f;do{if(l=e(o),isNaN(l)){fm(d<r&&a!==void 0,k(`Function [[FUNCTION_NAME]] didn't find any result.`)),d++,o=a(f),f=o;continue}s=o-l/t(o),c=Math.abs(s-o),o=s,u=c<i||Math.abs(l)<i,fm(d<r,k(`Function [[FUNCTION_NAME]] didn't find any result.`)),d++}while(!u);return o}let Uw={description:k(`Accrued interest of security paying at maturity.`),args:[W(`issue (date)`,k(`The date the security was initially issued.`)),W(`maturity (date)`,k(`The maturity date of the security.`)),W(`rate (number)`,k(`The annualized rate of interest.`)),W(`redemption (number)`,k(`The redemption amount per 100 face value, or par.`)),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i={value:0}){let a=Math.trunc(N(e,this.locale)),o=Math.trunc(N(t,this.locale)),s=N(r,this.locale),c=N(n,this.locale),l=Math.trunc(N(i,this.locale));if(a<0)return new j(cC(a));if(a>=o)return new j(fC(a,o));if(VC(l))return new j(YS(l));if(s<=0)return new j(AC(s));if(c<=0)return new j(kC(c));let u=Wi(a,o,l);return s*c*u},isExported:!0},Ww={description:k(`Depreciation for an accounting period.`),args:[W(`cost (number)`,k(`The initial cost of the asset.`)),W(`purchase_date (date)`,k(`The date the asset was purchased.`)),W(`first_period_end (date)`,k(`The date the first period ended.`)),W(`salvage (number)`,k(`The value of the asset at the end of depreciation.`)),W(`period (number)`,k(`The single period within life for which to calculate depreciation.`)),W(`rate (number)`,k(`The deprecation rate.`)),W(`day_count_convention (number, optional)`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=N(e,this.locale),c=Math.trunc(N(t,this.locale)),l=Math.trunc(N(n,this.locale)),u=N(r,this.locale),d=N(i,this.locale),f=N(a,this.locale),p=Math.trunc(N(o,this.locale));if(s<=0)return new j(qS(s));if(c<0)return new j(EC(c));if(u<0)return new j(jC(u));if(u>s)return new j(MC(u,s));if(d<0)return new j(yC(d));if(f<=0)return new j(kC(f));if(VC(p))return new j(YS(p));if(c>l)return new j(TC(c,l));let m=d<1&&d>0?1:Math.trunc(d),h=s*f,g=Wi(c,l,p),_=c===l?h:h*g,v=s-_-h*m;return v>=u?m===0?_:h:u-v<h?h-(u-v):0},isExported:!0},Gw={description:k(`Days in coupon period containing settlement date.`),args:Vw,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(N(e,this.locale)),a=Math.trunc(N(t,this.locale)),o=Math.trunc(N(n,this.locale)),s=Math.trunc(N(r,this.locale));if(i>=a)return new j(fC(i,a));if(HC(o))return new j(JS(o));if(VC(s))return new j(YS(s));if(s===1){let i=Xw.compute.bind(this)(e,t,n,r).value,a=Jw.compute.bind(this)(e,t,n,r).value;return N(a,this.locale)-N(i,this.locale)}return(s===3?365:360)/o},isExported:!0},Kw={description:k(`Days from settlement until next coupon.`),args:Vw,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(N(e,this.locale)),a=Math.trunc(N(t,this.locale)),o=Math.trunc(N(n,this.locale)),s=Math.trunc(N(r,this.locale));if(i>=a)return new j(fC(i,a));if(HC(o))return new j(JS(o));if(VC(s))return new j(YS(s));let c=Xw.compute.bind(this)(e,t,n,r).value,l=N(c,this.locale);if([1,2,3].includes(s))return i-l;if(s===4){let e=Wi(l,i,s);return Math.round(e*360)}let u=I(i,this.locale),d=I(l,this.locale),f=d.getFullYear(),p=u.getFullYear(),m=d.getMonth()+1,h=u.getMonth()+1,g=d.getDate(),_=u.getDate();return m===2&&h===2&&Vi(d)&&Vi(u)&&(_=30),_===31&&(g===30||g===31)&&(_=30),m===2&&Vi(d)&&(g=30),g===31&&(g=30),(p-f)*360+(h-m)*30+(_-g)},isExported:!0},qw={description:k(`Days from settlement until next coupon.`),args:Vw,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(N(e,this.locale)),a=Math.trunc(N(t,this.locale)),o=Math.trunc(N(n,this.locale)),s=Math.trunc(N(r,this.locale));if(i>=a)return new j(fC(i,a));if(HC(o))return new j(JS(o));if(VC(s))return new j(YS(s));let c=Jw.compute.bind(this)(e,t,n,r).value,l=N(c,this.locale);if([1,2,3].includes(s))return l-i;if(s===4){let e=Wi(i,l,s);return Math.round(e*360)}let u=Kw.compute.bind(this)(e,t,n,r);return N(Gw.compute.bind(this)(e,t,n,r),this.locale)-N(u,this.locale)},isExported:!0},Jw={description:k(`Next coupon date after the settlement date.`),args:Vw,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(N(e,this.locale)),a=Math.trunc(N(t,this.locale)),o=Math.trunc(N(n,this.locale)),s=Math.trunc(N(r,this.locale));if(i>=a)return new j(fC(i,a));if(HC(o))return new j(JS(o));if(VC(s))return new j(YS(s));let c=12/o,l=Yw.compute.bind(this)(e,t,n,r);return{value:Ri(Hi(I(a,this.locale),-(N(l,this.locale)-1)*c,!0)),format:this.locale.dateFormat}},isExported:!0},Yw={description:k(`Number of coupons between settlement and maturity.`),args:Vw,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(N(e,this.locale)),a=Math.trunc(N(t,this.locale)),o=Math.trunc(N(n,this.locale)),s=Math.trunc(N(r,this.locale));if(i>=a)return new j(fC(i,a));if(HC(o))return new j(JS(o));if(VC(s))return new j(YS(s));let c=1,l=a,u=12/o;for(;l>i;)l=Ri(Hi(I(l,this.locale),-u,!1)),c++;return c-1},isExported:!0},Xw={description:k(`Last coupon date prior to or on the settlement date.`),args:Vw,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(N(e,this.locale)),a=Math.trunc(N(t,this.locale)),o=Math.trunc(N(n,this.locale)),s=Math.trunc(N(r,this.locale));if(i>=a)return new j(fC(i,a));if(HC(o))return new j(JS(o));if(VC(s))return new j(YS(s));let c=12/o,l=Yw.compute.bind(this)(e,t,n,r);return{value:Ri(Hi(I(a,this.locale),-l*c,!0)),format:this.locale.dateFormat}},isExported:!0},Zw={description:k(`Cumulative interest paid over a set of periods.`),args:[W(`rate (number)`,k(`The interest rate.`)),W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`present_value (number)`,k(`The current value of the annuity.`)),W(`first_period (number)`,k(`The number of the payment period to begin the cumulative calculation.`)),W(`last_period (number)`,k(`The number of the payment period to end the cumulative calculation.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw)],compute:function(e,t,n,r,i,a={value:0}){let o=N(r,this.locale),s=N(i,this.locale),c=N(e,this.locale),l=N(n,this.locale),u=N(t,this.locale),d=+!!F(a);if(u<=0)return new j(gC(u));if(o<=0)return new j(aC(o));if(s<=0)return new j(uC(s));if(o>s)return new j(iC(o,s));if(s>u)return new j(lC(s,u));if(c<=0)return new j(kC(c));if(l<=0)return new j(CC(l));let f=0;for(let e=o;e<=s;e++)f+=dT(c,e,u,l,0,d);return f},isExported:!0},Qw={description:k(`Cumulative principal paid over a set of periods.`),args:[W(`rate (number)`,k(`The interest rate.`)),W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`present_value (number)`,k(`The current value of the annuity.`)),W(`first_period (number)`,k(`The number of the payment period to begin the cumulative calculation.`)),W(`last_period (number)`,k(`The number of the payment period to end the cumulative calculation.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw)],compute:function(e,t,n,r,i,a={value:0}){let o=N(r,this.locale),s=N(i,this.locale),c=N(e,this.locale),l=N(n,this.locale),u=N(t,this.locale),d=+!!F(a);if(u<=0)return new j(gC(u));if(o<=0)return new j(aC(o));if(s<=0)return new j(uC(s));if(o>s)return new j(iC(o,s));if(s>u)return new j(lC(s,u));if(c<=0)return new j(kC(c));if(l<=0)return new j(CC(l));let f=0;for(let e=o;e<=s;e++)f+=TT(c,e,u,l,0,d);return f},isExported:!0},$w={description:k(`Depreciation via declining balance method.`),args:[W(`cost (number)`,k(`The initial cost of the asset.`)),W(`salvage (number)`,k(`The value of the asset at the end of depreciation.`)),W(`life (number)`,k(`The number of periods over which the asset is depreciated.`)),W(`period (number)`,k(`The single period within life for which to calculate depreciation.`)),W(`month (number, optional)`,k(`The number of months in the first year of depreciation.`))],compute:function(e,t,n,r,...i){let a=N(e,this.locale),o=N(t,this.locale),s=N(n,this.locale),c=Math.trunc(N(r,this.locale)),l=i.length?Math.trunc(N(i[0],this.locale)):12,u=s+(l===12?0:1);if(a<0)return new j(KS(a));if(o<0)return new j(jC(o));if(c<=0)return new j(SC(c));if(s<=0)return new j(dC(s));if(1>l||l>12)return new j(pC(l));if(c>u)return new j(vC(c,u));let d=l/12,f=1-(o/a)**(1/s);f=Math.round(f*1e3)/1e3;let p=a,m=a*(1-f*d);for(let e=1;e<c;e++)p=m,m=p*(1-f),e===s&&(m=p*(1-f*(1-d)));return{value:p-m,format:`#,##0.00`}},isExported:!0},eT=`#,##0.00`,tT={description:k(`Depreciation via double-declining balance method.`),args:[W(`cost (number)`,k(`The initial cost of the asset.`)),W(`salvage (number)`,k(`The value of the asset at the end of depreciation.`)),W(`life (number)`,k(`The number of periods over which the asset is depreciated.`)),W(`period (number)`,k(`The single period within life for which to calculate depreciation.`)),W(`factor (number, default=2)`,k(`The factor by which depreciation decreases.`))],compute:function(e,t,n,r,i={value:2}){let a=N(e,this.locale),o=N(t,this.locale),s=N(n,this.locale),c=N(r,this.locale),l=N(i,this.locale);if(a<0)return new j(KS(a));if(o<0)return new j(jC(o));if(c<=0)return new j(SC(c));if(s<=0)return new j(dC(s));if(c>s)return new j(xC(c,s));if(l<=0)return new j(XS(l));if(a===0||o>=a)return{value:0,format:eT};let u=l/s;if(u>1)return{value:c===1?a-o:0,format:eT};if(c<=1)return{value:a*u,format:eT};let d=a*(1-u)**(c-1),f=a*(1-u)**c,p=f<o?d-o:d-f;return{value:Math.max(p,0),format:eT}},isExported:!0},nT={description:k(`Discount rate of a security based on price.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`price (number)`,k(`The price at which the security is bought per 100 face value.`)),W(`redemption (number)`,k(`The redemption amount per 100 face value, or par.`)),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(N(e,this.locale)),o=Math.trunc(N(t,this.locale)),s=N(n,this.locale),c=N(r,this.locale),l=Math.trunc(N(i,this.locale));if(a>=o)return new j(fC(a,o));if(VC(l))return new j(YS(l));if(s<=0)return new j(wC(s));if(c<=0)return new j(AC(c));let u=Wi(a,o,l);return(c-s)/c/u},isExported:!0},rT={description:k(`Convert a decimal fraction to decimal value.`),args:[W(`fractional_price (number)`,k(`The price quotation given using fractional decimal conventions.`)),W(`unit (number)`,k(`The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.`))],compute:function(e,t){let n=N(e,this.locale),r=Math.trunc(N(t,this.locale));if(r<=0)return new j(RC(r));let i=Math.trunc(n);return i+(n-i)*(10**Math.ceil(Math.log10(r))/r)},isExported:!0},iT={description:k(`Convert a decimal value to decimal fraction.`),args:[W(`decimal_price (number)`,k(`The price quotation given as a decimal value.`)),W(`unit (number)`,k(`The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.`))],compute:function(e,t){let n=N(e,this.locale),r=Math.trunc(N(t,this.locale));if(r<=0)return new j(RC(r));let i=Math.trunc(n);return i+(n-i)*(r/10**Math.ceil(Math.log10(r)))},isExported:!0},aT={description:k(`Number of periods for an investment to reach a value.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`rate (number)`,k(`The annualized rate of interest.`)),W(`yield (number)`,k(`The expected annual yield of the security.`)),W(`frequency (number)`,k(`The number of interest or coupon payments per year (1, 2, or 4).`),zw),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i,a={value:0}){let o=Math.trunc(N(e,this.locale)),s=Math.trunc(N(t,this.locale)),c=N(n,this.locale),l=N(r,this.locale),u=Math.trunc(N(i,this.locale)),d=Math.trunc(N(a,this.locale));if(o>=s)return new j(fC(o,s));if(HC(u))return new j(JS(u));if(VC(d))return new j(YS(d));if(c<0)return new j(OC(c));if(l<0)return new j(zC(l));let f=Wi(o,s,d),p=f-Math.trunc(f)||1/u,m=Math.ceil(f*u),h=c/u,g=l/u,_=0,v=0;for(let e=1;e<=m;e++){let t=(h+ +(e===m))/(1+g)**e;v+=(p+(e-1)/u)*t,_+=t}return _===0?0:v/_},isExported:!0},oT={description:k(`Annual effective interest rate.`),args:[W(`nominal_rate (number)`,k(`The nominal interest rate per year.`)),W(`periods_per_year (number)`,k(`The number of compounding periods per year.`))],compute:function(e,t){let n=N(e,this.locale),r=Math.trunc(N(t,this.locale));return n<=0?new j(mC(n)):r<=0?new j(bC(r)):(1+n/r)**+r-1},isExported:!0};function sT(e,t,n,r,i){return e===0?-(r+n*t):-r*(1+e)**t-n*(1+e*i)*((1+e)**t-1)/e}let cT={description:k(`Future value of an annuity investment.`),args:[W(`rate (number)`,k(`The interest rate.`)),W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`payment_amount (number)`,k(`The amount per period to be paid.`)),W(`present_value (number, default=0)`,k(`The current value of the annuity.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw)],compute:function(e,t,n,r={value:0},i={value:0}){return r||=0,i||=0,{value:sT(N(e,this.locale),N(t,this.locale),N(n,this.locale),N(r,this.locale),+!!F(i)),format:`#,##0.00`}},isExported:!0},lT={description:k(`Future value of principal from series of rates.`),args:[W(`principal (number)`,k(`The amount of initial capital or value to compound against.`)),W(`rate_schedule (number, range<number>)`,k(`A series of interest rates to compound against the principal.`))],compute:function(e,t){let n=N(e,this.locale);return Ga([t],(e,t)=>e*(1+N(t,this.locale)),n)},isExported:!0},uT={description:k(`Calculates effective interest rate.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`investment (number)`,k(`The amount invested in the security.`)),W(`redemption (number)`,k(`The amount to be received at maturity.`)),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i={value:0}){let a=Math.trunc(N(e,this.locale)),o=Math.trunc(N(t,this.locale)),s=N(r,this.locale),c=N(n,this.locale),l=Math.trunc(N(i,this.locale));if(a>=o)return new j(fC(a,o));if(c<=0)return new j(sC(c));if(s<=0)return new j(AC(s));if(VC(l))return new j(YS(l));let u=Wi(a,o,l);return(s-c)/c/u},isExported:!0};function dT(e,t,n,r,i,a){return CT(e,n,r,i,a)-TT(e,t,n,r,i,a)}let fT={description:k(`Payment on the principal of an investment.`),args:[W(`rate (number)`,k(`The annualized rate of interest.`)),W(`period (number)`,k(`The amortization period, in terms of number of periods.`)),W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`present_value (number)`,k(`The current value of the annuity.`)),W(`future_value (number, default=0)`,k(`The future value remaining after the final payment has been made.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw)],compute:function(e,t,n,r,i={value:0},a={value:0}){return{value:dT(N(e,this.locale),N(t,this.locale),N(n,this.locale),N(r,this.locale),N(i,this.locale),+!!F(a)),format:`#,##0.00`}},isExported:!0},pT=.1,mT={description:k(`Internal rate of return given periodic cashflows.`),args:[W(`cashflow_amounts (number, range<number>)`,k(`An array or range containing the income or payments associated with the investment.`)),W(`rate_guess (number, default=${pT})`,k(`An estimate for what the internal rate of return will be.`))],compute:function(e,t={value:pT}){let n=N(t,this.locale);if(n<=-1)return new j(DC(n));let r=!1,i=!1,a=[];if(Ua([e],({value:e})=>{e>0&&(r=!0),e<0&&(i=!0),a.push(e)},this.locale),!r||!i)return new j(GS);let o=a.shift();function s(e,t,n){let r=n.length,i=0;return n.reduce((t,n)=>(i++,t+n*e**(r-i)),t*e**r)}function c(e,t,n){let r=n.length,i=0;return n.reduce((t,n)=>(i++,t+n*(r-i)*e**(r-i-1)),t*r*e**(r-1))}function l(e){return s(e,o,a)}function u(e){return c(e,o,a)}return{value:Hw(l,u,n+1,20,1e-5)-1,format:`0%`}},isExported:!0},hT={description:k(`Returns the interest paid at a particular period of an investment.`),args:[W(`rate (number)`,k(`The interest rate.`)),W(`period (number)`,k(`The period for which you want to view the interest payment.`)),W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`present_value (number)`,k(`The current value of the annuity.`))],compute:function(e,t,n,r){let i=N(e,this.locale),a=N(t,this.locale),o=N(n,this.locale),s=N(r,this.locale);return o===0?new j(hC(o)):-1*(s-a/o*s)*i},isExported:!0},gT={description:k(`Modified Macaulay duration.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`rate (number)`,k(`The annualized rate of interest.`)),W(`yield (number)`,k(`The expected annual yield of the security.`)),W(`frequency (number)`,k(`The number of interest or coupon payments per year (1, 2, or 4).`),zw),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`))],compute:function(e,t,n,r,i,a={value:0}){let o=aT.compute.bind(this)(e,t,n,r,i,a),s=N(r,this.locale),c=Math.trunc(N(i,this.locale));return N(o,this.locale)/(1+s/c)},isExported:!0},_T={description:k(`Modified internal rate of return.`),args:[W(`cashflow_amounts (range<number>)`,k(`A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.`)),W(`financing_rate (number)`,k(`The interest rate paid on funds invested.`)),W(`reinvestment_return_rate (number)`,k(`The return (as a percentage) earned on reinvestment of income received from the investment.`))],compute:function(e,t,n){let r=N(t,this.locale),i=N(n,this.locale),a=Za(e).flat().filter(e=>e.value!==null).map(e=>N(e,this.locale)),o=a.length,s=0,c=0;for(let e of S(0,o)){let t=a[e];t>=0?s+=t*(i+1)**(o-e-1):c+=t/(r+1)**e}if(c===0||s===0)return new j(GS);let l=1/(o-1);return(-s/c)**l-1},isExported:!0},vT={description:k(`Annual nominal interest rate.`),args:[W(`effective_rate (number)`,k(`The effective interest rate per year.`)),W(`periods_per_year (number)`,k(`The number of compounding periods per year.`))],compute:function(e,t){let n=N(e,this.locale),r=Math.trunc(N(t,this.locale));return n<=0?new j(eC(n)):r<=0?new j(bC(r)):((n+1)**(1/r)-1)*r},isExported:!0},yT={description:k(`Number of payment periods for an investment.`),args:[W(`rate (number)`,k(`The interest rate.`)),W(`payment_amount (number)`,k(`The amount of each payment made.`)),W(`present_value (number)`,k(`The current value of the annuity.`)),W(`future_value (number, default=0)`,k(`The future value remaining after the final payment has been made.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw)],compute:function(e,t,n,r={value:0},i={value:0}){r||=0,i||=0;let a=N(e,this.locale),o=N(t,this.locale),s=N(n,this.locale),c=N(r,this.locale),l=+!!F(i);if(a===0)return-(c+s)/o;let u=o*(1+a*l)/a;return Math.log((u-c)/(s+u))/Math.log(1+a)},isExported:!0};function bT(e,t,n,r){let i=0;return Ka(n,(t,n)=>(i++,t+n/(1+e)**i),t,r)}let xT={description:k(`The net present value of an investment based on a series of periodic cash flows and a discount rate.`),args:[W(`discount (number)`,k(`The discount rate of the investment over one period.`)),W(`cashflow (number, range<number>, repeating)`,k(`The future cash flows.`))],compute:function(e,...t){let n=N(e,this.locale);return n===-1?new j(ZS(n)):{value:bT(n,0,t,this.locale),format:`#,##0.00`}},isExported:!0},ST={description:k(`Computes the number of periods needed for an investment to reach a value.`),args:[W(`rate (number)`,k(`The rate at which the investment grows each period.`)),W(`present_value (number)`,k(`The investment's current value.`)),W(`future_value (number)`,k(`The investment's desired future value.`))],compute:function(e,t,n){let r=N(e,this.locale),i=N(t,this.locale),a=N(n,this.locale);return r<=0?new j(kC(r)):i<=0?new j(CC(i)):a<=0?new j(oC(a)):(Math.log(a)-Math.log(i))/Math.log(1+r)},isExported:!0};function CT(e,t,n,r,i){if(t<=0)throw new j(gC(t));if(e===0)return-(r+n)/t;let a=-(n*(1+e)**t+r);return a=a*e/((1+e*i)*((1+e)**t-1)),a}let wT={description:k(`Periodic payment for an annuity investment.`),args:[W(`rate (number)`,k(`The annualized rate of interest.`)),W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`present_value (number)`,k(`The current value of the annuity.`)),W(`future_value (number, default=0)`,k(`The future value remaining after the final payment has been made.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw)],compute:function(e,t,n,r={value:0},i={value:0}){let a=N(t,this.locale),o=N(e,this.locale),s=+!!F(i),c=N(r,this.locale);return{value:CT(o,a,N(n,this.locale),c,s),format:`#,##0.00`}},isExported:!0};function TT(e,t,n,r,i,a){if(n<=0)throw new j(gC(n));if(t<=0||t>n)throw new j(_C(n));let o=CT(e,n,r,i,a);return a===1&&t===1?o:o+-sT(e,a===0?t-1:t-2,o,r+o*a,0)*e}let ET={description:k(`Payment on the principal of an investment.`),args:[W(`rate (number)`,k(`The annualized rate of interest.`)),W(`period (number)`,k(`The amortization period, in terms of number of periods.`)),W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`present_value (number)`,k(`The current value of the annuity.`)),W(`future_value (number, default=0)`,k(`The future value remaining after the final payment has been made.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw)],compute:function(e,t,n,r,i={value:0},a={value:0}){let o=N(n,this.locale),s=N(e,this.locale),c=N(t,this.locale),l=+!!F(a),u=N(i,this.locale);return{value:TT(s,c,o,N(r,this.locale),u,l),format:`#,##0.00`}},isExported:!0},DT={description:k(`Present value of an annuity investment.`),args:[W(`rate (number)`,k(`The interest rate.`)),W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`payment_amount (number)`,k(`The amount per period to be paid.`)),W(`future_value (number, default=0)`,k(`The future value remaining after the final payment has been made.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw)],compute:function(e,t,n,r={value:0},i={value:0}){r||=0,i||=0;let a=N(e,this.locale),o=N(t,this.locale),s=N(n,this.locale),c=N(r,this.locale),l=+!!F(i);return{value:a?-(s*(1+a*l)*((1+a)**o-1)/a+c)/(1+a)**o:-(c+s*o),format:`#,##0.00`}},isExported:!0},OT={description:k(`Price of a security paying periodic interest.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`rate (number)`,k(`The annualized rate of interest.`)),W(`yield (number)`,k(`The expected annual yield of the security.`)),W(`redemption (number)`,k(`The redemption amount per 100 face value, or par.`)),W(`frequency (number)`,k(`The number of interest or coupon payments per year (1, 2, or 4).`),zw),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=Math.trunc(N(e,this.locale)),c=Math.trunc(N(t,this.locale)),l=N(n,this.locale),u=N(r,this.locale),d=N(i,this.locale),f=Math.trunc(N(a,this.locale)),p=Math.trunc(N(o,this.locale));if(s>=c)return new j(fC(s,c));if(HC(f))return new j(JS(f));if(VC(p))return new j(YS(p));if(l<0)return new j(OC(l));if(u<0)return new j(zC(u));if(d<=0)return new j(AC(d));let m=Wi(s,c,p)*f,h=Math.ceil(m),g=m-Math.floor(m)||1,_=1+u/f,v=100*l/f;if(h===1)return(v+d)/(g*u/f+1)-v*(1-g);let y=0;for(let e=1;e<=h;e++)y+=v/_**(e-1+g);return d/_**(h-1+g)+y-v*(1-g)},isExported:!0},kT={description:k(`Price of a discount security.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`discount (number)`,k(`The discount rate of the security at time of purchase.`)),W(`redemption (number)`,k(`The redemption amount per 100 face value, or par.`)),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(N(e,this.locale)),o=Math.trunc(N(t,this.locale)),s=N(n,this.locale),c=N(r,this.locale),l=Math.trunc(N(i,this.locale));if(a>=o)return new j(fC(a,o));if(VC(l))return new j(YS(l));if(s<=0)return new j(QS(s));if(c<=0)return new j(AC(c));let u=Wi(a,o,l);return c-s*c*u},isExported:!0},AT={description:k(`Calculates the price of a security paying interest at maturity, based on expected yield.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`issue (date)`,k(`The date the security was initially issued.`)),W(`rate (number)`,k(`The annualized rate of interest.`)),W(`yield (number)`,k(`The expected annual yield of the security.`)),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i,a={value:0}){a||=0;let o=Math.trunc(N(e,this.locale)),s=Math.trunc(N(t,this.locale)),c=Math.trunc(N(n,this.locale)),l=N(r,this.locale),u=N(i,this.locale),d=Math.trunc(N(a,this.locale));if(o<=c)return new j(FC(o,c));if(o>=s)return new j(fC(o,s));if(VC(d))return new j(YS(d));if(l<0)return new j(OC(l));if(u<0)return new j(zC(u));let f=Wi(o,s,d),p=Wi(o,c,d),m=100+Wi(c,s,d)*l*100,h=1+f*u,g=p*l*100;return m/h-g},isExported:!0},jT=.1,MT={description:k(`Interest rate of an annuity investment.`),args:[W(`number_of_periods (number)`,k(`The number of payments to be made.`)),W(`payment_per_period (number)`,k(`The amount per period to be paid.`)),W(`present_value (number)`,k(`The current value of the annuity.`)),W(`future_value (number, default=0)`,k(`The future value remaining after the final payment has been made.`)),W(`end_or_beginning (number, default=0)`,k(`The timing of the payment payments are due for each period.`),Bw),W(`rate_guess (number, default=${jT})`,k(`An estimate for what the interest rate will be.`))],compute:function(e,t,n,r={value:0},i={value:0},a={value:jT}){let o=N(e,this.locale),s=N(t,this.locale),c=+!!F(i),l=N(a,this.locale)||jT,u=N(r,this.locale),d=N(n,this.locale);return o<=0?new j(gC(o)):BC([s,d,u])?l<=-1?new j(DC(l)):(u-=s*c,d+=s*c,{value:Hw(e=>{let t=(1+e)**+o,n=(t-1)/e;return u+d*t+s*n},e=>{let t=(1+e)**(o-1),n=((1+e)**+o-1)/e,r=o*t/e-n/e;return d*o*t+s*r},l,40,1e-5),format:`0%`}):new j(k(`There must be both positive and negative values in [payment_amount, present_value, future_value].`))},isExported:!0},NT={description:k(`Amount received at maturity for a security.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`investment (number)`,k(`The amount invested (irrespective of face value of each security).`)),W(`discount (number)`,k(`The discount rate of the security invested in.`)),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(N(e,this.locale)),o=Math.trunc(N(t,this.locale)),s=N(n,this.locale),c=N(r,this.locale),l=Math.trunc(N(i,this.locale));return a>=o?new j(fC(a,o)):VC(l)?new j(YS(l)):s<=0?new j(sC(s)):c<=0?new j(QS(c)):s/(1-c*Wi(a,o,l))},isExported:!0},PT={description:k(`Computes the rate needed for an investment to reach a specific value within a specific number of periods.`),args:[W(`number_of_periods (number)`,k(`The number of periods.`)),W(`present_value (number)`,k(`The present value of the investment.`)),W(`future_value (number)`,k(`The future value of the investment.`))],compute:function(e,t,n){let r=N(e,this.locale),i=N(t,this.locale),a=N(n,this.locale);return r<=0?new j(gC(r)):(a/i)**(1/r)-1},isExported:!0},FT={description:k(`Depreciation of an asset using the straight-line method.`),args:[W(`cost (number)`,k(`The initial cost of the asset.`)),W(`salvage (number)`,k(`The value of the asset at the end of depreciation.`)),W(`life (number)`,k(`The number of periods over which the asset is depreciated.`))],compute:function(e,t,n){let r=N(e,this.locale),i=N(t,this.locale),a=N(n,this.locale);return{value:(r-i)/a,format:`#,##0.00`}},isExported:!0},IT={description:k(`Depreciation via sum of years digit method.`),args:[W(`cost (number)`,k(`The initial cost of the asset.`)),W(`salvage (number)`,k(`The value of the asset at the end of depreciation.`)),W(`life (number)`,k(`The number of periods over which the asset is depreciated.`)),W(`period (number)`,k(`The single period within life for which to calculate depreciation.`))],compute:function(e,t,n,r){let i=N(e,this.locale),a=N(t,this.locale),o=N(n,this.locale),s=N(r,this.locale);if(s<=0)return new j(SC(s));if(o<=0)return new j(dC(o));if(s>o)return new j(xC(s,o));let c=o*(o+1)/2,l=o-s+1;return{value:(i-a)*(l/c),format:`#,##0.00`}},isExported:!0};function LT(e,t,n){return 100*(1-n*Wi(e,t,2))}let RT={description:k(`Price of a US Treasury bill.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`discount (number)`,k(`The discount rate of the bill at time of purchase.`))],compute:function(e,t,n){let r=Math.trunc(N(e,this.locale)),i=Math.trunc(N(t,this.locale)),a=N(n,this.locale);return r>=i?new j(fC(r,i)):UC(r,i,this.locale)?a<=0?new j(QS(a)):a>=1?new j($S(a)):LT(r,i,a):new j(PC(r,i))},isExported:!0},zT={description:k(`Equivalent rate of return for a US Treasury bill.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`discount (number)`,k(`The discount rate of the bill at time of purchase.`))],compute:function(e,t,n){let r=Math.trunc(N(e,this.locale)),i=Math.trunc(N(t,this.locale)),a=N(n,this.locale);if(r>=i)return new j(fC(r,i));if(!UC(r,i,this.locale))return new j(PC(r,i));if(a<=0)return new j(QS(a));if(a>=1)return new j($S(a));let o=ZC.compute.bind(this)({value:i},{value:r});if(o<=182)return 365*a/(360-a*o);let s=LT(r,i,a)/100,c=o/(o===366?366:365);return(-2*c+2*Math.sqrt(c**2-(2*c-1)*(1-1/s)))/(2*c-1)},isExported:!0},BT={description:k(`The yield of a US Treasury bill based on price.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`price (number)`,k(`The price at which the security is bought per 100 face value.`))],compute:function(e,t,n){let r=Math.trunc(N(e,this.locale)),i=Math.trunc(N(t,this.locale)),a=N(n,this.locale);if(r>=i)return new j(fC(r,i));if(!UC(r,i,this.locale))return new j(PC(r,i));if(a<=0)return new j(wC(a));let o=Wi(r,i,2);return(100-a)/a*(1/o)},isExported:!0},VT={description:k(`Variable declining balance. WARNING : does not handle decimal periods.`),args:[W(`cost (number)`,k(`The initial cost of the asset.`)),W(`salvage (number)`,k(`The value of the asset at the end of depreciation.`)),W(`life (number)`,k(`The number of periods over which the asset is depreciated.`)),W(`start (number)`,k(`Starting period to calculate depreciation.`)),W(`end (number)`,k(`Ending period to calculate depreciation.`)),W(`factor (number, default=2)`,k(`The number of months in the first year of depreciation.`)),W(`no_switch (number, default=false)`,k(`Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.`),[{value:!1,label:k(`Switch to straight-line depreciation`)},{value:!0,label:k(`Do not switch to straight-line depreciation`)}])],compute:function(e,t,n,r,i,a={value:2},o={value:!1}){a||=0;let s=N(e,this.locale),c=N(t,this.locale),l=N(n,this.locale),u=Math.trunc(N(r,this.locale)),d=Math.trunc(N(i,this.locale)),f=N(a,this.locale),p=F(o);if(s<0)return new j(KS(s));if(c<0)return new j(jC(c));if(l<=0)return new j(dC(l));if(u<0)return new j(IC(u));if(d<0)return new j(tC(d));if(u>d)return new j(LC(u,d));if(d>l)return new j(nC(d,l));if(f<=0)return new j(XS(f));if(s===0)return 0;if(c>=s)return u<1?s-c:0;let m=f/l;if(m>=1)return u<1?s-c:0;let h=s,g=0,_=0,v=!1;for(let e=0;e<d;e++){if(!v||p){let t=h*m,n=l-e,r=(h-c)/n;!p&&r>t?(v=!0,g=r):g=t}let t=Math.max(h-g,c);e>=u&&(_+=h-t),h=t}return _},isExported:!0},HT={description:k(`Internal rate of return given non-periodic cash flows.`),args:[W(`cashflow_amounts (range<number>)`,k(`An range containing the income or payments associated with the investment.`)),W(`cashflow_dates (range<number>)`,k(`An range with dates corresponding to the cash flows in cashflow_amounts.`)),W(`rate_guess (number, default=${jT})`,k(`An estimate for what the internal rate of return will be.`))],compute:function(e,t,n={value:jT}){let r=N(n,this.locale);if(!hm(e,t))return new j(WS);let i=e.flat().map(e=>N(e,this.locale)),a=t.flat().map(e=>N(e,this.locale));if(!BC(i))return new j(GS);if(a.some(e=>e<a[0]))return new j(rC(a[0]));if(r<=-1)return new j(DC(r));let o=new Map;for(let e of S(0,a.length)){let t=a[e];o.has(t)?o.set(t,o.get(t)+i[e]):o.set(t,i[e])}let s=Array.from(o.keys()),c=s.map(e=>o.get(e));return Hw(e=>{let t=c[0];for(let n of S(1,c.length)){let r=(s[0]-s[n])/365;t+=c[n]*(1+e)**r}return t},e=>{let t=0;for(let n of S(1,c.length)){let r=(s[0]-s[n])/365;t+=r*c[n]*(1+e)**(r-1)}return t},r,40,1e-5,e=>e?e/10-.9:-.9)},isExported:!0},UT={description:k(`Net present value given to non-periodic cash flows..`),args:[W(`discount (number)`,k(`The discount rate of the investment over one period.`)),W(`cashflow_amounts (number, range<number>)`,k(`An range containing the income or payments associated with the investment.`)),W(`cashflow_dates (number, range<number>)`,k(`An range with dates corresponding to the cash flows in cashflow_amounts.`))],compute:function(e,t,n){let r=N(e,this.locale);if(!hm(t,n))return new j(WS);let i=L(t).flat().map(e=>Pa(e,this.locale)),a=L(n).flat().map(e=>Pa(e,this.locale));if(a.some(e=>e<a[0]))return new j(rC(a[0]));if(r<=0)return new j(kC(r));if(i.length===1)return i[0];let o=new Map;for(let e of S(0,a.length)){let t=a[e];o.has(t)?o.set(t,o.get(t)+i[e]):o.set(t,i[e])}let s=Array.from(o.keys()),c=s.map(e=>o.get(e)),l=c[0];for(let e of S(1,c.length)){let t=(s[0]-s[e])/365;l+=c[e]*(1+r)**t}return l},isExported:!0},WT={description:k(`Annual yield of a security paying periodic interest.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`rate (number)`,k(`The annualized rate of interest.`)),W(`price (number)`,k(`The price at which the security is bought per 100 face value.`)),W(`redemption (number)`,k(`The redemption amount per 100 face value, or par.`)),W(`frequency (number)`,k(`The number of interest or coupon payments per year (1, 2, or 4).`),zw),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=Math.trunc(N(e,this.locale)),c=Math.trunc(N(t,this.locale)),l=N(n,this.locale),u=N(r,this.locale),d=N(i,this.locale),f=Math.trunc(N(a,this.locale)),p=Math.trunc(N(o,this.locale));if(s>=c)return new j(fC(s,c));if(HC(f))return new j(JS(f));if(VC(p))return new j(YS(p));if(l<0)return new j(OC(l));if(u<=0)return new j(wC(u));if(d<=0)return new j(AC(d));let m=Wi(s,c,p)*f,h=Math.ceil(m),g=m-Math.floor(m)||1,_=100*l/f;if(h===1){let e=u+_*(1-g);return(d+_-e)*f*(1/g)/e}function v(e,t,n,r,i,a){let o=a-(e+i*(1-t))*r**(n-1+t);for(let e=1;e<=n;e++)o+=i*r**(e-1);return o}function y(e,t,n,r,i){let a=-(e+i*(1-t))*(n-1+t)*r**(n-2+t);for(let e=1;e<=n;e++)a+=i*(e-1)*r**(e-2);return a}function ee(e){return v(u,g,h,e,_,d)}function te(e){return y(u,g,h,e,_)}return(Hw(ee,te,1+(l+1)/f,100,1e-5)-1)*f},isExported:!0},GT={description:k(`Annual yield of a discount security.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`price (number)`,k(`The price at which the security is bought per 100 face value.`)),W(`redemption (number)`,k(`The redemption amount per 100 face value, or par.`)),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(N(e,this.locale)),o=Math.trunc(N(t,this.locale)),s=N(n,this.locale),c=N(r,this.locale),l=Math.trunc(N(i,this.locale));if(a>=o)return new j(fC(a,o));if(VC(l))return new j(YS(l));if(s<=0)return new j(wC(s));if(c<=0)return new j(AC(c));let u=Wi(a,o,l);return(c/s-1)/u},isExported:!0},KT={description:k(`Annual yield of a security paying interest at maturity.`),args:[W(`settlement (date)`,k(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),W(`maturity (date)`,k(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),W(`issue (date)`,k(`The date the security was initially issued.`)),W(`rate (number)`,k(`The annualized rate of interest.`)),W(`price (number)`,k(`The price at which the security is bought.`)),W(`day_count_convention (number, default=0 )`,k(`An indicator of what day count method to use.`),WC)],compute:function(e,t,n,r,i,a={value:0}){a||=0;let o=Math.trunc(N(e,this.locale)),s=Math.trunc(N(t,this.locale)),c=Math.trunc(N(n,this.locale)),l=N(r,this.locale),u=N(i,this.locale),d=Math.trunc(N(a,this.locale));if(o>=s)return new j(fC(o,s));if(VC(d))return new j(YS(d));if(o<c)return new j(NC(o,c));if(l<0)return new j(OC(l));if(u<=0)return new j(wC(u));let f=Wi(c,s,d),p=Wi(c,o,d),m=Wi(o,s,d);return(100*(1+l*f)/(u+100*l*p)-1)/m},isExported:!0};var qT=l({CELL:()=>YT,ISBLANK:()=>rE,ISERR:()=>XT,ISERROR:()=>ZT,ISFORMULA:()=>aE,ISLOGICAL:()=>QT,ISNA:()=>$T,ISNONTEXT:()=>eE,ISNUMBER:()=>tE,ISTEXT:()=>nE,NA:()=>iE});let JT=[{value:`address`,label:k(`Returns an absolute reference as plain text of the top left cell in reference.`)},{value:`col`,label:k(`Returns the column number of the cell in reference.`)},{value:`contents`,label:k(`Returns the value contained in the top left cell in reference.`)},{value:`format`,label:k(`Returns the format of the top left cell in reference.`)},{value:`row`,label:k(`Returns the row number of the top left cell in reference.`)},{value:`type`,label:k(`Returns the type of data in the cell in reference. The following values are returned: "b" for a blank cell, "l" (for label) if the cell contains plain text, and "v" (for value) if the cell contains any other type of data.`)}],YT={description:k(`Gets information about a cell.`),args:[W(`info_type (string)`,k(`The type of information requested.`),JT),W(`reference (meta, range<meta>)`,k(`The reference to the cell.`))],compute:function(e,t){let n=P(e).toLowerCase();if(!JT.map(e=>e.value).includes(n))return new j(k(`The info_type should be one of %s.`,JT.join(`, `)));let r=this.__originSheetId,i=t[0][0].value,{sheetName:a,xc:o}=zc(i);a=a===this.getters.getSheetName(r)?void 0:a;let s=Bc(a,Uc(o,`colrow`)),c=this.getters.getRangeFromSheetXC(r,s);switch(n){case`address`:return this.getters.getRangeString(c,r);case`col`:return c.zone.left+1;case`contents`:{let e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top};return this.getters.getEvaluatedCell(e).value}case`format`:{let e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top};return this.getters.getEvaluatedCell(e).format||``}case`row`:return c.zone.top+1;case`type`:{let e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top},t=this.getters.getEvaluatedCell(e).type;return t===`empty`?`b`:t===`text`?`l`:`v`}}return``},isExported:!0},XT={description:k(`Whether a value is an error other than #N/A.`),args:[W(`value (any)`,k(`The value to be verified as an error type.`))],compute:function(e){let t=e?.value;return M(t)&&t!==A.NotAvailable},isExported:!0},ZT={description:k(`Whether a value is an error.`),args:[W(`value (any)`,k(`The value to be verified as an error type.`))],compute:function(e){let t=e?.value;return M(t)},isExported:!0},QT={description:k("Whether a value is `true` or `false`."),args:[W(`value (any)`,k(`The value to be verified as a logical TRUE or FALSE.`))],compute:function(e){return typeof e?.value==`boolean`},isExported:!0},$T={description:k(`Whether a value is the error #N/A.`),args:[W(`value (any)`,k(`The value to be verified as an error type.`))],compute:function(e){return e?.value===A.NotAvailable},isExported:!0},eE={description:k(`Whether a value is non-textual.`),args:[W(`value (any)`,k(`The value to be checked.`))],compute:function(e){return!nE.compute.bind(this)(e)},isExported:!0},tE={description:k(`Whether a value is a number.`),args:[W(`value (any)`,k(`The value to be verified as a number.`))],compute:function(e){return typeof e?.value==`number`},isExported:!0},nE={description:k(`Whether a value is text.`),args:[W(`value (any)`,k(`The value to be verified as text.`))],compute:function(e){return typeof e?.value==`string`&&M(e?.value)===!1},isExported:!0},rE={description:k(`Whether the referenced cell is empty`),args:[W(`value (any)`,k(`Reference to the cell that will be checked for emptiness.`))],compute:function(e){return e?.value===null},isExported:!0},iE={description:k(`Returns the error value #N/A.`),args:[],compute:function(){return{value:A.NotAvailable}},isExported:!0},aE={description:k(`Checks whether there is a reference to a cell that contains a formula, and returns TRUE or FALSE.`),args:[W(`cell_reference (meta)`,k(`A reference to a cell.`))],compute:function(e){let{sheetName:t,xc:n}=zc(e.value),{col:r,row:i}=tn(n),a=(t&&this.getters.getSheetIdByName(t))??this.__originSheetId;return this.getters.getCell({sheetId:a,col:r,row:i})?.isFormula??!1},isExported:!0};var oE=l({AND:()=>sE,FALSE:()=>cE,IF:()=>lE,IFERROR:()=>uE,IFNA:()=>dE,IFS:()=>fE,NOT:()=>pE,OR:()=>mE,SWITCH:()=>hE,TRUE:()=>gE,XOR:()=>_E});let sE={description:k("Logical `and` operator."),args:[W(`logical_expression (boolean, range<boolean>, repeating)`,k(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let{result:t,foundBoolean:n}=Km(e);return n?t:new j(po)},isExported:!0},cE={description:k("Logical value `false`."),args:[],compute:function(){return!1},isExported:!0},lE={description:k(`Returns value depending on logical expression.`),args:[W(`logical_expression (boolean, range<boolean>)`,k(`An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.`)),W(`value_if_true (any, range)`,k(`The value the function returns if logical_expression is TRUE.`)),W(`value_if_false (any, range, default=FALSE)`,k(`The value the function returns if logical_expression is FALSE.`))],compute:function(e,t,n){return wm(e)?Qa(lE.compute,[e,t,n]):(F(Sm(e))?t:n)??{value:0}},isExported:!0},uE={description:k(`Value if it is not an error, otherwise 2nd argument.`),args:[W(`value (any, range)`,k(`The value to return if value itself is not an error.`)),W(`value_if_error (any, range, default="empty")`,k(`The value the function returns if value is an error.`))],compute:function(e,t){return wm(e)?Qa(uE.compute,[e,t]):(M(Sm(e)?.value)?t:e)??{value:0}},isExported:!0},dE={description:k(`Value if it is not an #N/A error, otherwise 2nd argument.`),args:[W(`value (any, range)`,k(`The value to return if value itself is not #N/A an error.`)),W(`value_if_error (any, range, default="empty")`,k(`The value the function returns if value is an #N/A error.`))],compute:function(e,t){return wm(e)?Qa(dE.compute,[e,t]):(Sm(e)?.value===A.NotAvailable?t:e)??{value:0}},isExported:!0},fE={description:k(`Returns a value depending on multiple logical expressions.`),args:[W(`condition (any, range, repeating)`,k(`The condition to be evaluated. It can be a boolean, a number, an array, or a reference to any of those.`)),W(`value (any, range, repeating)`,k(`The value to be returned if its corresponding condition is TRUE.`))],compute:function(...e){if(e.length%2!=0)return new j(k(`Wrong number of arguments. Expected an even number of arguments.`));for(;e.length>0;){if(wm(e[0]))return Qa(fE.compute,e);let t=F(Sm(e.shift())),n=e.shift();if(t)return n??{value:0}}return new j(k(`No match.`))},isExported:!0},pE={description:k(`Returns opposite of provided logical value.`),args:[W(`logical_expression (boolean)`,k(`An expression or reference to a cell holding an expression that represents some logical value.`))],compute:function(e){return!F(e)},isExported:!0},mE={description:k("Logical `or` operator."),args:[W(`logical_expression (boolean, range<boolean>, repeating)`,k(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let{result:t,foundBoolean:n}=qm(e);return n?t:new j(po)},isExported:!0},hE={description:k(`Returns a value by comparing cases to an expression.`),args:[W(`expression (number, boolean, string)`,k(`The value to be checked.`)),W(`case (any, repeating)`,k(`Case to be checked against expression.`)),W(`value (any, repeating)`,k(`Value to be returned if its corresponding case matches expression.`)),W(`default (any, default="empty")`,k(`An optional default value to be returned if none of the cases match expression.`))],compute:function(e,...t){let n=t.length%2==0?Oa(e):t.pop();for(let n=0;n<t.length;n+=2){let r=t[n];if(r&&M(r.value))return r;if(e?.value===r?.value)return t[n+1]||{value:0}}return n||{value:0}},isExported:!0},gE={description:k("Logical value `true`."),args:[],compute:function(){return!0},isExported:!0},_E={description:k("Logical `xor` operator."),args:[W(`logical_expression (boolean, range<boolean>, repeating)`,k(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let t=!1,n=!1;return eo(e,e=>(t=!0,n=n?!e:e,!0)),t?n:new j(po)},isExported:!0};function vE(e,t){let n=t.getPivotId(e);if(!n)throw new j(k(`There is no pivot with id "%s"`,e));return n}function yE(e,t,n){let{measures:r}=n.getPivotCoreDefinition(e);if(!r.find(e=>e.id===t))throw new j(k(`The argument %s is not a valid measure. Here are the measures: %s`,t,`(${r.map(e=>e.id).join(`, `)})`))}function bE(e){if(e.length%2!=0)throw new j(k(`Function PIVOT takes an even number of arguments.`))}function xE(e,t,n){let r=[],i=e.getters.getPivotCoreDefinition(t);if(i.type===`SPREADSHEET`&&i.dataSet){let{sheetId:t,zone:n}=i.dataSet,a=yn(n),o=e.getters.getRangeFromSheetXC(t,a);if(o===void 0||o.invalidXc||o.invalidSheetName)throw new va;if(e.__originCellPosition&&o.sheetId===e.__originSheetId&&jn(E(e.__originCellPosition),n))throw new _a;r.push(o)}for(let i of n)i.computedBy&&r.push(...e.getters.getMeasureFullDependencies(t,i));let a=e.__originCellPosition;a&&r.length&&(e.updateDependencies?.(a),e.addDependencies?.(a,r))}var SE=l({ADDRESS:()=>TE,CHOOSE:()=>HE,COLUMN:()=>EE,COLUMNS:()=>DE,DROP:()=>UE,FORMULATEXT:()=>GE,HLOOKUP:()=>OE,INDEX:()=>kE,INDIRECT:()=>AE,LOOKUP:()=>jE,MATCH:()=>ME,OFFSET:()=>VE,PIVOT:()=>BE,PIVOT_HEADER:()=>zE,PIVOT_VALUE:()=>RE,ROW:()=>NE,ROWS:()=>PE,TAKE:()=>WE,VLOOKUP:()=>FE,XLOOKUP:()=>LE});let CE=[{value:!0,label:k(`A1 style (default)`)},{value:!1,label:k(`R1C1 style`)}],wE=[{value:!0,label:k(`Approximate match (default)`)},{value:!1,label:k(`Exact match`)}],TE={description:k(`Returns a cell reference as a string. `),args:[W(`row (number)`,k(`The row number of the cell reference. `)),W(`column (number)`,k(`The column number (not name) of the cell reference. A is column number 1. `)),W(`absolute_relative_mode (number, default=1)`,k(`An indicator of whether the reference is row/column absolute.`),[{value:1,label:k(`Absolute row and column (e.g. $A$1)`)},{value:2,label:k(`Absolute row, relative column (e.g. A$1)`)},{value:3,label:k(`Relative row, absolute column (e.g. $A1)`)},{value:4,label:k(`Relative row and column (e.g. A1)`)}]),W(`use_a1_notation (boolean, default=TRUE)`,k(`A boolean indicating whether to use A1 style notation or R1C1 style notation.`),CE),W(`sheet (string, optional)`,k(`A string indicating the name of the sheet into which the address points.`))],compute:function(e,t,n={value:1},r={value:!0},i){let a=Ia(e,this.locale),o=Ia(t,this.locale);if(a<1)return new j(_m(a));if(o<1)return new j(_m(o));let s=Ia(n,this.locale);if(![1,2,3,4].includes(s))return new j(Aa(1,4,s));let c=F(r),l;if(c){let e={rowFixed:[1,2].includes(s),colFixed:[1,3].includes(s)};l=T(o-1,a-1,e)}else l=([1,2].includes(s)?`R${a}`:`R[${a}]`)+([1,3].includes(s)?`C${o}`:`C[${o}]`);return i===void 0?l:Bc(P(i),l)},isExported:!0},EE={description:k(`Column number of a specified cell.`),args:[W(`cell_reference (meta, range<meta>, default='this cell')`,k(`The cell whose column number will be returned. Column A corresponds to 1. By default, the function use the cell in which the formula is entered.`))],compute:function(e){if(e===void 0)return this.__originCellPosition?.col===void 0?new j(k(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):this.__originCellPosition.col+1;if(e[0][0]===void 0)return new j(k(`The range is out of bounds.`));if(e[0][0].value===A.InvalidReference)return e[0][0];let t=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),e[0][0].value).zone.left;return e.length===1?t+1:Ja(e.length,1,(e,n)=>({value:t+e+1}))},isExported:!0},DE={description:k(`Number of columns in a specified array or range.`),args:[W(`range (any, range<any>)`,k(`The range whose column count will be returned.`))],compute:function(e){let t=L(e);return t[0][0]===void 0?new j(k(`The range is out of bounds.`)):t[0][0].value===A.InvalidReference?t[0][0]:t.length},isExported:!0},OE={description:k(`Horizontal lookup`),args:[W(`search_key (string, number, boolean)`,k(`The value to search for. For example, 42, 'Cats', or I24.`)),W(`range (any, range)`,k(`The range to consider for the search. The first row in the range is searched for the key specified in search_key.`)),W(`index (number)`,k(`The row index of the value to be returned, where the first row in range is numbered 1.`)),W(`is_sorted (boolean, default=true)`,k(`Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned.`),wE)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(N(n?.value,this.locale)),a=L(t);if(1>i||i>a[0].length)return new j(k(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[t][0].value,s=a[F(r.value)?ao(a,e,`nextSmaller`,`asc`,a.length,o):oo(a,e,`wildcard`,a.length,o,this.lookupCaches)];return s===void 0?Oa(e):s[i-1]},isExported:!0},kE={description:k(`Returns the content of a cell, specified by row and column offset.`),args:[W(`reference (any, range)`,k(`The range of cells from which the values are returned.`)),W(`row (number, default=0)`,k(`The index of the row to be returned from within the reference range of cells.`)),W(`column (number, default=0)`,k(`The index of the column to be returned from within the reference range of cells.`))],compute:function(e,t={value:0},n={value:0}){let r=L(e),i=N(t.value,this.locale),a=N(n.value,this.locale);return a<0||a-1>=r.length||i<0||i-1>=r[0].length?new j(k(`Index out of range.`)):i===0&&a===0?r:i===0?[r[a-1]]:a===0?r.map(e=>[e[i-1]]):r[a-1][i-1]},isExported:!0},AE={description:k(`Returns the content of a cell, specified by a string.`),args:[W(`reference (string)`,k(`The range of cells from which the values are returned.`)),W(`use_a1_notation (boolean, default=TRUE)`,k(`A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).`),CE)],compute:function(e,t={value:!0}){let n=e?.value?.toString();if(!n)return new va(k(`Reference should be defined.`));if(!F(t))return new j(k(`R1C1 notation is not supported.`));let r=this.__originSheetId,i=this.__originCellPosition;i&&this.updateDependencies?.(i);let a=this.getters.getRangeFromSheetXC(r,n);if(a===void 0||a.invalidXc||a.invalidSheetName)return new va;i&&this.addDependencies?.(i,[a]);let o=[];for(let e=a.zone.left;e<=a.zone.right;e++){let t=[];for(let n=a.zone.top;n<=a.zone.bottom;n++){let r={sheetId:a.sheetId,col:e,row:n};t.push(this.getters.getEvaluatedCell(r))}o.push(t)}return o.length===1&&o[0].length===1?o[0][0]:o},isExported:!0},jE={description:k(`Look up a value.`),args:[W(`search_key (string, number, boolean)`,k(`The value to search for. For example, 42, 'Cats', or I24.`)),W(`search_array (any, range)`,k(`One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.`)),W(`result_range (any, range, optional)`,k(`The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method.`))],compute:function(e,t,n){let r=L(t),i=L(n),a=r.length,o=r[0].length,s=o>=a,c=ao(r,e,`nextSmaller`,`asc`,s?o:a,s?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value);return c===-1||s&&r[0][c]===void 0||!s&&r[c][o-1]===void 0?Oa(e):i[0].length===0?s?r[a-1][c]:r[c][o-1]:(a=i.length,o=i[0].length,a!==1&&o!==1?new j(k(`The result_range must be a single row or a single column.`)):a>1?c>a-1?new j(k(`[[FUNCTION_NAME]] evaluates to an out of range row value %s.`,c+1)):i[c][0]:c>o-1?new j(k(`[[FUNCTION_NAME]] evaluates to an out of range column value %s.`,c+1)):i[0][c])},isExported:!0},ME={description:k(`Position of item in range that matches value.`),args:[W(`search_key (string, number, boolean)`,k(`The value to search for. For example, 42, 'Cats', or I24.`)),W(`range (any, range)`,k(`The one-dimensional array to be searched.`)),W(`search_type (number, default=1)`,k(`The search method is a number 1, 0 or -1 indicating which value to return. 1 finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order.`),[{value:1,label:k(`Ascending order (default)`)},{value:0,label:k(`Exact match`)},{value:-1,label:k(`Descending order`)}])],compute:function(e,t,n={value:1}){let r=N(n,this.locale),i=L(t),a=i.length,o=i[0].length;if(a!==1&&o!==1)return new j(k(`The range must be a single row or a single column.`));let s=-1,c=a===1?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,l=a===1?i[0].length:i.length;switch(r=Math.sign(r),r){case 1:s=ao(i,e,`nextSmaller`,`asc`,l,c);break;case 0:s=oo(i,e,`wildcard`,l,c,this.lookupCaches);break;case-1:s=ao(i,e,`nextGreater`,`desc`,l,c);break}return a===1&&i[0][s]===void 0||a!==1&&i[s]===void 0?Oa(e):s+1},isExported:!0},NE={description:k(`Row number of a specified cell.`),args:[W(`cell_reference (meta, range<meta>, default='this cell')`,k(`The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered.`))],compute:function(e){if(e===void 0)return this.__originCellPosition?.row===void 0?new j(k(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):this.__originCellPosition.row+1;if(e[0][0]===void 0)return new j(k(`The range is out of bounds.`));if(e[0][0].value===A.InvalidReference)return e[0][0];let t=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),e[0][0].value).zone.top;return e[0].length===1?t+1:Ja(1,e[0].length,(e,n)=>({value:t+n+1}))},isExported:!0},PE={description:k(`Number of rows in a specified array or range.`),args:[W(`range (any, range<any>)`,k(`The range whose row count will be returned.`))],compute:function(e){let t=L(e);return t[0][0]===void 0?new j(k(`The range is out of bounds.`)):t[0][0].value===A.InvalidReference?t[0][0]:t[0].length},isExported:!0},FE={description:k(`Vertical lookup.`),args:[W(`search_key (string, number, boolean)`,k(`The value to search for. For example, 42, 'Cats', or I24.`)),W(`range (any, range)`,k(`The range to consider for the search. The first column in the range is searched for the key specified in search_key.`)),W(`index (number)`,k(`The column index of the value to be returned, where the first column in range is numbered 1.`)),W(`is_sorted (boolean, default=true)`,k(`Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned.`),wE)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(N(n?.value,this.locale)),a=L(t);if(1>i||i>a.length)return new j(k(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[0][t].value,s=F(r.value)?ao(a,e,`nextSmaller`,`asc`,a[0].length,o):oo(a,e,`wildcard`,a[0].length,o,this.lookupCaches),c=a[i-1][s];return c===void 0?Oa(e):c},isExported:!0},IE={0:`strict`,1:`nextGreater`,"-1":`nextSmaller`,2:`wildcard`},LE={description:k(`Search a range for a match and return the corresponding item from a second range.`),args:[W(`search_key (string,number,boolean)`,k(`The value to search for.`)),W(`lookup_range (any, range)`,k(`The range to consider for the search. Should be a single column or a single row.`)),W(`return_range (any, range)`,k(`The range containing the return value. Should have the same dimensions as lookup_range.`)),W(`if_not_found (any, optional)`,k(`If a valid match is not found, return this value.`)),W(`match_mode (any, default=0)`,k(`Specifies how to match search_key with the items in lookup_range. `),[{value:0,label:k(`Exact match (default)`)},{value:-1,label:k(`Exact match or next smaller item`)},{value:1,label:k(`Exact match or next larger item`)},{value:2,label:k(`Wildcard character match`)}]),W(`search_mode (any, default=1)`,k(`Specifies the search mode to use. By default, a first to last search will be used.`),[{value:1,label:k(`Search first to last (default)`)},{value:-1,label:k(`Search last to first`)},{value:2,label:k(`Binary search (sorted ascending order)`)},{value:-2,label:k(`Binary search (sorted descending order)`)}])],compute:function(e,t,n,r,i={value:0},a={value:1}){let o=Math.trunc(N(i.value,this.locale)),s=Math.trunc(N(a.value,this.locale)),c=L(t),l=L(n);if(c.length!==1&&c[0].length!==1)return new j(k(`lookup_range should be either a single row or single column.`));if(![1,-1,2,-2].includes(s))return new j(k(`search_mode should be a value in [-1, 1, -2, 2].`));if(![-1,0,1,2].includes(o))return new j(k(`match_mode should be a value in [-1, 0, 1, 2].`));let u=c.length===1?`col`:`row`;if(o===2&&[-2,2].includes(s))return new j(k(`The search and match mode combination is not supported for XLOOKUP evaluation.`));if(u===`col`?l[0].length!==c[0].length:l.length!==c.length)return new j(k(`return_range should have the same dimensions as lookup_range.`));let d=u===`col`?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,f=u===`col`?c[0].length:c.length,p=IE[o],m=s===-1,h=s===2||s===-2?ao(c,e,p,s===2?`asc`:`desc`,f,d):oo(c,e,p,f,d,this.lookupCaches,m);return h===-1?r===void 0?Oa(e):[[r]]:u===`col`?l.map(e=>[e[h]]):[l[h]]},isExported:!0},RE={description:k(`Get the value from a pivot.`),args:[W(`pivot_id (number,string)`,k(`ID of the pivot.`)),W(`measure_name (string)`,k(`Name of the measure.`)),W(`domain_field_name (string,repeating,optional)`,k(`Field name.`)),W(`domain_value (number,string,boolean,repeating,optional)`,k(`Value.`))],compute:function(e,t,...n){let r=P(e),i=P(t),a=vE(r,this.getters);yE(a,i,this.getters),bE(n);let o=this.getters.getPivot(a),s=this.getters.getPivotCoreDefinition(a);xE(this,a,s.measures.filter(e=>e.id===i)),o.init({reload:o.needsReevaluation});let c=o.assertIsValid({throwOnError:!1});if(c)return c;if(!o.areDomainArgsFieldsValid(n)){let e=k(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${r})`);return{value:A.GenericError,message:k(`Dimensions don't match the pivot definition`)+`. `+e}}let l=o.parseArgsToPivotDomain(n);return this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(a)?.trackValue(i,l),o.getPivotCellValueAndFormat(i,l)}},zE={description:k(`Get the header of a pivot.`),args:[W(`pivot_id (number,string)`,k(`ID of the pivot.`)),W(`domain_field_name (string,repeating,optional)`,k(`Field name.`)),W(`domain_value (number,string,value,repeating,optional)`,k(`Value.`))],compute:function(e,...t){let n=P(e),r=vE(n,this.getters);bE(t);let i=this.getters.getPivot(r);xE(this,r,[]),i.init({reload:i.needsReevaluation});let a=i.assertIsValid({throwOnError:!1});if(a)return a;if(!i.areDomainArgsFieldsValid(t)){let e=k(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${n})`);return{value:A.GenericError,message:k(`Dimensions don't match the pivot definition`)+`. `+e}}let o=i.parseArgsToPivotDomain(t);this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(r)?.trackHeader(o);let s=o.at(-1);if(s?.field===`measure`)return i.getPivotMeasureValue(P(s.value),o);let{value:c,format:l}=i.getPivotHeaderValueAndFormat(o);return{value:c,format:!s||s.field===`measure`||s.value===`false`?void 0:l}}},BE={description:k(`Get a pivot table.`),args:[W(`pivot_id (string)`,k(`ID of the pivot.`)),W(`row_count (number, optional)`,k(`number of rows`)),W(`include_total (boolean, default=TRUE)`,k(`Whether to include total/sub-totals or not.`)),W(`include_column_titles (boolean, default=TRUE)`,k(`Whether to include the column titles or not.`)),W(`column_count (number, optional)`,k(`number of columns`)),W(`include_measure_titles (boolean, default=TRUE)`,k(`Whether to include the measure titles row or not.`))],compute:function(e,t,n,r,i,a){let o=vE(P(e),this.getters),s=this.getters.getPivot(o),c=this.getters.getPivotCoreDefinition(o),l=Vh(c,t,n,r,i,a,this.locale);if(l.numberOfRows<0)return new j(k(`The number of rows must be positive.`));if(l.numberOfColumns<0)return new j(k(`The number of columns must be positive.`));xE(this,o,c.measures),s.init({reload:s.needsReevaluation});let u=s.assertIsValid({throwOnError:!1});if(u)return u;let d=s.getCollapsedTableStructure();if(d.numberOfCells>5e5)return new j(dm(d.numberOfCells,this.locale));let f=d.getPivotCells(l),p=0;l.displayColumnHeaders&&(p=d.columns.length-1),l.displayMeasuresRow&&p++;let m=this.getters.getPivotName(o),{numberOfCols:h,numberOfRows:g}=d.getPivotTableDimensions(l);if(g===0)return[[{value:m}]];let _=[];for(let e of S(0,h)){_[e]=[];for(let t of S(0,g)){let n=f[e][t];switch(n.type){case`EMPTY`:_[e].push({value:``});break;case`HEADER`:let t=s.getPivotHeaderValueAndFormat(n.domain);_[e].push(Mh(n.domain,t));break;case`MEASURE_HEADER`:_[e].push(s.getPivotMeasureValue(n.measure,n.domain));break;case`VALUE`:_[e].push(s.getPivotCellValueAndFormat(n.measure,n.domain));break}}}return(l.displayColumnHeaders||l.displayMeasuresRow)&&(_[0][0]={value:m}),_}},VE={description:k(`Returns a range reference shifted by a specified number of rows and columns from a starting cell reference.`),args:[W(`cell_reference (meta, range<meta>)`,k(`The starting point from which to count the offset rows and columns.`)),W(`offset_rows (number)`,k(`The number of rows to offset by.`)),W(`offset_columns (number)`,k(`The number of columns to offset by.`)),W(`height (number, default='height of cell_reference')`,k(`The number of rows of the range to return starting at the offset target.`)),W(`width (number, default='width of cell_reference')`,k(`The number of columns of the range to return starting at the offset target.`))],compute:function(e,t,n,r,i){if(M(e[0][0].value))return e[0][0];let a=e[0][0].value;if(!a)return new j(`In this context, the function OFFSET needs to have a cell or range in parameter.`);let o=mn(a),s=e[0].length,c=e.length;if(r){let e=N(r,this.locale);if(e<1)return new j(k(`Height value is %(_height)s. It should be greater than or equal to 1.`,{_height:e}));s=e}if(i){let e=N(i,this.locale);if(e<1)return new j(k(`Width value is %(_width)s. It should be greater than or equal to 1.`,{_width:e}));c=e}let{sheetName:l}=zc(a),u=l&&this.getters.getSheetIdByName(l)||this.getters.getActiveSheetId(),d=N(t,this.locale),f=N(n,this.locale),p=this.__originCellPosition;p&&this.updateDependencies?.(p);let m=o.left+f,h=o.top+d;if(m<0||h<0)return new va(k(`OFFSET evaluates to an out of bounds range.`));let g={left:m,top:h,right:m+c-1,bottom:h+s-1},_=this.getters.getRangeFromZone(u,g);return _.invalidXc||_.invalidSheetName?new va:(p&&this.addDependencies?.(p,[_]),Ja(c,s,(e,t)=>this.getters.getEvaluatedCell({sheetId:u,col:m+e,row:h+t})))}},HE={description:k(`Returns an element from a list of choices based on index.`),args:[W(`index (number)`,k(`Which choice to return.`)),W(`choice (any, range<any>, repeating)`,k(`A potential value to return. May be a reference to a cell or an individual value.`))],compute:function(e,...t){let n=Math.floor(N(e,this.locale))-1;return n<0||n>=t.length?new j(k(`Index for CHOOSE is invalid. Valid values are between 1 and %(choices)s inclusive.`,{choices:t.length})):t[n]??new j(k(`Choice is undefined.`))},isExported:!0},UE={description:k(`Excludes a specified number of rows or columns from the start or end of an array.`),args:[W(`array (range)`,k(`The array from which to drop rows or columns`)),W(`rows (number)`,k(`The number of rows to drop. A negative value drops from the end of the array.`)),W(`columns (number, optional)`,k(`The number of columns to exclude. A negative value drops from the end of the array.`))],compute:function(e,t,n){let r=N(t,this.locale),i=N(n,this.locale),a=e;if(Math.abs(i)>=e.length||Math.abs(r)>=e[0].length)return new j(k(`The number of rows or column to exclude must be smaller than the number of elements in the array.`));a=i>=0?a.slice(i):a.slice(0,a.length+i);for(let e=0;e<a.length;e++)r>=0?a[e]=a[e].slice(r):a[e]=a[e].slice(0,a[e].length+r);return a},isExported:!0},WE={description:k(`Returns a specified number of contiguous rows or columns from the start or end of an array.`),args:[W(`array (range)`,k(`The array from which to take rows or columns.`)),W(`rows (number)`,k(`The number of rows to take. A negative value takes from the end of the array.`)),W(`columns (number, optional)`,k(`The number of columns to take. A negative value takes from the end of the array.`))],compute:function(e,t,n){let r=t?N(t,this.locale):e[0].length,i=N(n,this.locale),a=e;if((Math.abs(i)>=e.length||i===0)&&(i=e.length),Math.abs(r)>=e[0].length&&(r=e[0].length),a=i>=0?a.slice(0,i):a.slice(a.length+i,a.length),r===0)return new j(k(`The number of rows can not be zero.`));for(let e=0;e<a.length;e++)r>0?a[e]=a[e].slice(0,r):a[e]=a[e].slice(a[e].length+r,a[e].length);return a},isExported:!0},GE={description:k(`Returns a formula as a string.`),args:[W(`cell_reference (meta)`,k(`A reference to a cell.`))],compute:function(e){let{sheetName:t,xc:n}=zc(e.value),{col:r,row:i}=tn(n),a=(t&&this.getters.getSheetIdByName(t))??this.__originSheetId,o=this.getters.getCell({sheetId:a,col:r,row:i});return o?.isFormula?o.compiledFormula.toFormulaString(this.getters):new ya(k(`The cell does not contain a formula.`))},isExported:!0};var KE=l({ADD:()=>qE,CONCAT:()=>JE,DIVIDE:()=>YE,EQ:()=>$E,GT:()=>tD,GTE:()=>nD,LT:()=>rD,LTE:()=>iD,MINUS:()=>aD,MULTIPLY:()=>oD,NE:()=>sD,POW:()=>cD,SPILLED_RANGE:()=>lD,UMINUS:()=>uD,UNARY_PERCENT:()=>dD,UPLUS:()=>fD});let qE={description:k(`Sum of two numbers.`),args:[W(`value1 (number)`,k(`The first addend.`)),W(`value2 (number)`,k(`The second addend.`))],compute:function(e,t){return{value:N(e,this.locale)+N(t,this.locale),format:e?.format||t?.format}}},JE={description:k(`Concatenation of two values.`),args:[W(`value1 (string)`,k(`The value to which value2 will be appended.`)),W(`value2 (string)`,k(`The value to append to value1.`))],compute:function(e,t){return P(e)+P(t)},isExported:!0},YE={description:k(`One number divided by another.`),args:[W(`dividend (number)`,k(`The number to be divided.`)),W(`divisor (number)`,k(`The number to divide by.`))],compute:function(e,t){let n=N(t,this.locale);return n===0?new Sa(k(`The divisor must be different from zero.`)):{value:N(e,this.locale)/n,format:e?.format||t?.format}}};function XE(e){return e===void 0||e.value===null}let ZE={number:0,string:``,boolean:!1};function QE(e,t,n=2e-16){return Math.abs(e-t)<n}let $E={description:k(`Equal.`),args:[W(`value1 (string, number, boolean)`,k(`The first value.`)),W(`value2 (string, number, boolean)`,k(`The value to test against value1 for equality.`))],compute:function(e,t){if(M(e?.value))return e;if(M(t?.value))return t;let n=XE(e)?ZE[typeof t?.value]:e?.value,r=XE(t)?ZE[typeof e?.value]:t?.value;return typeof n==`string`&&(n=n.toUpperCase()),typeof r==`string`&&(r=r.toUpperCase()),typeof n==`number`&&typeof r==`number`?{value:QE(n,r)}:{value:n===r}}};function eD(e,t,n){if(M(e?.value))return e;if(M(t?.value))return t;let r=XE(e)?ZE[typeof t?.value]:e?.value,i=XE(t)?ZE[typeof e?.value]:t?.value;typeof r!=`number`&&(r=P(r).toUpperCase()),typeof i!=`number`&&(i=P(i).toUpperCase());let a=typeof r,o=typeof i;return a===`string`&&o===`number`?{value:!0}:o===`string`&&a===`number`?{value:!1}:{value:n(r,i)}}let tD={description:k(`Strictly greater than.`),args:[W(`value1 (number, string, boolean)`,k(`The value to test as being greater than value2.`)),W(`value2 (number, string, boolean)`,k(`The second value.`))],compute:function(e,t){return eD(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?!QE(e,t)&&e>t:e>t)}},nD={description:k(`Greater than or equal to.`),args:[W(`value1 (number, string, boolean)`,k(`The value to test as being greater than or equal to value2.`)),W(`value2 (number, string, boolean)`,k(`The second value.`))],compute:function(e,t){return eD(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?QE(e,t)||e>t:e>=t)}},rD={description:k(`Less than.`),args:[W(`value1 (number, string, boolean)`,k(`The value to test as being less than value2.`)),W(`value2 (number, string, boolean)`,k(`The second value.`))],compute:function(e,t){let n=nD.compute.bind(this)(e,t);return M(n.value)?n:{value:!n.value}}},iD={description:k(`Less than or equal to.`),args:[W(`value1 (number, string, boolean)`,k(`The value to test as being less than or equal to value2.`)),W(`value2 (number, string, boolean)`,k(`The second value.`))],compute:function(e,t){let n=tD.compute.bind(this)(e,t);return M(n.value)?n:{value:!n.value}}},aD={description:k(`Difference of two numbers.`),args:[W(`value1 (number)`,k(`The minuend, or number to be subtracted from.`)),W(`value2 (number)`,k(`The subtrahend, or number to subtract from value1.`))],compute:function(e,t){return{value:N(e,this.locale)-N(t,this.locale),format:e?.format||t?.format}}},oD={description:k(`Product of two numbers`),args:[W(`factor1 (number)`,k(`The first multiplicand.`)),W(`factor2 (number)`,k(`The second multiplicand.`))],compute:function(e,t){return{value:N(e,this.locale)*N(t,this.locale),format:e?.format||t?.format}}},sD={description:k(`Not equal.`),args:[W(`value1 (string, number, boolean)`,k(`The first value.`)),W(`value2 (string, number, boolean)`,k(`The value to test against value1 for inequality.`))],compute:function(e,t){let n=$E.compute.bind(this)(e,t);return M(n.value)?n:{value:!n.value}}},cD={description:k(`A number raised to a power.`),args:[W(`base (number)`,k(`The number to raise to the exponent power.`)),W(`exponent (number)`,k(`The exponent to raise base to.`))],compute:function(e,t){return Eb.compute.bind(this)(e,t)}},lD={description:k(`Gets the spilled range of an array formula.`),args:[W(`ref (meta , range<meta>)`,k(`The reference to get the spilled range from.`))],compute:function(e){if(e===void 0)return new j(k(`The range is out of bounds.`));if(e.length!==1||e[0].length!==1)return new j(k(`Only single-cell references are allowed to get the spilled range.`));let t=e[0][0];if(M(t.value))return t;let n=this.getters.getRangeFromSheetXC(this.__originSheetId,t.value),r={col:n.zone.left,row:n.zone.top,sheetId:n.sheetId},i=this.__originCellPosition;i&&this.updateDependencies?.(i);let a=this.getters.getSpreadZone(r);if(a===void 0)return new va;let o=this.getters.getRangeFromZone(n.sheetId,a);return i&&this.addDependencies?.(i,[o]),Ja(a.right-a.left+1,a.bottom-a.top+1,(e,t)=>this.getters.getEvaluatedCell({sheetId:o.sheetId,col:a.left+e,row:a.top+t}))},hidden:!0},uD={description:k(`A number with the sign reversed.`),args:[W(`value (number)`,k(`The number to have its sign reversed. Equivalently, the number to multiply by -1.`))],compute:function(e){return{value:-N(e,this.locale),format:e?.format}}},dD={description:k(`Value interpreted as a percentage.`),args:[W(`percentage (number)`,k(`The value to interpret as a percentage.`))],compute:function(e){return N(e,this.locale)/100}},fD={description:k(`A specified number, unchanged.`),args:[W(`value (any)`,k(`The number to return.`))],compute:function(e={value:null}){return e}},G=e=>({transform:t=>t*e,inverseTransform:t=>t/e}),pD={transform:e=>e,inverseTransform:e=>e},mD=1e-10,hD=.0254,gD=hD/72,_D=.3048,vD=.9144,yD=1609.34,bD=1852,xD=946073047258e4,SD={g:{...pD,category:`weight`},u:{...G(166053e-29),category:`weight`},grain:{...G(.0647989),category:`weight`},ozm:{...G(28.3495),category:`weight`},lbm:{...G(453.592),category:`weight`},stone:{...G(6350.29),category:`weight`},sg:{...G(14593.90294),category:`weight`},cwt:{...G(45359.237),category:`weight`},uk_cwt:{...G(50802.3),category:`weight`},ton:{...G(907184.74),category:`weight`},uk_ton:{...G(1016046.9),category:`weight`},m:{...pD,category:`distance`},km:{...G(1e3),category:`distance`},ang:{...G(mD),category:`distance`},Picapt:{...G(gD),category:`distance`},pica:{...G(hD/6),category:`distance`},in:{...G(hD),category:`distance`},ft:{...G(_D),category:`distance`},yd:{...G(vD),category:`distance`},ell:{...G(1.143),category:`distance`},mi:{...G(yD),category:`distance`},survey_mi:{...G(1609.34),category:`distance`},Nmi:{...G(bD),category:`distance`},ly:{...G(xD),category:`distance`},parsec:{...G(0x6da012f95c9fd0),category:`distance`},sec:{...pD,category:`time`},min:{...G(60),category:`time`},hr:{...G(3600),category:`time`},day:{...G(86400),category:`time`},yr:{...G(31556952),category:`time`},Pa:{...pD,category:`pressure`},bar:{...G(1e5),category:`pressure`},mmHg:{...G(133.322),category:`pressure`},Torr:{...G(133.322),category:`pressure`},psi:{...G(6894.76),category:`pressure`},atm:{...G(101325),category:`pressure`},N:{...pD,category:`force`},dyn:{...G(1e-5),category:`force`},pond:{...G(.00980665),category:`force`},lbf:{...G(4.44822),category:`force`},J:{...pD,category:`energy`},eV:{...G(160218e-24),category:`energy`},e:{...G(1e-7),category:`energy`},flb:{...G(1.3558179483),category:`energy`},c:{...G(4.184),category:`energy`},cal:{...G(4.1868),category:`energy`},BTU:{...G(1055.06),category:`energy`},Wh:{...G(3600),category:`energy`},HPh:{...G(2684520),category:`energy`},W:{...pD,category:`power`},PS:{...G(735.499),category:`power`},HP:{...G(745.7),category:`power`},T:{...pD,category:`magnetism`},ga:{...G(1e-4),category:`magnetism`},K:{...pD,category:`temperature`},C:{transform:e=>e+273.15,inverseTransform:e=>e-273.15,category:`temperature`},F:{transform:e=>(e-32)*5/9+273.15,inverseTransform:e=>(e-273.15)*9/5+32,category:`temperature`},Rank:{...G(5/9),category:`temperature`},Reau:{transform:e=>e*1.25+273.15,inverseTransform:e=>(e-273.15)/1.25,category:`temperature`},"m^3":{...pD,category:`volume`,order:3},"ang^3":{...G(mD**3),category:`volume`,order:3},"Picapt^3":{...G(gD**3),category:`volume`,order:3},tsp:{...G(492892e-11),category:`volume`},tspm:{...G(5e-6),category:`volume`},tbs:{...G(14786764825785619e-21),category:`volume`},"in^3":{...G(hD**3),category:`volume`,order:3},oz:{...G(295735295625e-16),category:`volume`},cup:{...G(237e-6),category:`volume`},pt:{...G(.0004731765),category:`volume`},uk_pt:{...G(568261e-9),category:`volume`},qt:{...G(.0009463529),category:`volume`},l:{...G(.001),category:`volume`},uk_qt:{...G(.0011365225),category:`volume`},gal:{...G(.0037854118),category:`volume`},uk_gal:{...G(.00454609),category:`volume`},"ft^3":{...G(_D**3),category:`volume`,order:3},bushel:{...G(.0352390704),category:`volume`},barrel:{...G(.158987295),category:`volume`},"yd^3":{...G(vD**3),category:`volume`,order:3},MTON:{...G(1.13267386368),category:`volume`},GRT:{...G(2.83168),category:`volume`},"mi^3":{...G(yD**3),category:`volume`,order:3},"Nmi^3":{...G(bD**3),category:`volume`,order:3},"ly^3":{...G(xD**3),category:`volume`,order:3},"m^2":{...pD,category:`area`,order:2},"ang^2":{...G(mD**2),category:`area`,order:2},"Picapt^2":{...G(gD**2),category:`area`,order:2},"in^2":{...G(hD**2),category:`area`,order:2},"ft^2":{...G(_D**2),category:`area`,order:2},"yd^2":{...G(vD**2),category:`area`,order:2},ar:{...G(100),category:`area`},Morgen:{...G(2500),category:`area`},uk_acre:{...G(4046.8564224),category:`area`},us_acre:{...G(4046.8726098743),category:`area`},ha:{...G(1e4),category:`area`},"mi^2":{...G(yD**2),category:`area`,order:2},"Nmi^2":{...G(bD**2),category:`area`,order:2},"ly^2":{...G(xD**2),category:`area`,order:2},bit:{...pD,category:`information`},byte:{...G(8),category:`information`},"m/s":{...pD,category:`speed`},"m/hr":{...G(1/3600),category:`speed`},"km/hr":{...G(1/3.6),category:`speed`},mph:{...G(.44704),category:`speed`},kn:{...G(.5144444444),category:`speed`},admkn:{...G(.5147733333),category:`speed`}},CD={shweight:`cwt`,lcwt:`uk_cwt`,hweight:`uk_cwt`,LTON:`uk_ton`,brton:`uk_ton`,pc:`parsec`,Pica:`Picapt`,d:`day`,mn:`min`,s:`sec`,p:`Pa`,at:`atm`,dy:`dyn`,ev:`eV`,hh:`HPh`,wh:`Wh`,btu:`BTU`,h:`HP`,cel:`C`,fah:`F`,kel:`K`,us_pt:`pt`,L:`l`,lt:`l`,ang3:`ang^3`,ft3:`ft^3`,in3:`in^3`,ly3:`ly^3`,m3:`m^3`,mi3:`mi^3`,yd3:`yd^3`,Nmi3:`Nmi^3`,Picapt3:`Picapt^3`,"Pica^3":`Picapt^3`,Pica3:`Picapt^3`,regton:`GRT`,ang2:`ang^2`,ft2:`ft^2`,in2:`in^2`,ly2:`ly^2`,m2:`m^2`,mi2:`mi^2`,Nmi2:`Nmi^2`,Picapt2:`Picapt^2`,"Pica^2":`Picapt^2`,Pica2:`Picapt^2`,yd2:`yd^2`,"m/h":`m/hr`,"m/sec":`m/s`},wD={"":1,Y:1e24,Z:1e21,E:0xde0b6b3a7640000,P:0x38d7ea4c68000,T:0xe8d4a51000,G:1e9,M:1e6,k:1e3,h:100,da:10,e:10,d:.1,c:.01,m:.001,u:1e-6,n:1e-9,p:1e-12,f:1e-15,a:1e-18,z:1e-21,y:1e-21,Yi:2**80,Zi:2**70,Ei:2**60,Pi:2**50,Ti:2**40,Gi:2**30,Mi:2**20,ki:2**10},TD={weight:k(`Weight`),distance:k(`Distance`),time:k(`Time`),pressure:k(`Pressure`),force:k(`Force`),energy:k(`Energy`),power:k(`Power`),magnetism:k(`Magnetism`),temperature:k(`Temperature`),volume:k(`Volume`),area:k(`Area`),information:k(`Information`),speed:k(`Speed`)},ED=Object.entries(SD).map(([e,t])=>({value:e,label:DD(t.category)}));function DD(e){return TD[e]??``}function OD(e){for(let[t,n]of Object.entries(wD)){if(t&&!e.startsWith(t))continue;let r=e.slice(t.length),i=SD[r];if(!i&&CD[r]&&(i=SD[CD[r]]),i)return{...i,factor:i.order?n**+i.order:n}}}var kD=l({CONVERT:()=>AD});let AD={description:k(`Converts a numeric value to a different unit of measure.`),args:[W(`value (number)`,k(`the numeric value in start_unit to convert to end_unit`)),W(`start_unit (string)`,k(`The starting unit, the unit currently assigned to value`),ED),W(`end_unit (string)`,k(`The unit of measure into which to convert value`),ED)],compute:function(e,t,n){let r=N(e,this.locale),i=P(t),a=P(n),o=OD(i),s=OD(a);return o?s?o.category===s.category?{value:s.inverseTransform(o.factor*o.transform(r))/s.factor,format:e?.format}:{value:A.GenericError,message:k(`Incompatible units of measure ('%s' vs '%s')`,DD(o.category),DD(s.category))}:{value:A.GenericError,message:k(`Invalid units of measure ('%s')`,a)}:{value:A.GenericError,message:k(`Invalid units of measure ('%s')`,i)}},isExported:!0};var jD=l({CHAR:()=>FD,CLEAN:()=>ID,CONCATENATE:()=>LD,EXACT:()=>RD,FIND:()=>zD,FORMAT_LARGE_NUMBER:()=>BD,JOIN:()=>VD,LEFT:()=>HD,LEN:()=>UD,LOWER:()=>WD,MID:()=>GD,PROPER:()=>KD,REGEXEXTRACT:()=>JD,REGEXREPLACE:()=>YD,REGEXTEST:()=>qD,REPLACE:()=>XD,RIGHT:()=>ZD,SEARCH:()=>QD,SPLIT:()=>$D,SUBSTITUTE:()=>eO,TEXT:()=>aO,TEXTAFTER:()=>sO,TEXTBEFORE:()=>cO,TEXTJOIN:()=>tO,TEXTSPLIT:()=>nO,TRIM:()=>rO,UPPER:()=>iO,VALUE:()=>oO});let MD=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,ND=[{value:0,label:k(`Case-sensitive (default)`)},{value:1,label:k(`Case-insensitive`)}],PD=[{value:0,label:k(`Don't match to end (default)`)},{value:1,label:k(`Match to end`)}],FD={description:k(`Gets character associated with number.`),args:[W(`table_number (number)`,k(`The number of the character to look up from the current Unicode table in decimal format.`))],compute:function(e){let t=Math.trunc(N(e,this.locale));return t<1?new j(k(`The table_number (%s) is out of range.`,t)):String.fromCharCode(t)},isExported:!0},ID={description:k(`Remove non-printable characters from a piece of text.`),args:[W(`text (string)`,k(`The text whose non-printable characters are to be removed.`))],compute:function(e){let t=P(e),n=``;for(let e of t)e&&e.charCodeAt(0)>31&&(n+=e);return n},isExported:!0},LD={description:k(`Appends strings to one another.`),args:[W(`string (string, range<string>, repeating)`,k(`String to append in sequence.`))],compute:function(...e){return Ga(e,(e,t)=>e+P(t),``)},isExported:!0},RD={description:k(`Tests whether two strings are identical.`),args:[W(`string1 (string)`,k(`The first string to compare.`)),W(`string2 (string)`,k(`The second string to compare.`))],compute:function(e,t){return P(e)===P(t)},isExported:!0},zD={description:k(`First position of string found in text, case-sensitive.`),args:[W(`search_for (string)`,k(`The string to look for within text_to_search.`)),W(`text_to_search (string)`,k(`The text to search for the first occurrence of search_for.`)),W(`starting_at (number, default=1)`,k(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=P(e),i=P(t),a=N(n,this.locale);if(i===``)return new j(k(`The text_to_search must be non-empty.`));if(a<1)return new j(k(`The starting_at (%s) must be greater than or equal to 1.`,a));let o=i.indexOf(r,a-1);return o===-1?new j(k(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)):o+1},isExported:!0},BD={description:k(`Apply a large number format`),args:[W(`value (number)`,k(`The number.`)),W(`unit (string, optional)`,k(`The formatting unit. Use 'k', 'm', or 'b' to force the unit`),[{value:`k`,label:k(`Thousand`)},{value:`m`,label:k(`Million`)},{value:`b`,label:k(`Billion`)}])],compute:function(e,t){return{value:N(e,this.locale),format:bs(e,t,this.locale)}}},VD={description:k(`Concatenates elements of arrays with delimiter.`),args:[W(`delimiter (string)`,k(`The character or string to place between each concatenated value.`)),W(`value_or_array (string, range<string>, repeating)`,k(`Value to be appended using delimiter.`))],compute:function(e,...t){let n=P(e);return Ga(t,(e,t)=>(e?e+n:``)+P(t),``)}},HD={description:k(`Substring from beginning of specified string.`),args:[W(`text (string)`,k(`The string from which the left portion will be returned.`)),W(`number_of_characters (number, optional)`,k(`The number of characters to return from the left side of string.`))],compute:function(e,...t){let n=t.length?N(t[0],this.locale):1;return n<0?new j(k(`The number_of_characters (%s) must be positive or null.`,n)):P(e).substring(0,n)},isExported:!0},UD={description:k(`Length of a string.`),args:[W(`text (string)`,k(`The string whose length will be returned.`))],compute:function(e){return P(e).length},isExported:!0},WD={description:k(`Converts a specified string to lowercase.`),args:[W(`text (string)`,k(`The string to convert to lowercase.`))],compute:function(e){return P(e).toLowerCase()},isExported:!0},GD={description:k(`A segment of a string.`),args:[W(`text (string)`,k(`The string to extract a segment from.`)),W(`starting_at (number)`,k(`The index from the left of string from which to begin extracting. The first character in string has the index 1.`)),W(`extract_length (number)`,k(`The length of the segment to extract.`))],compute:function(e,t,n){let r=P(e),i=N(t,this.locale),a=N(n,this.locale);return i<1?new j(k(`The starting_at argument (%s) must be positive greater than one.`,i.toString())):a<0?new j(k(`The extract_length argument (%s) must be positive or null.`,a)):r.slice(i-1,i+a-1)},isExported:!0},KD={description:k(`Capitalizes each word in a specified string.`),args:[W(`text_to_capitalize (string)`,k(`The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase.`))],compute:function(e){return P(e).replace(MD,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())},isExported:!0},qD={description:k(`Checks whether a string matches the supplied regular expression.`),args:[W(`text (string)`,k(`The string to test.`)),W(`pattern (string)`,k(`The regular expression pattern to match against the text.`)),W(`case_sensitivity (number, default=0)`,k(`Whether the match is case-sensitive.`),[{value:0,label:k(`Case-sensitive`)},{value:1,label:k(`Case-insensitive`)}])],compute:function(e,t,n={value:0}){let r=P(e),i=P(t),a=N(n,this.locale);if(i===``)return!0;if(r===``)return!1;if(a!==0&&a!==1)return new j(k(`The case_sensitivity (%s) must be 0 or 1.`,a));let o=a===1?`gi`:`g`,s;try{s=new RegExp(i,o)}catch{return new j(k(`Invalid regular expression`))}return s.test(r)},isExported:!0},JD={description:k(`Extract text from a string based on the supplied regular expression.`),args:[W(`text (string)`,k(`The string on which you want to extract text.`)),W(`pattern (string)`,k(`The regular expression pattern to match against the text.`)),W(`return_mode (number, default=0)`,k(`0 = first match, 1 = all matches as an array, 2 = capturing groups from the first match as an array.`),[{value:0,label:k(`First match`)},{value:1,label:k(`All matches`)},{value:2,label:k(`Capture groups of first match`)}]),W(`case_sensitivity (number, default=0)`,k(`Whether the match is case-sensitive.`),[{value:0,label:k(`Case-sensitive`)},{value:1,label:k(`Case-insensitive`)}])],compute:function(e,t,n={value:0},r={value:0}){let i=P(e),a=P(t),o=N(n,this.locale),s=N(r,this.locale);if(i===``||a===``)return{value:``};if(o<0||o>2)return new j(k(`The return_mode (%s) must be 0, 1 or 2.`,o));if(s!==0&&s!==1)return new j(k(`The case_sensitivity (%s) must be 0 or 1.`,s));let c=s===1?`gi`:`g`,l;try{l=new RegExp(a,c)}catch{return new j(k(`Invalid regular expression`))}let u=[...i.matchAll(l)];return u.length===0?{value:A.NotAvailable,message:k(`No matches found.`)}:o===0?u[0][0]:o===1?u.map(e=>[e[0]]):u[0].length<2?new j(k(`No capturing groups found.`)):u[0].slice(1).map(e=>[e])},isExported:!0},YD={description:k(`Replace text in a string based on the supplied regular expression.`),args:[W(`text (string)`,k(`The string in which you want to replace text.`)),W(`pattern (string)`,k(`The regular expression pattern to match against the text.`)),W(`replacement (string)`,k(`The text to use as the replacement.`)),W(`occurrence (number, default=0)`,k(`0 = replace all matches. A negative number counts from the end.`)),W(`case_sensitivity (number, default=0)`,k(`Whether the match is case-sensitive.`),[{value:0,label:k(`Case-sensitive`)},{value:1,label:k(`Case-insensitive`)}])],compute:function(e,t,n,r={value:0},i={value:0}){let a=P(e),o=P(t),s=P(n),c=N(r,this.locale),l=N(i,this.locale);if(l!==0&&l!==1)return new j(k(`The case_sensitivity (%s) must be 0 or 1.`,l));let u=l===1?`gi`:`g`,d;try{d=new RegExp(o,u)}catch{return new j(k(`Invalid regular expression`))}if(c!==0){let e=[...a.matchAll(d)];if(e.length===0||Math.abs(c)>e.length)return a;let t=c>0?c-1:e.length+c,n=e[t][0].length,r=e[t].index;return a.substring(0,r)+s+a.substring(r+n)}return a.replace(d,s)},isExported:!0},XD={description:k(`Replaces part of a text string with different text.`),args:[W(`text (string)`,k(`The text, a part of which will be replaced.`)),W(`position (number)`,k(`The position where the replacement will begin (starting from 1).`)),W(`length (number)`,k(`The number of characters in the text to be replaced.`)),W(`new_text (string)`,k(`The text which will be inserted into the original text.`))],compute:function(e,t,n,r){let i=N(t,this.locale);if(i<1)return new j(k(`The position (%s) must be greater than or equal to 1.`,i));let a=P(e),o=N(n,this.locale),s=P(r);return a.substring(0,i-1)+s+a.substring(i-1+o)},isExported:!0},ZD={description:k(`A substring from the end of a specified string.`),args:[W(`text (string)`,k(`The string from which the right portion will be returned.`)),W(`number_of_characters (number, optional)`,k(`The number of characters to return from the right side of string.`))],compute:function(e,...t){let n=t.length?N(t[0],this.locale):1;if(n<0)return new j(k(`The number_of_characters (%s) must be positive or null.`,n));let r=P(e),i=r.length;return r.substring(i-n,i)},isExported:!0},QD={description:k(`First position of string found in text, ignoring case.`),args:[W(`search_for (string)`,k(`The string to look for within text_to_search.`)),W(`text_to_search (string)`,k(`The text to search for the first occurrence of search_for.`)),W(`starting_at (number, default=1)`,k(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=P(e).toLowerCase(),i=P(t).toLowerCase(),a=N(n,this.locale);if(i===``)return{value:A.GenericError,message:k(`The text_to_search must be non-empty.`)};if(a<1)return{value:A.GenericError,message:k(`The starting_at (%s) must be greater than or equal to 1.`,a)};let o=i.indexOf(r,a-1);return o===-1?{value:A.GenericError,message:k(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)}:{value:o+1}},isExported:!0},$D={description:k(`Split text by specific character delimiter(s).`),args:[W(`text (string)`,k(`The text to divide.`)),W(`delimiter (string)`,k(`The character or characters to use to split text.`)),W(`split_by_each (boolean, default=true})`,k(`Whether or not to divide text around each character contained in delimiter.`)),W(`remove_empty_text (boolean, default=true)`,k(`Whether or not to remove empty text messages from the split results. The default behavior is to treat consecutive delimiters as one (if TRUE). If FALSE, empty cells values are added between consecutive delimiters.`))],compute:function(e,t,n={value:!0},r={value:!0}){let i=P(e),a=qe(P(t)),o=F(n),s=F(r);if(a.length<=0)return new j(k(`The delimiter (%s) must be not be empty.`,a));let c=o?RegExp(`[${a}]`,`g`):new RegExp(a,`g`),l=i.split(c);return s&&(l=l.filter(e=>e!==``)),Za([l])},isExported:!1},eO={description:k(`Replaces existing text with new text in a string.`),args:[W(`text_to_search (string)`,k(`The text within which to search and replace.`)),W(`search_for (string)`,k(`The string to search for within text_to_search.`)),W(`replace_with (string)`,k(`The string that will replace search_for.`)),W(`occurrence_number (number, optional)`,k(`The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced.`))],compute:function(e,t,n,r){let i=N(r,this.locale);if(i<0)return new j(k(`The occurrenceNumber (%s) must be positive or null.`,i));let a=P(e),o=P(t);if(o===``)return a;let s=P(n),c=new RegExp(qe(o),`g`);if(i===0)return a.replace(c,s);let l=0;return a.replace(c,e=>++l===i?s:e)},isExported:!0},tO={description:k(`Combines text from multiple strings and/or arrays.`),args:[W(`delimiter (string)`,k(`A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.`)),W(`ignore_empty (boolean)`,k(`A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.`),[{value:!0,label:k(`Ignore empty cells`)},{value:!1,label:k(`Include empty cells (default)`)}]),W(`texts (string, range<string>, repeating)`,k(`Text item to join.`))],compute:function(e,t={value:!0},...n){let r=P(e),i=F(t),a=0;return Ga(n,(e,t)=>i&&P(t)===``?e:(a++?e+r:``)+P(t),``)},isExported:!0},nO={description:k(`Splits text into rows or columns using specified column and row delimiters.`),args:[W(`text (string)`,k(`The text to split.`)),W(`col_delimiter (string, range<string>)`,k(`Character or string to split columns by.`)),W(`row_delimiter (string, range<string>, optional)`,k(`Character or string to split rows by.`)),W(`ignore_empty (boolean, default=false)`,k(`Whether to ignore empty cells.`),[{value:!1,label:k(`Include empty cells (default)`)},{value:!0,label:k(`Ignore empty cells`)}]),W(`match_mode (number, default=0)`,k(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),ND),W(`pad_with (string, default="${A.NotAvailable}")`,k(`The value to use for padding empty cells.`))],compute:function(e,t,n,r={value:!1},i={value:0},a=new ya){let o=P(e);if(o.length<=0)return new j(k(`No text to split.`));if(t===void 0&&n===void 0)return new j(k(`At least one delimiter must be provided.`));let s=L(t).flat().map(e=>qe(P(e))),c=L(n).flat().map(e=>qe(P(e)));if(s.some(e=>e===``)||c.some(e=>e===``))return new j(k(`The delimiters cannot be empty values.`));let l=F(r),u=N(i,this.locale);if(![0,1].includes(u))return new j(k(`match_mode should be a value of 0 or 1.`));let d=[],f=u===1?`gi`:`g`,p=c.filter(e=>!s.includes(e)),m=p.length?o.split(new RegExp(p.join(`|`),f)):[o];l&&(m=m.filter(e=>e!==``));let h=new RegExp(s.join(`|`),f);for(let e of m){let t=s.length?e.split(h):[e];l&&(t=t.filter(e=>e!==``)),d.push(t.map(e=>({value:e})))}let g=Math.max(...d.map(e=>e.length));for(let e of d)for(;e.length<g;)e.push(a);return Za(d)},isExported:!0},rO={description:k(`Removes space characters.`),args:[W(`text (string)`,k(`The text or reference to a cell containing text to be trimmed.`))],compute:function(e){return Pt(P(e))},isExported:!0},iO={description:k(`Converts a specified string to uppercase.`),args:[W(`text (string)`,k(`The string to convert to uppercase.`))],compute:function(e){return P(e).toUpperCase()},isExported:!0},aO={description:k(`Converts a number to text according to a specified format.`),args:[W(`number (number)`,k(`The number, date or time to format.`)),W(`format (string)`,k(`The case-sensitive format of the result, enclosed in quotation marks. Examples: "0.00" rounded to 2 decimal places, "hh:mm:ss" for hour:minutes:seconds.`))],compute:function(e,t){return z(N(e,this.locale),{format:P(t),locale:this.locale})},isExported:!0},oO={description:k(`Converts a string to a numeric value.`),args:[W(`value (number)`,k(`the string to be converted`))],compute:function(e){return N(e,this.locale)},isExported:!0},sO={description:k(`Returns text that occurs after a given substring or delimiter.`),args:[W(`text (string)`,k(`The source text.`)),W(`delimiter (string)`,k(`The substring after which text will be returned.`)),W(`instance_num (number, default=1)`,k(`The desired instance of the delimiter after which we extract the text. A negative number searches from the end.`)),W(`match_mode (number, default=0)`,k(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),ND),W(`match_end (number, default=0))`,k(`Whether to treat the end of text as a delimiter.`),PD),W(`if_not_found (string, default="${A.NotAvailable}")`,k(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new ya){let o=P(e),s=N(n,this.locale),c=N(r,this.locale),l=N(i,this.locale);if(s===0)return new j(k(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new j(k(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new j(k(`match_end should have a value of 0 or 1.`));let u=P(t);if(u===``)return Math.sign(s)>0?{value:o}:{value:``};let d=c===1?`gi`:`g`,f=qe(u),p=new RegExp(f,d),m=[...o.matchAll(p)].map(e=>e.index+f.length);if(s<0&&(m=m.reverse()),l&&Math.abs(s)===m.length+1)return Math.sign(s)>0?{value:``}:{value:o};let h=m[Math.abs(s)-1];return h===void 0?a:{value:o.substring(h)}},isExported:!0},cO={description:k(`Returns text that occurs before a given substring or delimiter.`),args:[W(`text (string)`,k(`The source text.`)),W(`delimiter (string)`,k(`The substring after which text will be returned.`)),W(`instance_num (number, default=1)`,k(`The desired instance of the delimiter before which we extract the text. A negative number searches from the end.`)),W(`match_mode (number, default=0)`,k(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),ND),W(`match_end (number, default=0))`,k(`Whether to match a delimiter against the end of the text.`),PD),W(`if_not_found (string, default="${A.NotAvailable}")`,k(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new ya){let o=P(e),s=N(n,this.locale),c=N(r,this.locale),l=N(i,this.locale);if(s===0)return new j(k(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new j(k(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new j(k(`match_end should have a value of 0 or 1.`));let u=P(t);if(u===``)return Math.sign(s)>0?{value:``}:{value:o};let d=c===1?`gi`:`g`,f=qe(u),p=new RegExp(f,d),m=[...o.matchAll(p)].map(e=>e.index+f.length);if(s<0&&(m=m.reverse()),l&&Math.abs(s)===m.length+1)return Math.sign(s)>0?{value:o}:{value:``};let h=m[Math.abs(s)-1];return h===void 0?a:{value:o.substring(0,h-u.length)}},isExported:!0};var lO=l({HYPERLINK:()=>uO});let uO={description:k(`Creates a hyperlink in a cell.`),args:[W(`url (string)`,k(`The full URL of the link enclosed in quotation marks.`)),W(`link_label (string, optional)`,k(`The text to display in the cell, enclosed in quotation marks.`))],compute:function(e,t){let n=P(e).trim(),r=P(t)||n;return n===``?r:ot(r,n)},isExported:!0},dO=/^[A-Z0-9\_\.]+$/,fO=new class extends B{mapping={};add(e,t){if(e=e.toUpperCase(),e in this.content)throw Error(`${e} is already present in this registry!`);return this.replace(e,t)}replace(e,t){if(e=e.toUpperCase(),!dO.test(e))throw Error(k(`Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)`,e));let n=Kv(e,t);return Zv(n),this.mapping[e]=Qv(n),super.replace(e,n),this}},pO=[{name:k(`Array`),functions:oy},{name:k(`Database`),functions:dS},{name:k(`Date`),functions:GC},{name:k(`Filter`),functions:Mw},{name:k(`Financial`),functions:Rw},{name:k(`Info`),functions:qT},{name:k(`Lookup`),functions:SE},{name:k(`Logical`),functions:oE},{name:k(`Math`),functions:Iy},{name:k(`Operator`),functions:KE},{name:k(`Statistical`),functions:Qb},{name:k(`Text`),functions:jD},{name:k(`Engineering`),functions:Dw},{name:k(`Web`),functions:lO},{name:k(`Parser`),functions:kD}];for(let e of pO){let t=e.functions;for(let n in t){let r=t[n];r.category=r.category||e.name,n=n.replace(/_/g,`.`),fO.add(n,{isExported:!1,...r})}}var mO=class{xmlString;constructor(e){this.xmlString=e}toString(){return this.xmlString}};let hO=[`areaChart`,`area3DChart`,`lineChart`,`line3DChart`,`stockChart`,`radarChart`,`scatterChart`,`pieChart`,`pie3DChart`,`doughnutChart`,`barChart`,`bar3DChart`,`ofPieChart`,`surfaceChart`,`surface3DChart`,`bubbleChart`,`comboChart`,`radarChart`],gO={name:`ARROW_DOWN`,width:448,height:512,paths:[{fillColor:`#E06666`,path:`M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z`}]},_O={name:`ARROW_UP`,width:448,height:512,paths:[{fillColor:`#6AA84F`,path:`M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z`}]},vO={name:`ARROW_RIGHT`,width:448,height:512,paths:[{fillColor:`#F0AD4E`,path:`M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z`}]},yO={name:`SMILE`,width:496,height:512,paths:[{fillColor:`#6AA84F`,path:`M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm4 72.6c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.7-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.1-8.4-25.3-7.1-33.8 3.1z`}]},bO={name:`MEH`,width:496,height:512,paths:[{fillColor:`#F0AD4E`,path:`M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm8 144H160c-13.2 0-24 10.8-24 24s10.8 24 24 24h176c13.2 0 24-10.8 24-24s-10.8-24-24-24z`}]},xO={name:`FROWN`,width:496,height:512,paths:[{fillColor:`#E06666`,path:`M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-80 128c-40.2 0-78 17.7-103.8 48.6-8.5 10.2-7.1 25.3 3.1 33.8 10.2 8.4 25.3 7.1 33.8-3.1 16.6-19.9 41-31.4 66.9-31.4s50.3 11.4 66.9 31.4c8.1 9.7 23.1 11.9 33.8 3.1 10.2-8.5 11.5-23.6 3.1-33.8C326 321.7 288.2 304 248 304z`}]},SO=`M256 9 a247 247 0 1 0.1 0 0`,CO={name:`GREEN_DOT`,width:512,height:512,paths:[{fillColor:`#6AA84F`,path:SO}]},wO={name:`YELLOW_DOT`,width:512,height:512,paths:[{fillColor:`#F0AD4E`,path:SO}]},TO={name:`RED_DOT`,width:512,height:512,paths:[{fillColor:`#E06666`,path:SO}]},EO=`M40 160 h320 l-160 160`;function DO(e){return{name:`CARET_DOWN`,width:512,height:512,paths:[{fillColor:e.textColor||`#374151C2`,path:EO}]}}function OO(e){return{name:`CARET_UP`,width:512,height:512,paths:[{fillColor:e.textColor||`#374151C2`,path:`M40 320 h320 l-160 -160`}]}}function kO(e){return{name:`CARET_DOWN`,width:512,height:512,paths:[{fillColor:e.textColor||`#374151C2`,path:`M200 32a200 200 0 1 1 0 400 200 200 0 1 1 0-400`},{fillColor:e.fillColor||`#fff`,path:EO}]}}let AO={name:`CHECKBOX_UNCHECKED`,width:512,height:512,paths:[{fillColor:fe,path:`M45,45 h422 v422 h-422 v-422 m30,30 v362 h362 v-362`}]},jO={name:`CHECKBOX_UNCHECKED`,width:512,height:512,paths:[{fillColor:me,path:`M45,45 h422 v422 h-422 v-422 m30,30 v362 h362 v-362`}]},MO={name:`CHECKBOX_CHECKED`,width:512,height:512,paths:[{fillColor:me,path:`M45,45 h422 v422 h-422 v-422`},{fillColor:`#FFF`,path:`M165,240 l45,45 l135,-135 h60 l-195,195 l-105,-105`}]};function NO(e,t){return{name:`PIVOT_ICON`,width:512,height:512,paths:[{path:`M21,21 h469 v469 h-469`,fillColor:t?de:`#777`},{path:`M64,64 v384 h384 v-384`,fillColor:t?`#E7E9ED`:`#eee`},{path:e?`M149,235 h213 v43 h-213 M235,149 h43 v213 h-43`:`M149,235 h213 v43 h-213`,fillColor:t?de:`#777`}]}}function PO(e,t,n){let r=e?`M18.6 3.5H4.29c-.7 0-1.06.85-.56 1.35l6.1 6.1v6.8c0 .26.13.5.34.65l2.64 1.85a.79.79 0 0 0 1.25-.65v-8.64l6.1-6.1a.79.79 0 0 0-.56-1.35`:`M 339.667 681 L 510.333 681 L 510.333 595.667 L 339.667 595.667 L 339.667 681 Z M 41 169 L 41 254.333 L 809 254.333 L 809 169 L 41 169 Z M 169 467.667 L 681 467.667 L 681 382.333 L 169 382.333 L 169 467.667 Z`,i=e?`M0,0 h24 v24 h-24`:`M0,0 h850 v850 h-850`,a={iconColor:ce,hoverBackgroundColor:ce};return n&&!t?a.iconColor=`#fff`:!n&&t?a.iconColor=`#defade`:n&&t&&(a.iconColor=ce,a.hoverBackgroundColor=`#fff`),{name:`DATA_FILTER_ICON`,width:e?24:850,height:e?24:850,paths:[n?{path:i,fillColor:a.hoverBackgroundColor}:void 0,{path:r,fillColor:a.iconColor}].filter(C)}}let FO={arrowGood:{template:`ARROW_UP`,svg:_O},arrowNeutral:{template:`ARROW_RIGHT`,svg:vO},arrowBad:{template:`ARROW_DOWN`,svg:gO},smileyGood:{template:`SMILE`,svg:yO},smileyNeutral:{template:`MEH`,svg:bO},smileyBad:{template:`FROWN`,svg:xO},dotGood:{template:`GREEN_DOT`,svg:CO},dotNeutral:{template:`YELLOW_DOT`,svg:wO},dotBad:{template:`RED_DOT`,svg:TO}},IO={arrows:{good:`arrowGood`,neutral:`arrowNeutral`,bad:`arrowBad`},smiley:{good:`smileyGood`,neutral:`smileyNeutral`,bad:`smileyBad`},dots:{good:`dotGood`,neutral:`dotNeutral`,bad:`dotBad`}},LO={};function RO(e){if(LO[e])return LO[e];let t=new Path2D(e);return LO[e]=t,t}function zO(e,t){let n=e.split(`/`),r=t.split(`/`),i=``,a=0;for(let e=0;e<n.length-1;e++)n[e]===r[e]?a++:i+=`../`;return i+=r.slice(a).join(`/`),i}function BO(e,t=0){let n={};for(let r=0;r<e.length;r++)e[r]&&(n[r+t]=e[r]);return n}function VO(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,(e,t)=>String.fromCharCode(parseInt(t,16)))}function HO(e,t,n){return t===`COL`?(e.cols[n]||(e.cols[n]={}),e.cols[n]):(e.rows[n]||(e.rows[n]={}),e.rows[n])}function UO(e){if(e[0]===`=`)return e;let t=Tu(e);return t.length===1&&t[0].type!==`REFERENCE`?e:`=`+e}var WO=class{_parsingWarnings=new Set;_conversionWarnings=new Set;addParsingWarning(e){this._parsingWarnings.add(e)}addConversionWarning(e){this._conversionWarnings.add(e)}get warnings(){return[...this._parsingWarnings,...this._conversionWarnings]}generateNotSupportedWarning(e,t,n){let r=`${e} ${t?`"`+t+`" is`:`are`} not yet supported. `;n&&(r+=`Only ${n.join(`, `)} are currently supported.`),this._conversionWarnings.has(r)||this._conversionWarnings.add(r)}};let GO=[`thin`,`medium`,`thick`,`dashed`,`dotted`],KO=[`general`,`left`,`center`,`right`],qO=[`top`,`center`,`bottom`],JO=[`Arial`],YO=[`solid`,`none`],XO=[`expression`,`cellIs`,`colorScale`,`iconSet`,`containsText`,`notContainsText`,`beginsWith`,`endsWithText`,`containsBlanks`,`notContainsBlanks`],ZO={b:`boolean`,d:`date`,e:`error`,inlineStr:`inlineStr`,n:`number`,s:`sharedString`,str:`str`},QO={dashDot:`thin`,dashDotDot:`thin`,dashed:`dashed`,dotted:`dotted`,double:`thin`,hair:`thin`,medium:`medium`,mediumDashDot:`thin`,mediumDashDotDot:`thin`,mediumDashed:`thin`,none:void 0,slantDashDot:`thin`,thick:`thick`,thin:`thin`},$O={general:void 0,left:`left`,center:`center`,right:`right`,fill:`left`,justify:`left`,centerContinuous:`center`,distributed:`center`},ek={top:`top`,center:`middle`,bottom:`bottom`,justify:`middle`,distributed:`middle`},tk={top:`top`,middle:`center`,bottom:`bottom`},nk={beginsWith:`beginsWithText`,endsWith:`endsWithText`,containsText:`containsText`,notContains:`notContainsText`,between:`isBetween`,notBetween:`isNotBetween`,equal:`isEqual`,notEqual:`isNotEqual`,greaterThan:`isGreaterThan`,greaterThanOrEqual:`isGreaterOrEqualTo`,lessThan:`isLessThan`,lessThanOrEqual:`isLessOrEqualTo`},rk={aboveAverage:void 0,expression:`customFormula`,cellIs:void 0,colorScale:void 0,dataBar:void 0,iconSet:void 0,top10:`top10`,uniqueValues:`uniqueValues`,duplicateValues:`duplicateValues`,containsText:`containsText`,notContainsText:`notContainsText`,beginsWith:`beginsWithText`,endsWith:`endsWithText`,containsBlanks:`isEmpty`,notContainsBlanks:`isNotEmpty`,containsErrors:void 0,notContainsErrors:void 0,timePeriod:void 0},ik={num:`number`,percent:`percentage`,max:`value`,min:`value`,percentile:`percentile`,formula:`formula`},ak={NoIcons:void 0,"3Arrows":`arrows`,"3ArrowsGray":`arrows`,"3Symbols":`smiley`,"3Symbols2":`smiley`,"3Signs":`dots`,"3Flags":`dots`,"3TrafficLights1":`dots`,"3TrafficLights2":`dots`,"4Arrows":`arrows`,"4ArrowsGray":`arrows`,"4RedToBlack":`dots`,"4Rating":`smiley`,"4TrafficLights":`dots`,"5Arrows":`arrows`,"5ArrowsGray":`arrows`,"5Rating":`smiley`,"5Quarters":`dots`,"3Stars":`smiley`,"3Triangles":`arrows`,"5Boxes":`dots`},ok={none:`none`,b:`bottom`,t:`top`,l:`left`,r:`right`,tr:`right`},sk={areaChart:void 0,area3DChart:void 0,lineChart:`line`,line3DChart:void 0,stockChart:void 0,radarChart:`radar`,scatterChart:`scatter`,pieChart:`pie`,pie3DChart:void 0,doughnutChart:`pie`,barChart:`bar`,bar3DChart:void 0,ofPieChart:void 0,surfaceChart:void 0,surface3DChart:void 0,bubbleChart:void 0,comboChart:`combo`},ck={exp:`exponential`,log:`logarithmic`,poly:`polynomial`,movingAvg:`trailingMovingAverage`},lk={1:`AVERAGE`,2:`COUNT`,3:`COUNTA`,4:`MAX`,5:`MIN`,6:`PRODUCT`,7:`STDEV`,8:`STDEVP`,9:`SUM`,10:`VAR`,11:`VARP`,101:`AVERAGE`,102:`COUNT`,103:`COUNTA`,104:`MAX`,105:`MIN`,106:`PRODUCT`,107:`STDEV`,108:`STDEVP`,109:`SUM`,110:`VAR`,111:`VARP`},uk={0:`General`,1:`0`,2:`0.00`,3:`#,#00`,4:`#,##0.00`,9:`0%`,10:`0.00%`,11:void 0,12:void 0,13:void 0,14:`m/d/yyyy`,15:`m/d/yyyy`,16:`m/d/yyyy`,17:`m/d/yyyy`,18:`hh:mm:ss a`,19:`hh:mm:ss a`,20:`hhhh:mm:ss`,21:`hhhh:mm:ss`,22:`m/d/yy h:mm`,37:void 0,38:void 0,39:void 0,40:void 0,45:`hhhh:mm:ss`,46:`hhhh:mm:ss`,47:`hhhh:mm:ss`,48:void 0,49:`@`},dk={0:1,"0.00":2,"#,#00":3,"#,##0.00":4,"0%":9,"0.00%":10,"0.00E+00":11,"# ?/?":12,"# ??/??":13,"mm-dd-yy":14,"d-mm-yy":15,"mm-yy":16,"mmm-yy":17,"h:mm AM/PM":18,"h:mm:ss AM/PM":19,"h:mm":20,"h:mm:ss":21,"m/d/yy h:mm":22,"#,##0 ;(#,##0)":37,"#,##0 ;[Red](#,##0)":38,"#,##0.00;(#,##0.00)":39,"#,##0.00;[Red](#,##0.00)":40,"mm:ss":45,"[h]:mm:ss":46,"mmss.0":47,"##0.0E+0":48,"@":49,"hh:mm:ss a":19},fk={0:`000000`,1:`FFFFFF`,2:`FF0000`,3:`00FF00`,4:`0000FF`,5:`FFFF00`,6:`FF00FF`,7:`00FFFF`,8:`000000`,9:`FFFFFF`,10:`FF0000`,11:`00FF00`,12:`0000FF`,13:`FFFF00`,14:`FF00FF`,15:`00FFFF`,16:`800000`,17:`008000`,18:`000080`,19:`808000`,20:`800080`,21:`008080`,22:`C0C0C0`,23:`808080`,24:`9999FF`,25:`993366`,26:`FFFFCC`,27:`CCFFFF`,28:`660066`,29:`FF8080`,30:`0066CC`,31:`CCCCFF`,32:`000080`,33:`FF00FF`,34:`FFFF00`,35:`00FFFF`,36:`800080`,37:`800000`,38:`008080`,39:`0000FF`,40:`00CCFF`,41:`CCFFFF`,42:`CCFFCC`,43:`FFFF99`,44:`99CCFF`,45:`FF99CC`,46:`CC99FF`,47:`FFCC99`,48:`3366FF`,49:`33CCCC`,50:`99CC00`,51:`FFCC00`,52:`FF9900`,53:`FF6600`,54:`666699`,55:`969696`,56:`003366`,57:`339966`,58:`003300`,59:`333300`,60:`993300`,61:`993366`,62:`333399`,63:`333333`,64:`000000`,65:`FFFFFF`},pk={"image/avif":`avif`,"image/bmp":`bmp`,"image/gif":`gif`,"image/vnd.microsoft.icon":`ico`,"image/jpeg":`jpeg`,"image/png":`png`,"image/tiff":`tiff`,"image/webp":`webp`},mk={avif:`image/avif`,bmp:`image/bmp`,gif:`image/gif`,ico:`image/vnd.microsoft.icon`,jpeg:`image/jpeg`,png:`image/png`,tiff:`image/tiff`,webp:`image/webp`,jpg:`image/jpeg`},hk={between:`isBetween`,notBetween:`isNotBetween`,equal:`isEqual`,notEqual:`isNotEqual`,greaterThan:`isGreaterThan`,greaterThanOrEqual:`isGreaterOrEqualTo`,lessThan:`isLessThan`,lessThanOrEqual:`isLessOrEqualTo`},gk={between:`dateIsBetween`,notBetween:`dateIsNotBetween`,equal:`dateIs`,greaterThan:`dateIsAfter`,greaterThanOrEqual:`dateIsOnOrAfter`,lessThan:`dateIsBefore`,lessThanOrEqual:`dateIsOnOrBefore`};function _k(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=lu;else if(e.indexed)t=fk[e.indexed];else return;return t=vk(t),e.tint&&(t=yk(t,e.tint)),t=t.toUpperCase(),t.length===9&&t.endsWith(`FF`)&&(t=t.slice(0,7)),t}function vk(e){return e.length===6?`#`+e+`FF`:`#`+e.slice(2)+e.slice(0,2)}function yk(e,t){let n=Rr(Ir(e));return t<0&&(n.l*=1+t),t>0&&(n.l=n.l*(1-t)+(100-100*(1-t))),Fr(Lr(n))}function bk(e){return e.length===9&&(e=e.slice(0,7)),parseInt(e.replace(`#`,``),16)}function xk(e){switch(e){case`isNotEmpty`:return`notContainsBlanks`;case`isEmpty`:return`containsBlanks`;case`notContainsText`:return`notContainsBlanks`;case`containsText`:return`containsText`;case`beginsWithText`:return`beginsWith`;case`endsWithText`:return`endsWith`;case`isGreaterThan`:return`greaterThan`;case`isGreaterOrEqualTo`:return`greaterThanOrEqual`;case`isLessThan`:return`lessThan`;case`isLessOrEqualTo`:return`lessThanOrEqual`;case`isBetween`:return`between`;case`isNotBetween`:return`notBetween`;case`isEqual`:return`equal`;case`isNotEqual`:return`notEqual`;case`customFormula`:return``;case`dateIs`:return``;case`dateIsBefore`:return`lessThan`;case`dateIsAfter`:return`greaterThan`;case`dateIsOnOrAfter`:return`greaterThanOrEqual`;case`dateIsOnOrBefore`:return`lessThanOrEqual`;case`top10`:return`top10`;case`uniqueValues`:return`uniqueValues`;case`duplicateValues`:return`duplicateValues`}}function Sk(e){switch(typeof e){case`boolean`:return`b`;case`string`:return`str`;case`number`:return`n`;default:return}}function Ck(e){return Math.round(_u*e*100)/100}function wk(e){return Math.round(vu*e*100)/100}function Tk(e){return e&&Math.round(e/_u*100)/100}function Ek(e){return e&&Math.round(e/vu*100)/100}function Dk(e,t,n,r,i){let a=n?e.styles[n]:{},o=r?e.formats[r]:void 0,s={font:{size:a?.fontSize||we,color:{rgb:a?.textColor?a.textColor:`000000`},family:2,name:`Arial`},fill:a?.fillColor?{fgColor:{rgb:a.fillColor}}:{reservedAttribute:`none`},numFmt:o?{format:o,id:0}:void 0,border:i||0,alignment:{horizontal:a.align,vertical:a.verticalAlign?tk[a.verticalAlign]:void 0,wrapText:a.wrapping===`wrap`||t?.includes(`
|
|
66
66
|
`)?!0:void 0,textRotation:a.rotation?Ok(a.rotation):void 0,shrinkToFit:a.wrapping===`clip`?!0:void 0}};return s.font.strike=!!a?.strikethrough||void 0,s.font.underline=!!a?.underline||void 0,s.font.bold=!!a?.bold||void 0,s.font.italic=!!a?.italic||void 0,s}function Ok(e){let t=Math.round(-e/Math.PI*180)%180;return t>90?t-=180:t<-90&&(t+=180),t>=0?t:90-t}function kk(e){return e<=90?-(e/180)*Math.PI:-(90-e)/180*Math.PI}function Ak(e,t){let n=jk(t.numFmt,e.numFmts);return Pk({fontId:Pk(t.font,e.fonts),fillId:Pk(t.fill,e.fills),borderId:t.border,numFmtId:n,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal,wrapText:t.alignment.wrapText,textRotation:t.alignment.textRotation,shrinkToFit:t.alignment.shrinkToFit}},e.styles)}function jk(e,t){if(!e)return 0;let n=dk[e.format];return n||=Pk(e,t)+164,n}function Mk(e,t,n){let r=e.find(e=>e.path===t),i;return r?(i=`rId${(r.rels.length+1).toString()}`,r.rels.push({...n,id:i})):(i=`rId1`,e.push({path:t,rels:[{...n,id:i}]})),i}let Nk=new WeakMap;function Pk(e,t){let n=Nk.get(t);if(!n){n=new Map;for(let e=0;e<t.length;e++){let r=Tc(t[e]);n.set(r,e)}Nk.set(t,n)}let r=Tc(e);if(n.has(r))return n.get(r);let i=t.length;return t.push(e),n.set(r,i),i}function Fk(e,t){let n=t.chartIds.findIndex(t=>t===e);return n===-1?(t.chartIds.push(e),t.chartIds.length):n+1}let Ik=[];function Lk(e){let t=Ik.findIndex(t=>t===e);return t===-1?(Ik.push(e),Ik.length):t+1}function Rk(e){return Math.round(e*914400/96)}function zk(e,t,n){let r=e,i;({xc:r,sheetName:i}=zc(e));let a;if(i){let e=n.sheets.findIndex(e=>wl(e.name,i));if(e<0)throw Error(`Unable to find a sheet with the name `+i);a=e}else a=Number(t);let o=pn(r);return o.right===void 0&&(o.right=n.sheets[a].colNumber),o.bottom===void 0&&(o.bottom=n.sheets[a].rowNumber),(o.right-o.left+1)*(o.bottom-o.top+1)}function Bk(e){return Math.round(e*96/914400)}function Vk(e,t){let n=0;for(let r=0;r<e;r++){let e=t.cols.find(e=>r>=e.min&&r<=e.max);e?.width?n+=e.width:t.sheetFormat?.defaultColWidth?n+=t.sheetFormat.defaultColWidth:n+=yu}return n/vu}function Hk(e,t){let n=0;for(let r=0;r<e;r++){let e=t.rows.find(e=>e.index-1===r);e?.height?n+=e.height:t.sheetFormat?.defaultRowHeight?n+=t.sheetFormat.defaultRowHeight:n+=bu}return n/_u}function Uk(e){return Object.keys(hk).find(t=>hk[t]===e)}function Wk(e){return Object.keys(gk).find(t=>gk[t]===e)}let Gk=/^(yy|yyyy|m{1,5}|d{1,4}|h{1,2}|s{1,2}|am\/pm|a\/m|\s|-|\/|\.|:)+$/i;function Kk(e,t,n){let r=uk[e]||t.find(t=>t.id===e)?.format;if(r!==`General`){if(r)try{let e=r.replace(/\[(.*)-[A-Z0-9]{3}\]/g,`[$1]`);if(e=e.replace(/\[\$\]/g,``),e=e.replace(/_.{1}/g,``),e=e.replace(/\*.{1}/g,``),Jk(e)&&(e=Yk(e)),qk(e))return e}catch{}n.generateNotSupportedWarning(`Number format`,r||`nmFmtId ${e}`)}}function qk(e){try{return z(0,{format:e,locale:R}),!0}catch{return!1}}function Jk(e){return Gk.test(e)}function Yk(e){return e=e.toLowerCase(),e=e.replace(/mmmmm/g,`mmm`),e=e.replace(/am\/pm|a\/m/g,`a`),e=e.replace(/hhhh/g,`hh`),e=e.replace(/\bh\b/g,`hh`),e}function Xk(e,t){return BO(e.borders.map(e=>{rA(e,t);let n={top:Zk(e.top,t),bottom:Zk(e.bottom,t),left:Zk(e.left,t),right:Zk(e.right,t)};return Object.keys(n).forEach(e=>n[e]===void 0&&delete n[e]),n}),1)}function Zk(e,t){if(!e)return;nA(e,t);let n=QO[e.style];return n?{style:n,color:_k(e.color)}:void 0}function Qk(e,t){return BO(e.styles.map(n=>$k({fontStyle:e.fonts[n.fontId],fillStyle:e.fills[n.fillId],alignment:n.alignment},t)),1)}function $k(e,t){return tA(e?.fontStyle,e?.fillStyle,t),iA(e?.alignment?.horizontal,t),aA(e?.alignment?.vertical,t),{bold:e.fontStyle?.bold,italic:e.fontStyle?.italic,strikethrough:e.fontStyle?.strike,underline:e.fontStyle?.underline,verticalAlign:e.alignment?.vertical?ek[e.alignment.vertical]:void 0,align:e.alignment?.horizontal?$O[e.alignment.horizontal]:void 0,rotation:e.alignment?.textRotation?kk(e.alignment.textRotation):void 0,fillColor:e.fillStyle?.patternType===`solid`?_k(e.fillStyle?.fgColor):_k(e.fillStyle?.bgColor),textColor:_k(e.fontStyle?.color),fontSize:e.fontStyle?.size,wrapping:e.alignment?.wrapText?`wrap`:`overflow`}}function eA(e,t){let n=[];for(let r of e.styles){let i=Kk(r.numFmtId,e.numFmts,t);i&&(n[r.numFmtId]=i)}return BO(n,1)}function tA(e,t,n){e&&e.name&&!JO.includes(e.name)&&n.generateNotSupportedWarning(`Font`,e.name,JO),t&&t.patternType&&!YO.includes(t.patternType)&&n.generateNotSupportedWarning(`Fill Style`,t.patternType,YO)}function nA(e,t){GO.includes(e.style)||t.generateNotSupportedWarning(`Border style`,e.style,GO)}function rA(e,t){e.diagonal&&t.generateNotSupportedWarning(`Diagonal Borders`)}function iA(e,t){e&&!KO.includes(e)&&t.generateNotSupportedWarning(`Horizontal Alignment`,e,KO)}function aA(e,t){e&&!qO.includes(e)&&t.generateNotSupportedWarning(`Vertical Alignments`,e,qO)}function oA(e,t,n){let r=[],i=1;for(let a of e){if(a.cfRules.length===0)continue;dA(a,t,n);let e=a.cfRules[0],o,s=[],c={};if(!(e.dxfId===void 0&&!(e.type===`colorScale`||e.type===`iconSet`||e.type===`dataBar`))){switch(e.type){case`aboveAverage`:case`containsErrors`:case`notContainsErrors`:case`timePeriod`:continue;case`dataBar`:let t=sA(i++,a);t&&r.push(t);continue;case`colorScale`:let l=cA(i++,a);l&&r.push(l);continue;case`iconSet`:let u=lA(i++,a,n);u&&r.push(u);continue;case`containsText`:case`notContainsText`:case`beginsWith`:case`endsWith`:if(!e.text)continue;o=rk[e.type],s.push(e.text);break;case`expression`:if(!e.formula?.length)continue;o=rk[e.type],s.push(`=${e.formula[0]}`);break;case`duplicateValues`:case`uniqueValues`:case`containsBlanks`:case`notContainsBlanks`:o=rk[e.type];break;case`cellIs`:if(!e.operator||!e.formula||e.formula.length===0)continue;o=nk[e.operator],s.push(UO(e.formula[0])),e.formula.length===2&&s.push(UO(e.formula[1]));break;case`top10`:if(e.rank===void 0)continue;o=rk[e.type],s.push(e.rank.toString()),e.percent&&(c.isPercent=!0),e.bottom&&(c.isBottom=!0);break}o&&e.dxfId!==void 0&&r.push({id:(i++).toString(),ranges:a.sqref,stopIfTrue:e.stopIfTrue,rule:{type:`CellIsRule`,operator:o,values:s,...c,style:$k({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},n)}})}}return r}function sA(e,t){let n=t.cfRules[0].dataBar;if(!n)return;let r=bk(_k(n.color)||`#FFFFFF`);return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:`DataBarRule`,color:r}}}function cA(e,t){let n=t.cfRules[0].colorScale;if(!n||n.cfvos.length!==n.colors.length||n.cfvos.length<2||n.cfvos.length>3)return;let r=[];for(let e=0;e<n.cfvos.length;e++)r.push({color:bk(_k(n.colors[e])||`#FFFFFF`),type:ik[n.cfvos[e].type],value:n.cfvos[e].value});let i=r[0],a=r.length===2?r[1]:r[2],o=r.length===3?r[1]:void 0;return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:`ColorScaleRule`,minimum:i,midpoint:o,maximum:a}}}function lA(e,t,n){let r=t.cfRules[0].iconSet;if(!r)return;let i=r.cfvos,a=r.cfIcons;if(i.length<3||a&&a.length<3)return;i.length>3&&(i=[i[0],i[Math.floor(i.length/2)],i[i.length-1]]),a&&a.length>3&&(a=[a[0],a[Math.floor(a.length/2)],a[a.length-1]]);let o=[];for(let e=1;e<=2;e++){let t=ik[i[e].type];if(t===`value`)return;o.push({value:i[e].value||``,operator:i[e].gte?`ge`:`gt`,type:t})}let s={lower:a?uA(a[0].iconSet,a[0].iconId):uA(r.iconSet,0),middle:a?uA(a[1].iconSet,a[1].iconId):uA(r.iconSet,1),upper:a?uA(a[2].iconSet,a[2].iconId):uA(r.iconSet,2)};r.reverse&&(s={upper:s.lower,middle:s.middle,lower:s.upper});for(let e of Object.keys(s))if(!s[e])switch(n.generateNotSupportedWarning(`IconSets with empty icons`),e){case`upper`:s[e]=IO.dots.good;break;case`middle`:s[e]=IO.dots.neutral;break;case`lower`:s[e]=IO.dots.bad;break}return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:`IconSetRule`,icons:s,upperInflectionPoint:o[1],lowerInflectionPoint:o[0]}}}function uA(e,t){let n=ak[e];return n?t===0?IO[n].bad:t===1?IO[n].neutral:IO[n].good:``}function dA(e,t,n){if(e.cfRules.length>1&&n.generateNotSupportedWarning(`Multiple rules conditional formats`),XO.includes(e.cfRules[0].type)||n.generateNotSupportedWarning(`Conditional format type`,e.cfRules[0].type),e.cfRules[0].dxfId){let r=t[e.cfRules[0].dxfId];r.border&&n.generateNotSupportedWarning(`Borders in conditional formats`),r.alignment&&n.generateNotSupportedWarning(`Alignment in conditional formats`),r.numFmt&&n.generateNotSupportedWarning(`Num formats in conditional formats`)}}function fA(e){let t=1;return e.figures.map(n=>pA(n,(t++).toString(),e)).filter(C)}function pA(e,t,n){let r,i,a,o,s;if(e.anchors.length===1)({col:r,row:i,offset:a}=yA(e.anchors[0])),s=Bk(e.figureSize.cx),o=Bk(e.figureSize.cy);else{({col:r,row:i,offset:a}=yA(e.anchors[0]));let{x:t,y:c}=bA(e.anchors[0],n),{x:l,y:u}=bA(e.anchors[1],n);s=l-t,o=u-c}let c={id:t,col:r,row:i,offset:a};if(mA(e.data))return{...c,width:s,height:o,tag:`chart`,data:gA(e.data)};if(hA(e.data))return{...c,width:Bk(e.data.size.cx),height:Bk(e.data.size.cy),tag:`image`,data:{path:e.data.imageSrc,mimetype:e.data.mimetype}}}function mA(e){return`dataSets`in e&&e.dataSets.length>0}function hA(e){return`imageSrc`in e}function gA(e){let t=e.dataSets.some(e=>`reference`in(e.label??{})),n=e.labelRange?_A(e.labelRange,t):void 0,r=e.dataSets.map(e=>{let n;return e.label&&`text`in e.label&&(n=e.label.text),{dataRange:_A(e.range,t),label:n,backgroundColor:e.backgroundColor,trend:vA(e.trend)}});e.type===`pie`&&r.reverse();let i={range:r,dataSetsHaveTitle:t,auxiliaryRange:n,title:e.title??{text:``},background:_k({rgb:e.backgroundColor})||`#FFFFFF`,legendPosition:e.legendPosition,stacked:e.stacked||!1,aggregated:!1,cumulative:e.cumulative||!1,labelsAsText:!1,horizontal:e.horizontal,isDoughnut:e.isDoughnut,pieHolePercentage:e.pieHolePercentage,showValues:e.showValues};try{return b_.get(e.type).getChartDefinitionFromContextCreation(i)}catch{return}}function _A(e,t){let{sheetName:n,xc:r}=zc(e),i=pn(r);if(t&&i.bottom!==void 0&&i.right!==void 0){let e=i.bottom-i.top+1,t=i.right-i.left+1;e===1?i={...i,left:i.left-1}:t===1&&(i={...i,top:i.top-1})}return Bc(n,yn(i))}function vA(e){if(!(!e||!e.type))return{type:e.type===`linear`?`polynomial`:ck[e.type],order:e.type===`linear`?1:e.order,color:e.color,window:e.window||2,display:!0}}function yA(e){let t={x:Bk(e.colOffset)-1,y:Bk(e.rowOffset)-1};return{col:e.col,row:e.row,offset:t}}function bA(e,t){return{x:Vk(e.col,t)+Bk(e.colOffset),y:Hk(e.row,t)+Bk(e.rowOffset)}}function xA(e,t){let n=[],r=1;for(let i of e)if(i)switch(i.type){case`time`:t.generateNotSupportedWarning(`Time data validation rules`);break;case`textLength`:t.generateNotSupportedWarning(`Text length data validation rules`);break;case`whole`:t.generateNotSupportedWarning(`Whole number data validation rules`);break;case`decimal`:let e=SA(r++,i);n.push(e);break;case`list`:let a=CA(r++,i);n.push(a);break;case`date`:if(i.operator===`notEqual`){t.generateNotSupportedWarning(`Not equal date data validation rules`);break}let o=wA(r++,i);n.push(o);break;case`custom`:let s=TA(r++,i);n.push(s);break}return n}function SA(e,t){let n=[UO(t.formula1.toString())];return t.formula2&&n.push(UO(t.formula2.toString())),{id:e.toString(),ranges:t.sqref,isBlocking:t.errorStyle!==`warning`,criterion:{type:hk[t.operator],values:n}}}function CA(e,t){let n=t.formula1.toString(),r=Nc.test(n);return{id:e.toString(),ranges:t.sqref,isBlocking:t.errorStyle!==`warning`,criterion:{type:r?`isValueInRange`:`isValueInList`,values:r?[n]:n.replaceAll(`"`,``).split(`,`),displayStyle:`arrow`}}}function wA(e,t){let n,r=[UO(t.formula1.toString())];return t.formula2?(r.push(UO(t.formula2.toString())),n={type:gk[t.operator],values:yc(r,R)}):n={type:gk[t.operator],values:yc(r,R),dateValue:`exactDate`},{id:e.toString(),ranges:t.sqref,isBlocking:t.errorStyle!==`warning`,criterion:n}}function TA(e,t){return{id:e.toString(),ranges:t.sqref,isBlocking:t.errorStyle!==`warning`,criterion:{type:`customFormula`,values:[UO(t.formula1.toString())]}}}let EA=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),DA=new RegExp(/SUBTOTAL\(([0-9]*),/g),OA=new RegExp(Dc.source,`ig`);function kA(e,t){let n=AA(e);for(let r of e.rows.map(e=>e.cells).flat())r?.formula&&(r.formula.content=r.formula.sharedIndex!==void 0&&!r.formula.content?`=`+MA(r.xc,n[r.formula.sharedIndex]):`=`+r.formula.content,r.formula.content=jA(r.formula.content,t))}function AA(e){let t={};for(let n of e.rows)for(let e of n.cells)e.formula&&e.formula.sharedIndex!==void 0&&e.formula.content&&(t[e.formula.sharedIndex]={refCellXc:e.xc,formula:e.formula.content});return t}function jA(e,t){return e=e.replace(`_xlfn.`,``),e=e.replace(/#REF!/g,`#REF`),e=e.replace(DA,(e,t)=>{let n=lk[t];return n?n+`(`:e}),e=e.replace(EA,(e,n,r,i)=>{n=Number(n)-1,i=i.replace(/\$/g,``);let a=t.externalBooks[n]?.sheetNames.findIndex(e=>wl(e,r))??-1;if(a===-1)return e;let o=t.externalBooks[n].datasets.find(e=>e.sheetId===a)?.data;if(!o)return e;let s=o&&o[i];return(Number(s)?s:`"${s}"`)||e}),e}function MA(e,t){let n=tn(t.refCellXc),r=t.formula.slice(),i;do if(i=OA.exec(r),i){let t=tn(i[0].replace(`$`,``)),a=tn(e),o={colFixed:i[0].startsWith(`$`),rowFixed:i[0].includes(`$`,1)},s={col:a.col-n.col,row:a.row-n.row},c={col:o.colFixed?t.col:t.col+s.col,row:o.rowFixed?t.row:t.row+s.row};r=r.slice(0,i.index)+T(c.col,c.row,o)+r.slice(i.index+i[0].length)}while(i);return r}function NA(e,t){return e.sheets.map(n=>{kA(n,e);let r=BA(n),i=n.sheetViews[0],a=VA(n,`ROW`,r[1]),o=VA(n,`COL`,r[0]);return{id:n.sheetName,areGridLinesVisible:i?i.showGridLines:!0,name:n.sheetName,colNumber:r[0],rowNumber:r[1],...LA(n,e,r,t),merges:n.merges,cols:PA(n,r[0],o),rows:FA(n,r[1],a),conditionalFormats:oA(n.cfs,e.dxfs,t),dataValidationRules:xA(n.dataValidations,t),figures:fA(n),isVisible:n.isVisible,panes:i?{xSplit:i.pane.xSplit,ySplit:i.pane.ySplit}:{xSplit:0,ySplit:0},tables:[],headerGroups:{COL:o,ROW:a},color:_k(n.sheetProperties?.tabColor),isLocked:n.isLocked}})}function PA(e,t,n){let r={};for(let i=1;i<t+1;i++){let t=e.cols.find(e=>e.min<=i&&i<=e.max),a;a=t&&t.width?t.width:e.sheetFormat?.defaultColWidth?e.sheetFormat.defaultColWidth:yu;let o=i-1,s=n.some(e=>e.isFolded&&e.start<=o&&o<=e.end);r[o]={size:Ek(a),isHidden:!s&&t?.hidden}}return r}function FA(e,t,n){let r={};for(let i=1;i<t+1;i++){let t=e.rows.find(e=>e.index===i),a;a=t&&t.height?t.height:e.sheetFormat?.defaultRowHeight?e.sheetFormat.defaultRowHeight:bu;let o=i-1,s=n.some(e=>e.isFolded&&e.start<=o&&o<=e.end);r[o]={size:Tk(a),isHidden:!s&&t?.hidden}}return r}function IA(e){return e.map(Ot)}function LA(e,t,n,r){let i={},a={},o={},s={},c=IA(t.sharedStrings),l=e.hyperlinks.reduce((e,t)=>(e[t.xc]=t,e),{});for(let n of e.rows)for(let e of n.cells)i[e.xc]=RA(e,l,c,r),e.styleIndex&&(a[e.xc]=e.styleIndex+1,o[e.xc]=t.styles[e.styleIndex].numFmtId+1,s[e.xc]=t.styles[e.styleIndex].borderId+1);for(let r of e.rows.filter(e=>e.styleIndex))for(let e=1;e<=n[0];e++){let n=T(e-1,r.index-1);a[n]??=r.styleIndex+1,s[n]??=t.styles[r.styleIndex].borderId+1,o[n]??=t.styles[r.styleIndex].numFmtId+1}for(let r of e.cols.filter(e=>e.styleIndex))for(let e=r.min;e<=Math.min(r.max,n[0]);e++)for(let i=1;i<=n[1];i++){let n=T(e-1,i-1);a[n]??=r.styleIndex+1,s[n]??=t.styles[r.styleIndex].borderId+1,o[n]??=t.styles[r.styleIndex].numFmtId+1}return{cells:i,styles:a,formats:o,borders:s}}function RA(e,t,n,r){let i;switch(e.type){case`sharedString`:i=n[parseInt(e.value,10)];break;case`boolean`:i=Number(e.value)?`TRUE`:`FALSE`;break;case`date`:case`error`:case`inlineStr`:case`number`:case`str`:i=e.value;break}return i&&t[e.xc]&&(i=zA(t[e.xc],i,r)),e.formula&&(i=e.formula.content),i}function zA(e,t,n){let r=e.display||t;return!e.relTarget&&!e.location&&n.generateNotSupportedWarning(`Badly formatted hyperlink`),ot(r,e.relTarget?e.relTarget:ut(zc(e.location).sheetName))}function BA(e){let t=[0,0];for(let n of e.rows)t[0]=Math.max(t[0],Lt(n.cells.map(e=>tn(e.xc).col))),t[1]=Math.max(t[1],n.index);for(let n of e.figures)t[0]=Math.max(t[0],n.anchors[n.anchors.length-1]?.col??0),t[1]=Math.max(t[1],n.anchors[n.anchors.length-1]?.row??0);return t[0]=Math.max(t[0]+5,30),t[1]=Math.max(t[1]+5,100),t}function VA(e,t,n){let r=e?.sheetProperties?.outlinePr,i=[],a=0;for(let o=0;o<n;o++){let n=UA(e,t,o)?.outlineLevel||0;if(n>a){let n=(t===`ROW`?r?.summaryBelow:r?.summaryRight)??!0,a=HA(e,t,o,n);a&&i.push(a)}a=n}return i}function HA(e,t,n,r){let i=UA(e,t,n),a=i?.outlineLevel;if(!a||!a)return;let o=a,s=n,c=i;for(;c&&o>=a;)s++,c=UA(e,t,s),o=c?.outlineLevel||0;let l=n,u=s-1,d=(r?UA(e,t,u+1):UA(e,t,l-1))?.collapsed||!1;return{start:l-1,end:u-1,isFolded:d}}function UA(e,t,n){return t===`COL`?e.cols.find(e=>e.min<=n&&n<=e.max):e.rows.find(e=>e.index===n)}let WA={hasFilters:!1,totalRow:!1,firstColumn:!1,lastColumn:!1,numberOfHeaders:1,bandedRows:!0,bandedColumns:!1,automaticAutofill:!0,styleId:`TableStyleMedium2`},GA={light:k(`Light`),medium:k(`Medium`),dark:k(`Dark`)};function KA(e,t){return{coloredText:Kr(t,.3),light:Gr(t,.8),medium:Gr(t,.6),dark:Kr(t,.3),mediumBorder:Gr(t,.45),highlight:t,name:e}}let K={black:{name:k(`Black`),coloredText:`#000000`,light:`#D9D9D9`,medium:`#A6A6A6`,dark:`#404040`,mediumBorder:`#000000`,highlight:`#000000`},lightBlue:KA(k(`Blue`),`#346B90`),red:KA(k(`Red`),`#C53628`),lightGreen:KA(k(`Green`),`#748747`),purple:KA(k(`Purple`),`#6C4E65`),gray:{name:k(`Gray`),coloredText:`#666666`,light:`#EEEEEE`,medium:`#DDDDDD`,dark:`#767676`,mediumBorder:`#D0D0D0`,highlight:`#A9A9A9`},orange:KA(k(`Orange`),`#C37034`)},qA={black:K.black,orangeBlue:{...K.lightBlue,highlight:K.orange.highlight},purpleGreen:{...K.lightGreen,highlight:K.purple.highlight},redBlue:{...K.lightBlue,highlight:K.red.highlight}},JA=e=>({category:`light`,templateName:`lightColoredText`,primaryColor:e.highlight,wholeTable:{style:{textColor:e.coloredText},border:{top:{color:e.highlight,style:`thin`},bottom:{color:e.highlight,style:`thin`}}},headerRow:{border:{bottom:{color:e.highlight,style:`thin`}},style:{bold:!0}},totalRow:{border:{top:{color:e.highlight,style:`thin`}},style:{bold:!0}},firstRowStripe:{style:{fillColor:e.light}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}}}),YA=e=>({category:`light`,templateName:`lightWithHeader`,primaryColor:e.highlight,wholeTable:{border:{top:{color:e.highlight,style:`thin`},bottom:{color:e.highlight,style:`thin`},left:{color:e.highlight,style:`thin`},right:{color:e.highlight,style:`thin`}}},headerRow:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0},border:{bottom:{color:e.highlight,style:`thin`}}},totalRow:{border:{top:{color:e.highlight,style:`medium`}},style:{bold:!0}},firstRowStripe:{border:{bottom:{color:e.highlight,style:`thin`}}},secondRowStripe:{border:{bottom:{color:e.highlight,style:`thin`}}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}}}),XA=e=>({category:`light`,templateName:`lightAllBorders`,primaryColor:e.highlight,wholeTable:{border:{top:{color:e.highlight,style:`thin`},bottom:{color:e.highlight,style:`thin`},left:{color:e.highlight,style:`thin`},right:{color:e.highlight,style:`thin`},horizontal:{color:e.highlight,style:`thin`},vertical:{color:e.highlight,style:`thin`}}},headerRow:{border:{bottom:{color:e.highlight,style:`medium`}},style:{bold:!0}},totalRow:{border:{top:{color:e.highlight,style:`medium`}},style:{bold:!0}},firstRowStripe:{style:{fillColor:e.light}},firstColumnStripe:{style:{fillColor:e.light}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}}}),ZA=e=>({category:`medium`,templateName:`mediumBandedBorders`,primaryColor:e.highlight,wholeTable:{border:{top:{color:e.mediumBorder,style:`thin`},bottom:{color:e.mediumBorder,style:`thin`},left:{color:e.mediumBorder,style:`thin`},right:{color:e.mediumBorder,style:`thin`},horizontal:{color:e.mediumBorder,style:`thin`}}},headerRow:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},totalRow:{border:{top:{color:e.highlight,style:`medium`}},style:{bold:!0}},firstRowStripe:{style:{fillColor:e.light}},firstColumnStripe:{style:{fillColor:e.light}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}}}),QA=e=>({category:`medium`,templateName:`mediumWhiteBorders`,primaryColor:e.highlight,wholeTable:{border:{horizontal:{color:`#FFFFFF`,style:`thin`},vertical:{color:`#FFFFFF`,style:`thin`}},style:{fillColor:e.light}},headerRow:{border:{bottom:{color:`#FFFFFF`,style:`thick`}},style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},totalRow:{border:{top:{color:`#FFFFFF`,style:`thick`}},style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},firstColumn:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},lastColumn:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},firstRowStripe:{style:{fillColor:e.medium}},firstColumnStripe:{style:{fillColor:e.medium}}}),$A=e=>({category:`medium`,templateName:`mediumMinimalBorders`,primaryColor:e.highlight,wholeTable:{border:{top:{color:`#000000`,style:`medium`},bottom:{color:`#000000`,style:`medium`}}},totalRow:{border:{top:{color:`#000000`,style:`medium`}},style:{bold:!0}},headerRow:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0},border:{bottom:{color:`#000000`,style:`medium`}}},firstColumn:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},lastColumn:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},firstRowStripe:{style:{fillColor:K.black.light}},firstColumnStripe:{style:{fillColor:K.black.light}}}),ej=e=>({category:`medium`,templateName:`mediumAllBorders`,primaryColor:e.highlight,wholeTable:{border:{top:{color:e.mediumBorder,style:`thin`},bottom:{color:e.mediumBorder,style:`thin`},left:{color:e.mediumBorder,style:`thin`},right:{color:e.mediumBorder,style:`thin`},horizontal:{color:e.mediumBorder,style:`thin`},vertical:{color:e.mediumBorder,style:`thin`}},style:{fillColor:e.light}},totalRow:{border:{top:{color:e.highlight,style:`medium`}},style:{bold:!0}},firstRowStripe:{style:{fillColor:e.medium}},firstColumnStripe:{style:{fillColor:e.medium}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}},headerRow:{style:{bold:!0}}}),tj=e=>({category:`dark`,templateName:`dark`,primaryColor:e.highlight,wholeTable:{style:{fillColor:e.highlight,textColor:`#FFFFFF`}},totalRow:{style:{fillColor:e.dark,textColor:`#FFFFFF`,bold:!0},border:{top:{color:`#FFFFFF`,style:`thick`}}},headerRow:{style:{fillColor:`#000000`,bold:!0},border:{bottom:{color:`#FFFFFF`,style:`thick`}}},firstColumn:{style:{fillColor:e.dark,bold:!0},border:{right:{color:`#FFFFFF`,style:`thick`}}},lastColumn:{style:{fillColor:e.dark,bold:!0},border:{left:{color:`#FFFFFF`,style:`thick`}}},firstRowStripe:{style:{fillColor:e.dark}},firstColumnStripe:{style:{fillColor:e.dark}}}),nj=e=>({category:`dark`,templateName:`darkNoBorders`,primaryColor:e.highlight,wholeTable:{style:{fillColor:e.light}},totalRow:{border:{top:{color:`#000000`,style:`medium`}},style:{bold:!0}},headerRow:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},firstRowStripe:{style:{fillColor:e.medium}},firstColumnStripe:{style:{fillColor:e.medium}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}}}),rj=tj(K.black);rj.wholeTable.style.fillColor=`#737373`;let ij=$A(K.black);ij.wholeTable.border={...ij.wholeTable.border,left:{color:`#000000`,style:`thin`},right:{color:`#000000`,style:`thin`},horizontal:{color:`#000000`,style:`thin`},vertical:{color:`#000000`,style:`thin`}};function q(e,t,n){return{...t(n),displayName:`${n.name}, ${e}`}}let aj={None:{category:`light`,templateName:`none`,primaryColor:``,displayName:k(`None`)},TableStyleLight1:q(`TableStyleLight1`,JA,K.black),TableStyleLight2:q(`TableStyleLight2`,JA,K.lightBlue),TableStyleLight3:q(`TableStyleLight3`,JA,K.red),TableStyleLight4:q(`TableStyleLight4`,JA,K.lightGreen),TableStyleLight5:q(`TableStyleLight5`,JA,K.purple),TableStyleLight6:q(`TableStyleLight6`,JA,K.gray),TableStyleLight7:q(`TableStyleLight7`,JA,K.orange),TableStyleLight8:q(`TableStyleLight8`,YA,K.black),TableStyleLight9:q(`TableStyleLight9`,YA,K.lightBlue),TableStyleLight10:q(`TableStyleLight10`,YA,K.red),TableStyleLight11:q(`TableStyleLight11`,YA,K.lightGreen),TableStyleLight12:q(`TableStyleLight12`,YA,K.purple),TableStyleLight13:q(`TableStyleLight13`,YA,K.gray),TableStyleLight14:q(`TableStyleLight14`,YA,K.orange),TableStyleLight15:q(`TableStyleLight15`,XA,K.black),TableStyleLight16:q(`TableStyleLight16`,XA,K.lightBlue),TableStyleLight17:q(`TableStyleLight17`,XA,K.red),TableStyleLight18:q(`TableStyleLight18`,XA,K.lightGreen),TableStyleLight19:q(`TableStyleLight19`,XA,K.purple),TableStyleLight20:q(`TableStyleLight20`,XA,K.gray),TableStyleLight21:q(`TableStyleLight21`,XA,K.orange),TableStyleMedium1:q(`TableStyleMedium1`,ZA,K.black),TableStyleMedium2:q(`TableStyleMedium2`,ZA,K.lightBlue),TableStyleMedium3:q(`TableStyleMedium3`,ZA,K.red),TableStyleMedium4:q(`TableStyleMedium4`,ZA,K.lightGreen),TableStyleMedium5:q(`TableStyleMedium5`,ZA,K.purple),TableStyleMedium6:q(`TableStyleMedium6`,ZA,K.gray),TableStyleMedium7:q(`TableStyleMedium7`,ZA,K.orange),TableStyleMedium8:q(`TableStyleMedium8`,QA,K.black),TableStyleMedium9:q(`TableStyleMedium9`,QA,K.lightBlue),TableStyleMedium10:q(`TableStyleMedium10`,QA,K.red),TableStyleMedium11:q(`TableStyleMedium11`,QA,K.lightGreen),TableStyleMedium12:q(`TableStyleMedium12`,QA,K.purple),TableStyleMedium13:q(`TableStyleMedium13`,QA,K.gray),TableStyleMedium14:q(`TableStyleMedium14`,QA,K.orange),TableStyleMedium15:{...ij,displayName:`Black, TableStyleMedium15`},TableStyleMedium16:q(`TableStyleMedium16`,$A,K.lightBlue),TableStyleMedium17:q(`TableStyleMedium17`,$A,K.red),TableStyleMedium18:q(`TableStyleMedium18`,$A,K.lightGreen),TableStyleMedium19:q(`TableStyleMedium19`,$A,K.purple),TableStyleMedium20:q(`TableStyleMedium20`,$A,K.gray),TableStyleMedium21:q(`TableStyleMedium21`,$A,K.orange),TableStyleMedium22:q(`TableStyleMedium22`,ej,K.black),TableStyleMedium23:q(`TableStyleMedium23`,ej,K.lightBlue),TableStyleMedium24:q(`TableStyleMedium24`,ej,K.red),TableStyleMedium25:q(`TableStyleMedium25`,ej,K.lightGreen),TableStyleMedium26:q(`TableStyleMedium26`,ej,K.purple),TableStyleMedium27:q(`TableStyleMedium27`,ej,K.gray),TableStyleMedium28:q(`TableStyleMedium28`,ej,K.orange),TableStyleDark1:{...rj,displayName:`Black, TableStyleDark1`},TableStyleDark2:q(`TableStyleDark2`,tj,K.lightBlue),TableStyleDark3:q(`TableStyleDark3`,tj,K.red),TableStyleDark4:q(`TableStyleDark4`,tj,K.lightGreen),TableStyleDark5:q(`TableStyleDark5`,tj,K.purple),TableStyleDark6:q(`TableStyleDark6`,tj,K.gray),TableStyleDark7:q(`TableStyleDark7`,tj,K.orange),TableStyleDark8:q(`TableStyleDark8`,nj,qA.black),TableStyleDark9:q(`TableStyleDark9`,nj,qA.redBlue),TableStyleDark10:q(`TableStyleDark10`,nj,qA.purpleGreen),TableStyleDark11:q(`TableStyleDark11`,nj,qA.orangeBlue)},oj={none:()=>({category:`none`,templateName:`none`,primaryColor:``,name:`none`}),lightColoredText:JA,lightAllBorders:XA,mediumAllBorders:ej,lightWithHeader:YA,mediumBandedBorders:ZA,mediumMinimalBorders:$A,darkNoBorders:nj,mediumWhiteBorders:QA,dark:tj};function sj(e,t,n){let r=KA(``,n);return{...oj[t](r),category:`custom`,displayName:e}}function cj(e,t){for(let n of t.sheets){let t=e.sheets.find(e=>e.name===n.sheetName);if(t){t.tables||=[];for(let e of n.tables)t.tables.push({range:e.ref,config:lj(e)});for(let e of n.pivotTables)t.tables.push({range:e.location.ref,config:uj(e)})}}dj(e.sheets,t.sheets)}function lj(e){let t=e.style?.name||``;return{hasFilters:e.autoFilter!==void 0,numberOfHeaders:e.headerRowCount,totalRow:e.totalsRowCount>0,firstColumn:e.style?.showFirstColumn||!1,lastColumn:e.style?.showLastColumn||!1,bandedRows:e.style?.showRowStripes||!1,bandedColumns:e.style?.showColumnStripes||!1,styleId:aj[t]?t:WA.styleId}}function uj(e){return{hasFilters:!1,numberOfHeaders:e.location.firstDataRow,totalRow:e.rowGrandTotals,firstColumn:!0,lastColumn:e.style?.showLastColumn||!1,bandedRows:e.style?.showRowStripes||!1,bandedColumns:e.style?.showColStripes||!1,styleId:WA.styleId}}function dj(e,t){let n=null;for(let r of e){let i=t.find(e=>wl(e.sheetName,r.name)).tables;if(!(!i||i.length===0)){n||=fj(e);for(let t of i)for(let i in n){let a=e.find(e=>e.id===i);for(let e in n[i]){let o=n[i][e];for(let s=o.length-3;s>=0;s-=2){let o=n[i][e][s];if(!o.endsWith(t.name))continue;let c=n[i][e][s+1],l=pj(r.id===a.id?``:r.name+`!`,c,t,e);n[i][e][s+2]=o.slice(0,o.indexOf(t.name))+l+n[i][e][s+2],n[i][e].splice(s,2)}}}}}if(n)for(let t in n){let r=e.find(e=>e.id===t);for(let e in n[t]){let i=n[t][e];if(i.length===1){r.cells[e]=i[0];continue}let a=``;for(let e=0;e<i.length;e+=2)a+=i[e]+`[`+i[e+1]+`]`;a+=i[i.length-1],r.cells[e]=a}}}function fj(e){let t={};for(let n of e)for(let e in n.cells){let r=n.cells[e];if(!r||!r.startsWith(`=`))continue;let i=r.indexOf(`[`);if(i===-1)continue;let a=[],o=r.slice(0,i),s=``,c=1,l=0,u=i;for(let e=i+1;e<r.length;e++){if(r[e]===`[`){c===0&&(o=r.slice(l,e),u=e),c++;continue}r[e]===`]`&&(c--,c===0&&(s=r.slice(u+1,e),a.push(o),a.push(s),l=e+1))}a.length&&(t[n.id]||(t[n.id]={}),a.push(r.slice(l)),t[n.id][e]=[...a])}return t}function pj(e,t,n,r){let i=t.split(`,`).map(e=>e.trim()),a=mn(n.ref),o=[],s=[],c=[];for(let e of i)if(mj(e).startsWith(`#`)){let t=mj(e);switch(c.push(t),t){case`#All`:s.push(a.top,a.bottom);break;case`#Data`:let e=n.headerRowCount?a.top+n.headerRowCount:a.top,t=n.totalsRowCount?a.bottom-n.totalsRowCount:a.bottom;s.push(e,t);break;case`#This Row`:s.push(tn(r).row);break;case`#Headers`:if(!n.headerRowCount)return A.InvalidReference;s.push(a.top);break;case`#Totals`:if(!n.totalsRowCount)return A.InvalidReference;s.push(a.bottom);break}}else{let t=e.split(`:`).map(e=>e.trim()).map(mj);if(o.length)return A.InvalidReference;let r=n.cols.findIndex(e=>e.name===t[0]);if(r===-1)return A.InvalidReference;if(o.push(r+a.left),t[1]){let e=n.cols.findIndex(e=>e.name===t[1]);if(e===-1)return A.InvalidReference;o.push(e+a.left)}}if(!hj(c))return A.InvalidReference;if(s.length===0){let e=n.headerRowCount?a.top+n.headerRowCount:a.top,t=n.totalsRowCount?a.bottom-n.totalsRowCount:a.bottom;s.push(e,t)}return o.length===0&&o.push(a.left,a.right),e+yn({top:Math.min(...s),left:Math.min(...o),bottom:Math.max(...s),right:Math.max(...o)})}function mj(e){return e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,e.length-1):e}function hj(e){return e.length<2?!0:e.length>2?!1:e.includes(`#Data`)&&e.includes(`#Totals`)?!0:!!(e.includes(`#Headers`)&&e.includes(`#Data`))}function gj(e,t,n){return{content:new XMLSerializer().serializeToString(e),path:t,contentType:n}}function _j(e){return String(e).replace(/\&/g,`&`).replace(/\</g,`<`).replace(/\>/g,`>`).replace(/\"/g,`"`).replace(/\'/g,`'`).replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,``)}function J(e){return new mO(e.map(([e,t])=>`${e}="${_j(t)}"`).join(` `))}function vj(e,t=`text/xml`){let n=new DOMParser().parseFromString(e.toString(),t),r=n.querySelector(`parsererror`);if(r){let t=r.innerHTML,n=parseInt(t.split(`:`)[0],10),i=e.toString().trim().split(`
|
|
67
67
|
`),a=i.slice(Math.max(n-3,0),Math.min(n+2,i.length)).join(`
|
|
68
68
|
`);throw Error(`XML string could not be parsed: ${t}\n${a}`)}return n}function yj(e){if(e)return{style:e.style,color:{rgb:e.color}}}function bj(e){let t=[{},...Object.values(e.borders).map(e=>({left:yj(e.left),right:yj(e.right),bottom:yj(e.bottom),top:yj(e.top)}))];return{relsFiles:[],sharedStrings:[],chartIds:[],imageIds:[],styles:[{fontId:0,fillId:0,numFmtId:0,borderId:0,alignment:{}}],fonts:[{size:we,family:2,color:{rgb:`000000`},name:`Arial`}],fills:[{reservedAttribute:`none`},{reservedAttribute:`gray125`}],borders:t,numFmts:[],dxfs:[]}}function xj(e,t){return X`
|
|
@@ -86,7 +86,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
86
86
|
`},CU=class extends t.Component{static template=`o-spreadsheet-ClientTag`;static props={active:Boolean,name:String,color:String,col:Number,row:Number};get tagStyle(){let{col:e,row:t,color:n}=this.props,{height:r}=this.env.model.getters.getSheetViewDimensionWithHeaders(),i=this.env.model.getters.isVisibleInViewport({sheetId:this.env.model.getters.getActiveSheetId(),col:e,row:t}),{x:a,y:o}=this.env.model.getters.getVisibleRect({left:e,top:t,right:e,bottom:t});return U({bottom:`${r-o+15}px`,left:`${a-1}px`,border:`1px solid ${n}`,"background-color":n,visibility:i?`visible`:`hidden`})}};let wU=[`*`,`+`,`&`];function TU(e,t=60){return`=`+NU(RU(e),t-1)}function EU(){return{type:`insertLine`}}function DU(e,t){return{type:`nest`,indentLevel:e,doc:t}}function OU(e){return{type:`concat`,docs:e}}function kU(e){return AU(jU(e),e)}function AU(e,t){return{type:`chooseBetween`,doc1:e,doc2:t}}function jU(e){return typeof e==`string`?e:e.type===`chooseBetween`?jU(e.doc1):e.type===`concat`?OU(e.docs.map(jU)):e.type===`nest`?{type:`nest`,indentLevel:e.indentLevel,doc:jU(e.doc)}:e.type===`insertLine`?``:e}let MU=At(function(e){return`
|
|
87
87
|
`+` `.repeat(e)});function NU(e,t){return PU(FU(t,e))}function PU(e){let t=``;for(;e;)t+=e.subString,e=e.next;return t}function FU(e,t){return IU(e,0,{indentLevel:0,doc:t,next:null})}function IU(e,t,n){if(n===null)return null;let{indentLevel:r,doc:i,next:a}=n;if(typeof i==`string`)return{subString:i,next:IU(e,t+i.length,a)};if(i.type===`concat`){let n=a;for(let e=i.docs.length-1;e>=0;e--)n={indentLevel:r,doc:i.docs[e],next:n};return IU(e,t,n)}if(i.type===`nest`)return IU(e,t,{indentLevel:r+i.indentLevel,doc:i.doc,next:a});if(i.type===`insertLine`)return{subString:MU(r),next:IU(e,r,a)};if(i.type===`chooseBetween`){let n=IU(e,t,{indentLevel:r,doc:i.doc1,next:a});return LU(e-t,n)?n:IU(e,t,{indentLevel:r,doc:i.doc2,next:a})}return null}function LU(e,t){for(;t;){if(t.subString[0]===`
|
|
88
88
|
`)return!0;if(e-=t.subString.length,e<0)return!1;t=t.next}return!0}function RU(e){let t=e.debug?`?`:``;switch(e.type){case`NUMBER`:return t+String(e.value);case`STRING`:return t+`"${e.value}"`;case`BOOLEAN`:return t+(e.value?`TRUE`:`FALSE`);case`FUNCALL`:let n=fO.get(e.value.toUpperCase()),r=Jv(n,e.args.length),i=[],a=0;for(;a<e.args.length;)if(n.args[r(a).index??-1]?.repeating){let t=e.args.slice(a,a+n.nbrArgRepeating).map(e=>RU(e));i.push(kU(OU(zU(t)))),a+=n.nbrArgRepeating}else i.push(RU(e.args[a])),a++;return BU(OU(zU(i)),t+e.value);case`ARRAY`:return VU(OU(e.value.map(e=>OU(e.map((e,t)=>t===0?RU(e):OU([`, `,EU(),RU(e)])))).map((e,t)=>t===0?kU(e):OU([`; `,EU(),kU(e)]))));case`UNARY_OPERATION`:let o=RU(e.operand),s=(e.postfix?UU(e):WU(e))?BU(o):o;return e.postfix?OU([s,t+e.value]):OU([t+e.value,s]);case`BIN_OPERATION`:{let n=RU(e.left),r=UU(e)?BU(n):n,i=RU(e.right),a=WU(e)?BU(i):i;return kU(OU([r,`${t}${e.value}`,DU(1,OU([EU(),a]))]))}default:return t+e.value}}function zU(e){let t=e.length?[e[0]]:[];for(let n=1;n<e.length;n++)t.push(`, `,EU()),t.push(e[n]);return t}function BU(e,t=void 0){let n=[`(`,DU(1,OU([EU(),e])),EU(),`)`];return t&&n.unshift(t),kU(OU(n))}function VU(e){return kU(OU([`{`,DU(1,OU([EU(),e])),EU(),`}`]))}function HU(e){let t=e.debug?`?`:``;switch(e.type){case`FUNCALL`:let n=e.args.map(e=>HU(e));return`${t}${e.value}(${n.join(`,`)})`;case`NUMBER`:return t+e.value.toString();case`STRING`:return t+`"${e.value}"`;case`BOOLEAN`:return t+(e.value?`TRUE`:`FALSE`);case`UNARY_OPERATION`:if(e.postfix)return(UU(e)?`(${HU(e.operand)})`:HU(e.operand))+t+e.value;let r=WU(e)?`(${HU(e.operand)})`:HU(e.operand);return t+e.value+r;case`ARRAY`:return`{`+t+e.value.map(e=>e.map(e=>HU(e)).join(`,`)).join(`;`)+`}`;case`BIN_OPERATION`:let i=UU(e)?`(${HU(e.left)})`:HU(e.left),a=WU(e)?`(${HU(e.right)})`:HU(e.right);return i+t+e.value+a;default:return t+e.value}}function UU(e){let t=e.value,n=`left`in e?e.left:e.operand,r=n.value;return n.type===`BIN_OPERATION`&&iN[r]<iN[t]}function WU(e){let t=e.value,n=`right`in e?e.right:e.operand,r=iN[n.value],i=iN[t];return n.type===`BIN_OPERATION`?r<i?!0:r===i&&!wU.includes(t):!1}let GU=k(`The cell you are trying to edit has been deleted.`);var KU=class extends jN{canStopEdition(){return this.editionMode===`inactive`?!0:this.checkDataValidation()}stopEdition(e){if(this.canStopEdition()){let{col:t,row:n}=this.currentEditedCell;this._stopEdition(),e&&(this.getters.isSingleCellOrMerge(this.sheetId,this.getters.getSelectedZone())?(this.model.selection.selectCell(t,n),this.model.selection.moveAnchorCell(e,1)):BM(this.getters,this.model.selection,e));return}let t=this.currentEditedCell,n=T(t.col,t.row),r=this.getters.getValidationRuleForCell(t);if(!r)return;let i=Z.get(r.criterion.type).getErrorString(r.criterion,this.getters,t.sheetId);this.notificationStore.raiseError(k(`The data you entered in %s violates the data validation rule set on the cell:
|
|
89
|
-
%s`,n,i)),this.cancelEdition()}handle(e){switch(super.handle(e),e.type){case`SET_FORMATTING`:this.cancelEdition();break;case`ADD_COLUMNS_ROWS`:this.onAddElements(e);break;case`REMOVE_COLUMNS_ROWS`:e.dimension===`COL`?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case`ACTIVATE_SHEET`:if(Ut(this._currentContent)||(this._cancelEdition(),this.resetContent()),this.model.selection.isListening(this)&&e.sheetIdFrom!==e.sheetIdTo){let t=this.getters.getActivePosition(),{col:n,row:r}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:t.col,row:t.row}),i=this.getters.expandZone(e.sheetIdTo,E({col:n,row:r}));this.model.selection.resetAnchor(this,{cell:{col:n,row:r},zone:i})}break;case`DELETE_SHEET`:case`UNDO`:case`REDO`:!this.getters.tryGetSheet(this.sheetId)&&this.editionMode!==`inactive`&&(this.sheetId=this.getters.getActiveSheetId(),this.resetContent(),this.cancelEditionAndActivateSheet(),this.notificationStore.raiseError(GU));break}}get placeholder(){let e=this.getters.getActivePosition(),t=this.model.getters.getArrayFormulaSpreadingOn(e);if(t)return this.getters.getCellText(t,{showFormula:!0})}get currentEditedCell(){return{sheetId:this.sheetId,col:this.col,row:this.row}}onColumnsRemoved(e){if(e.elements.includes(this.col)&&this.editionMode!==`inactive`){this.cancelEdition(),this.notificationStore.raiseError(GU);return}let{top:t,left:n}=Sn({left:this.col,right:this.col,top:this.row,bottom:this.row},`left`,[...e.elements]);this.col=n,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&this.editionMode!==`inactive`){this.cancelEdition(),this.notificationStore.raiseError(GU);return}let{top:t,left:n}=Sn({left:this.col,right:this.col,top:this.row,bottom:this.row},`top`,[...e.elements]);this.col=n,this.row=t}onAddElements(e){let{top:t,left:n}=xn({left:this.col,right:this.col,top:this.row,bottom:this.row},e.dimension===`COL`?`left`:`top`,e.base,e.position,e.quantity);this.col=n,this.row=t}confirmEdition(e){let t;if(e){let n={sheetId:this.getters.getActiveSheetId(),col:this.col,row:this.row},r=this.getters.getEvaluatedCell(n);r.link&&!Ut(e)&&(e=ot(e,r.link.url));let i=this.getters.getCell(n)?.format,a=i
|
|
89
|
+
%s`,n,i)),this.cancelEdition()}handle(e){switch(super.handle(e),e.type){case`SET_FORMATTING`:this.cancelEdition();break;case`ADD_COLUMNS_ROWS`:this.onAddElements(e);break;case`REMOVE_COLUMNS_ROWS`:e.dimension===`COL`?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case`ACTIVATE_SHEET`:if(Ut(this._currentContent)||(this._cancelEdition(),this.resetContent()),this.model.selection.isListening(this)&&e.sheetIdFrom!==e.sheetIdTo){let t=this.getters.getActivePosition(),{col:n,row:r}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:t.col,row:t.row}),i=this.getters.expandZone(e.sheetIdTo,E({col:n,row:r}));this.model.selection.resetAnchor(this,{cell:{col:n,row:r},zone:i})}break;case`DELETE_SHEET`:case`UNDO`:case`REDO`:!this.getters.tryGetSheet(this.sheetId)&&this.editionMode!==`inactive`&&(this.sheetId=this.getters.getActiveSheetId(),this.resetContent(),this.cancelEditionAndActivateSheet(),this.notificationStore.raiseError(GU));break}}get placeholder(){let e=this.getters.getActivePosition(),t=this.model.getters.getArrayFormulaSpreadingOn(e);if(t)return this.getters.getCellText(t,{showFormula:!0})}get currentEditedCell(){return{sheetId:this.sheetId,col:this.col,row:this.row}}onColumnsRemoved(e){if(e.elements.includes(this.col)&&this.editionMode!==`inactive`){this.cancelEdition(),this.notificationStore.raiseError(GU);return}let{top:t,left:n}=Sn({left:this.col,right:this.col,top:this.row,bottom:this.row},`left`,[...e.elements]);this.col=n,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&this.editionMode!==`inactive`){this.cancelEdition(),this.notificationStore.raiseError(GU);return}let{top:t,left:n}=Sn({left:this.col,right:this.col,top:this.row,bottom:this.row},`top`,[...e.elements]);this.col=n,this.row=t}onAddElements(e){let{top:t,left:n}=xn({left:this.col,right:this.col,top:this.row,bottom:this.row},e.dimension===`COL`?`left`:`top`,e.base,e.position,e.quantity);this.col=n,this.row=t}confirmEdition(e){let t;if(e){let n={sheetId:this.getters.getActiveSheetId(),col:this.col,row:this.row},r=this.getters.getEvaluatedCell(n);r.link&&!Ut(e)&&(e=ot(e,r.link.url));let i=this.getters.getCell(n)?.format,a=i&&os(i),o=ds(e,this.getters.getLocale()),s;i!==`@`&&(o&&!a?s=o:a&&ra(e,this.getters.getLocale())&&(s=``)),this.addHeadersForSpreadingFormula(e),t=this.model.dispatch(`UPDATE_CELL`,{...this.currentEditedCell,content:e,format:s})}else t=this.model.dispatch(`UPDATE_CELL`,{...this.currentEditedCell,content:``});t.isSuccessful&&this.model.dispatch(`AUTOFILL_TABLE_COLUMN`,{...this.currentEditedCell}),this.setContent(``)}getComposerContent(e,t){let n=this.getters.getLocale(),r=this.getters.getCell(e);if(r?.isFormula){let e=this.getPrettifiedFormula(r);function i(t){let n=0,r=0;for(;r<t;){n++;let t=e[n];t!==`
|
|
90
90
|
`&&t!==` `&&r++}return n}let a=t;return t&&(a={start:i(t.start),end:i(t.end)}),{text:MS(e,n),adjustedSelection:a}}if(this.model.getters.getArrayFormulaSpreadingOn(e))return{text:``};if(r?.content.startsWith(`'`))return{text:r.content};let{format:i,value:a,type:o,formattedValue:s}=this.getters.getEvaluatedCell(e);switch(o){case`empty`:return{text:``};case`text`:case`error`:return{text:a};case`boolean`:return{text:s};case`number`:return i&&os(i)?Di(s,n)===null?{text:z(a,{locale:n,format:Number.isInteger(a)?n.dateFormat:US(n)})}:{text:s}:{text:this.numberComposerContent(a,i,n)}}}getPrettifiedFormula(e){if(e.compiledFormula.isBadExpression)return e.compiledFormula.toFormulaString(this.getters);let t=this.editionMode===`inactive`?1/0:80;return TU(e.compiledFormula.getAst(this.getters),t)}numberComposerContent(e,t,n){return t?.includes(`%`)?`${as(e*100,n.decimalSeparator)}%`:as(e,n.decimalSeparator)}addHeadersForSpreadingFormula(e){if(!Ut(e))return;let t=this.getters.evaluateFormula(this.sheetId,e,{sheetId:this.sheetId,col:this.col,row:this.row});if(!Ta(t))return;let n=this.getters.getNumberRows(this.sheetId),r=this.getters.getNumberCols(this.sheetId),i=this.row+t[0].length-n,a=this.col+t.length-r;a>0&&this.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:this.sheetId,sheetName:this.getters.getSheetName(this.sheetId),dimension:`COL`,base:r-1,position:`after`,quantity:a+20}),i>0&&this.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:this.sheetId,sheetName:this.getters.getSheetName(this.sheetId),dimension:`ROW`,base:n-1,position:`after`,quantity:i+50})}checkDataValidation(){let e={sheetId:this.sheetId,col:this.col,row:this.row},t=this.getCurrentCanonicalContent(),n=Ut(t)?this.getters.evaluateFormula(this.sheetId,t):sc(t,this.getters.getLocale());if(wm(n))return!0;let r=this.getters.getValidationResultForCellValue(Sm(n),e);return!(!r.isValid&&r.rule.isBlocking)}startEdition(e,t){return this.getters.isCurrentSheetLocked()?(this.model.trigger(`command-rejected`,{result:new Ys(`SheetLocked`),command:{sheetId:this.getters.getActiveSheetId()}}),`NoStateChange`):super.startEdition(e,t)}evaluateCanonicalFormula(e){return this.getters.evaluateFormulaResult(this.sheetId,e,{sheetId:this.sheetId,col:this.col,row:this.row})}};let qU=3*.4*globalThis.devicePixelRatio||1;var JU=class extends t.Component{static template=`o-spreadsheet-GridComposer`;static props={gridDims:Object,onInputContextMenu:Function};static components={Composer:$M};rect=this.defaultRect;isEditing=!1;isCellReferenceVisible=!1;currentEditedCell={col:0,row:0,sheetId:this.env.model.getters.getActiveSheetId()};composerStore;composerFocusStore;composerInterface;get defaultRect(){return{x:0,y:0,width:0,height:0}}setup(){let e=D(KU);this.composerStore=e,this.composerFocusStore=D(xr),this.composerInterface={id:`gridComposer`,get editionMode(){return e.editionMode},startEdition:this.composerStore.startEdition,setCurrentContent:this.composerStore.setCurrentContent,stopEdition:this.composerStore.stopEdition},this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`inactive`}),(0,t.onWillUpdateProps)(()=>{this.updateComponentPosition(),this.updateCellReferenceVisibility()})}get shouldDisplayCellReference(){return!this.env.isMobile()&&this.isCellReferenceVisible}get cellReference(){let{col:e,row:t,sheetId:n}=this.composerStore.currentEditedCell;return Bc(n===this.env.model.getters.getActiveSheetId()?void 0:this.env.model.getters.getSheetName(n),T(e,t))}get cellReferenceStyle(){let{x:e,y:t}=this.rect;return U({left:`${e-qU}px`,top:`${t-28}px`})}get focus(){return this.composerFocusStore.activeComposer===this.composerInterface?this.composerFocusStore.focusMode:`inactive`}get composerProps(){let{width:e,height:t}=this.env.model.getters.getSheetViewDimensionWithHeaders(),n=this.props.gridDims.height-this.rect.y-2*qU;return{rect:{...this.rect},delimitation:{width:e,height:t},focus:this.focus,isDefaultFocus:!0,onComposerContentFocused:e=>this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`contentFocus`,selection:e}),onComposerCellFocused:e=>this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`cellFocus`,content:e}),onInputContextMenu:this.props.onInputContextMenu,composerStore:this.composerStore,inputStyle:`max-height: ${n}px;`,inputMode:this.composerStore.editionMode===`inactive`?`none`:void 0}}get containerStyle(){if(this.composerStore.editionMode===`inactive`||this.env.isMobile())return`z-index: -1000; opacity: 0;`;let e=Ut(this.composerStore.currentContent),t=this.env.model.getters.getActiveCell(),n=this.env.model.getters.getActivePosition(),r=this.env.model.getters.getCellComputedStyle(n),{x:i,y:a,width:o,height:s}=this.rect,c=!e&&r.fillColor||`#ffffff`,l=!e&&r.textColor||`#000000`,u=!e&&r.fontSize||10,d=!e&&r.bold?`bold`:void 0,f=!e&&r.italic?`italic`:`normal`,p=e?`none`:iv(r),m=`left`;e||(m=r.align||t.defaultAlign);let h=this.props.gridDims.height-this.rect.y,g=this.props.gridDims.width-this.rect.x,_=Math.min(s+1,h),v=Math.min(o+1,g);return U({left:`${i-1}px`,top:`${a}px`,border:`${qU}px solid ${ae}`,"min-width":`${v}px`,"min-height":`${_}px`,"max-width":`${g}px`,"max-height":`${h}px`,background:c,color:l,"font-size":`${Ll(u)}px`,"font-weight":d,"font-style":f,"text-decoration":p,"text-align":m})}updateComponentPosition(){let e=this.composerFocusStore.activeComposer.editionMode!==`inactive`;!e&&this.composerFocusStore.activeComposer!==this.composerInterface&&this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`inactive`});let t=!w(this.currentEditedCell,this.composerStore.currentEditedCell);if(this.isEditing!==e){if(this.isEditing=e,!e){this.rect=this.defaultRect;return}this.currentEditedCell=this.composerStore.currentEditedCell,t=!0}if(t){let e=this.env.model.getters.getActivePosition(),t=this.env.model.getters.expandZone(e.sheetId,E(e));this.rect=this.env.model.getters.getVisibleRect(t)}}updateCellReferenceVisibility(){if(this.composerStore.editionMode===`inactive`){this.isCellReferenceVisible=!1;return}if(this.isCellReferenceVisible)return;let e=this.env.model.getters.getActiveSheetId(),t=E(this.env.model.getters.getSelection().anchor.cell);(!w(this.env.model.getters.getVisibleRect(t),this.rect)||e!==this.composerStore.currentEditedCell.sheetId)&&(this.isCellReferenceVisible=!0)}onFocus(){this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`contentFocus`})}};function YU({x:e,y:t},{x:n,y:r},i,{maxX:a,maxY:o},{scrollX:s,scrollY:c},{scrollX:l,scrollY:u}){let d=e-n+l-s,f=x(i.x+d,0,a-i.width),p=t-r+u-c,m=x(i.y+p,0,o-i.height);return{...i,x:f,y:m}}function XU(e,t,n,{x:r,y:i},{x:a,y:o},s,c,{scrollX:l,scrollY:u},{scrollX:d,scrollY:f},{maxX:p,maxY:m}){let{x:h,y:g,width:_,height:v}=e;if(s&&t!==0&&n!==0){let e=Math.min(t*(a-r+d-l),_-c),s=Math.min(n*(o-i+f-u),v-c),p=Math.min(e/_,s/v);t<0&&(h+=_*p),n<0&&(g+=v*p),_*=1-p,v*=1-p}else{let e=Math.max(t*(r-a+d-l),c-_),s=Math.max(n*(i-o+f-u),c-v);_+=e,v+=s,t<0&&(h-=e),n<0&&(g-=s)}return h+d<=0?(_=_+h+d,h=-d):h+_>p&&(_=p-h),g+f<=0?(v=v+g+f,g=-f):g+v>m&&(v=m-g),{...e,x:h,y:g,width:_,height:v}}function ZU(e,t,n){let r=tW(e,t,[`hCenter`,`right`,`left`],n,[`hCenter`,`right`,`left`]),i=tW(e,t,[`vCenter`,`bottom`,`top`],n,[`vCenter`,`bottom`,`top`]),{y:a,x:o}=e.getMainViewportCoordinates(),{scrollY:s,scrollX:c}=e.getActiveSheetScrollInfo();if(i){t.y-=i.snapOffset;let e=t.y<a,n=t.y<a;e&&!n?t.y+=s:!e&&n&&(t.y-=s)}if(r){t.x-=r.snapOffset;let e=t.x<o,n=t.x<o;e&&!n?t.x+=c:!e&&n&&(t.x-=c)}return{snappedFigure:t,verticalSnapLine:r,horizontalSnapLine:i}}function QU(e,t,n,r,i){let a=tW(e,r,[t===-1?`left`:`right`],i,[`right`,`left`]);a&&(t===1?r.width-=a.snapOffset:t===-1&&(r.x-=a.snapOffset,r.width+=a.snapOffset));let o=tW(e,r,[n===-1?`top`:`bottom`],i,[`bottom`,`top`]);return o&&(n===1?r.height-=o.snapOffset:n===-1&&(r.y-=o.snapOffset,r.height+=o.snapOffset)),r.x=Math.round(r.x),r.y=Math.round(r.y),r.height=Math.round(r.height),r.width=Math.round(r.width),{snappedFigure:r,verticalSnapLine:a,horizontalSnapLine:o}}function $U(e,t,n){return n.map(n=>rW(e,t,!1,n)).filter(n=>eW(e,t,n))}function eW(e,t,n){let{x:r,y:i}=e.getMainViewportCoordinates(),a=[];switch(n.axisType){case`top`:case`bottom`:case`vCenter`:if(t.y<i)return!0;a.push({x:t.x,y:n.position}),a.push({x:t.x+t.width,y:n.position});break;case`left`:case`right`:case`hCenter`:if(t.x<r)return!0;a.push({x:n.position,y:t.y}),a.push({x:n.position,y:t.y+t.height});break}return a.some(e.isPixelPositionVisible)}function tW(e,t,n,r,i){let a=n.map(n=>rW(e,t,!0,n)),o;for(let t of r){let n=$U(e,t,i);for(let e of a)for(let r of n){if(!nW(e.position,r.position))continue;let n=e.position-r.position;o&&n===o.snapOffset?o.matchedFigIds.push(t.id):(!o||Math.abs(n)<=Math.abs(o.snapOffset))&&(o={matchedFigIds:[t.id],snapOffset:n,snappedAxisType:e.axisType,position:r.position})}}return o}function nW(e,t){return Math.abs(e-t)<=5}function rW(e,t,n,r){let i=0,{scrollX:a,scrollY:o}=e.getActiveSheetScrollInfo(),{x:s,y:c}=e.getMainViewportCoordinates(),l=!n&&t.y<c?t.y+o:t.y,u=!n&&t.x<s?t.x+a:t.x;switch(r){case`top`:i=l;break;case`bottom`:i=l+t.height-1;break;case`vCenter`:i=l+Math.floor(t.height/2)-1;break;case`left`:i=u;break;case`right`:i=u+t.width-1;break;case`hCenter`:i=u+Math.floor(t.width/2)-1;break}return{position:i,axisType:r}}var iW=class extends t.Component{static template=`o-spreadsheet-FiguresContainer`;static props={};static components={FigureComponent:Vv};dnd=(0,t.useState)({draggedFigure:void 0,horizontalSnap:void 0,verticalSnap:void 0,cancelDnd:void 0,overlappingCarousel:void 0});setup(){(0,t.onMounted)(()=>{this.render()}),(0,t.onWillUpdateProps)(()=>{let e=this.env.model.getters.getActiveSheetId(),t=this.dnd.draggedFigure?.id;t&&!this.env.model.getters.getFigure(e,t)&&(this.dnd.cancelDnd&&this.dnd.cancelDnd(),this.dnd.draggedFigure=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0,this.dnd.overlappingCarousel=void 0,this.dnd.cancelDnd=void 0)})}getVisibleFigures(){let e=this.env.model.getters.getVisibleFigures();return this.dnd.draggedFigure&&!e.some(e=>e.id===this.dnd.draggedFigure?.id)&&this.dnd.draggedFigure&&e.push(this.dnd.draggedFigure),e}get containers(){let e=this.getVisibleFigures(),t=[];for(let n of[`topLeft`,`topRight`,`bottomLeft`,`bottomRight`]){let r=e.filter(e=>this.getFigureContainer(e)===n);r.length>0&&t.push({type:n,figures:r,style:this.getContainerStyle(n),inverseViewportStyle:this.getInverseViewportPositionStyle(n)})}return this.dnd.draggedFigure&&t.push({type:`dnd`,figures:[this.getDndFigure()],style:this.getContainerStyle(`dnd`),inverseViewportStyle:this.getInverseViewportPositionStyle(`dnd`)}),t}getContainerStyle(e){return this.rectToCss(this.getContainerRect(e))}rectToCss(e){return U({left:`${e.x}px`,top:`${e.y}px`,width:`${e.width}px`,height:`${e.height}px`})}getContainerRect(e){let{width:t,height:n}=this.env.model.getters.getSheetViewDimension(),{x:r,y:i}=this.env.model.getters.getMainViewportCoordinates(),a=[`bottomRight`,`topRight`].includes(e)?r:0,o=t-a,s=[`bottomRight`,`bottomLeft`].includes(e)?i:0;return{x:a,y:s,width:o,height:n-s}}getInverseViewportPositionStyle(e){let{scrollX:t,scrollY:n}=this.env.model.getters.getActiveSheetScrollInfo(),{x:r,y:i}=this.env.model.getters.getMainViewportCoordinates(),a=0,o=0;return e===`dnd`&&(a=-t,o=-n),[`bottomRight`,`topRight`].includes(e)&&(a=-t-r),[`bottomRight`,`bottomLeft`].includes(e)&&(o=-n-i),U({left:`${a}px`,top:`${o}px`})}getFigureContainer(e){let{x:t,y:n}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.draggedFigure?.id?`dnd`:e.x<t&&e.y<n?`topLeft`:e.x<t?`bottomLeft`:e.y<n?`topRight`:`bottomRight`}toBottomRightViewport(e){let t=this.getFigureContainer(e),n=this.env.model.getters.getActiveSheetScrollInfo(),r={...e};return[`bottomLeft`,`topLeft`].includes(t)&&(r.x+=n.scrollX),[`topLeft`,`topRight`].includes(t)&&(r.y+=n.scrollY),r}startDraggingFigure(e,t){if(t.button>0||this.env.model.getters.isReadonly()||!this.env.model.dispatch(`SELECT_FIGURE`,{figureId:e.id}).isSuccessful||this.env.isMobile()||this.env.model.getters.isCurrentSheetLocked())return;let n=this.env.model.getters.getActiveSheetId(),r=this.env.model.getters.getViewportZoomLevel(),i={x:t.clientX/r,y:t.clientY/r},a=this.env.model.getters.getActiveSheetScrollInfo(),o=this.toBottomRightViewport(e),s={maxX:this.env.model.getters.getColDimensions(n,this.env.model.getters.getNumberCols(n)-1).end,maxY:this.env.model.getters.getRowDimensions(n,this.env.model.getters.getNumberRows(n)-1).end},c=!1,l=e=>{let t=this.env.model.getters,n={x:e.clientX/r,y:e.clientY/r},l=Math.abs(n.x-i.x),u=Math.abs(n.y-i.y);if(!c&&l<5&&u<5)return;c=!0;let d=YU(n,i,o,s,a,t.getActiveSheetScrollInfo()),f=this.getOtherFigures(o.id),p=this.getCarouselOverlappingChart(d,f);if(this.dnd.overlappingCarousel=p,p)this.dnd.draggedFigure=d,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0;else{let e=ZU(t,d,f);this.dnd.draggedFigure=e.snappedFigure,this.dnd.horizontalSnap=this.getSnap(e.horizontalSnapLine),this.dnd.verticalSnap=this.getSnap(e.verticalSnapLine)}},u=t=>{if(!this.dnd.draggedFigure)return;let{col:r,row:i,offset:a}=this.env.model.getters.getPositionAnchorOffset(this.dnd.draggedFigure);this.dnd.overlappingCarousel?this.env.model.dispatch(`ADD_FIGURE_CHART_TO_CAROUSEL`,{sheetId:n,carouselFigureId:this.dnd.overlappingCarousel.id,chartFigureId:e.id}):this.env.model.dispatch(`UPDATE_FIGURE`,{sheetId:n,figureId:e.id,offset:a,col:r,row:i}),this.dnd.draggedFigure=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0,this.dnd.overlappingCarousel=void 0};this.dnd.cancelDnd=BN(l,u)}startResize(e,t,n,r){r.stopPropagation();let i=this.env.model.getters.getActiveSheetScrollInfo(),a=Bv.get(e.tag).keepRatio||!1,o=Bv.get(e.tag).minFigSize||80,s=this.env.model.getters.getViewportZoomLevel(),c=this.env.model.getters.getActiveSheetId(),l={x:r.clientX/s,y:r.clientY/s},u={maxX:this.env.model.getters.getColDimensions(c,this.env.model.getters.getNumberCols(c)-1).end,maxY:this.env.model.getters.getRowDimensions(c,this.env.model.getters.getNumberRows(c)-1).end},d=r=>{let c=XU(e,t,n,{x:r.clientX/s,y:r.clientY/s},l,a,o,i,this.env.model.getters.getActiveSheetScrollInfo(),u),d=this.getOtherFigures(e.id),f=QU(this.env.model.getters,t,n,c,d);this.dnd.draggedFigure=f.snappedFigure,this.dnd.horizontalSnap=this.getSnap(f.horizontalSnapLine),this.dnd.verticalSnap=this.getSnap(f.verticalSnapLine)},f=r=>{if(!this.dnd.draggedFigure)return;let i=this.env.model.getters.getPositionAnchorOffset(this.dnd.draggedFigure);t&&(i.width=this.dnd.draggedFigure.width),n&&(i.height=this.dnd.draggedFigure.height),this.env.model.dispatch(`UPDATE_FIGURE`,{sheetId:this.env.model.getters.getActiveSheetId(),figureId:e.id,...i}),this.dnd.draggedFigure=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0,this.dnd.overlappingCarousel=void 0};this.dnd.cancelDnd=BN(d,f)}getOtherFigures(e){return this.getVisibleFigures().filter(t=>t.id!==e)}getDndFigure(){let e=this.dnd.draggedFigure;if(!e)throw Error(`Dnd figure not found`);return e}getFigureStyle(e){return e.id===this.dnd.draggedFigure?.id?U({opacity:this.dnd.overlappingCarousel?.id?`0.6`:`0.9`,cursor:`grabbing`}):``}getFigureClass(e){return e.id===this.dnd.overlappingCarousel?.id?`o-add-to-carousel`:``}getSnap(e){if(!e||!this.dnd.draggedFigure)return;let{scrollX:t,scrollY:n}=this.env.model.getters.getActiveSheetScrollInfo(),r=e.matchedFigIds.map(e=>this.getVisibleFigures().find(t=>t.id===e)).filter(C).map(e=>({x:e.x-t,y:e.y-n,width:e.width,height:e.height})).filter(C),i=Tv({...this.dnd.draggedFigure,x:this.dnd.draggedFigure.x-t,y:this.dnd.draggedFigure.y-n},...r);return{line:e,containerStyle:this.rectToCss(i),lineStyle:this.getSnapLineStyle(e,i)}}getSnapLineStyle(e,t){if(!e)return``;let{scrollX:n,scrollY:r}=this.env.model.getters.getActiveSheetScrollInfo();return[`top`,`vCenter`,`bottom`].includes(e.snappedAxisType)?U({top:`${e.position-t.y-r}px`,left:`0px`,width:`100%`}):U({top:`0px`,left:`${e.position-t.x-n}px`,height:`100%`})}getCarouselOverlappingChart(e,t){if(e.tag!==`chart`)return;let n=e.x+e.width/2,r=e.y+e.height/2,i,a=1/0;for(let o of t){if(o.tag!==`carousel`)continue;let t=o.x+o.width/2,s=o.y+o.height/2,c=Math.abs(n-t),l=Math.abs(r-s),u=c**2+l**2;c<=e.width/2&&l<=e.height/2&&u<a&&(a=u,i=o)}return i}},aW=class extends t.Component{static template=`o-spreadsheet-GridAddRowsFooter`;static props={};static components={ValidationMessages:OI};DOMFocusableElementStore;inputRef=(0,t.useRef)(`inputRef`);state=(0,t.useState)({inputValue:`100`,errorFlag:!1});setup(){this.DOMFocusableElementStore=D(LM),(0,t.useExternalListener)(window,`click`,this.onExternalClick,{capture:!0})}get addRowsPosition(){let e=this.env.model.getters.getActiveSheetId(),{numberOfRows:t}=this.env.model.getters.getSheetSize(e),{scrollY:n}=this.env.model.getters.getActiveSheetScrollInfo();return U({top:`${this.env.model.getters.getRowDimensions(e,t-1).end-n}px`})}get errorMessages(){return[k(`Please enter a number between 0 and 10000.`)]}onKeydown(e){e.key.toUpperCase()===`ESCAPE`?this.focusDefaultElement():e.key.toUpperCase()===`ENTER`&&this.onConfirm()}onInput(e){let t=e.target.value;this.state.inputValue=t;let n=Number(t);this.state.errorFlag=Number.isNaN(n)||n<=0||n>1e4}onConfirm(){if(this.state.errorFlag)return;let e=Number(this.state.inputValue),t=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getNumberRows(t);this.env.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:t,sheetName:this.env.model.getters.getSheetName(t),position:`after`,base:n-1,quantity:e,dimension:`ROW`}),this.focusDefaultElement();let{scrollX:r}=this.env.model.getters.getActiveSheetScrollInfo(),{end:i}=this.env.model.getters.getRowDimensions(t,n+e-1);this.env.model.dispatch(`SET_VIEWPORT_OFFSET`,{offsetX:r,offsetY:i})}onExternalClick(e){this.inputRef.el!==document.activeElement||e.target===this.inputRef.el||this.focusDefaultElement()}focusDefaultElement(){document.activeElement===this.inputRef.el&&this.DOMFocusableElementStore.focus()}};let oW={figureHandlers:new B,cellHandlers:new B},sW=[`cell`,`border`,`table`,`conditionalFormat`,`merge`];var cW=class extends yr{mutators=[`activate`,`cancel`,`pasteFormat`];highlightStore=this.get(ON);status=`inactive`;copiedData;constructor(e){super(e),this.highlightStore.register(this),this.onDispose(()=>{this.highlightStore.unRegister(this)})}handle(e){switch(e.type){case`PAINT_FORMAT`:this.paintFormat(e.sheetId,e.target);break}}activate(e){this.copiedData=this.copyFormats(),this.status=e.persistent?`persistent`:`oneOff`}cancel(){this.status=`inactive`,this.copiedData=void 0}pasteFormat(e){this.model.dispatch(`PAINT_FORMAT`,{target:e,sheetId:this.getters.getActiveSheetId()})}get isActive(){return this.status!==`inactive`}get clipboardHandlers(){return sW.map(e=>({handlerName:e,handler:new(oW.cellHandlers.get(e))(this.getters,this.model.dispatch)}))}copyFormats(){let e=this.getters.getActiveSheetId(),t=this.getters.getSelectedZones(),n={zones:t,sheetId:e};for(let{handlerName:r,handler:i}of this.clipboardHandlers){let a=i.copy(wP(e,t),!1);a!==void 0&&(n[r]=a)}return n}paintFormat(e,t){if(!this.copiedData)return;let n={isCutOperation:!1,pasteOption:`onlyFormat`},{target:r,selectedZones:i}=AP(e,t,this.copiedData,this.clipboardHandlers,n);kP(this.clipboardHandlers,this.copiedData,r,n),jP(this.model.selection,t,i),this.status===`oneOff`&&this.cancel()}get highlights(){let e=this.copiedData;return e?e.zones.map(t=>({range:this.model.getters.getRangeFromZone(e.sheetId,t),color:ae,dashed:!0,sheetId:e.sheetId,noFill:!0,thinLine:!0,interactive:!1})):[]}},lW=class extends yr{mutators=[`clear`,`hover`];col;row;overlayColors=new wV;handle(e){switch(e.type){case`ACTIVATE_SHEET`:this.clear()}}hover(e){if(!this.getters.isDashboard()||e.col===this.col&&e.row===this.row)return`noStateChange`;this.col=e.col,this.row=e.row,this.computeOverlay()}clear(){this.col=void 0,this.row=void 0}computeOverlay(){this.overlayColors=new wV;let{col:e,row:t}=this;if(e===void 0||t===void 0)return;let n=this.getters.getActiveSheetId(),r=this.getters.getTable({sheetId:n,col:e,row:t});if(!r)return;let{left:i,right:a,top:o}=r.range.zone,s=t<o+r.config.numberOfHeaders,c=S(i,a+1).some(e=>!this.getters.isColHidden(n,e)&&this.getters.getEvaluatedCell({sheetId:n,col:e,row:t}).formattedValue);if(!s&&c)for(let e=i;e<=a;e++)this.overlayColors.set({sheetId:n,col:e,row:t},`#017E8414`)}},uW=class extends yr{mutators=[`setHoveredIcon`];hoveredIcon=void 0;setHoveredIcon(e){this.hoveredIcon=e}};function dW(e,n){let r=D(Hv),i=D(lW),a={col:void 0,row:void 0},{Date:o}=window,s,c,l=0;function u(){return s===void 0||c===void 0?{col:-1,row:-1}:{col:e.model.getters.getColIndex(s),row:e.model.getters.getRowIndex(c)}}function d(e){let t=op(n.el);return{x:e.clientX-t.x,y:e.clientY-t.y}}let{pause:f,resume:p}=xv(m,200);function m(){let{col:e,row:t}=u(),n=o.now()-l;if(n>300&&(e!==a.col||t!==a.row)&&y(void 0,void 0),n>300){if(e<0||t<0)return;y(e,t)}}function h(e){np(n.el,e.ev)&&({x:s,y:c}=d(e),l=o.now(),i.hover(u()))}function g(){let{col:e,row:t}=u();(e!==a.col||t!==a.row)&&y(void 0,void 0)}function _(t){let r=Ep(e,t),{x:i,y:a}=d(r),o=op(n.el);return a<0||a>o.height||i<0||i>o.width?h(r):f()}ML(n,`pointermove`,t=>!e.isMobile()&&h(Ep(e,t))),ML(n,`mouseleave`,_),ML(n,`mouseenter`,p),ML(n,`pointerdown`,g),ML(n,`pointerdown`,t=>e.isMobile()&&h(Ep(e,t))),(0,t.useExternalListener)(window,`click`,v);function v(e){let t=e.target;n.el.contains(t)||y(void 0,void 0)}function y(e,t){(e!==a.col||t!==a.row)&&(a.col=e,a.row=t,r.hover({col:e,row:t}))}return a}var fW=class extends t.Component{static template=`o-spreadsheet-GridOverlay`;static props={onCellDoubleClicked:{type:Function,optional:!0},onCellClicked:{type:Function,optional:!0},onCellRightClicked:{type:Function,optional:!0},onGridResized:{type:Function,optional:!0},onGridMoved:Function,gridOverlayDimensions:String,slots:{type:Object,optional:!0}};static components={FiguresContainer:iW,GridAddRowsFooter:aW};static defaultProps={onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{}};gridOverlay=(0,t.useRef)(`gridOverlay`);cellPopovers;paintFormatStore;hoveredIconStore;setup(){dW(this.env,this.gridOverlay);let e=new ResizeObserver(()=>{this.props.onGridResized()});(0,t.onMounted)(()=>{e.observe(this.gridOverlayEl)}),(0,t.onWillUnmount)(()=>{e.disconnect()}),this.cellPopovers=D(sP),this.paintFormatStore=D(cW),this.hoveredIconStore=D(uW)}get gridOverlayEl(){if(!this.gridOverlay.el)throw Error(`GridOverlay el is not defined.`);return this.gridOverlay.el}get style(){return this.props.gridOverlayDimensions+U({cursor:this.hoveredIconStore.hoveredIcon?`pointer`:`default`})}get isPaintingFormat(){return this.paintFormatStore.isActive}onPointerMove(e){if(this.env.isMobile())return;let t=this.getInteractiveIconAtEvent(Ep(this.env,e)),n=t?.type?{id:t.type,position:t.position}:void 0;w(n,this.hoveredIconStore.hoveredIcon)||this.hoveredIconStore.setHoveredIcon(n)}onPointerDown(e){e.button>0||this.env.isMobile()||this.onCellClicked(Ep(this.env,e))}onClick(e){e.button>0||!this.env.isMobile()||this.onCellClicked(Ep(this.env,e))}onCellClicked(e){let t=this.cellPopovers.persistentCellPopover,[n,r]=this.getCartesianCoordinates(e),i=this.getInteractiveIconAtEvent(e);if(i&&this.env.model.selection.getBackToDefault(),this.props.onCellClicked(n,r,{expandZone:e.ev.shiftKey,addZone:hp(e.ev)},e),i?.onClick&&i.onClick(i.position,this.env),e.ev.target===this.gridOverlay.el&&this.cellPopovers.isOpen&&w(t,this.cellPopovers.persistentCellPopover)){this.cellPopovers.close();return}}onDoubleClick(e){let t=Ep(this.env,e);if(this.getInteractiveIconAtEvent(t))return;let[n,r]=this.getCartesianCoordinates(t);this.props.onCellDoubleClicked(n,r)}onContextMenu(e){let[t,n]=this.getCartesianCoordinates(Ep(this.env,e));this.props.onCellRightClicked(t,n,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}getInteractiveIconAtEvent(e){let t=ap(this.gridOverlay),n=this.env.model.getters.getGridOffset(),r=e.clientX-t.x+n.x,i=e.clientY-t.y+n.y,[a,o]=this.getCartesianCoordinates(e),s=this.env.model.getters.getActiveSheetId(),c={col:a,row:o,sheetId:s},l=this.env.model.getters.getMerge(c);l&&(c={col:l.left,row:l.top,sheetId:s});let u=this.env.model.getters.getCellIcons(c).find(e=>{let t=this.env.model.getters.getMerge(c)||E(c),n=this.env.model.getters.getRect(t);return Ov(r,i,this.env.model.getters.getCellIconRect(e,n))});return u?.onClick?u:void 0}},pW=class extends t.Component{static template=`o-spreadsheet-GridPopover`;static props={onClosePopover:Function,onMouseWheel:Function,gridRect:Object};static components={Popover:jv};cellPopovers;setup(){this.cellPopovers=D(sP)}get cellPopover(){let e=this.cellPopovers.cellPopover;if(!e.isOpen)return{isOpen:!1};let t=Op(this.env.model.getters.getViewportZoomLevel(),e.anchorRect);return{...e,anchorRect:{...t,x:t.x+this.props.gridRect.x,y:t.y+this.props.gridRect.y}}}},mW=class extends t.Component{static template=`o-spreadsheet-UnhideRowHeaders`;static props={headersGroups:Array,headerRange:Object,offset:{type:Number,optional:!0}};static defaultProps={offset:0};get sheetId(){return this.env.model.getters.getActiveSheetId()}getUnhidePreviousButtonStyle(e){let t=this.env.model.getters.getRect(E({col:0,row:e}));return U({top:t.y+t.height-26-this.props.offset+`px`,"margin-right":`1px`})}getUnhideNextButtonStyle(e){return U({top:this.env.model.getters.getRect(E({col:0,row:e})).y-26-this.props.offset+`px`,"margin-right":`1px`})}unhide(e){this.env.model.dispatch(`UNHIDE_COLUMNS_ROWS`,{sheetId:this.sheetId,dimension:`ROW`,elements:e})}isVisible(e){return e>=this.props.headerRange.start&&e<=this.props.headerRange.end}},hW=class extends t.Component{static template=`o-spreadsheet-UnhideColumnHeaders`;static props={headersGroups:Array,headerRange:Object,offset:{type:Number,optional:!0}};static defaultProps={offset:0};get sheetId(){return this.env.model.getters.getActiveSheetId()}getUnhidePreviousButtonStyle(e){let t=this.env.model.getters.getRect(E({col:e,row:0}));return U({left:t.x+t.width-48-this.props.offset+`px`})}getUnhideNextButtonStyle(e){return U({left:this.env.model.getters.getRect(E({col:e,row:0})).x-48-this.props.offset+`px`})}unhide(e){this.env.model.dispatch(`UNHIDE_COLUMNS_ROWS`,{sheetId:this.sheetId,dimension:`COL`,elements:e})}isVisible(e){return e>=this.props.headerRange.start&&e<=this.props.headerRange.end}},gW=class extends t.Component{static props={onOpenContextMenu:Function};composerFocusStore;PADDING=0;MAX_SIZE_MARGIN=0;MIN_ELEMENT_SIZE=0;lastSelectedElementIndex=null;state=(0,t.useState)({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0,position:`before`});dragNDropGrid=yU(this.env);setup(){this.composerFocusStore=D(xr)}_computeHandleDisplay(e){let t=this._getEvOffset(e),n=this._getElementIndex(t);if(n<0)return;let r=this._getDimensionsInViewport(n);t-r.start<this.PADDING&&n!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=r.start,this.state.activeElement=this._getPreviousVisibleElement(n)):r.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=r.end,this.state.activeElement=n):this.state.resizerIsActive=!1}_computeGrabDisplay(e){if(hp(e.ev)){this.state.waitingForMove=!1;return}let t=this._getElementIndex(this._getEvOffset(e)),n=this._getActiveElements(),r=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();if(n.has(r)&&r<=t&&t<=i){this.state.waitingForMove=!0;return}this.state.waitingForMove=!1}onMouseMove(e){if(this.env.isMobile()||this.env.model.getters.isReadonly()||this.state.isResizing||this.state.isMoving||this.state.isSelecting)return;let t=Ep(this.env,e);this._computeHandleDisplay(t),this._computeGrabDisplay(t)}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(e){let t=Ep(this.env,e);this._fitElementSize(this.state.activeElement),this.state.isResizing=!1,this._computeHandleDisplay(t),this._computeGrabDisplay(t)}onMouseDown(e){this.state.isResizing=!0,this.state.delta=0;let t=Ep(this.env,e),n=this._getClientPosition(t),r=this.state.draggerLinePosition,i=this._getElementSize(this.state.activeElement),a=r-i+this.MIN_ELEMENT_SIZE,o=this._getMaxSize();BN(e=>{this.state.delta=this._getClientPosition(Ep(this.env,e))-n,this.state.draggerLinePosition=r+this.state.delta,this.state.draggerLinePosition<a&&(this.state.draggerLinePosition=a,this.state.delta=this.MIN_ELEMENT_SIZE-i),this.state.draggerLinePosition>o&&(this.state.draggerLinePosition=o,this.state.delta=o-r)},e=>{this.state.isResizing=!1,this.state.delta!==0&&this._updateSize()})}onClick(e){if(!this.env.isMobile()||e.button>0)return;let t=Ep(this.env,e),n=this._getElementIndex(this._getEvOffset(t));this._selectElement(n,!1)}select(e){if(this.env.isMobile()||e.button>0)return;let t=Ep(this.env,e),n=this._getElementIndex(this._getEvOffset(t));if(!(n<0)){if(this.env.model.getters.isReadonly()){this._selectElement(n,!1);return}if(!hp(e)&&this.state.waitingForMove){this.env.model.getters.isGridSelectionActive()?this.startMovement(e):this._selectElement(n,!1);return}this.composerFocusStore.activeComposer.editionMode===`editing`&&this.env.model.selection.getBackToDefault(),this.startSelection(e,n)}}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;let t=Ep(this.env,e),n=this._getDimensionsInViewport(this._getSelectedZoneStart()),r=this._getDimensionsInViewport(this._getSelectedZoneEnd()),i=n.start;this.state.draggerLinePosition=i,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=i,this.state.draggerShadowThickness=r.end-n.start,this.dragNDropGrid.start(t,(e,t)=>{let r=this._getType()===`COL`?e:t;if(r>=0){let e=this._getDimensionsInViewport(r);r<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=r,this.state.position=`before`):this._getSelectedZoneEnd()<r?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=r,this.state.position=`after`):(this.state.draggerLinePosition=n.start,this.state.draggerShadowPosition=n.start,this.state.base=this._getSelectedZoneStart())}},()=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements();let t=Ep(this.env,e);this._computeGrabDisplay(t)})}startSelection(e,t){if(this.env.isMobile())return;this.state.isSelecting=!0,e.shiftKey?this._increaseSelection(t):this._selectElement(t,hp(e)),this.lastSelectedElementIndex=t;let n=Ep(this.env,e);this.dragNDropGrid.start(n,(e,t)=>{let n=this._getType()===`COL`?e:t;n!==this.lastSelectedElementIndex&&n!==-1&&(this._increaseSelection(n),this.lastSelectedElementIndex=n)},()=>{this.env.model.selection.commitSelection(),this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this._computeGrabDisplay(n)})}onContextMenu(e){e.preventDefault();let t=this._getElementIndex(this._getEvOffset(Ep(this.env,e)));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);let n=this._getType();this.props.onOpenContextMenu(n,e.clientX,e.clientY)}},_W=class extends gW{static props={onOpenContextMenu:Function};static template=`o-spreadsheet-ColResizer`;static components={UnhideColumnHeaders:hW};colResizerRef;setup(){super.setup(),this.colResizerRef=(0,t.useRef)(`colResizer`),this.PADDING=15,this.MAX_SIZE_MARGIN=90,this.MIN_ELEMENT_SIZE=5}get sheetId(){return this.env.model.getters.getActiveSheetId()}_getEvOffset(e){return e.offsetX}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().left}_getClientPosition(e){return e.clientX}_getElementIndex(e){return this.env.model.getters.getColIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().left}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().right}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollCol(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getColDimensionsInViewport(this.sheetId,e)}_getElementSize(e){return this.env.model.getters.getColSize(this.sheetId,e)}_getMaxSize(){return this.colResizerRef.el.clientWidth}_updateSize(){let e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),n=this.env.model.getters.getActiveCols();this.env.model.dispatch(`RESIZE_COLUMNS_ROWS`,{dimension:`COL`,sheetId:this.sheetId,elements:n.has(e)?[...n]:[e],size:t})}_moveElements(){let e=[],t=this._getSelectedZoneStart(),n=this._getSelectedZoneEnd();for(let r=t;r<=n;r++)e.push(r);let r=this.env.model.dispatch(`MOVE_COLUMNS_ROWS`,{sheetId:this.sheetId,sheetName:this.env.model.getters.getActiveSheetName(),dimension:`COL`,base:this.state.base,elements:e,position:this.state.position});!r.isSuccessful&&r.reasons.includes(`WillRemoveExistingMerge`)&&this.env.raiseError(am)}_selectElement(e,t){this.env.model.selection.selectColumn(e,t?`newAnchor`:`overrideSelection`)}_increaseSelection(e){this.env.model.selection.selectColumn(e,`updateAnchor`)}_fitElementSize(e){let t=this.env.model.getters.getActiveCols();this.env.model.dispatch(`AUTORESIZE_COLUMNS`,{sheetId:this.sheetId,cols:t.has(e)?[...t]:[e]})}_getType(){return`COL`}_getActiveElements(){return this.env.model.getters.getActiveCols()}_getPreviousVisibleElement(e){let t=this.sheetId,n;for(n=e-1;n>=0&&this.env.model.getters.isColHidden(t,n);n--);return n}unhide(e){this.env.model.dispatch(`UNHIDE_COLUMNS_ROWS`,{sheetId:this.sheetId,elements:e,dimension:`COL`})}get mainUnhideHeadersProps(){let{left:e,right:t}=this.env.model.getters.getActiveMainViewport(),{xSplit:n}=this.env.model.getters.getPaneDivisions(this.sheetId),r=this.env.model.getters.getHiddenColsGroups(this.sheetId),i=r.findIndex(e=>e[0]>=n-1);return{headersGroups:i===-1?[]:r.slice(i),offset:this.env.model.getters.getMainViewportCoordinates().x,headerRange:{start:e,end:t}}}get frozenUnhideHeadersProps(){let{xSplit:e}=this.env.model.getters.getPaneDivisions(this.sheetId),t=this.env.model.getters.getHiddenColsGroups(this.sheetId),n=t.findIndex(t=>t[0]>=e-1);return{headersGroups:n===-1?t:t.slice(0,n+1),headerRange:{start:0,end:e-1}}}get frozenContainerStyle(){return U({width:this.env.model.getters.getMainViewportCoordinates().x+`px`})}get hasFrozenPane(){return this.env.model.getters.getPaneDivisions(this.sheetId).xSplit>0}},vW=class extends gW{static props={onOpenContextMenu:Function};static template=`o-spreadsheet-RowResizer`;static components={UnhideRowHeaders:mW};setup(){super.setup(),this.rowResizerRef=(0,t.useRef)(`rowResizer`),this.PADDING=5,this.MAX_SIZE_MARGIN=60,this.MIN_ELEMENT_SIZE=10}rowResizerRef;get sheetId(){return this.env.model.getters.getActiveSheetId()}_getEvOffset(e){return e.offsetY}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().top}_getClientPosition(e){return e.clientY}_getElementIndex(e){return this.env.model.getters.getRowIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().top}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().bottom}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollRow(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getRowDimensionsInViewport(this.sheetId,e)}_getElementSize(e){return this.env.model.getters.getRowSize(this.sheetId,e)}_getMaxSize(){return this.rowResizerRef.el.clientHeight}_updateSize(){let e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),n=this.env.model.getters.getActiveRows();this.env.model.dispatch(`RESIZE_COLUMNS_ROWS`,{dimension:`ROW`,sheetId:this.sheetId,elements:n.has(e)?[...n]:[e],size:t})}_moveElements(){let e=[],t=this._getSelectedZoneStart(),n=this._getSelectedZoneEnd();for(let r=t;r<=n;r++)e.push(r);let r=this.env.model.dispatch(`MOVE_COLUMNS_ROWS`,{sheetId:this.sheetId,sheetName:this.env.model.getters.getActiveSheetName(),dimension:`ROW`,base:this.state.base,elements:e,position:this.state.position});r.isSuccessful||(r.reasons.includes(`WillRemoveExistingMerge`)?this.env.raiseError(am):r.reasons.includes(`CannotMoveTableHeader`)&&this.env.raiseError(om))}_selectElement(e,t){this.env.model.selection.selectRow(e,t?`newAnchor`:`overrideSelection`)}_increaseSelection(e){this.env.model.selection.selectRow(e,`updateAnchor`)}_fitElementSize(e){let t=this.env.model.getters.getActiveRows();this.env.model.dispatch(`AUTORESIZE_ROWS`,{sheetId:this.sheetId,rows:t.has(e)?[...t]:[e]})}_getType(){return`ROW`}_getActiveElements(){return this.env.model.getters.getActiveRows()}_getPreviousVisibleElement(e){let t=this.sheetId,n;for(n=e-1;n>=0&&this.env.model.getters.isRowHidden(t,n);n--);return n}get mainUnhideHeadersProps(){let{top:e,bottom:t}=this.env.model.getters.getActiveMainViewport(),{ySplit:n}=this.env.model.getters.getPaneDivisions(this.sheetId),r=this.env.model.getters.getHiddenRowsGroups(this.sheetId),i=r.findIndex(e=>e[0]>=n-1);return{headersGroups:i===-1?[]:r.slice(i),offset:this.env.model.getters.getMainViewportCoordinates().y,headerRange:{start:e,end:t}}}get frozenUnhideHeadersProps(){let{ySplit:e}=this.env.model.getters.getPaneDivisions(this.sheetId),t=this.env.model.getters.getHiddenRowsGroups(this.sheetId),n=t.findIndex(t=>t[0]>=e-1);return{headersGroups:n===-1?t:t.slice(0,n+1),headerRange:{start:0,end:e-1}}}get frozenContainerStyle(){return U({height:this.env.model.getters.getMainViewportCoordinates().y+`px`})}get hasFrozenPane(){return this.env.model.getters.getPaneDivisions(this.sheetId).ySplit>0}},yW=class extends t.Component{static props={onOpenContextMenu:Function};static template=`o-spreadsheet-HeadersOverlay`;static components={ColResizer:_W,RowResizer:vW};selectAll(){this.env.model.selection.selectAll()}},bW=class extends yr{fingerprints;hoveredTables;hoveredIcon;lastRenderBoxes=new Map;preventNewAnimationsInNextFrame=!1;zonesWithPreventedAnimationsInNextFrame=[];animations=new Map;constructor(e){super(e),this.getters=e(mr).getters,this.fingerprints=e(TV),this.hoveredTables=e(lW),this.hoveredIcon=e(uW)}handle(e){switch(e.type){case`START`:case`ACTIVATE_SHEET`:case`ADD_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:this.animations.clear(),this.preventNewAnimationsInNextFrame=!0;break;case`RESIZE_COLUMNS_ROWS`:this.preventNewAnimationsInNextFrame=!0;break;case`REDO`:this.zonesWithPreventedAnimationsInNextFrame=[];break;case`UNDO`:for(let t of e.commands)if(t.type===`ADD_COLUMNS_ROWS`||t.type===`REMOVE_COLUMNS_ROWS`||t.type===`RESIZE_COLUMNS_ROWS`){this.animations.clear(),this.preventNewAnimationsInNextFrame=!0;break}break;case`PASTE`:this.zonesWithPreventedAnimationsInNextFrame.push(...this.getters.getSelectedZones());break;case`UPDATE_CELL`:let t=this.getters.getCommandZones(e);this.zonesWithPreventedAnimationsInNextFrame.push(...t);break}}finalize(){this.zonesWithPreventedAnimationsInNextFrame=nn(this.zonesWithPreventedAnimationsInNextFrame)}get renderingLayers(){return[`Background`,`Headers`]}drawLayer(e,t,n){switch(t){case`Background`:this.drawGlobalBackground(e);let t=this.lastRenderBoxes;this.lastRenderBoxes=new Map;for(let{zone:r,rect:i}of this.getters.getAllActiveViewportsZonesAndRect()){let{ctx:a}=e;a.save(),a.beginPath(),a.rect(i.x,i.y,i.width,i.height),a.clip();let o=this.getGridBoxes(r),s=this.getBoxesWithAnimations(o,t,n);this.drawBackground(e,s),this.drawOverflowingCellBackground(e,s),this.drawCellBackground(e,s),this.drawBorders(e,s),this.drawTexts(e,s),this.drawIcon(e,s),a.restore()}this.drawFrozenPanes(e),this.preventNewAnimationsInNextFrame=!1,this.zonesWithPreventedAnimationsInNextFrame=[];break;case`Headers`:this.getters.isDashboard()||(this.drawHeaders(e),this.drawFrozenPanesHeaders(e));break}}drawGlobalBackground(e){let{ctx:t}=e,{width:n,height:r}=this.getters.getSheetViewDimensionWithHeaders();t.fillStyle=`#ffffff`,t.fillRect(0,0,n+y,r+y)}drawBackground(e,t){let{ctx:n,thinLineWidth:r}=e,i=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId()),a=i?.1*r:0;if(i)for(let e of t)e.style.hideGridLines||(n.strokeStyle=`#E2E3E3`,n.lineWidth=r,n.strokeRect(e.x+a,e.y+a,e.width-2*a,e.height-2*a))}drawCellBackground(e,t){let{ctx:n}=e;for(let e of t){let t=e.style;if(t.fillColor&&t.fillColor!==`#ffffff`&&(n.fillStyle=t.fillColor||`#ffffff`,n.fillRect(e.x-y,e.y-y,e.width+y*2,e.height+y*2)),e.dataBarFill){n.fillStyle=e.dataBarFill.color;let t=e.dataBarFill.percentage,r=e.width*(t/100);n.fillRect(e.x,e.y,r,e.height)}if(e.overlayColor&&(n.fillStyle=Vr(t.fillColor||`#ffffff`,e.overlayColor),n.fillRect(e.x-y,e.y-y,e.width+y*2,e.height+y*2)),e?.chip){n.save(),n.beginPath(),n.rect(e.x,e.y,e.width,e.height),n.clip();let t=e.chip;n.fillStyle=e.overlayColor?Vr(t.color,e.overlayColor):t.color,n.beginPath(),n.roundRect(t.x,t.y,t.width,t.height,10),n.fill(),n.restore()}e.isError&&(n.fillStyle=`red`,n.beginPath(),n.moveTo(e.x+e.width-5,e.y),n.lineTo(e.x+e.width,e.y),n.lineTo(e.x+e.width,e.y+5),n.fill())}}drawOverflowingCellBackground(e,t){let{ctx:n,thinLineWidth:r}=e;for(let e of t)if(e.content&&e.isOverflow){let t=e.content.align||`left`,i,a,o=e.y+r/2,s=e.height-r,c=Math.min(e.clipRect?.width||1/0,e.content.width);t===`left`?(i=e.x+r/2,a=c-2*r):t===`right`?(i=e.x+e.width-r/2,a=-c+2*r):(i=(e.clipRect?.x||e.x+e.width/2-e.content.width/2)+r/2,a=c-2*r),n.fillStyle=`#ffffff`,n.fillRect(i,o,a,s)}}drawBorders(e,t){let{ctx:n}=e;for(let e of t){let t=e.border;if(t){let{x:n,y:i,width:a,height:o}=e;t.left&&r(t.left,n,i,n,i+o),t.top&&r(t.top,n,i,n+a,i),t.right&&r(t.right,n+a,i,n+a,i+o),t.bottom&&r(t.bottom,n,i+o,n+a,i+o)}}function r({color:e,style:t,opacity:r},i,a,o,s){switch(n.globalAlpha=r??1,n.strokeStyle=e,t){case`medium`:n.lineWidth=2,i+=a===s?-.5:.5,o+=a===s?1.5:.5,a+=i===o?-.5:.5,s+=i===o?1.5:.5;break;case`thick`:n.lineWidth=3,a===s&&(i--,o++),i===o&&(a--,s++);break;case`dashed`:n.lineWidth=1,n.setLineDash([1,3]);break;case`dotted`:n.lineWidth=1,a===s&&(i+=.5,o+=.5),i===o&&(a+=.5,s+=.5),n.setLineDash([1,1]);break;default:n.lineWidth=1;break}n.beginPath(),n.moveTo(i,a),n.lineTo(o,s),n.stroke(),n.lineWidth=1,n.setLineDash([]),n.globalAlpha=1}}drawTexts(e,t){let{ctx:n}=e;n.textBaseline=`top`;let r;for(let e of t)if(e.content){n.globalAlpha=e.textOpacity??1;let t=e.content.align||`left`,i=e.chip?0:e.style.rotation,a={...e.style,align:t,rotation:i},o=Rl(a);if(o!==r&&(r=o,n.font=o),n.fillStyle=a.textColor||`#000`,n.textAlign=t,e.clipRect){n.save(),n.beginPath();let{x:t,y:r,width:i,height:a}=e.clipRect;n.rect(t,r,i,a),n.clip()}let s=e.content.x,c=e.content.y;a.rotation&&(n.save(),n.rotate(a.rotation),{x:s,y:c}=Yl(e.content,a));for(let t of e.content.textLines)ql(n,t,{x:s,y:c},a.underline,a.strikethrough),c+=4+e.content.fontSizePx;a.rotation&&n.restore(),e.clipRect&&n.restore(),n.globalAlpha=1}}drawIcon(e,t){let{ctx:n}=e;for(let e of t)for(let t of Object.values(e.icons)){if(!t)continue;let r=w({id:t.type,position:t.position},this.hoveredIcon.hoveredIcon)&&t.hoverSvg||t.svg;if(!r)continue;n.save(),n.globalAlpha=t.opacity??1,n.beginPath();let i=t.clipRect||e;n.rect(i.x,i.y,i.width,i.height),n.clip();let a=t.size,{x:o,y:s}=this.getters.getCellIconRect(t,e);n.translate(o,s),n.scale(a/r.width,a/r.height);for(let e of r.paths)n.fillStyle=e.fillColor,n.fill(RO(e.path));n.restore()}}drawHeaders(e){let{ctx:t,thinLineWidth:n}=e,r=this.getters.getSheetViewVisibleCols(),i=r[0],a=this.getters.getSheetViewVisibleRows(),o=a[0],{width:s,height:c}=this.getters.getSheetViewDimensionWithHeaders(),l=this.getters.getSelectedZones(),u=Xn(l),d=Qn(l),f=this.getters.getActiveSheetId(),p=this.getters.getNumberCols(f),m=this.getters.getNumberRows(f),h=this.getters.getActiveCols(),g=this.getters.getActiveRows();t.font=`400 11px ${Te}`,t.textAlign=`center`,t.textBaseline=`middle`,t.lineWidth=n,t.strokeStyle=`#333`;for(let e of r){let n={left:e,right:e,top:0,bottom:m-1},{x:r,width:i}=this.getters.getVisibleRect(n),a=h.has(e),o=u.has(e);a?t.fillStyle=re:o?t.fillStyle=ne:t.fillStyle=te,t.fillRect(r,0,i,26)}for(let e of a){let n={top:e,bottom:e,left:0,right:p-1},{y:r,height:i}=this.getters.getVisibleRect(n),a=g.has(e),o=d.has(e);a?t.fillStyle=re:o?t.fillStyle=ne:t.fillStyle=te,t.fillRect(0,r,48,i)}t.beginPath(),t.moveTo(48,0),t.lineTo(48,c),t.moveTo(0,26),t.lineTo(s,26),t.strokeStyle=`#C0C0C0`,t.stroke();for(let e of r){let n=Kt(e);t.fillStyle=h.has(e)?`#fff`:ie;let r={left:e,right:e,top:o,bottom:o},{x:i,width:a}=this.getters.getRect(r),{x:s,width:c}=this.getters.getVisibleRect(r);t.save(),t.beginPath(),t.rect(s,0,c,26),t.clip(),t.fillText(n,i+a/2,26/2),t.restore(),t.beginPath(),t.moveTo(i+a,0),t.lineTo(i+a,26),t.stroke()}for(let e of a){t.fillStyle=g.has(e)?`#fff`:ie;let n={top:e,bottom:e,left:i,right:i},{y:r,height:a}=this.getters.getRect(n),{y:o,height:s}=this.getters.getVisibleRect(n);t.save(),t.beginPath(),t.rect(0,o,48,s),t.clip(),t.fillText(String(e+1),48/2,r+a/2),t.restore(),t.beginPath(),t.moveTo(0,r+a),t.lineTo(48,r+a),t.stroke()}}drawFrozenPanesHeaders(e){let{ctx:t,thinLineWidth:n}=e,{x:r,y:i}=this.getters.getMainViewportCoordinates(),a=this.getters.isDashboard()?0:48,o=this.getters.isDashboard()?0:26;t.lineWidth=6*n,t.strokeStyle=`#BCBCBC`,t.beginPath(),r&&(t.moveTo(a+r,0),t.lineTo(a+r,o)),i&&(t.moveTo(0,o+i),t.lineTo(a,o+i)),t.stroke()}drawFrozenPanes(e){let{ctx:t,thinLineWidth:n}=e,{x:r,y:i}=this.getters.getMainViewportCoordinates(),a=this.getters.getSheetViewVisibleCols(),o=a[0],s=a[a.length-1],c=this.getters.getSheetViewVisibleRows(),l={left:o,right:s,top:c[0],bottom:c[c.length-1]},u=this.getters.getVisibleRect(l),d=this.getters.isDashboard()?0:48,f=this.getters.isDashboard()?0:26;t.lineWidth=6*n,t.strokeStyle=`#DADFE8`,t.beginPath(),r&&(t.moveTo(d+r,f),t.lineTo(d+r,u.height+f)),i&&(t.moveTo(d,f+i),t.lineTo(u.width+d,f+i)),t.stroke()}findNextEmptyCol(e,t,n){let r=this.getters.getActiveSheetId(),i=e;for(;i<t;){let e={sheetId:r,col:i+1,row:n},t=this.getters.getEvaluatedCell(e),a=this.getters.getCellComputedBorder(e),o=this.getters.doesCellHaveGridIcon(e);if(t.type!==`empty`||this.getters.isInMerge(e)||a?.left||o)return i;i++}return i}findPreviousEmptyCol(e,t,n){let r=this.getters.getActiveSheetId(),i=e;for(;i>t;){let e={sheetId:r,col:i-1,row:n},t=this.getters.getEvaluatedCell(e),a=this.getters.getCellComputedBorder(e),o=this.getters.doesCellHaveGridIcon(e);if(t.type!==`empty`||this.getters.isInMerge(e)||a?.right||o)return i;i--}return i}computeCellAlignment(e,t){if(this.getters.getCell(e)?.isFormula&&this.getters.shouldShowFormulas())return`left`;let{align:n}=this.getters.getCellStyle(e),r=this.getters.getEvaluatedCell(e);return!n&&ks(r.value,r.format)?`left`:t&&r.type===`number`?n===`center`?n:`left`:n||r.defaultAlign}createZoneBox(e,t,n){let{left:r,right:i}=n,a=t.left,o=t.top,s={sheetId:e,col:a,row:o},c=this.getters.getEvaluatedCell(s),l=this.getters.shouldShowFormulas(),{x:u,y:d,width:f,height:p}=this.getters.getRect(t),m=this.getters.getDataValidationChipStyle(s),h=this.getters.getCellComputedStyle(s);if(this.fingerprints.isEnabled){let e=this.fingerprints.colors.get(s);h={...h,fillColor:e}}m?.textColor&&(h={...h,textColor:m.textColor});let g=this.fingerprints.isEnabled?void 0:this.getters.getConditionalDataBar(s),_=this.getters.getCellIcons(s),v={left:_.find(e=>e?.horizontalAlign===`left`),right:_.find(e=>e?.horizontalAlign===`right`),center:_.find(e=>e?.horizontalAlign===`center`)},y={id:yn(t),x:u,y:d,width:f,height:p,border:this.getters.getCellComputedBorder(s)||void 0,style:h,dataBarFill:g,overlayColor:this.hoveredTables.overlayColors.get(s),isError:c.type===`error`&&!!c.message||this.getters.isDataValidationInvalid(s),icons:v,disabledAnimation:this.zonesWithPreventedAnimationsInNextFrame.some(e=>jn(t,e)||On(t,e))},ee=zl(y.style);if(c.type===`empty`||y.icons.center)return y;let te=h.wrapping||`overflow`,ne=te===`wrap`&&!l,re=f-8,ie=h.align?0:re,ae=this.getters.getCellMultiLineText(s,{maxWidth:re,formatWidth:ie,wrapText:ne}),oe={...h,align:`left`,rotation:0},se=Math.max(...ae.map(e=>this.getters.getTextWidth(e,oe)))+4,ce=this.getters.getMultilineTextSize(ae,h),le=m?5:0,ue=(y.icons.left?y.icons.left.size+y.icons.left.margin:0)+le,de=(y.icons.right?y.icons.right.size+y.icons.right.margin:0)+le,fe=ue+ce.width+de+4,pe=this.computeCellAlignment(s,fe>f),me=ae.length,he=Math.round(this.getters.computeTextYCoordinate(y,ee,h.verticalAlign,me)),ge=y.x;pe===`left`?ge+=4+ue:pe===`right`?ge+=y.width-4-de:ge+=y.width/2,ge=Math.round(ge);let _e=El(ee,me);if(y.content={textLines:ae,width:te===`overflow`?se:f,textHeight:_e,textWidth:se,align:pe,x:ge,y:he,fontSizePx:ee},m?.fillColor){let e=ue;y.chip={color:m.fillColor,width:y.width-e-5,height:_e+2,x:y.x+e,y:he-2}}let ve=fe>f||ce.height>p;if(y.icons.left||y.icons.right||y.chip)y.clipRect={x:y.x+ue,y:y.y,width:Math.max(0,f-ue-de),height:p};else if(ve&&te===`overflow`){let e,n;switch(this.getters.isInMerge(s)?(e=this.getters.getMerge(s).right,n=a):(e=y.border?.right?t.right:this.findNextEmptyCol(a,i,o),n=y.border?.left?t.left:this.findPreviousEmptyCol(a,r,o),y.isOverflow=!0),pe){case`left`:{let n=E({col:e,row:o}),{x:r,y:i,width:a,height:s}=this.getters.getVisibleRect(wn(t,n));(a<fe||ee>s||ae.length>1)&&(y.clipRect={x:r,y:i,width:a,height:s});break}case`right`:{let e=E({col:n,row:o}),{x:r,y:i,width:a,height:s}=this.getters.getVisibleRect(wn(t,e));(a<fe||ee>s||ae.length>1)&&(y.clipRect={x:r,y:i,width:a,height:s});break}case`center`:{let r={...t,left:n,right:e},{x:i,y:a,height:o,width:s}=this.getters.getVisibleRect(r),c=fe/2,l=y.x+y.width/2;if(i+s<l+c||i>l-c||ee>o||ae.length>1){let e=i>l-c?i:l-c;y.clipRect={x:e,y:a,width:i+s-e,height:o}}break}}}else(te===`clip`||te===`wrap`||ae.length>1)&&(y.clipRect={x:y.x,y:y.y,width:f,height:p});return y}getGridBoxes(e){let t=[],n=this.getters.getSheetViewVisibleCols().filter(t=>t>=e.left&&t<=e.right),r=n[0],i=n[n.length-1],a=this.getters.getSheetViewVisibleRows().filter(t=>t>=e.top&&t<=e.bottom),o={left:r,right:i,top:a[0],bottom:a[a.length-1]},s=this.getters.getActiveSheetId();for(let e of a)for(let r of n){let n={sheetId:s,col:r,row:e};this.getters.isInMerge(n)||t.push(this.createZoneBox(s,E(n),o))}for(let e of this.getters.getMerges(s))if(!this.getters.isMergeHidden(s,e)&&On(e,o)){let n=this.createZoneBox(s,e,o),r=this.getters.getCellComputedBorder({sheetId:s,col:e.right,row:e.bottom});n.border={...n.border,bottom:r?r.bottom:void 0,right:r?r.right:void 0},n.isMerge=!0,t.push(n)}return t}getBoxesWithAnimations(e,t,n){return this.updateAnimationsProgress(n),this.addNewAnimations(e,t,n),this.animations.size>0?(this.renderer.startAnimation(`grid_renderer_animation`),this.updateBoxesWithAnimations(e)):(this.renderer.stopAnimation(`grid_renderer_animation`),e)}updateBoxesWithAnimations(e){let t=[];for(let n of e){let e=this.animations.get(n.id);if(!e){t.push(n);continue}let r=b(n);t.push(r);for(let i of e.animationTypes){let a=fv.get(i).updateAnimation(e.progress,r,e.oldBox,n);a&&t.push(...a.newBoxes)}}return t}updateAnimationsProgress(e){if(e!==void 0)for(let t of this.animations.keys()){let n=this.animations.get(t);if(n.startTime===void 0){n.startTime=e;continue}let r=e-n.startTime,i=Math.min(1,r/200);i>=1&&this.animations.delete(t),n.progress=i}}addNewAnimations(e,t,n){for(let r of e){this.lastRenderBoxes.set(r.id,r);let e=t.get(r.id);if(this.preventNewAnimationsInNextFrame||!e||r.disabledAnimation)continue;let i=[];for(let t of fv.getAll())t.hasAnimation(e,r)&&i.push(t.id);let a=i.length>0?{animationTypes:i,oldBox:e,progress:0,startTime:n}:void 0;a&&this.animations.set(r.id,a)}}};function xW(e,n,r){let i=(0,t.useRef)(e);(0,t.useEffect)(o);let a=D(vr);D(bW);function o(){let e=i.el,t=window.devicePixelRatio||1,o=e.getContext(`2d`,{alpha:!1}),s=Math.max(n.getters.getViewportZoomLevel(),1),c={ctx:o,dpr:t,thinLineWidth:.4*t},{width:l,height:u}=r();l=s*l,u=s*u,e.style.width=`${l}px`,e.style.height=`${u}px`,e.width=l*t,e.height=u*t,e.setAttribute(`style`,`width:${l}px;height:${u}px;zoom:${1/s};`),!(l===0||u===0)&&(o.translate(-.5,-.5),o.scale(t*s,t*s),a.draw(c))}}let SW=.95;function CW(e,{updateScroll:n,canMoveUp:r,canMoveDown:i,getZoom:a,setZoom:o}){let s=0,c=0,l=0,u=0,d=!1,f=0,p=null,m=!1,h=[],g=-1;ML(e,`touchstart`,_,{capture:!1}),ML(e,`touchmove`,v,{capture:!1}),ML(e,`touchend`,y,{capture:!1}),ML(e,`pointerdown`,te,{passive:!1,capture:!1}),ML(e,`pointermove`,re,{passive:!1,capture:!1}),(0,t.useExternalListener)(window,`pointerup`,ne,{passive:!1,capture:!0}),ML(e,`pointercancel`,ne,{passive:!1});function _(e){d=!0,{clientX:s,clientY:c}=e.touches[0],l=0,u=0}function v(e){if(!d||m){e.cancelable&&e.preventDefault(),e.stopPropagation();return}p&&=(clearTimeout(p),null);let t=Date.now(),{clientX:a,clientY:o}=e.touches[0],h=s-a,g=c-o,_=t-f;_&&(l=h/_,u=g/_,s=a,c=o,f=t,(g<0&&r()||g>0&&i())&&(e.cancelable&&e.preventDefault(),e.stopPropagation()),p=setTimeout(()=>{l=0,u=0},100),n(h*1,g*1))}function y(e){d=!1,s=c=0,p&&clearTimeout(p),l*=1.2,u*=1.2,requestAnimationFrame(ee)}function ee(){if(Math.abs(l)<.05&&(l=0),Math.abs(u)<.05&&(u=0),!l&&!u)return;let e=Date.now(),t=Math.abs(e-f),r=l*t,i=u*t;n(r*1,i*1),f=e,l*=SW,u*=SW,requestAnimationFrame(ee)}function te(e){e.button===0&&h.findIndex(t=>t.pointerId===e.pointerId)===-1&&(h.push(e),h.length<2?g=-1/0:h.length===2&&(g=wW(h[0],h[1])))}function ne(e){let t=h.findIndex(t=>t.pointerId===e.pointerId);t!==-1&&(h.splice(t,1),h.length<2&&(g=-1/0,m=!1))}function re(e){let t=h.findIndex(t=>t.pointerId===e.pointerId);if(t!==-1&&(h[t]=e,h.length===2)){let e=wW(h[0],h[1]);if(!m&&Math.abs(e-g)>=30&&(m=!0,g=e),m){let t=(e/g)**.5;o(Math.round(a()*t*1e3)/1e3),g=e}}}}function wW(e,t){let n=e.clientX-t.clientX,r=e.clientY-t.clientY;return Math.sqrt(n*n+r*r)}function TW(e){function t(e,t){return e*(t===0?1:23)}return n=>{e(t(n.shiftKey&&!mp()?n.deltaY:n.deltaX,n.deltaMode),t(n.shiftKey&&!mp()?n.deltaX:n.deltaY,n.deltaMode))}}var EW=class extends t.Component{static template=`o-spreadsheet-Border`;static props={zone:Object,orientation:String,isMoving:Boolean,onMoveHighlight:Function};get style(){let e=[`n`,`w`,`e`].includes(this.props.orientation),t=[`n`,`w`,`s`].includes(this.props.orientation),n=[`n`,`s`].includes(this.props.orientation),r=[`w`,`e`].includes(this.props.orientation),i=this.props.zone,a=this.env.model.getters.getVisibleRect(i),o=a.x,s=a.x+a.width-4,c=a.y,l=a.y+a.height-4,u=t?o:s,d=e?c:l,f=n?s-o:4,p=r?l-c:4;return U({left:`${u}px`,top:`${d}px`,width:`${f}px`,height:`${p}px`})}onMouseDown(e){this.props.onMoveHighlight(e)}},DW=class extends t.Component{static template=`o-spreadsheet-Corner`;static props={zone:Object,color:String,orientation:String,isResizing:Boolean,onResizeHighlight:Function};dirX;dirY;setup(){let{dirX:e,dirY:t}=OW(this.props.orientation);this.dirX=e,this.dirY=t}get handlerStyle(){let e=this.props.zone,t=this.env.model.getters.getVisibleRect({left:this.dirX===1?e.right:e.left,right:this.dirX===-1?e.left:e.right,top:this.dirY===1?e.bottom:e.top,bottom:this.dirY===-1?e.top:e.bottom});if(t.width*t.height===0)return`display: none !important;`;let n=t.x+t.width/2+this.dirX*t.width/2,r=t.y+t.height/2+this.dirY*t.height/2,i=this.getHandlerEdgeLength(),a={left:`${n-i/2}px`,top:`${r-i/2}px`,height:`${i}px`,width:`${i}px`};return this.env.isMobile()&&(a[`border-radius`]=`${i/2}px`),U(a)}getHandlerEdgeLength(){return this.env.isMobile()?40:8}get buttonLook(){let e={"background-color":this.props.color,cursor:`${this.props.orientation}-resize`};return this.env.isMobile()&&(e[`border-radius`]=`${8/2}px`),U(e)}onMouseDown(e){this.props.onResizeHighlight(e,this.dirX,this.dirY)}};function OW(e){return{dirX:e.includes(`w`)?-1:+!!e.includes(`e`),dirY:e.includes(`n`)?-1:+!!e.includes(`s`)}}var kW=class extends t.Component{static template=`o-spreadsheet-Highlight`;static props={range:Object,color:String};static components={Corner:DW,Border:EW};highlightState=(0,t.useState)({shiftingMode:`none`});dragNDropGrid=yU(this.env);get cornerOrientations(){if(!this.env.isMobile())return[`nw`,`ne`,`sw`,`se`];let e=this.props.range.unboundedZone;return e.bottom===void 0?[`w`,`e`]:e.right===void 0?[`n`,`s`]:[`nw`,`se`]}onResizeHighlight(e,t,n){let r=this.env.model.getters.getActiveSheetId(),i=Ep(this.env,e);this.highlightState.shiftingMode=`isResizing`;let a=this.props.range.zone,o=t===1?a.left:a.right,s=n===1?a.top:a.bottom,c=t===1?a.right:a.left,l=n===1?a.bottom:a.top,u=a,d=`all`;this.env.isMobile()&&(d=t===0?`vertical`:n===0?`horizontal`:`all`),this.env.model.dispatch(`START_CHANGE_HIGHLIGHT`,{zone:u}),this.dragNDropGrid.start(i,(e,t)=>{if(c!==e||l!==t){let{left:n,right:i,top:a,bottom:f}=u;d!==`horizontal`&&(l=l=x(t===-1?l:t,0,this.env.model.getters.getNumberRows(r)-1),a=Math.min(s,l),f=Math.max(s,l)),d!==`vertical`&&(c=x(e===-1?c:e,0,this.env.model.getters.getNumberCols(r)-1),n=Math.min(o,c),i=Math.max(o,c));let p={left:n,right:i,top:a,bottom:f};Dn(p,u)||(this.env.model.selection.selectZone({cell:{col:p.left,row:p.top},zone:p},{unbounded:!0}),u=p)}},()=>{this.highlightState.shiftingMode=`none`},d)}onMoveHighlight(e){this.highlightState.shiftingMode=`isMoving`;let t=this.props.range.zone,n=rp(this.env.model.getters.getViewportZoomLevel()),r=Ep(this.env,e,n),i=this.env.model.getters.getActiveSheetId(),a=this.env.model.getters.getColIndex(r.clientX-n.x),o=this.env.model.getters.getRowIndex(r.clientY-n.y),s=-t.left,c=this.env.model.getters.getNumberCols(i)-t.right-1,l=-t.top,u=this.env.model.getters.getNumberRows(i)-t.bottom-1,d=t;this.env.model.dispatch(`START_CHANGE_HIGHLIGHT`,{zone:d});let f=a,p=o;this.dragNDropGrid.start(r,(e,n)=>{if(f!==e||p!==n){f=e===-1?f:e,p=n===-1?p:n;let r=x(f-a,s,c),i=x(p-o,l,u),m={left:t.left+r,top:t.top+i,right:t.right+r,bottom:t.bottom+i};Dn(m,d)||(this.env.model.selection.selectZone({cell:{col:m.left,row:m.top},zone:m},{unbounded:!0}),d=m)}},()=>{this.highlightState.shiftingMode=`none`})}},AW=class{direction;el;constructor(e,t){this.el=e,this.direction=t}get scroll(){return this.direction===`horizontal`?this.el.scrollLeft:this.el.scrollTop}set scroll(e){this.direction===`horizontal`?this.el.scrollLeft=e:this.el.scrollTop=e}},jW=class extends t.Component{static props={width:{type:Number,optional:!0},height:{type:Number,optional:!0},direction:String,position:Object,offset:Number,onScroll:Function};static template=t.xml`
|
|
91
91
|
<div
|
|
92
92
|
t-attf-class="o-scrollbar {{props.direction}}"
|
|
@@ -118,7 +118,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
118
118
|
`,`;`,`,`,` `,`.`])if(e.includes(t))return t}splitIntoColumns({separator:e,addNewColumns:t}){let n=this.getters.getSelectedZone(),r=this.getters.getActiveSheetId(),i=this.getSplittedCols(n,e);t&&this.addColsToAvoidCollisions(n,i),this.removeMergesInSplitZone(n,i),this.addColumnsToNotOverflowSheet(n,i);for(let e=0;e<i.length;e++){let t=n.top+e,a=i[e],o=n.left,s=this.getters.getCell({sheetId:r,col:o,row:t});if(!(a.length===1&&!s?.isFormula&&a[0]===s?.content))for(let[e,n]of a.entries())this.dispatch(`UPDATE_CELL`,{sheetId:r,col:o+e,row:t,content:DS(n,this.getters.getLocale()),format:``,style:s?.style||null})}}getSplittedCols(e,t){if(!t)throw Error(`Separator cannot be empty`);let n=this.getters.getActiveSheetId(),r=[];for(let i of S(e.top,e.bottom+1)){let a=this.getters.getEvaluatedCell({sheetId:n,col:e.left,row:i}).formattedValue;r.push(this.splitAndRemoveTrailingEmpty(a,t))}return r}splitAndRemoveTrailingEmpty(e,t){let n=e.split(t);for(;n.length>1&&n[n.length-1]===``;)n.pop();return n}willSplittedColsOverwriteContent(e,t){let n=this.getters.getActiveSheetId();for(let r of S(e.top,e.bottom+1)){let i=t[r-e.top];for(let t=1;t<i.length;t++){let i=this.getters.getCell({sheetId:n,col:e.left+t,row:r});if(i?.isFormula||i?.content)return!0}}return!1}removeMergesInSplitZone(e,t){let n=this.getters.getActiveSheetId(),r=Math.max(...t.map(e=>e.length)),i={...e,right:e.left+r-1},a=this.getters.getMergesInZone(n,i);this.dispatch(`REMOVE_MERGE`,{sheetId:n,target:a})}addColsToAvoidCollisions(e,t){let n=this.getters.getActiveSheetId(),r=0;for(let i of S(e.top,e.bottom+1)){let a={sheetId:n,col:e.left,row:i},o=t[i-e.top],s=this.getColsToAddToAvoidCollision(a,o);r=Math.max(r,s)}r&&this.dispatch(`ADD_COLUMNS_ROWS`,{dimension:`COL`,base:e.left,sheetId:n,sheetName:this.getters.getSheetName(n),quantity:r,position:`after`})}getColsToAddToAvoidCollision(e,t){let n=t.length;for(let t=1;t<n;t++){let r=e.col+t,i=this.getters.getCell({...e,col:r});if(i?.isFormula||i?.content)return n-t}return 0}addColumnsToNotOverflowSheet(e,t){let n=this.getters.getActiveSheetId(),r=Math.max(...t.map(e=>e.length-1)),i=this.getters.getNumberCols(n)-1;e.left+r>i&&this.dispatch(`ADD_COLUMNS_ROWS`,{dimension:`COL`,base:i,sheetId:n,sheetName:this.getters.getSheetName(n),quantity:e.left+r-i,position:`after`})}checkSingleColSelected(){return this.getters.isSingleColSelected()?`Success`:`MoreThanOneColumnSelected`}checkNonEmptySelector(e){return e.separator===``?`EmptySplitSeparator`:`Success`}checkNotOverwritingContent(e){if(e.addNewColumns||e.force)return`Success`;let t=this.getters.getSelectedZones()[0],n=this.getSplittedCols(t,e.separator);return this.willSplittedColsOverwriteContent(t,n)?`SplitWillOverwriteContent`:`Success`}checkSeparatorInSelection({separator:e}){let t=this.getters.getSelectedCells();for(let n of t)if(n.formattedValue.includes(e))return`Success`;return`NoSplitSeparatorInSelection`}},Nq=class extends lK{handle(e){Us.has(e.type)&&this.dispatch(`EVALUATE_CELLS`,{cellIds:this.getters.getCellsWithTrackedFormula(`SUBTOTAL`)})}},Pq=class extends lK{handle(e){switch(e.type){case`AUTOFILL_TABLE_COLUMN`:let t=this.getters.getCoreTable(e),n=this.getters.getCell(e);if(!t?.config.automaticAutofill||t.type===`dynamic`||!n?.isFormula)return;let{col:r,row:i}=e,a=KB(t.range.zone,t.config);if(a&&An(r,i,a)){let t=e.autofillRowStart??a.top,n=e.autofillRowEnd??a.bottom,r={...a,top:t,bottom:n};this.autofillTableZone(e,r)}break}}autofillTableZone(e,t){if(t.top===t.bottom)return;let{col:n,row:r,sheetId:i}=e;for(let e=t.top;e<=t.bottom;e++)if(e!==r&&this.getters.getEvaluatedCell({col:n,row:e,sheetId:i}).type!==`empty`)return;let a={zone:this.getters.getSelectedZone(),cell:this.getters.getActivePosition()};this.selection.selectCell(n,r),this.dispatch(`AUTOFILL_SELECT`,{col:n,row:t.bottom}),this.dispatch(`AUTOFILL`),this.selection.selectCell(n,r),this.dispatch(`AUTOFILL_SELECT`,{col:n,row:t.top}),this.dispatch(`AUTOFILL`),this.selection.selectZone(a)}},Fq=class extends lK{allowDispatch(e){switch(e.type){case`RESIZE_TABLE`:let t=this.getters.getCoreTableMatchingTopLeft(e.sheetId,e.zone);if(!t)return`TableNotFound`;let n=t.range.zone,r=this.getters.getRangeFromRangeData(e.newTableRange).zone;return r.top!==n.top||r.left!==n.left?`InvalidTableResize`:this.canDispatch(`UPDATE_TABLE`,{...e}).reasons}return`Success`}handle(e){switch(e.type){case`RESIZE_TABLE`:{let t=this.getters.getCoreTableMatchingTopLeft(e.sheetId,e.zone);if(this.dispatch(`UPDATE_TABLE`,{...e}),!t)return;let n=this.getters.getRangeFromRangeData(e.newTableRange).zone;if(this.selection.selectCell(n.right,n.bottom),!t.config.automaticAutofill)return;let r=t.range.zone;if(n.bottom>=r.bottom){for(let t=n.left;t<=n.right;t++){let i={col:t,row:r.bottom,sheetId:e.sheetId};this.getters.getCell(i)?.isFormula&&this.dispatch(`AUTOFILL_TABLE_COLUMN`,{...i,autofillRowStart:r.bottom,autofillRowEnd:n.bottom})}break}}}}},Iq=class extends lK{static getters=[`shouldShowFormulas`];showFormulas=!1;handle(e){switch(e.type){case`SET_FORMULA_VISIBILITY`:this.showFormulas=e.show;break}}shouldShowFormulas(){return this.showFormulas}},Lq=class extends lK{static getters=[`getCellWidth`,`getTextWidth`,`getCellText`,`getCellMultiLineText`,`getMultilineTextSize`,`getContiguousZone`,`computeTextYCoordinate`];ctx=Dl();allowDispatch(e){return this.chainValidations(this.checkSheetExists,this.checkZonesAreInSheet)(e)}handle(e){switch(e.type){case`AUTORESIZE_COLUMNS`:for(let t of e.cols){let n=this.getColMaxWidth(e.sheetId,t);n!==0&&this.dispatch(`RESIZE_COLUMNS_ROWS`,{elements:[t],dimension:`COL`,size:n,sheetId:e.sheetId})}break;case`AUTORESIZE_ROWS`:this.autoResizeRows(e.sheetId,e.rows);break;case`DELETE_UNFILTERED_CONTENT`:let t=[];for(let n of e.target){let r=$e(S(n.top,n.bottom+1).filter(t=>!this.getters.isRowFiltered(e.sheetId,t)));for(let e of r)t.push({...n,top:e[0],bottom:e[e.length-1]})}this.dispatch(`DELETE_CONTENT`,{sheetId:e.sheetId,target:t});break}}getCellWidth(e){let t=this.getters.getCellComputedStyle(e),n=0,r=this.getters.getEvaluatedCell(e).formattedValue;if(r){let e=Vl(this.ctx,r,t,void 0);n+=jl(this.ctx,e,t).width}for(let t of this.getters.getCellIcons(e))n+=t.margin+t.size;if(this.getters.getDataValidationChipStyle(e)&&(n+=10),n===0)return 0;if(n+=8,t.wrapping===`wrap`){let t=this.getters.getColSize(e.sheetId,e.col);return Math.min(t,n)}return n}getTextWidth(e,t){return Ml(this.ctx,e,t)}getMultilineTextSize(e,t){return jl(this.ctx,e,t)}getCellText(e,t){let n=this.getters.getCell(e),r=this.getters.getLocale();if(t?.showFormula){if(n?.isFormula)return MS(n.compiledFormula.toFormulaString(this.getters),r);if(!n?.content)return``}let i=this.getters.getEvaluatedCell(e),a=t?.availableWidth?{availableWidth:t.availableWidth,measureText:e=>Ml(this.ctx,e,n?.style||{})}:void 0;return z(i.value,{format:i.format,locale:r,formatWidth:a})}getCellMultiLineText(e,t){let n=this.getters.getCellStyle(e),r=this.getters.getCellText(e,{showFormula:this.getters.shouldShowFormulas(),availableWidth:t.formatWidth});return Vl(this.ctx,r,n,t.wrapText?t.maxWidth:void 0)}computeTextYCoordinate(e,t,n=Se,r=1){let i=e.y+1,a=El(t,r);if(e.height>a+8){if(n===`middle`)return Math.ceil(i+(e.height-a)/2);if(n===`bottom`)return i+e.height-a-4}return i+4}getContiguousZone(e,t){let n=t=>{for(let n of S(t.left,t.right+1)){if(!this.isCellEmpty({sheetId:e,col:n,row:t.top-1}))return{...t,top:t.top-1};if(!this.isCellEmpty({sheetId:e,col:n,row:t.bottom+1}))return{...t,bottom:t.bottom+1}}for(let n of S(t.top,t.bottom+1)){if(!this.isCellEmpty({sheetId:e,col:t.left-1,row:n}))return{...t,left:t.left-1};if(!this.isCellEmpty({sheetId:e,col:t.right+1,row:n}))return{...t,right:t.right+1}}return t},r=!1,i=t;do{r=!1;let e=n(i);Dn(i,e)||(r=!0,i=e)}while(r);return i}isCellEmpty(e){let t=this.getters.getMainCellPosition(e);return this.getters.getEvaluatedCell(t).type===`empty`}getColMaxWidth(e,t){let n=Fn(this.getters.getColsZone(e,t,t)).map(t=>this.getCellWidth({sheetId:e,...t}));return Math.max(0,Lt(n))}checkSheetExists(e){return`sheetId`in e&&this.getters.tryGetSheet(e.sheetId)===void 0&&e.type!==`CREATE_SHEET`?`InvalidSheetId`:`Success`}checkZonesAreInSheet(e){let t=`sheetId`in e?e.sheetId:this.getters.tryGetActiveSheetId();if(`ranges`in e&&e.ranges.some(e=>!this.getters.tryGetSheet(e._sheetId)))return`InvalidSheetId`;let n=this.getters.getCommandZones(e);return!t&&n.length>0?`NoActiveSheet`:t&&n.length>0?this.getters.checkZonesExistInSheet(t,n):`Success`}autoResizeRows(e,t){let n=[];for(let r of t){let t=0;for(let n of this.getters.getRowCellIds(e,r)){let r=this.getters.getCellById(n);if(!r)continue;let i=this.getters.getCellPosition(r.id),a=this.getters.getColSize(e,i.col);if(r.isFormula||this.getters.getArrayFormulaSpreadingOn(i)){let e=this.getters.getEvaluatedCell(i).formattedValue,n=kl(this.ctx,e,r?.style,a);n>t&&n>23&&(t=n)}else{let e=r.content,n=kl(this.ctx,e,r?.style,a);n>=t&&n>23&&(t=0)}}n.push(t||null)}let r=new Map(n.map(e=>[e,[]]));for(let e=0;e<n.length;e++)r.get(n[e])?.push(t[e]);for(let[t,n]of r)this.dispatch(`RESIZE_COLUMNS_ROWS`,{elements:n,dimension:`ROW`,size:t,sheetId:e})}},Rq=class extends lK{static getters=[`getSelectedCarouselItem`,`getChartFromFigureId`,`getChartIdFromFigureId`];uuidGenerator=new Xl;carouselStates={};allowDispatch(e){switch(e.type){case`ADD_FIGURE_CHART_TO_CAROUSEL`:return!this.getters.doesCarouselExist(e.carouselFigureId)||this.getters.getFigure(e.sheetId,e.chartFigureId)?.tag!==`chart`?`InvalidFigureId`:`Success`;case`DUPLICATE_CAROUSEL_CHART`:return!this.getters.doesCarouselExist(e.carouselId)||!this.getters.getCarousel(e.carouselId).items.some(t=>t.type===`chart`&&t.chartId===e.chartId)||this.getters.getChart(e.duplicatedChartId)?`InvalidFigureId`:`Success`;case`ADD_NEW_CHART_TO_CAROUSEL`:return this.getters.doesCarouselExist(e.figureId)?`Success`:`InvalidFigureId`;case`UPDATE_CAROUSEL_ACTIVE_ITEM`:return this.getters.doesCarouselExist(e.figureId)?this.getters.getCarousel(e.figureId).items.some(t=>w(t,e.item))?`Success`:`InvalidCarouselItem`:`InvalidFigureId`}return`Success`}handle(e){switch(e.type){case`ADD_NEW_CHART_TO_CAROUSEL`:this.addNewChartToCarousel(e.figureId,e.sheetId);break;case`ADD_FIGURE_CHART_TO_CAROUSEL`:this.addFigureChartToCarousel(e.carouselFigureId,e.chartFigureId,e.sheetId);break;case`DUPLICATE_CAROUSEL_CHART`:this.duplicateCarouselChart(e);break;case`UPDATE_CAROUSEL_ACTIVE_ITEM`:this.carouselStates[e.figureId]=this.getCarouselItemId(e.item);break;case`POPOUT_CHART_FROM_CAROUSEL`:this.popOutChartFromCarousel(e.carouselId,e.chartId,e.sheetId);break;case`DELETE_FIGURE`:delete this.carouselStates[e.figureId];break;case`UPDATE_CAROUSEL`:this.fixWrongCarouselState(e.figureId);break;case`DELETE_CHART`:case`UNDO`:case`REDO`:case`DELETE_SHEET`:for(let e in this.carouselStates)this.fixWrongCarouselState(e);break}}popOutChartFromCarousel(e,t,n){let r=this.getters.getCarousel(e);if(!r)return;let i=this.getters.getFigure(n,e),a=this.getters.getChartDefinition(t);if(!a||!i)return;let o=this.getters.getFigureUI(n,i),s=this.getters.getPositionAnchorOffset({x:o.x+50,y:o.y+50}),c=this.uuidGenerator.smallUuid();this.dispatch(`CREATE_CHART`,{...s,chartId:this.uuidGenerator.smallUuid(),figureId:c,sheetId:n,size:{width:i.width,height:i.height},definition:{...a}});let l=r.items.filter(e=>e.type!==`chart`||e.chartId!==t);this.dispatch(`UPDATE_CAROUSEL`,{sheetId:n,figureId:e,definition:{...r,items:l}}),this.dispatch(`SELECT_FIGURE`,{figureId:c})}getSelectedCarouselItem(e){let t=this.getters.getCarousel(e);if(t.items.length)return this.carouselStates[e]?t.items.find(t=>this.getCarouselItemId(t)===this.carouselStates[e]):t.items[0]}getChartFromFigureId(e){if(!this.getters.getFigureSheetId(e))return;let t=this.getChartIdFromFigureId(e);return t?this.getters.getChart(t):void 0}getChartIdFromFigureId(e){let t=this.getters.getFigureSheetId(e);if(!t)return;let n=this.getters.getFigure(t,e);if(!(!n||n.tag!==`chart`&&n.tag!==`carousel`)){if(n.tag===`carousel`){let t=this.getSelectedCarouselItem(e);return t?.type===`chart`?t.chartId:void 0}return this.getters.getChartIds(t).find(t=>this.getters.getFigureIdFromChartId(t)===e)}}fixWrongCarouselState(e){if(!this.getters.doesCarouselExist(e)){delete this.carouselStates[e];return}let t=this.getters.getCarousel(e);t.items.length===0?delete this.carouselStates[e]:this.carouselStates[e]&&t.items.some(t=>this.getCarouselItemId(t)===this.carouselStates[e])||(this.carouselStates[e]=this.getCarouselItemId(t.items[0]))}addNewChartToCarousel(e,t){let n=this.getters.getCarousel(e),r=this.uuidGenerator.smallUuid();this.dispatch(`CREATE_CHART`,{chartId:r,figureId:e,sheetId:t,definition:tv});let i={...n,items:[...n.items,{type:`chart`,chartId:r}]};this.dispatch(`UPDATE_CAROUSEL`,{sheetId:t,figureId:e,definition:i})}addFigureChartToCarousel(e,t,n){let r=this.getChartIdFromFigureId(t);if(!r)return;let i=this.getters.getCarousel(e),a={...i,items:[...i.items,{type:`chart`,chartId:r}]};this.dispatch(`UPDATE_CAROUSEL`,{sheetId:n,figureId:e,definition:a}),this.dispatch(`UPDATE_CHART`,{sheetId:n,chartId:r,figureId:e,definition:this.getters.getChartDefinition(r)}),this.dispatch(`DELETE_FIGURE`,{sheetId:n,figureId:t})}duplicateCarouselChart({carouselId:e,chartId:t,sheetId:n,duplicatedChartId:r}){let i=this.getters.getChart(t);if(!i)return;let a=this.getters.getCarousel(e),o=a.items.findIndex(e=>e.type===`chart`&&e.chartId===t);if(o===-1)return;this.dispatch(`CREATE_CHART`,{chartId:r,figureId:e,sheetId:n,definition:i.getDefinition()});let s=Mt(a.items,[{type:`chart`,chartId:r}],o+1);this.dispatch(`UPDATE_CAROUSEL`,{sheetId:n,figureId:e,definition:{...a,items:s}})}getCarouselItemId(e){return e.type===`chart`?e.chartId:`carouselDataView`}};async function zq(e){return new Promise((t,n)=>{let r=new Image;r.addEventListener(`load`,()=>{let e=document.createElement(`canvas`);e.width=r.width,e.height=r.height,e.getContext(`2d`)?.drawImage(r,0,0),e.toBlob(t,`image/png`)}),r.addEventListener(`error`,n),r.src=e})}var Bq=class extends lK{static layers=[`Clipboard`];static getters=[`getClipboardTextAndImageContent`,`getClipboardId`,`getClipboardTextContent`,`isCutOperation`];status=`invisible`;originSheetId;copiedData;_isCutOperation=!1;clipboardId=new Xl().uuidv4();fileStore;uuidGenerator;constructor(e){super(e),this.fileStore=e.external.fileStore,this.uuidGenerator=new Xl}allowDispatch(e){switch(e.type){case`CUT`:let t=this.getters.getSelectedZones();return this.isCutAllowedOn(t);case`PASTE_FROM_OS_CLIPBOARD`:{let t=this.convertTextToClipboardData(e.clipboardContent.text??``),n=e.pasteOption;return this.isPasteAllowed(e.target,t,{pasteOption:n,isCutOperation:!1})}case`PASTE`:{if(!this.copiedData)return`EmptyClipboard`;let t=e.pasteOption;return this.isPasteAllowed(e.target,this.copiedData,{pasteOption:t,isCutOperation:this._isCutOperation})}case`COPY_PASTE_CELLS_ABOVE`:{let e=this.getters.getSelectedZones();if(e.length>1||e[0].top===0&&e[0].bottom===0)return`InvalidCopyPasteSelection`;let t=this.getters.getSelectedZone(),n=this.getCopiedDataAbove(t);return this.isPasteAllowed(e,n,{isCutOperation:!1})}case`COPY_PASTE_CELLS_ON_LEFT`:{let e=this.getters.getSelectedZones();if(e.length>1||e[0].left===0&&e[0].right===0)return`InvalidCopyPasteSelection`;let t=this.getters.getSelectedZone(),n=this.getCopiedDataOnLeft(t);return this.isPasteAllowed(e,n,{isCutOperation:!1})}case`COPY_PASTE_CELLS_ON_ZONE`:{let e=this.getters.getSelectedZones();if(e.length>1)return`InvalidCopyPasteSelection`;let t=this.getters.getSelectedZone(),n=this.getCopiedDataOnLeft(t);return this.isPasteAllowed(e,n,{isCutOperation:!1})}case`INSERT_CELL`:{let{cut:t,paste:n}=this.getInsertCellsTargets(e.zone,e.shiftDimension),r=this.copy(t,`shiftCells`);return this.isPasteAllowed(n,r,{isCutOperation:!0})}case`DELETE_CELL`:{let{cut:t,paste:n}=this.getDeleteCellsTargets(e.zone,e.shiftDimension),r=this.copy(t,`shiftCells`);return this.isPasteAllowed(n,r,{isCutOperation:!0})}}return`Success`}handle(e){switch(e.type){case`COPY`:case`CUT`:let t=this.getters.getSelectedZones();this.status=`visible`,this.originSheetId=this.getters.getActiveSheetId(),this._isCutOperation=e.type===`CUT`,this.copiedData=this.copy(t);break;case`PASTE_FROM_OS_CLIPBOARD`:{this._isCutOperation=!1;let t=e.clipboardContent;if(t.data?.version!==Yj()&&(t={...t},delete t.data),t.imageData){let n=this.getters.getActiveSheetId(),r=this.uuidGenerator.uuidv4(),i=t.imageData,a=G_(this.getters,i.size);this.dispatch(`CREATE_IMAGE`,{definition:i,size:a,col:e.target[0].left,row:e.target[0].top,offset:{x:0,y:0},sheetId:n,figureId:r})}t.data?this.copiedData=t.data:this.copiedData=this.convertTextToClipboardData(t.text??``);let n=e.pasteOption;this.paste(e.target,this.copiedData,{pasteOption:n,selectTarget:!0,isCutOperation:!1}),this.status=`invisible`,this.copiedData=void 0;break}case`PASTE`:{let t=e.pasteOption;this.paste(e.target,this.copiedData,{pasteOption:t,selectTarget:!0,isCutOperation:this._isCutOperation}),this.status=`invisible`,this._isCutOperation&&=(this.copiedData=void 0,!1);break}case`COPY_PASTE_CELLS_ABOVE`:{let e=this.getters.getSelectedZone();this.originSheetId=this.getters.getActiveSheetId();let t=this.getCopiedDataAbove(e);this.paste([e],t,{isCutOperation:!1,selectTarget:!0})}break;case`COPY_PASTE_CELLS_ON_LEFT`:{let e=this.getters.getSelectedZone();this.originSheetId=this.getters.getActiveSheetId();let t=this.getCopiedDataOnLeft(e);this.paste([e],t,{isCutOperation:!1,selectTarget:!0})}break;case`COPY_PASTE_CELLS_ON_ZONE`:{let e=this.getters.getSelectedZone();this.originSheetId=this.getters.getActiveSheetId();let t=this.getCopiedDataAboveOnLeft(e);this.paste([e],t,{isCutOperation:!1,selectTarget:!0})}break;case`CLEAN_CLIPBOARD_HIGHLIGHT`:this.status=`invisible`;break;case`DELETE_CELL`:{let{cut:t,paste:n}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!_n(t[0])){this.dispatch(`CLEAR_CELLS`,{target:[e.zone],sheetId:this.getters.getActiveSheetId()});break}let r=this.copy(t,`shiftCells`);this.paste(n,r,{isCutOperation:!0});break}case`INSERT_CELL`:{let{cut:t,paste:n}=this.getInsertCellsTargets(e.zone,e.shiftDimension),r=this.copy(t,`shiftCells`);this.paste(n,r,{isCutOperation:!0});break}case`ADD_COLUMNS_ROWS`:if(this.status=`invisible`,!this._isCutOperation||e.sheetId!==this.copiedData?.sheetId)return;this.isColRowDirtyingClipboard(e.position===`before`?e.base:e.base+1,e.dimension)&&(this.copiedData=void 0);break;case`REMOVE_COLUMNS_ROWS`:if(this.status=`invisible`,!this._isCutOperation||e.sheetId!==this.copiedData?.sheetId)return;for(let t of e.elements)if(this.isColRowDirtyingClipboard(t,e.dimension)){this.copiedData=void 0;break}this.status=`invisible`;break;case`REPEAT_PASTE`:this.paste(e.target,this.copiedData,{isCutOperation:!1,pasteOption:e.pasteOption,selectTarget:!0});break;case`DELETE_SHEET`:if(!this._isCutOperation)return;this.originSheetId===e.sheetId&&(this.copiedData=void 0,this.status=`invisible`);break;default:qs(e)&&(this.status=`invisible`)}}getCopiedDataAbove(e){let t=e.top!==e.bottom,n={...e,bottom:t?e.top:e.top-1,top:t?e.top:e.top-1};return this.copy([n])}getCopiedDataOnLeft(e){let t=e.left!==e.right,n={...e,right:t?e.left:e.left-1,left:t?e.left:e.left-1};return this.copy([n])}getCopiedDataAboveOnLeft(e){let t={...e,right:e.left,bottom:e.top};return this.copy([t])}convertTextToClipboardData(e){let t=this.selectClipboardHandlers({figureId:!0}).concat(this.selectClipboardHandlers({})),n={};for(let{handlerName:r,handler:i}of t){let t=i.convertTextToClipboardData(e);n[r]=t;for(let e of[`sheetId`,`cells`,`zones`,`figureId`])t&&e in t&&(n[e]=t[e])}return n}selectClipboardHandlers(e){let t=`figureId`in e?oW.figureHandlers:oW.cellHandlers;return t.getKeys().map(e=>({handlerName:e,handler:new(t.get(e))(this.getters,this.dispatch)}))}isCutAllowedOn(e){let t=this.getClipboardData(e);for(let{handler:e}of this.selectClipboardHandlers(t)){let n=e.isCutAllowed(t);if(n!==`Success`)return n}return`Success`}isPasteAllowed(e,t,n){for(let{handler:r}of this.selectClipboardHandlers(t)){let i=r.isPasteAllowed(this.getters.getActiveSheetId(),e,t,{...n});if(i!==`Success`)return i}return`Success`}isColRowDirtyingClipboard(e,t){if(!this.copiedData||!this.copiedData.zones)return!1;let{zones:n}=this.copiedData;for(let r of n)if(t===`COL`&&e<=r.right||t===`ROW`&&e<=r.bottom)return!0;return!1}copy(e,t=`copyPaste`){let n={},r=this.getClipboardData(e);for(let{handlerName:e,handler:i}of this.selectClipboardHandlers(r)){let a=i.copy(r,this._isCutOperation,t);n[e]=a;for(let e of[`sheetId`,`cells`,`zones`,`figureId`])a&&e in a&&(n[e]=a[e])}return n}paste(e,t,n){if(!t)return;let r=this.getters.getActiveSheetId(),i=this.selectClipboardHandlers(t),{target:a,zone:o,selectedZones:s}=AP(r,e,t,i,n);o!==void 0&&this.addMissingDimensions(r,o.right-o.left+1,o.bottom-o.top+1,o.left,o.top),kP(i,t,a,n),n?.selectTarget&&jP(this.selection,e,s)}addMissingDimensions(e,t,n,r,i){let a=n+i-this.getters.getNumberRows(e);a>0&&this.dispatch(`ADD_COLUMNS_ROWS`,{dimension:`ROW`,base:this.getters.getNumberRows(e)-1,sheetId:e,sheetName:this.getters.getSheetName(e),quantity:a,position:`after`});let o=t+r-this.getters.getNumberCols(e);o>0&&this.dispatch(`ADD_COLUMNS_ROWS`,{dimension:`COL`,base:this.getters.getNumberCols(e)-1,sheetId:e,sheetName:this.getters.getSheetName(e),quantity:o,position:`after`})}getClipboardTextContent(){return this.getPlainTextContent()}getClipboardId(){return this.clipboardId}async getClipboardTextAndImageContent(){let e=await this.getImageContent(),t=e?.type,n={"text/plain":this.getPlainTextContent(),"text/html":await this.getHTMLContent()};return t&&e&&(n[t]=e),n}getSheetData(){let e={version:Yj(),clipboardId:this.clipboardId};return this.copiedData&&`figureId`in this.copiedData?e:{...e,...this.copiedData}}getPlainTextContent(){return this.copiedData?.cells&&this.copiedData.cells.map(e=>e.map(e=>this.getters.shouldShowFormulas()&&e?.compiledFormula?e?.content||``:e.evaluatedCell?.formattedValue||``).join(` `)).join(`
|
|
119
119
|
`)||` `}async getHTMLContent(){let e=``,t=this.copiedData?.cells;if(!t)if(this.copiedData?.figureId){let t=this.copiedData.figureId,n=this.getters.getFigureSheetId(t);e=this.getters.getFigure(n,t).tag===`image`?await this.craftImageHTML(t):` `}else e=` `;else if(t.length===1&&t[0].length===1)e=`${this.getters.getCellText(t[0][0].position)}`;else if(t[0][0]){let n=`<table border="1" style="border-collapse:collapse">`;for(let e of t){n+=`<tr>`;for(let t of e){if(!t)continue;let e=U(av(this.getters.getCellComputedStyle(t.position))),r=this.getters.getCellText(t.position);n+=`<td style="${e}">`+_j(r)+`</td>`}n+=`</tr>`}n+=`</table>`,e=n}else return``;return`<div data-osheet-clipboard='${_j(JSON.stringify(this.getSheetData()))}'>${e}</div>`}readFileAsDataURL(e){return new Promise(t=>{let n=new FileReader;n.onload=()=>t(n.result),n.readAsDataURL(e)})}async craftImageHTML(e){if(!this.fileStore)return` `;let t=this.getters.getImage(e).path,n=await this.fileStore?.getFile(t)||null;return n?`<img src="${_j(await this.readFileAsDataURL(n))}" />`:` `}async getImageContent(){let e=this.copiedData?.figureId;if(!e)return;let t=this.getters.getFigureSheetId(e),n=this.getters.getFigure(t,e),r;if(n.tag===`image`){if(!this.fileStore)return;let t=this.getters.getImage(e).path;if(r=await this.fileStore?.getFile(t),r.type!==`image/png`){if(r.size>5242880){this.ui.notifyUI({text:k(`The file you are trying to copy is too large (>%sMB).
|
|
120
120
|
It will not be added to your OS clipboard.
|
|
121
|
-
You can download it directly instead.`,5),sticky:!1,type:`warning`});return}r=await zq(t)}}if(r)return r instanceof File?r:new File([r],`image.png`,{type:`image/png`})}isCutOperation(){return this._isCutOperation??!1}getDeleteCellsTargets(e,t){let n=this.getters.getActiveSheetId(),r;return r=t===`COL`?{...e,left:e.right+1,right:this.getters.getNumberCols(n)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(n)-1},{cut:[r],paste:[e]}}getInsertCellsTargets(e,t){let n=this.getters.getActiveSheetId(),r,i;return t===`COL`?(r={...e,right:this.getters.getNumberCols(n)-1},i={...e,left:e.right+1,right:e.right+1}):(r={...e,bottom:this.getters.getNumberRows(n)-1},i={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(n)-1}),{cut:[r],paste:[i]}}getClipboardData(e){let t=this.getters.getActiveSheetId(),n=this.getters.getSelectedFigureId();if(n)return{figureId:n,sheetId:t};let r=wP(t,e);return this._isCutOperation||(r.rowsIndexes=r.rowsIndexes.filter(e=>!this.getters.isRowFiltered(t,e))),r}drawLayer(e){if(this.status!==`visible`||!this.copiedData)return;let{sheetId:t,zones:n}=this.copiedData;if(t!==this.getters.getActiveSheetId()||!n||!n.length)return;let{ctx:r,thinLineWidth:i}=e;r.setLineDash([8,5]),r.strokeStyle=ae,r.lineWidth=3.3*i;for(let e of n){let{x:t,y:n,width:i,height:a}=this.getters.getVisibleRect(e);i>0&&a>0&&r.strokeRect(t,n,i,a)}}};let Vq={filterType:`criterion`,type:`none`,values:[]};var Hq=class extends lK{static getters=[`getFilterValue`,`getFilterHiddenValues`,`getFilterCriterionValue`,`getFirstTableInSelection`,`isRowFiltered`,`isFilterActive`];filterValues={};hiddenRows={};isEvaluationDirty=!1;allowDispatch(e){switch(e.type){case`UPDATE_FILTER`:if(!this.getters.getFilterId(e))return`FilterNotFound`;break}return`Success`}handle(e){switch(e.type){case`UNDO`:case`REDO`:case`UPDATE_CELL`:case`EVALUATE_CELLS`:case`ACTIVATE_SHEET`:case`REMOVE_TABLE`:case`ADD_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:case`UPDATE_TABLE`:this.isEvaluationDirty=!0;break;case`START`:for(let e of this.getters.getSheetIds())this.filterValues[e]={};break;case`CREATE_SHEET`:this.filterValues[e.sheetId]={};break;case`HIDE_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`GROUP_HEADERS`:case`UNGROUP_HEADERS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_ALL_HEADER_GROUPS`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:this.updateHiddenRows(e.sheetId);break;case`UPDATE_FILTER`:this.updateFilter(e),this.updateHiddenRows(e.sheetId);break;case`DUPLICATE_SHEET`:this.filterValues[e.sheetIdTo]=b(this.filterValues[e.sheetId]);break}}finalize(){if(this.isEvaluationDirty){for(let e of this.getters.getSheetIds())this.updateHiddenRows(e);this.isEvaluationDirty=!1}}isRowFiltered(e,t){return!!this.hiddenRows[e]?.has(t)}getFilterValue(e){let t=this.getters.getFilterId(e),n=e.sheetId;return t?this.filterValues[n]?.[t]:void 0}getFilterHiddenValues(e){let t=this.getters.getFilterId(e),n=e.sheetId;if(!t||!this.filterValues[n])return[];let r=this.filterValues[n][t]||[];return r.filterType===`values`?r.hiddenValues:[]}getFilterCriterionValue(e){let t=this.getters.getFilterId(e),n=e.sheetId;if(!t||!this.filterValues[n])return Vq;let r=this.filterValues[n][t];return r&&r.filterType===`criterion`?r:Vq}isFilterActive(e){let t=this.getters.getFilterId(e);if(!t)return!1;let n=e.sheetId,r=this.filterValues[n]?.[t];return r?r.filterType===`values`?r.hiddenValues.length>0:r.type!==`none`:!1}getFirstTableInSelection(){let e=this.getters.getActiveSheetId(),t=this.getters.getSelectedZones();return this.getters.getTablesOverlappingZones(e,t)[0]}updateFilter({col:e,row:t,value:n,sheetId:r}){let i=this.getters.getFilterId({sheetId:r,col:e,row:t});i&&(this.filterValues[r]||(this.filterValues[r]={}),this.filterValues[r][i]=n)}updateHiddenRows(e){let t=this.getters.getFilters(e).sort((e,t)=>e.rangeWithHeaders.zone.top-t.rangeWithHeaders.zone.top),n=new Set;for(let r of t){let t=this.filterValues[e]?.[r.id],i=r.filteredRange?.zone;if(!(!t||!i||n.has(r.rangeWithHeaders.zone.top)||this.getters.isRowHiddenByUser(e,r.rangeWithHeaders.zone.top)))if(t.filterType===`values`){let a=t.hiddenValues?.map(Ul);if(!a)continue;let o=new Set(a);for(let t=i.top;t<=i.bottom;t++){let i=this.getCellValueAsString(e,r.col,t);o.has(i)&&n.add(t)}}else{if(t.type===`none`)continue;let a=Z.get(t.type),o=a.preComputeCriterion?.(t,[r.filteredRange],this.getters),s=t.values.map(t=>t.startsWith(`=`)?this.getters.evaluateFormula(e,t)??``:sc(t,R));if(s.some(wm))continue;let c={type:t.type,values:s.map(Sm),dateValue:t.dateValue};for(let t=i.top;t<=i.bottom;t++){let i={sheetId:e,col:r.col,row:t},s=this.getters.getEvaluatedCell(i).value??``;a.isValueValid(s,c,o)||n.add(t)}}}this.hiddenRows[e]=n}getCellValueAsString(e,t,n){let r=this.getters.getEvaluatedCell({sheetId:e,col:t,row:n}).formattedValue;return Ul(r)}exportForExcel(e){for(let t of e.sheets){let e=t.id;for(let n of t.tables){let r=mn(n.range),i=[],a=[];for(let n of S(0,Mn(r).numberOfCols)){let o={sheetId:t.id,col:r.left+n,row:r.top},s=this.getFilterHiddenValues(o),c=this.getters.getFilter(o),l=c?.filteredRange?Fn(c.filteredRange.zone).map(t=>this.getters.getEvaluatedCell({sheetId:e,...t}).formattedValue):[];if(s.length){let e=l.filter(e=>e).filter(e=>!s.includes(e));i.push({colId:n,displayedValues:[...new Set(e)],displayBlanks:!s.includes(``)&&l.some(e=>!e)})}let u=this.getters.getEvaluatedCell(o).formattedValue,d=this.getUniqueColNameForExcel(n,u,a);a.push(d);let f=T(o.col,o.row);t.cells[f]=d,t.cellValues[f]=d}n.filters=i}}}getUniqueColNameForExcel(e,t,n){return t||=`Column${e}`,Ht(t,n,{compute:(e,n)=>t+String(n),start:2})}},Uq=class extends lK{static getters=[`getColDimensions`,`getRowDimensions`,`getColRowOffset`];headerPositions={};isDirty=!0;handle(e){switch(Rs.has(e.type)&&(this.headerPositions={},this.isDirty=!0),e.type){case`START`:for(let e of this.getters.getSheetIds())this.headerPositions[e]=this.computeHeaderPositionsOfSheet(e);break;case`UPDATE_CELL`:this.headerPositions={},this.isDirty=!0;break;case`UPDATE_FILTER`:case`UPDATE_TABLE`:case`REMOVE_TABLE`:this.headerPositions={},this.isDirty=!0;break;case`REMOVE_COLUMNS_ROWS`:case`RESIZE_COLUMNS_ROWS`:case`HIDE_COLUMNS_ROWS`:case`ADD_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_ALL_HEADER_GROUPS`:case`UNGROUP_HEADERS`:case`GROUP_HEADERS`:case`CREATE_SHEET`:this.getters.tryGetSheet(e.sheetId)&&(this.headerPositions[e.sheetId]=this.computeHeaderPositionsOfSheet(e.sheetId));break;case`DUPLICATE_SHEET`:this.headerPositions[e.sheetIdTo]=b(this.headerPositions[e.sheetId]);break}}finalize(){for(let e of this.getters.getSheetIds())(this.isDirty||!this.headerPositions[e])&&(this.headerPositions[e]=this.computeHeaderPositionsOfSheet(e));this.isDirty=!1}getColDimensions(e,t){let n=this.headerPositions[e].COL[t],r=this.getters.getColSize(e,t);return{start:n,size:r,end:n+(this.getters.isColHidden(e,t)?0:r)}}getRowDimensions(e,t){let n=this.headerPositions[e].ROW[t],r=this.getters.getRowSize(e,t);return{start:n,size:r,end:n+(this.getters.isRowHidden(e,t)?0:r)}}getColRowOffset(e,t,n,r=this.getters.getActiveSheetId()){let i=this.headerPositions[r][e][t];return this.headerPositions[r][e][n]-i}computeHeaderPositionsOfSheet(e){return{COL:this.computePositions(e,`COL`),ROW:this.computePositions(e,`ROW`)}}computePositions(e,t){let n={},r=0;for(let i=0;i<this.getters.getNumberHeaders(e,t)+1;i++)n[i]=r,!this.getters.isHeaderHidden(e,t,i)&&(r+=this.getters.getHeaderSize(e,t,i));return n}},Wq=class extends lK{static layers=[`Selection`];static getters=[`getActiveSheet`,`getActiveSheetId`,`getActiveSheetName`,`getActiveCell`,`getActiveCols`,`getActiveRows`,`getCurrentStyle`,`getSelectedZones`,`getSelectedZone`,`getSelectedCells`,`getSelectedFigureId`,`getSelection`,`getActivePosition`,`getSheetPosition`,`isSingleColSelected`,`getElementsFromSelection`,`tryGetActiveSheetId`,`isGridSelectionActive`,`getSelectecUnboundedZone`,`getSelectionRangeString`];gridSelection={anchor:{cell:{col:0,row:0},zone:{top:0,left:0,bottom:0,right:0}},zones:[{top:0,left:0,bottom:0,right:0}]};selectedFigureId=null;sheetsData={};moveClient;isUnbounded;activeSheet=null;constructor(e){super(e),this.moveClient=e.moveClient,this.isUnbounded=!1}allowDispatch(e){switch(e.type){case`ACTIVATE_SHEET`:try{if(!this.getters.getSheet(e.sheetIdTo).isVisible)return`SheetIsHidden`;break}catch{return`InvalidSheetId`}case`MOVE_COLUMNS_ROWS`:return this.isMoveElementAllowed(e)}return`Success`}handleEvent(e){let t=e.anchor,n=[...this.gridSelection.zones];switch(this.isUnbounded=e.options?.unbounded||!1,e.mode){case`overrideSelection`:n=[t.zone];break;case`updateAnchor`:let r=n.findIndex(t=>Dn(t,e.previousAnchor.zone));r>=0&&(n[r]=t.zone);break;case`newAnchor`:n.push(t.zone);break;case`commitSelection`:let i=n.find(e=>jn(t.zone,e)&&!Dn(t.zone,e));if(n.filter(e=>Dn(t.zone,e)).length>1&&n.length>2)n=n.filter(e=>!Dn(e,t.zone));else if(i){let e=tr(t.zone,i);n=n.filter(e=>!Dn(e,t.zone)&&!Dn(e,i)).concat(e)}n=zn(n);let a=n[n.length-1];t={cell:An(t.cell.col,t.cell.row,a)?t.cell:{col:a.left,row:a.top},zone:a};break}this.setSelectionMixin(t,n),this.selection.resetDefaultAnchor(this,b(this.gridSelection.anchor));let{col:r,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:r,row:i}),this.selectedFigureId=null}handle(e){switch(e.type){case`ACTIVATE_SHEET`:this.selectedFigureId=null;break;case`DELETE_FIGURE`:this.selectedFigureId===e.figureId&&(this.selectedFigureId=null);break;case`DELETE_SHEET`:this.selectedFigureId&&this.getters.getFigure(e.sheetId,this.selectedFigureId)&&(this.selectedFigureId=null);break}switch(e.type){case`START`:let t=this.getters.getVisibleSheetIds()[0];this.activateSheet(t,t);let{col:n,row:r}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(n,r),this.selection.registerAsDefault(this,this.gridSelection.anchor,{handleEvent:this.handleEvent.bind(this)}),this.moveClient({sheetId:t,col:0,row:0});break;case`ACTIVATE_SHEET`:this.activateSheet(e.sheetIdFrom,e.sheetIdTo);break;case`REMOVE_COLUMNS_ROWS`:{let t=this.getters.getActiveSheetId();if(e.sheetId===t){e.dimension===`COL`?this.onColumnsRemoved(e):this.onRowsRemoved(e);let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:n,row:r})}break}case`ADD_COLUMNS_ROWS`:{let t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:n,row:r})}break}case`MOVE_COLUMNS_ROWS`:e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case`SELECT_FIGURE`:this.selectedFigureId=e.figureId;break;case`ACTIVATE_NEXT_SHEET`:this.activateNextSheet(`right`);break;case`ACTIVATE_PREVIOUS_SHEET`:this.activateNextSheet(`left`);break;case`HIDE_SHEET`:e.sheetId===this.getActiveSheetId()&&this.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:e.sheetId,sheetIdTo:this.getters.getVisibleSheetIds()[0]});break;case`UNDO`:case`REDO`:case`DELETE_SHEET`:let i=Object.keys(this.sheetsData).filter(e=>!this.getters.tryGetSheet(e));for(let e of i)delete this.sheetsData[e];for(let e in this.sheetsData){let t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:b(t)}}this.fallbackToVisibleSheet();let a=this.getters.getActiveSheetId();this.gridSelection.zones=this.gridSelection.zones.map(e=>this.getters.expandZone(a,e)),this.gridSelection.anchor.zone=this.getters.expandZone(a,this.gridSelection.anchor.zone),this.setSelectionMixin(this.gridSelection.anchor,this.gridSelection.zones),this.selectedFigureId=null;break}}finalize(){this.fallbackToVisibleSheet(),this.selection.resetDefaultAnchor(this,b(this.gridSelection.anchor))}isGridSelectionActive(){return this.selection.isListening(this)}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}getActiveSheetName(){return this.activeSheet.name}tryGetActiveSheetId(){return this.activeSheet?.id}getActiveCell(){return this.getters.getEvaluatedCell(this.getActivePosition())}getActiveCols(){let e=new Set;for(let t of this.gridSelection.zones)if(t.top===0&&t.bottom===this.getters.getNumberRows(this.getters.getActiveSheetId())-1)for(let n=t.left;n<=t.right;n++)e.add(n);return e}getActiveRows(){let e=new Set,t=this.getters.getActiveSheetId();for(let n of this.gridSelection.zones)if(n.left===0&&n.right===this.getters.getNumberCols(t)-1)for(let t=n.top;t<=n.bottom;t++)e.add(t);return e}getCurrentStyle(){let e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();return this.getters.getCellStyle({sheetId:t,col:e.left,row:e.top})}getSelectedZones(){return b(this.gridSelection.zones)}getSelectedZone(){return b(this.gridSelection.anchor.zone)}getSelectecUnboundedZone(){return b(this.isUnbounded?this.getters.getUnboundedZone(this.activeSheet.id,this.gridSelection.anchor.zone):this.gridSelection.anchor.zone)}getSelection(){return b(this.gridSelection)}getSelectedCells(){let e=this.getters.getActiveSheetId(),t=[];for(let n of this.gridSelection.zones)t.push(...this.getters.getEvaluatedCellsInZone(e,n));return t}getSelectedFigureId(){return this.selectedFigureId}getActivePosition(){return this.getters.getMainCellPosition({sheetId:this.getActiveSheetId(),col:this.gridSelection.anchor.cell.col,row:this.gridSelection.anchor.cell.row})}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getActivePosition();{let t=this.sheetsData[e];return t?{sheetId:e,col:t.gridSelection.anchor.cell.col,row:t.gridSelection.anchor.cell.row}:this.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0})}}isSingleColSelected(){let e=this.getters.getSelectedZones();return!(e.length!==1||e[0].left!==e[0].right)}getElementsFromSelection(e){if(e===`COL`&&this.getters.getActiveCols().size===0||e===`ROW`&&this.getters.getActiveRows().size===0)return[];let t=this.getters.getSelectedZones(),n=[],r=e===`COL`?`left`:`top`,i=e===`COL`?`right`:`bottom`;for(let e of t){let t=Array.from({length:e[i]-e[r]+1},(t,n)=>e[r]+n);n=n.concat(t)}return[...new Set(n)].sort()}getSelectionRangeString(e,t,{allowSpilledReferences:n}={allowSpilledReferences:!1}){let r=this.getters.expandZone(e.sheetId,e.zone),i=Yc({...e,zone:{...r,bottom:Qc(e)?void 0:r.bottom,right:$c(e)?void 0:r.right}},this.getters.getSheetSize),a=this.getters.getRangeString(i,t);if(this.getters.isSingleCellOrMerge(e.sheetId,e.zone)){let{sheetName:e,xc:t}=zc(a);return Bc(e,t.split(`:`)[0])}if(n){let e=this.getters.getArrayFormulaSpreadingOn({sheetId:i.sheetId,col:i.zone.left,row:i.zone.top}),t=e&&this.getters.getSpreadZone(e,{ignoreSpillError:!0});if(t&&Dn(t,i.zone)){let{sheetName:e,xc:t}=zc(a);return Bc(e,t.split(`:`)[0])+`#`}}return a}activateSheet(e,t){if(this.setActiveSheet(t),this.sheetsData[e]={gridSelection:b(this.gridSelection)},t in this.sheetsData)Object.assign(this,this.sheetsData[t]),this.selection.resetDefaultAnchor(this,b(this.gridSelection.anchor));else{let{col:e,row:n}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(e,n)}let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.activeSheet.id,col:n,row:r})}setSelectionMixin(e,t){let{anchor:n,zones:r}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=n,this.gridSelection.zones=r}selectCell(e,t){let n=this.getters.getActiveSheetId(),r=this.getters.expandZone(n,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:r,cell:{col:e,row:t}},[r])}setActiveSheet(e){this.activeSheet=this.getters.getSheet(e)}activateNextSheet(e){let t=this.getters.getSheetIds(),n=(t.findIndex(e=>e===this.activeSheet.id)+(e===`left`?t.length-1:1))%t.length;this.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[n]})}onColumnsRemoved(e){let{cell:t,zone:n}=this.gridSelection.anchor,r=Sn(n,`left`,[...e.elements]),i={left:t.col,right:t.col,top:t.row,bottom:t.row};i=Sn(i,`left`,[...e.elements]);let a={cell:{col:i.left,row:i.top},zone:r},o=this.gridSelection.zones.map(t=>Sn(t,`left`,[...e.elements]));this.setSelectionMixin(a,o)}onRowsRemoved(e){let{cell:t,zone:n}=this.gridSelection.anchor,r=Sn(n,`top`,[...e.elements]),i={left:t.col,right:t.col,top:t.row,bottom:t.row};i=Sn(i,`top`,[...e.elements]);let a={cell:{col:i.left,row:i.top},zone:r},o=this.gridSelection.zones.map(t=>Sn(t,`top`,[...e.elements]));this.setSelectionMixin(a,o)}onAddElements(e){let t=e.dimension===`COL`?`left`:`top`,n=xn(this.gridSelection.anchor.zone,t,e.base,e.position,e.quantity),r=this.gridSelection.zones.map(n=>xn(n,t,e.base,e.position,e.quantity)),i={cell:{col:n.left,row:n.top},zone:n};this.setSelectionMixin(i,r)}onMoveElements(e){let t=e.elements.length,n=this.getFiguresUpdates(e);this.dispatch(`ADD_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,sheetName:e.sheetName,base:e.base,quantity:t,position:e.position});let r=e.dimension===`COL`,i=e.elements[0],a=e.elements[t-1],o=e.base<i,s=o&&r?t:0,c=o&&!r?t:0,l=o?e.elements.map(e=>e+t):e.elements,u={};for(let t of l)u[t]=this.getters.getHeaderSize(e.sheetId,e.dimension,t);let d=[{left:r?i+s:0,right:r?a+s:this.getters.getNumberCols(e.sheetId)-1,top:r?0:i+c,bottom:r?this.getters.getNumberRows(e.sheetId)-1:a+c}],f=this.getActiveSheetId(),p=o?e.base:e.base+1,m=[{left:r?p:0,right:r?p+t-1:this.getters.getNumberCols(e.sheetId)-1,top:r?0:p,bottom:r?this.getters.getNumberRows(e.sheetId)-1:p+t-1}],h=oW.cellHandlers.getKeys().map(e=>[e,new(oW.cellHandlers.get(e))(this.getters,this.dispatch)]),g={};for(let[e,t]of h)g[e]=t.copy(wP(f,d),!1,`shiftCells`);for(let[e,t]of h)g[e]&&t.paste({zones:m,sheetId:f},g[e],{isCutOperation:!0});let _=m[0],v=_.left,y=_.top;this.setSelectionMixin({zone:_,cell:{col:v,row:y}},[_]);let ee=o?e.base:e.base+1,te={};for(let t of l){let n=u[t];n!==this.getters.getHeaderSize(e.sheetId,e.dimension,ee)&&(te[n]??=[],te[n].push(ee)),ee+=1}for(let t in te)this.dispatch(`RESIZE_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,size:parseInt(t,10),elements:te[t]});this.dispatch(`REMOVE_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,sheetName:e.sheetName,elements:l}),this.applyFigureUpdates(n)}getFiguresUpdates(e){let t=[],n={},r=e.elements[0]<e.base?e.base-e.elements.length+1:e.base;for(let t=0;t<e.elements.length;t++)n[e.elements[t]]=r+t;for(let r of this.getters.getFigures(e.sheetId))e.dimension===`COL`&&r.col in n&&t.push({type:`UPDATE_FIGURE`,sheetId:e.sheetId,figureId:r.id,col:n[r.col],row:r.row}),e.dimension===`ROW`&&r.row in n&&t.push({type:`UPDATE_FIGURE`,sheetId:e.sheetId,figureId:r.id,row:n[r.row],col:r.col});return t}applyFigureUpdates(e){for(let t of e)this.dispatch(t.type,{...t})}isMoveElementAllowed(e){let t=e.dimension===`COL`,n=e.elements[0],r=e.elements[e.elements.length-1],i=e.sheetId,a=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;if(a(i,n-1,n)||a(i,r,r+1)||a(i,e.base-1,e.base))return`WillRemoveExistingMerge`;let o=[e.base,...e.elements],s=t?this.getters.getNumberCols(i):this.getters.getNumberRows(i);return o.some(e=>e<0||e>=s)?`InvalidHeaderIndex`:!t&&!this.isTableRowMoveAllowed(i,e.elements)?`CannotMoveTableHeader`:`Success`}isTableRowMoveAllowed(e,t){let n=this.getters.getCoreTables(e);if(n.length===0)return!0;let r=new Set(t);return n.every(({range:{zone:e},config:n})=>{let{top:i,bottom:a}=e;if(n.numberOfHeaders===0)return!0;let o=i+n.numberOfHeaders-1;return t.some(e=>e>=i&&e<=o)?S(i,a+1).every(e=>r.has(e)):!0})}fallbackToVisibleSheet(){if(!this.getters.tryGetSheet(this.getters.getActiveSheetId())){let e=this.getters.getVisibleSheetIds();if(this.activeSheet=this.getters.getSheet(e[0]),this.activeSheet.id in this.sheetsData){let{anchor:e}=this.clipSelection(this.activeSheet.id,this.sheetsData[this.activeSheet.id].gridSelection);this.selectCell(e.cell.col,e.cell.row)}else this.selectCell(0,0);let{col:t,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:n})}}clipSelection(e,t){let n=this.getters.getNumberCols(e)-1,r=this.getters.getNumberRows(e)-1,i=t.zones.map(e=>({left:x(e.left,0,n),right:x(e.right,0,n),top:x(e.top,0,r),bottom:x(e.bottom,0,r)})),a=x(t.anchor.cell.col,0,n),o=x(t.anchor.cell.row,0,r),s={left:x(t.anchor.zone.left,0,n),right:x(t.anchor.zone.right,0,n),top:x(t.anchor.zone.top,0,r),bottom:x(t.anchor.zone.bottom,0,r)};return{zones:i,anchor:{cell:{col:a,row:o},zone:s}}}drawLayer(e){if(this.getters.isDashboard())return;let{ctx:t,thinLineWidth:n}=e,r=this.getSelectedZones();t.fillStyle=`#f3f7fe`,t.fillStyle=r.length===1&&r[0].left===r[0].right&&r[0].top===r[0].bottom?`#f3f7fe`:`#e9f0ff`,t.strokeStyle=ae,t.lineWidth=1.5*n;for(let e of r){let{x:n,y:r,width:i,height:a}=this.getters.getVisibleRect(e);t.globalCompositeOperation=`multiply`,t.fillRect(n,r,i,a),t.globalCompositeOperation=`source-over`,t.strokeRect(n,r,i,a)}t.globalCompositeOperation=`source-over`;let i=this.getActivePosition();t.strokeStyle=ae,t.lineWidth=3*n;let a;a=this.getters.isInMerge(i)?this.getters.getMerge(i):E(i);let{x:o,y:s,width:c,height:l}=this.getters.getVisibleRect(a);c>0&&l>0&&t.strokeRect(o,s,c,l)}},Gq=class{getters;sheetId;boundaries;top;bottom;left;right;offsetX;offsetY;canScrollVertically;canScrollHorizontally;viewportWidth;viewportHeight;offsetCorrectionX;offsetCorrectionY;constructor(e,t,n,r,i,a){if(this.getters=e,this.sheetId=t,this.boundaries=n,r.width<0||r.height<0)throw Error(`Viewport size cannot be negative`);this.viewportWidth=r.height&&r.width,this.viewportHeight=r.width&&r.height,this.top=n.top,this.bottom=n.bottom,this.left=n.left,this.right=n.right,this.offsetX=a.x,this.offsetY=a.y,this.canScrollVertically=i.canScrollVertically,this.canScrollHorizontally=i.canScrollHorizontally,this.offsetCorrectionX=this.getters.getColDimensions(this.sheetId,this.boundaries.left).start,this.offsetCorrectionY=this.getters.getRowDimensions(this.sheetId,this.boundaries.top).start,this.adjustViewportOffsetX(),this.adjustViewportOffsetY()}getMaxSize(){let e=this.getters.findLastVisibleColRowIndex(this.sheetId,`COL`,{first:this.boundaries.left,last:this.boundaries.right}),t=this.getters.findLastVisibleColRowIndex(this.sheetId,`ROW`,{first:this.boundaries.top,last:this.boundaries.bottom}),{end:n}=this.getters.getColDimensions(this.sheetId,e),{end:r}=this.getters.getRowDimensions(this.sheetId,t),i=n-this.offsetCorrectionX;this.canScrollHorizontally&&(i=Math.max(i,this.viewportWidth));let a=r-this.offsetCorrectionY;return this.canScrollVertically&&(a=Math.max(a,this.viewportHeight),r+46>a&&!this.getters.isReadonly()&&(a+=46)),{width:i,height:a}}getColIndex(e){return e<this.offsetCorrectionX||e>this.offsetCorrectionX+this.viewportWidth?-1:this.searchHeaderIndex(`COL`,e-this.offsetCorrectionX+this.snapCorrection.x,this.left)}getRowIndex(e){return e<this.offsetCorrectionY||e>this.offsetCorrectionY+this.viewportHeight?-1:this.searchHeaderIndex(`ROW`,e-this.offsetCorrectionY+this.snapCorrection.y,this.top)}adjustPosition(e){let t=this.sheetId,n=this.getters.getMainCellPosition({sheetId:t,...e}),{col:r,row:i}=this.getters.getNextVisibleCellPosition(n);An(r,this.boundaries.top,this.boundaries)&&this.adjustPositionX(r),An(this.boundaries.left,i,this.boundaries)&&this.adjustPositionY(i)}adjustPositionX(e){let t=this.sheetId,{start:n,end:r}=this.getters.getColDimensions(t,e);this.offsetX+this.viewportWidth+this.offsetCorrectionX<r?this.offsetX=r-this.viewportWidth-this.offsetCorrectionX:this.offsetX+this.offsetCorrectionX>n&&(this.offsetX=n-this.offsetCorrectionX),this.adjustViewportZoneX()}adjustPositionY(e){let t=this.sheetId,{start:n,end:r}=this.getters.getRowDimensions(t,e);this.offsetY+this.viewportHeight+this.offsetCorrectionY<r?this.offsetY=r-this.viewportHeight-this.offsetCorrectionY:this.offsetY+this.offsetCorrectionY>n&&(this.offsetY=n-this.offsetCorrectionY),this.adjustViewportZoneY()}willNewOffsetScrollViewport(e,t){return this.canScrollHorizontally&&this.offsetX!==e||this.canScrollVertically&&this.offsetY!==t}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}getVisibleRect(e){let t=En(e,this),n=this.snapCorrection.x,r=this.snapCorrection.y;if(t)return{x:this.getters.getColRowOffset(`COL`,this.left,t.left)+this.offsetCorrectionX-(this.left===t.left?0:n),y:this.getters.getColRowOffset(`ROW`,this.top,t.top)+this.offsetCorrectionY-(this.top===t.top?0:r),width:Math.min(this.getters.getColRowOffset(`COL`,t.left,t.right+1)-(this.left===t.left?n:0),this.viewportWidth),height:Math.min(this.getters.getColRowOffset(`ROW`,t.top,t.bottom+1)-(this.top===t.top?r:0),this.viewportHeight)}}getFullRect(e){let t=En(e,this.boundaries),n=this.snapCorrection.x,r=this.snapCorrection.y;if(t){let t=this.getters.getColRowOffset(`COL`,this.left,e.left)+this.offsetCorrectionX,i=this.getters.getColRowOffset(`ROW`,this.top,e.top)+this.offsetCorrectionY,a=this.getters.getColRowOffset(`COL`,e.left,e.right+1),o=this.getters.getColRowOffset(`ROW`,e.top,e.bottom+1);return{x:t-n,y:i-r,width:a,height:o}}}isVisible(e,t){return t<=this.bottom&&t>=this.top&&e>=this.left&&e<=this.right&&!this.getters.isColHidden(this.sheetId,e)&&!this.getters.isRowHidden(this.sheetId,t)}searchHeaderIndex(e,t,n=0){if(this.viewportWidth<=0||this.viewportHeight<=0)return-1;let r=this.sheetId,i=this.getters.getNumberHeaders(r,e),a=n,o=i;for(;a<=o&&a!==i&&o!==-1;){let i=Math.floor((a+o)/2),s=this.getters.getColRowOffset(e,n,i),c=this.getters.getHeaderSize(r,e,i);if(t>=s&&t<s+c)return i;t>=s+c?a=i+1:o=i-1}return-1}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){let{width:e}=this.getMaxSize();this.viewportWidth+this.offsetX>e&&(this.offsetX=Math.max(0,e-this.viewportWidth))}this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){let{height:e}=this.getMaxSize();this.viewportHeight+this.offsetY>e&&(this.offsetY=Math.max(0,e-this.viewportHeight))}this.adjustViewportZoneY()}adjustViewportZoneX(){this.left=this.searchHeaderIndex(`COL`,this.offsetX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex(`COL`,Math.max(this.viewportWidth+this.snapCorrection.x-.1),this.left)),this.viewportWidth&&(this.left===-1&&(this.left=this.boundaries.left),this.right===-1&&(this.right=this.boundaries.right))}adjustViewportZoneY(){this.top=this.searchHeaderIndex(`ROW`,this.offsetY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex(`ROW`,Math.max(this.viewportHeight+this.snapCorrection.y-.1,0),this.top)),this.viewportHeight&&(this.top===-1&&(this.top=this.boundaries.top),this.bottom===-1&&(this.bottom=this.boundaries.bottom))}get snapCorrection(){return{x:Math.abs(this.offsetX-this.getters.getColRowOffset(`COL`,this.boundaries.left,Math.max(0,this.left))),y:Math.abs(this.offsetY-this.getters.getColRowOffset(`ROW`,this.boundaries.top,Math.max(0,this.top)))}}},Kq=class extends lK{static getters=`getColIndex.getRowIndex.getActiveMainViewport.getSheetViewDimension.getSheetViewDimensionWithHeaders.getMainViewportRect.isVisibleInViewport.getEdgeScrollCol.getEdgeScrollRow.getVisibleFigures.getVisibleRect.getVisibleRectWithoutHeaders.getVisibleRectWithZoom.getVisibleCellPositions.getColRowOffsetInViewport.getMainViewportCoordinates.getActiveSheetScrollInfo.getSheetViewVisibleCols.getSheetViewVisibleRows.getFrozenSheetViewRatio.isPixelPositionVisible.getColDimensionsInViewport.getRowDimensionsInViewport.getAllActiveViewportsZonesAndRect.getRect.getFigureUI.getPositionAnchorOffset.getGridOffset.getViewportZoomLevel.getScrollBarWidth.getMaximumSheetOffset`.split(`.`);viewports={};sheetViewWidth=Fe();sheetViewHeight=Fe();gridOffsetX=0;gridOffsetY=0;zoomLevel=1;sheetsWithDirtyViewports=new Set;shouldAdjustViewports=!1;allowDispatch(e){switch(e.type){case`SET_VIEWPORT_OFFSET`:return this.chainValidations(this.checkScrollingDirection,this.checkIfViewportsWillChange)(e);case`RESIZE_SHEETVIEW`:return this.chainValidations(this.checkValuesAreDifferent,this.checkPositiveDimension)(e);case`SET_ZOOM`:return e.zoom>2||e.zoom<.5?`InvalidZoomLevel`:`Success`;default:return`Success`}}handleEvent(e){let t=this.getters.getActiveSheetId();if(e.options.scrollIntoView){let n=e.previousAnchor.zone,r=e.anchor.zone,i=e.mode===`updateAnchor`,a=Dn(n,r),{col:o,row:s}=i&&a?e.anchor.cell:Vn(n,r);if(i&&!a){let{top:e,bottom:i,left:a,right:c}=this.getMainInternalViewport(t);n.left===r.left&&n.right===r.right&&(o=a>o||o>c?a:o),n.top===r.top&&n.bottom===r.bottom&&(s=e>s||s>i?e:s)}o=Math.min(o,this.getters.getNumberCols(t)-1),s=Math.min(s,this.getters.getNumberRows(t)-1),this.sheetsWithDirtyViewports.has(t)||this.refreshViewport(this.getters.getActiveSheetId(),{col:o,row:s})}}handle(e){if(Rs.has(e.type))for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);switch(e.type){case`START`:this.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.resetViewports(this.getters.getActiveSheetId());break;case`UNDO`:case`REDO`:this.cleanViewports();for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);this.shouldAdjustViewports=!0;break;case`RESIZE_SHEETVIEW`:this.resizeSheetView(e.height,e.width,e.gridOffsetX,e.gridOffsetY);break;case`SET_VIEWPORT_OFFSET`:this.setSheetViewOffset(e.offsetX,e.offsetY);break;case`SET_ZOOM`:this.zoomLevel=e.zoom||1;break;case`SHIFT_VIEWPORT_DOWN`:let t=this.getters.getActiveSheetId(),{top:n,viewportHeight:r,offsetCorrectionY:i}=this.getMainInternalViewport(t),a=this.getters.getRowDimensions(t,n);this.shiftVertically(a.start+r-i);break;case`SHIFT_VIEWPORT_UP`:{let e=this.getters.getActiveSheetId(),{top:t,viewportHeight:n,offsetCorrectionY:r}=this.getMainInternalViewport(e),i=this.getters.getRowDimensions(e,t);this.shiftVertically(i.end-r-n);break}case`REMOVE_TABLE`:case`UPDATE_TABLE`:case`UPDATE_FILTER`:case`UNFREEZE_ROWS`:case`UNFREEZE_COLUMNS`:case`FREEZE_COLUMNS`:case`FREEZE_ROWS`:case`UNFREEZE_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:case`RESIZE_COLUMNS_ROWS`:case`HIDE_COLUMNS_ROWS`:case`ADD_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`UNGROUP_HEADERS`:case`GROUP_HEADERS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_ALL_HEADER_GROUPS`:this.sheetsWithDirtyViewports.add(e.sheetId);break;case`UPDATE_CELL`:case`SET_FORMATTING`:for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);break;case`DELETE_SHEET`:this.cleanViewports(),this.sheetsWithDirtyViewports.delete(e.sheetId);break;case`ACTIVATE_SHEET`:this.sheetsWithDirtyViewports.add(e.sheetIdTo);break;case`SCROLL_TO_CELL`:this.refreshViewport(this.getters.getActiveSheetId(),{col:e.col,row:e.row});break}}finalize(){for(let e of this.sheetsWithDirtyViewports)if(this.resetViewports(e),this.shouldAdjustViewports){let t=this.getters.getSheetPosition(e);this.getSubViewports(e).forEach(e=>{e.adjustPosition(t)})}this.sheetsWithDirtyViewports=new Set,this.shouldAdjustViewports=!1,this.setViewports()}setViewports(){let e=this.getters.getSheetIds();for(let t of e)this.viewports[t]?.bottomRight||this.resetViewports(t)}getColIndex(e){let t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map(t=>t.getColIndex(e)))}getRowIndex(e){let t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map(t=>t.getRowIndex(e)))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getGridOffset(){return{x:this.gridOffsetX,y:this.gridOffsetY}}getActiveMainViewport(){let e=this.getters.getActiveSheetId();return this.getMainViewport(e)}getActiveSheetScrollInfo(){let e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getSheetViewVisibleCols(){let e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map(e=>S(e.left,e.right+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`COL`,t))}getSheetViewVisibleRows(){let e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map(e=>S(e.top,e.bottom+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`ROW`,t))}getVisibleCellPositions(){let e=this.getSheetViewVisibleCols(),t=this.getSheetViewVisibleRows(),n=this.getters.getActiveSheetId(),r=[];for(let i of e)for(let e of t){let t={sheetId:n,col:i,row:e},a=this.getters.getMainCellPosition(t);a.row!==e||a.col!==i||r.push(t)}return r}getMainViewportRect(){let e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e),{xSplit:n,ySplit:r}=this.getters.getPaneDivisions(e),{width:i,height:a}=t.getMaxSize();return{x:this.getters.getColDimensions(e,n).start,y:this.getters.getRowDimensions(e,r).start,width:i,height:a}}getMaximumSheetOffset(){let e=this.getters.getActiveSheetId(),{width:t,height:n}=this.getMainViewportRect(),r=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-r.viewportWidth),maxOffsetY:Math.max(0,n-r.viewportHeight)}}getColRowOffsetInViewport(e,t,n){if(n<t)return-this.getColRowOffsetInViewport(e,n,t);let r=this.getters.getActiveSheetId(),i=e===`COL`?this.getters.getSheetViewVisibleCols():this.getters.getSheetViewVisibleRows(),a=i.findIndex(e=>t>=e),o=i.findIndex(e=>n<=e);o=o===-1?i.length:o;let s=i.slice(a,o),c=0;for(let t of s)c+=this.getters.getHeaderSize(r,e,t);return c*this.zoomLevel}isVisibleInViewport({sheetId:e,col:t,row:n}){return this.getSubViewports(e).some(e=>e.isVisible(t,n))}getScrollBarWidth(){return 15/this.zoomLevel}getEdgeScrollCol(e,t,n){let r=!1,i=0,a=0,{xSplit:o}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:s}=this.getSheetViewDimension(),{x:c}=this.getMainViewportCoordinates(),l=this.getActiveSheetScrollInfo().scrollX;return e>s?(r=!0,a=Ec(e-s),i=1):e<c&&n>=c&&l>0?(r=!0,a=Ec(c-e),i=-1):o&&t<c&&e>c&&(r=!0,a=Ec(e),i=`reset`),{canEdgeScroll:r,direction:i,delay:a}}getEdgeScrollRow(e,t,n){let r=!1,i=0,a=0,{ySplit:o}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:s}=this.getSheetViewDimension(),{y:c}=this.getMainViewportCoordinates(),l=this.getActiveSheetScrollInfo().scrollY;return e>s?(r=!0,a=Ec(e-s),i=1):e<c&&n>=c&&l>0?(r=!0,a=Ec(c-e),i=-1):o&&t<c&&e>c&&(r=!0,a=Ec(e),i=`reset`),{canEdgeScroll:r,direction:i,delay:a}}getVisibleRect(e){let t=this.getVisibleRectWithoutHeaders(e);return{...t,x:t.x+this.gridOffsetX,y:t.y+this.gridOffsetY}}getVisibleRectWithZoom(e){let t=this.getViewportZoomLevel(),n=this.getVisibleRectWithoutHeaders(e);return n.width*=t,n.height*=t,n.x=n.x*t+this.gridOffsetX*t,n.y=n.y*t+this.gridOffsetY*t,n}getVisibleRectWithoutHeaders(e){let t=this.getters.getActiveSheetId();return this.mapViewportsToRect(t,t=>t.getVisibleRect(e))}getRect(e){let t=this.getters.getActiveSheetId(),n=this.mapViewportsToRect(t,t=>t.getFullRect(e));return{...n,x:n.x+this.gridOffsetX,y:n.y+this.gridOffsetY}}getRectWithoutHeaders(e){let t=this.getters.getActiveSheetId();return this.mapViewportsToRect(t,t=>t.getFullRect(e))}getMainViewportCoordinates(){let e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,n).start}}getColDimensionsInViewport(e,t){let{top:n}=this.getMainInternalViewport(e),r={left:t,right:t,top:n,bottom:n},{x:i,width:a}=this.getVisibleRect(r),o=i-this.gridOffsetX;return{start:o,size:a,end:o+a}}getRowDimensionsInViewport(e,t){let{left:n}=this.getMainInternalViewport(e),r={left:0,right:n,top:t,bottom:t},{y:i,height:a}=this.getVisibleRect(r),o=i-this.gridOffsetY;return{start:o,size:a,end:o+a}}getAllActiveViewportsZonesAndRect(){let e=this.getters.getActiveSheetId();return this.getSubViewports(e).map(e=>({zone:e,rect:{x:e.offsetCorrectionX+this.gridOffsetX,y:e.offsetCorrectionY+this.gridOffsetY,...e.getMaxSize()}}))}getViewportZoomLevel(){return this.zoomLevel}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(C)}checkPositiveDimension(e){return e.width<0||e.height<0?`InvalidViewportSize`:`Success`}checkValuesAreDifferent(e){let{height:t,width:n}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===n&&e.height===t?`ValuesNotChanged`:`Success`}checkScrollingDirection({offsetX:e,offsetY:t}){let n=this.getMainInternalViewport(this.getters.getActiveSheetId());return!n.canScrollHorizontally&&e>0||!n.canScrollVertically&&t>0?`InvalidScrollingDirection`:`Success`}checkIfViewportsWillChange({offsetX:e,offsetY:t}){let n=this.getters.getActiveSheetId(),{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset();return this.getSubViewports(n).some(n=>n.willNewOffsetScrollViewport(x(e,0,r),x(t,0,i)))?`Success`:`ViewportScrollLimitsReached`}getMainViewport(e){let t=this.getMainInternalViewport(e);return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}getMainInternalViewport(e){return this.ensureMainViewportExist(e),this.viewports[e].bottomRight}cleanViewports(){let e={};for(let t of this.getters.getSheetIds())e[t]=this.viewports[t];this.viewports=e}resizeSheetView(e,t,n=0,r=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=n,this.gridOffsetY=r,this.recomputeViewports()}recomputeViewports(){for(let e of this.getters.getSheetIds())this.resetViewports(e)}setSheetViewOffset(e,t){let n=this.getters.getActiveSheetId(),{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset();this.getSubViewports(n).forEach(n=>n.setViewportOffset(x(e,0,r),x(t,0,i)))}getViewportOffset(e){return{x:this.viewports[e]?.bottomRight.offsetX||0,y:this.viewports[e]?.bottomRight.offsetY||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;let{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e),r=this.getters.getNumberCols(e),i=this.getters.getNumberRows(e),a=Math.min(this.getters.getColRowOffset(`COL`,0,t,e),this.sheetViewWidth),o=Math.min(this.getters.getColRowOffset(`ROW`,0,n,e),this.sheetViewHeight),s=Math.max(this.sheetViewWidth-a,0),c=Math.max(this.sheetViewHeight-o,0),{xRatio:l,yRatio:u}=this.getFrozenSheetViewRatio(e),d=l<1,f=u<1,p=this.getViewportOffset(e),m={topLeft:n&&t&&new Gq(this.getters,e,{left:0,right:t-1,top:0,bottom:n-1},{width:a,height:o},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:n&&new Gq(this.getters,e,{left:t,right:r-1,top:0,bottom:n-1},{width:s,height:o},{canScrollHorizontally:d,canScrollVertically:!1},{x:d?p.x:0,y:0})||void 0,bottomLeft:t&&new Gq(this.getters,e,{left:0,right:t-1,top:n,bottom:i-1},{width:a,height:c},{canScrollHorizontally:!1,canScrollVertically:f},{x:0,y:f?p.y:0})||void 0,bottomRight:new Gq(this.getters,e,{left:t,right:r-1,top:n,bottom:i-1},{width:s,height:c},{canScrollHorizontally:d,canScrollVertically:f},{x:d?p.x:0,y:f?p.y:0})};this.viewports[e]=m}refreshViewport(e,t){this.getSubViewports(e).forEach(e=>{e.adjustViewportZone(),e.adjustPosition(t)})}shiftVertically(e){let t=this.getters.getActiveSheetId(),{top:n}=this.getMainInternalViewport(t),{scrollX:r}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(r,e);let{anchor:i}=this.getters.getSelection();if(i.cell.row>=this.getters.getPaneDivisions(t).ySplit){let e=this.getMainInternalViewport(t).top-n;this.selection.selectCell(i.cell.col,i.cell.row+e)}}getColIndexLeftOfMainViewport(e){if(e>=0)return-1;let t=this.getters.getActiveSheetId(),n=this.getActiveMainViewport().left,r=-this.getActiveSheetScrollInfo().scrollX-this.getters.getColRowOffset(`COL`,n,0);for(;e<r;n--)r-=this.getters.getColSize(t,n-1);return Math.max(n,0)}getRowIndexTopOfMainViewport(e){if(e>=0)return-1;let t=this.getters.getActiveSheetId(),n=this.getActiveMainViewport().top,r=-this.getActiveSheetScrollInfo().scrollY-this.getters.getColRowOffset(`ROW`,n,0);for(;e<r;n--)r-=this.getters.getRowSize(t,n-1);return Math.max(n,0)}getVisibleFigures(){let e=this.getters.getActiveSheetId(),t=[],n=this.getters.getFigures(e),{scrollX:r,scrollY:i}=this.getters.getActiveSheetScrollInfo(),{x:a,y:o}=this.getMainViewportCoordinates(),{width:s,height:c}=this.getters.getSheetViewDimensionWithHeaders();for(let l of n){let n=this.getFigureUI(e,l),{x:u,y:d}=n;u>=a&&(u+l.width<r+a||u>s+r+a)||d>=o&&(d+l.height<i+o||d>c+i+o)||t.push(n)}return t}getFigureUI(e,t){let n=t.offset.x+this.getters.getColDimensions(e,t.col).start,r=t.offset.y+this.getters.getRowDimensions(e,t.row).start;return{...t,x:n,y:r}}getPositionAnchorOffset(e){let{scrollX:t,scrollY:n}=this.getters.getActiveSheetScrollInfo(),r=e.x-t,i=e.y-n,a=r>=0?this.getColIndex(r):this.getColIndexLeftOfMainViewport(r),o=i>=0?this.getRowIndex(i):this.getRowIndexTopOfMainViewport(i),{x:s,y:c}=this.getRect(E({col:a,row:o}));return{col:a,row:o,offset:{x:Math.max(r-s+this.gridOffsetX,0),y:Math.max(i-c+this.gridOffsetY,0)}}}isPixelPositionVisible(e){let{scrollX:t,scrollY:n}=this.getters.getActiveSheetScrollInfo(),{x:r,y:i}=this.getters.getMainViewportCoordinates(),{width:a,height:o}=this.getters.getSheetViewDimension();return!(e.x>=r&&(e.x<r+t||e.x>a+t+r)||e.y>=i&&(e.y<i+n||e.y>o+n+i))}getFrozenSheetViewRatio(e){let{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e),r=this.getters.getColDimensions(e,t).start,i=this.getters.getRowDimensions(e,n).start,a=this.sheetViewWidth+this.gridOffsetX,o=this.sheetViewHeight+this.gridOffsetY;return{xRatio:r/a,yRatio:i/o}}mapViewportsToRect(e,t){let n=1/0,r=1/0,i=0,a=0,o=!1;for(let s of this.getSubViewports(e)){let e=t(s);e&&(o=!0,n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x+e.width),a=Math.max(a,e.y+e.height))}return o?{x:n,y:r,width:i-n,height:a-r}:{x:0,y:0,width:0,height:0}}};let qq=new B().add(`settings`,uG).add(`sheet`,dG).add(`header grouping`,nG).add(`header visibility`,iG).add(`tables`,mG).add(`dataValidation`,eG).add(`cell`,XW).add(`merge`,oG).add(`headerSize`,rG).add(`borders`,WW).add(`conditional formatting`,$W).add(`figures`,tG).add(`chart`,ZW).add(`carousel`,GW).add(`image`,aG).add(`pivot_core`,lG).add(`spreadsheet_pivot_core`,fG).add(`tableStyle`,pG),Jq=new B().add(`ui_sheet`,Lq).add(`ui_options`,Iq).add(`autofill`,wK).add(`sort`,jq).add(`automatic_sum`,TK).add(`format`,_q).add(`insert_pivot`,bq).add(`pivot_presence`,Aq).add(`split_to_columns`,Mq).add(`subtotal_evaluation`,Nq).add(`collaborative`,mq).add(`history`,Dq).add(`table_autofill`,Pq).add(`table_ui_resize`,Fq).add(`datavalidation_insert`,hq).add(`checkbox_toggle`,AK).add(`dynamic_translate`,gq).add(`geo_features`,vq).add(`data_cleanup`,uK),Yq=new B().add(`selection`,Wq).add(`evaluation_filter`,Hq).add(`header_visibility_ui`,yq).add(`cell_computed_style`,kK).add(`table_computed_style`,EK).add(`header_positions`,Uq).add(`viewport`,Kq).add(`clipboard`,Bq).add(`carousel_ui`,Rq).add(`lock_sheet`,Oq),Xq=new B().add(`evaluation`,BG).add(`evaluation_chart`,JG).add(`evaluation_cf`,YG).add(`row_size`,eK).add(`data_validation_ui`,ZG).add(`dynamic_tables`,qG).add(`custom_colors`,KG).add(`pivot_ui`,aK).add(`cell_icon`,HG).add(`formula_tracker`,$G);EN.add(`dataValidation`,{displayAllOnInitialContent:!0,canBeToggled:!1,getProposals(e,t){if(Ut(t)||!this.composer.currentEditedCell)return[];let n=this.composer.currentEditedCell,r=this.getters.getValidationRuleForCell(n);if(!r||r.criterion.type!==`isValueInList`&&r.criterion.type!==`isValueInRange`)return[];let i=this.composer.currentEditedCell.sheetId,a=r.criterion.type===`isValueInRange`?this.getters.getDataValidationRangeValues(i,r.criterion):r.criterion.values.map(e=>({label:e,value:e}));if(r.criterion.displayStyle!==`chip`)return a.map(e=>({text:e.value,fuzzySearchKey:e.label,htmlContent:[{value:e.label}]}));let o=r.criterion.colors;return a.map(e=>{let t=o?.[e.value];return{text:e.value,htmlContent:[{value:e.label,color:qr(t||`#E7E9ED`),backgroundColor:t||`#E7E9ED`,classes:[`badge rounded-pill fs-6 fw-normal w-100 mt-1 text-start`]}],fuzzySearchKey:e.label}})},selectProposal(e,t){this.composer.setCurrentContent(t),this.composer.stopEdition()}}),EN.add(`functions`,{sequence:100,autoSelectFirstProposal:!0,maxDisplayedProposals:10,getProposals(e){if(e.type!==`SYMBOL`)return[];let t=e.value;return Ut(this.composer.currentContent)?Object.entries(fO.content).filter(([e,{hidden:t}])=>!t).map(([e,{description:n}])=>({text:e,description:n,htmlContent:oz(t,e,le,`o-semi-bold`)})).sort((e,t)=>e.text.length-t.text.length||e.text.localeCompare(t.text)):[]},selectProposal(e,t){let n=e.end,r=e.end;[`SYMBOL`,`FUNCTION`].includes(e.type)&&(n=e.start);let i=this.composer.currentTokens;t+=`(`;let a=i.map(e=>e.start).indexOf(e.start);a+1<i.length&&i[a+1]?.type===`LEFT_PAREN`&&r++,this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t)}});function Zq(e,t){for(let n=0;n<t.length;n++){let r=t[n].proposalValues;r===void 0||r.length===0||EN.add(`${e}_function_${t[n].name}_argument_proposals`,{sequence:50,autoSelectFirstProposal:!0,selectProposal:Qq,getProposals:t=>{let i=t.functionContext;if(!i||i.parent.toUpperCase()!==e.toUpperCase()||i.argPosition!==n)return;let a=[],o=``;for(let{value:e,label:t}of r){switch(typeof e){case`string`:o=`"${e}"`;break;case`number`:o=e.toString();break;case`boolean`:o=e?`TRUE`:`FALSE`;break;default:}a.push({text:o,description:t,htmlContent:[{value:o,color:typeof e==`string`?We.STRING:We.NUMBER}],fuzzySearchKey:o,alwaysExpanded:!0})}return a}})}}function Qq(e,t){let n=e.end,r=e.end;[`LEFT_PAREN`,`ARG_SEPARATOR`].includes(e.type)||(n=e.start),this.composer.stopComposerRangeSelection(),this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t)}fO.getAll().forEach(e=>Zq(e.name,e.args)),EN.add(`pivot_ids`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||![`PIVOT.VALUE`,`PIVOT.HEADER`,`PIVOT`].includes(t.parent.toUpperCase())||t.argPosition!==0)return;let n=this.getters.getPivotIds();if(!n.includes(e.value))return n.map(e=>{let t=this.getters.getPivotCoreDefinition(e),n=`${this.getters.getPivotFormulaId(e)}`;return{text:n,description:t.name,htmlContent:[{value:n,color:We.NUMBER}],fuzzySearchKey:n+t.name,alwaysExpanded:!0}}).filter(C)},selectProposal:Qq}),EN.add(`pivot_measures`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(t?.parent.toUpperCase()!==`PIVOT.VALUE`||t.argPosition!==1)return[];let n=wB(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return[];let i=this.getters.getPivot(r);return i.init(),i.isValid()?i.definition.measures.map(e=>{if(e.fieldName===`__count`){let e=`"__count"`;return{text:e,description:k(`Count`),htmlContent:[{value:e,color:We.STRING}],fuzzySearchKey:k(`Count`)+e}}return xB(e)}).filter(C):[]},selectProposal:Qq}),EN.add(`pivot_group_fields`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!$q(e)&&!eJ(e))return;let n=wB(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return;let i=this.getters.getPivot(r);i.init();let a=i.getFields(),{columns:o,rows:s}=i.definition,c=t.args;t?.parent.toUpperCase()===`PIVOT.VALUE`?(c=c.filter((e,t)=>t%2==0),c=c.slice(1,t.argPosition)):c=c.filter((e,t)=>t%2==1);let l=c.map(e=>e?.value).filter(C),u=o.map(e=>e.nameWithGranularity),d=s.map(e=>e.nameWithGranularity),f=[],p=[`ARG_SEPARATOR`,`SPACE`].includes(e.type)?l.at(-1):l.at(-2),m=RW.get(i.type);if(m&&p?.startsWith(`#`)&&(p=p.slice(1)),p===void 0&&(f.push(u[0]),f.push(d[0])),d.includes(p)){let e=d[d.indexOf(p)+1];f.push(e),f.push(u[0])}if(u.includes(p)){let e=u[u.indexOf(p)+1];f.push(e)}let h=f.filter(C);return h.map(e=>{let[t,n]=e.split(`:`),r=a[t];return r?bB(r,n):void 0}).concat(h.map(e=>{if(!m)return;let t=a[e.split(`:`)[0]];if(!t)return;let n=`"#${e}"`;return{text:n,description:k(`%s (positional)`,t.string)+(t.help?` (${t.help})`:``),htmlContent:[{value:n,color:We.STRING}],fuzzySearchKey:t.string+n}})).filter(C)},selectProposal:Qq});function $q(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==0}function eJ(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==1}EN.add(`pivot_group_values`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!e||!tJ(e)&&!nJ(e))return;let n=wB(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return;let i=this.getters.getPivot(r);if(!i.isValid())return;let a=t.argPosition,o=e.functionContext?.args[a-1]?.value;if(!o)return;let s;try{s=i.definition.getDimension(o)}catch{return}return s.granularity===`month_number`?Object.values(Wo).map((e,t)=>({text:`${t+1}`,fuzzySearchKey:e.toString(),description:e.toString(),htmlContent:[{value:`${t+1}`,color:We.NUMBER}]})):s.granularity===`quarter_number`?[1,2,3,4].map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:k(`Quarter %s`,e),htmlContent:[{value:`${e}`,color:We.NUMBER}]})):s.granularity===`day_of_month`?S(1,32).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:We.NUMBER}]})):s.granularity===`iso_week_number`?S(0,54).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:We.NUMBER}]})):s.granularity===`day_of_week`?S(1,8).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:We.NUMBER}]})):s.granularity===`hour_number`?S(0,24).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:We.NUMBER}]})):s.granularity===`minute_number`?S(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:We.NUMBER}]})):s.granularity===`second_number`?S(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:We.NUMBER}]})):i.getPossibleFieldValues(s).map(({value:e,label:t})=>{let n=typeof e==`string`,r=n?`"${e}"`:e.toString(),i=n?We.STRING:We.NUMBER,a=t===e?``:t;return{text:r,description:a,htmlContent:[{value:r,color:i}],fuzzySearchKey:r+a}})},selectProposal:Qq});function tJ(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==1}function nJ(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==0}EN.add(`sheet_names`,{sequence:150,autoSelectFirstProposal:!0,getProposals(e){return e.type===`SYMBOL`||e.type===`UNKNOWN`&&e.value.startsWith(`'`)?this.getters.getSheetIds().map(e=>{let t=Ze(this.getters.getSheetName(e));return{text:t,fuzzySearchKey:t.startsWith(`'`)?t:`'`+t}}):[]},selectProposal(e,t){let n=e.start,r=e.end;this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t+`!`)}});let rJ=new B;rJ.add(`link`,{condition:(e,t)=>!!t.getEvaluatedCell(e).link,execute:(e,t,n)=>ic(t.model.getters.getEvaluatedCell(e).link,t,n),title:(e,t)=>{let n=t.getEvaluatedCell(e).link;return n?n.isExternal?k(`Go to url: %(url)s`,{url:n.url}):k(`Go to %(label)s`,{label:n.label}):``},sequence:5}),rJ.add(`dashboard_pivot_sorting`,{condition:(e,t)=>{if(!t.isDashboard())return!1;let n=t.getPivotCellFromPosition(e);return HH(t,e)&&n.type===`MEASURE_HEADER`},execute:(e,t)=>{UH(t,e,aJ(t.model.getters,e))},component:zW,componentProps:(e,t)=>({position:e,sortDirection:t.getPivotCellSortDirection(e)}),sequence:2});let iJ={none:`asc`,asc:`desc`,desc:`none`};function aJ(e,t){return iJ[e.getPivotCellSortDirection(t)??`none`]}VG.add(`filter_icon`,(e,t)=>{if(e.isFilterHeader(t)){let n=e.isFilterActive(t),r=Nr(e.getCellComputedStyle(t).fillColor||`#fff`)<.45;return{type:`filter_icon`,svg:PO(n,r,!1),hoverSvg:PO(n,r,!0),priority:3,horizontalAlign:`right`,size:17,margin:2,position:t,onClick:(e,t)=>{let n=t.getStore(sP),r=n.persistentCellPopover;if(r.isOpen&&r.col===e.col&&r.row===e.row&&r.type===`FilterMenu`){n.close();return}n.open(e,`FilterMenu`)}}}});let oJ=new B().add(`ADD_COLUMNS_ROWS`,lJ).add(`REMOVE_COLUMNS_ROWS`,mJ).add(`ADD_MERGE`,uJ).add(`REMOVE_MERGE`,dJ).add(`CREATE_SHEET`,fJ).add(`DELETE_SHEET`,hJ).add(`DUPLICATE_SHEET`,pJ).add(`CREATE_FIGURE`,gJ).add(`CREATE_CHART`,_J).add(`HIDE_COLUMNS_ROWS`,vJ).add(`UNHIDE_COLUMNS_ROWS`,yJ).add(`CREATE_TABLE_STYLE`,bJ).add(`ADD_PIVOT`,cJ).add(`RENAME_SHEET`,xJ).add(`LOCK_SHEET`,SJ).add(`UNLOCK_SHEET`,CJ);for(let e of Ks.values())oJ.contains(e)||oJ.add(e,sJ);function sJ(e){return[e]}function cJ(e){return[{type:`REMOVE_PIVOT`,pivotId:e.pivotId}]}function lJ(e){let t=[],n=e.base;e.position===`after`&&n++;for(let r=0;r<e.quantity;r++)t.push(r+n);return[{type:`REMOVE_COLUMNS_ROWS`,dimension:e.dimension,elements:t,sheetId:e.sheetId,sheetName:e.sheetName}]}function uJ(e){return[{type:`REMOVE_MERGE`,sheetId:e.sheetId,target:e.target}]}function dJ(e){return[{type:`ADD_MERGE`,sheetId:e.sheetId,target:e.target}]}function fJ(e){return[{type:`DELETE_SHEET`,sheetId:e.sheetId,sheetName:e.name}]}function pJ(e){return[{type:`DELETE_SHEET`,sheetId:e.sheetIdTo,sheetName:``}]}function mJ(e){let t=[],n=[...e.elements].sort((e,t)=>e-t);for(let r of $e(n)){let n=r[0]===0?0:r[0]-1,i=r[0]===0?`before`:`after`;t.push({type:`ADD_COLUMNS_ROWS`,dimension:e.dimension,quantity:r.length,base:n,sheetId:e.sheetId,sheetName:e.sheetName,position:i})}return t}function hJ(e){return[{type:`CREATE_SHEET`,sheetId:e.sheetId,position:1,name:e.sheetName}]}function gJ(e){return[{type:`DELETE_FIGURE`,figureId:e.figureId,sheetId:e.sheetId}]}function _J(e){return[{type:`DELETE_FIGURE`,figureId:e.figureId,sheetId:e.sheetId}]}function vJ(e){return[{type:`UNHIDE_COLUMNS_ROWS`,sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}function yJ(e){return[{type:`HIDE_COLUMNS_ROWS`,sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}function bJ(e){return[{type:`REMOVE_TABLE_STYLE`,tableStyleId:e.tableStyleId}]}function xJ(e){return[{type:`RENAME_SHEET`,sheetId:e.sheetId,oldName:e.newName,newName:e.oldName}]}function SJ(e){return[{type:`UNLOCK_SHEET`,sheetId:e.sheetId}]}function CJ(e){return[{type:`LOCK_SHEET`,sheetId:e.sheetId}]}let wJ=new B;wJ.add(`format_number_automatic`,{...KL,id:`format_number_automatic`,sequence:10}).add(`format_number_plain_text`,{...qL,id:`format_number_plain_text`,sequence:15,separator:!0}).add(`format_number_number`,{...JL,id:`format_number_number`,sequence:20}).add(`format_number_percent`,{...XL,id:`format_number_percent`,sequence:30,separator:!1}).add(`format_number_scientific`,{...ZL,id:`format_number_scientific`,sequence:33,separator:!0}).add(`format_number_currency`,{...QL,id:`format_number_currency`,sequence:40}).add(`format_number_accounting`,{...eR,id:`format_number_accounting`,sequence:45}).add(`format_number_currency_rounded`,{...$L,id:`format_number_currency_rounded`,sequence:50,separator:!0}).add(`format_number_date`,{...rR,id:`format_number_date`,sequence:70}).add(`format_number_time`,{...iR,id:`format_number_time`,sequence:80}).add(`format_number_date_time`,{...aR,id:`format_number_date_time`,sequence:90}).add(`format_number_duration`,{...oR,id:`format_number_duration`,sequence:100,separator:!0}).add(`format_custom_currency`,{...nR,id:`format_custom_currency`,sequence:120}).add(`format_custom_date`,{...sR,id:`format_custom_date`,sequence:130}).add(`format_custom_number`,{...cR,id:`format_custom_number`,sequence:140});function TJ(e){let t=new Set(wJ.getAll().map(t=>typeof t.format==`function`?t.format(e):t.format)),n=new Map;for(let r of e.model.getters.getSheetIds()){let i=e.model.getters.getEvaluatedCells(r);for(let e in i){let r=i[e];if(r.format&&!n.has(r.format)&&!t.has(r.format)){let e=EJ(r.format);(e===`date`||e===`currency`)&&n.set(r.format,GL({descriptionValue:e===`currency`?1e3:tR,format:r.format,name:r.format}))}}}return[...n.values()]}let EJ=At(e=>os(e)?`date`:e.includes(`[$`)?`currency`:`number`),DJ={name:k(`More formats`),icon:`o-spreadsheet-Icon.NUMBER_FORMATS`,children:[e=>{let t=TJ(e).map(e=>({...e,sequence:110}));return t.length>0&&(t[t.length-1].separator=!0),[...wJ.getAll(),...t]}]};function OJ(e){let t=new bP;return t.add(`delete`,{...dP,sequence:10}).add(`hide_sheet`,{..._P,sequence:20}).add(`duplicate`,{...fP,sequence:30,separator:!0}).add(`rename`,{...pP(e),sequence:40}).add(`change_color`,{...mP(e),sequence:50,separator:!0}).add(`protect_sheet`,{...vP,sequence:60}).add(`remove_sheet_protection`,{...yP,sequence:70}).add(`move_right`,{...hP,sequence:80}).add(`move_left`,{...gP,sequence:90}),t}let kJ=new bP;kJ.add(`file`,{name:k(`File`),sequence:10}).addChild(`settings`,[`file`],{name:k(`Settings`),sequence:200,execute:e=>e.openSidePanel(`Settings`),isEnabled:e=>!e.isSmall,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.COG`}).add(`edit`,{name:k(`Edit`),sequence:20}).addChild(`undo`,[`edit`],{...aH,sequence:10}).addChild(`redo`,[`edit`],{...oH,sequence:20,separator:!0}).addChild(`copy`,[`edit`],{...sH,sequence:30}).addChild(`cut`,[`edit`],{...cH,sequence:40}).addChild(`paste`,[`edit`],{...lH,sequence:50}).addChild(`paste_special`,[`edit`],{...uH,sequence:60,separator:!0}).addChild(`paste_special_value`,[`edit`,`paste_special`],{...dH,sequence:10}).addChild(`paste_special_format`,[`edit`,`paste_special`],{...fH,sequence:20}).addChild(`edit_table`,[`edit`],{...TH,isVisible:TF,sequence:60}).addChild(`find_and_replace`,[`edit`],{...pH,sequence:65,separator:!0}).addChild(`delete`,[`edit`],{name:k(`Delete`),icon:`o-spreadsheet-Icon.TRASH`,sequence:70}).addChild(`edit_delete_cell_values`,[`edit`,`delete`],{...mH,sequence:10}).addChild(`edit_delete_row`,[`edit`,`delete`],{...hH,sequence:20}).addChild(`edit_delete_column`,[`edit`,`delete`],{...vH,sequence:30}).addChild(`edit_delete_cell_shift_up`,[`edit`,`delete`],{...SH,sequence:40}).addChild(`edit_delete_cell_shift_left`,[`edit`,`delete`],{...CH,sequence:50}).addChild(`edit_unhide_columns`,[`edit`],{...AV,sequence:80}).addChild(`edit_unhide_rows`,[`edit`],{...NV,sequence:80}).add(`view`,{name:k(`View`),sequence:30}).addChild(`unfreeze_panes`,[`view`],{...PV,sequence:4}).addChild(`freeze_panes`,[`view`],{...FV,sequence:5}).addChild(`unfreeze_rows`,[`view`,`freeze_panes`],{...IV,sequence:5}).addChild(`freeze_first_row`,[`view`,`freeze_panes`],{...LV,sequence:10}).addChild(`freeze_second_row`,[`view`,`freeze_panes`],{...RV,sequence:15}).addChild(`freeze_current_row`,[`view`,`freeze_panes`],{...zV,sequence:20,separator:!0}).addChild(`unfreeze_columns`,[`view`,`freeze_panes`],{...BV,sequence:25}).addChild(`freeze_first_col`,[`view`,`freeze_panes`],{...VV,sequence:30}).addChild(`freeze_second_col`,[`view`,`freeze_panes`],{...HV,sequence:35}).addChild(`freeze_current_col`,[`view`,`freeze_panes`],{...UV,sequence:40}).addChild(`group_headers`,[`view`],{name:k(`Group`),sequence:15,separator:!0,icon:`o-spreadsheet-Icon.PLUS_IN_BOX`,isVisible:jF}).addChild(`group_columns`,[`view`,`group_headers`],{...JV,sequence:5}).addChild(`ungroup_columns`,[`view`,`group_headers`],{...XV,isVisible:e=>eH(e,`COL`),sequence:10}).addChild(`group_rows`,[`view`,`group_headers`],{...YV,sequence:15}).addChild(`ungroup_rows`,[`view`,`group_headers`],{...ZV,isVisible:e=>eH(e,`ROW`),sequence:20}).addChild(`show`,[`view`],{name:k(`Show`),sequence:1,icon:`o-spreadsheet-Icon.SHOW`}).addChild(`view_gridlines`,[`view`,`show`],{...WV,sequence:5}).addChild(`view_formulas`,[`view`,`show`],{...qV,sequence:10}).addChild(`zoom`,[`view`],{name:k(`Zoom`),sequence:1,icon:`o-spreadsheet-Icon.ZOOM`}).addChild(`toggle_pin_panel`,[`view`],{...tH,sequence:6}).addChild(`view_irregularity_map`,[`view`],{...GV,sequence:40,separator:!0}).add(`insert`,{name:k(`Insert`),sequence:40}).addChild(`insert_row`,[`insert`],{...PF,sequence:10}).addChild(`insert_row_before`,[`insert`,`insert_row`],{...IF,sequence:10}).addChild(`insert_row_after`,[`insert`,`insert_row`],{...zF,sequence:20}).addChild(`insert_column`,[`insert`],{...BF,sequence:20}).addChild(`insert_column_before`,[`insert`,`insert_column`],{...HF,sequence:10}).addChild(`insert_column_after`,[`insert`,`insert_column`],{...GF,sequence:20}).addChild(`insert_cell`,[`insert`],{...KF,sequence:30}).addChild(`insert_cell_down`,[`insert`,`insert_cell`],{...qF,name:k(`Shift down`),sequence:10}).addChild(`insert_cell_right`,[`insert`,`insert_cell`],{...JF,name:k(`Shift right`),sequence:20}).addChild(`insert_sheet`,[`insert`],{...fI,sequence:40,separator:!0}).addChild(`insert_chart`,[`insert`],{...YF,sequence:50}).addChild(`insert_carousel`,[`insert`],{...XF,sequence:51}).addChild(`insert_pivot`,[`insert`],{...ZF,sequence:52}).addChild(`insert_image`,[`insert`],{...QF,sequence:55}).addChild(`insert_table`,[`insert`],{...$F,sequence:57}).addChild(`insert_function`,[`insert`],{...eI,sequence:60}).addChild(`insert_function_sum`,[`insert`,`insert_function`],{...tI,sequence:0}).addChild(`insert_function_average`,[`insert`,`insert_function`],{...nI,sequence:10}).addChild(`insert_function_count`,[`insert`,`insert_function`],{...rI,sequence:20}).addChild(`insert_function_max`,[`insert`,`insert_function`],{...iI,sequence:30}).addChild(`insert_function_min`,[`insert`,`insert_function`],{...aI,sequence:40,separator:!0}).addChild(`categorie_function_all`,[`insert`,`insert_function`],{...oI,sequence:50}).addChild(`categories_function_list`,[`insert`,`insert_function`],cI).addChild(`insert_link`,[`insert`],{...lI,separator:!0,sequence:70}).addChild(`insert_checkbox`,[`insert`],{...uI,sequence:80}).addChild(`insert_dropdown`,[`insert`],{...dI,separator:!0,sequence:90}).add(`format`,{name:k(`Format`),sequence:50}).addChild(`format_number`,[`format`],{...DJ,name:k(`Number`),sequence:10,separator:!0}).addChild(`format_bold`,[`format`],{...dR,sequence:20}).addChild(`format_italic`,[`format`],{...fR,sequence:30}).addChild(`format_underline`,[`format`],{...pR,sequence:40}).addChild(`format_strikethrough`,[`format`],{...SR,sequence:50,separator:!0}).addChild(`format_font_size`,[`format`],{...CR,sequence:60,separator:!0}).addChild(`format_alignment`,[`format`],{...wR,sequence:70}).addChild(`format_alignment_left`,[`format`,`format_alignment`],{...ER,sequence:10}).addChild(`format_alignment_center`,[`format`,`format_alignment`],{...DR,sequence:20}).addChild(`format_alignment_right`,[`format`,`format_alignment`],{...OR,sequence:30,separator:!0}).addChild(`format_alignment_top`,[`format`,`format_alignment`],{...AR,sequence:40}).addChild(`format_alignment_middle`,[`format`,`format_alignment`],{...jR,sequence:50}).addChild(`format_alignment_bottom`,[`format`,`format_alignment`],{...MR,sequence:60,separator:!0}).addChild(`format_wrapping`,[`format`],{...NR,sequence:80,separator:!0}).addChild(`format_wrapping_overflow`,[`format`,`format_wrapping`],{...FR,sequence:10}).addChild(`format_wrapping_wrap`,[`format`,`format_wrapping`],{...IR,sequence:20}).addChild(`format_wrapping_clip`,[`format`,`format_wrapping`],{...LR,sequence:30}).addChild(`format_cf`,[`format`],{...RR,sequence:90,separator:!0}).addChild(`format_clearFormat`,[`format`],{...zR,sequence:100,separator:!0}).add(`data`,{name:k(`Data`),sequence:60}).addChild(`sort_range`,[`data`],{...QH,sequence:10,separator:!0}).addChild(`sort_ascending`,[`data`,`sort_range`],{...$H,sequence:10}).addChild(`sort_descending`,[`data`,`sort_range`],{...rU,sequence:20}).addChild(`data_cleanup`,[`data`],{...eU,sequence:15}).addChild(`remove_duplicates`,[`data`,`data_cleanup`],{...tU,sequence:10}).addChild(`trim_whitespace`,[`data`,`data_cleanup`],{...nU,sequence:20}).addChild(`split_to_columns`,[`data`],{...oU,sequence:20}).addChild(`data_validation`,[`data`],{name:k(`Data Validation`),execute:e=>{e.openSidePanel(`DataValidation`)},isEnabled:e=>!e.isSmall,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.DATA_VALIDATION`,sequence:30,separator:!0}).addChild(`add_remove_data_filter`,[`data`],{...iU,sequence:40,separator:!0}).addChild(`pivot_data_sources`,[`data`],e=>{let t=e.model.getters.getPivotIds().length;return e.model.getters.getPivotIds().map((n,r)=>{let i={get highlights(){return nz(e.model.getters,n)}};return{id:`item_pivot_${e.model.getters.getPivotFormulaId(n)}`,name:e.model.getters.getPivotDisplayName(n),sequence:50+r/t,isReadonlyAllowed:!0,isEnabledOnLockedSheet:!0,execute:e=>e.openSidePanel(`PivotSidePanel`,{pivotId:n}),isEnabled:e=>!e.isSmall,onStartHover:e=>e.getStore(ON).register(i),onStopHover:e=>e.getStore(ON).unRegister(i),icon:`o-spreadsheet-Icon.PIVOT`,separator:r===e.model.getters.getPivotIds().length-1,secondaryIcon:e=>e.model.getters.isPivotUnused(n)?`o-spreadsheet-Icon.UNUSED_PIVOT_WARNING`:void 0}})}).addChild(`reinsert_dynamic_pivot`,[`data`],sU).addChild(`reinsert_static_pivot`,[`data`],cU),ve.forEach(e=>{kJ.addChild(`zoom${e}`,[`view`,`zoom`],KV(e))});let AJ=[jJ,MJ,PJ,FJ];function jJ(e,t){return`sheetId`in t?{...b(t),sheetId:e.getActiveSheetId()}:t}function MJ(e,t){return!(`target`in t)||!Array.isArray(t.target)?t:{...b(t),target:e.getSelectedZones()}}function NJ(e,t){return`zone`in t?{...b(t),zone:e.getSelectedZone()}:t}function PJ(e,t){if(!(`row`in t)||!(`col`in t))return t;let{col:n,row:r}=e.getActivePosition();return{...b(t),col:n,row:r}}function FJ(e,t){return`ranges`in t?{...b(t),ranges:e.getSelectedZones().map(t=>e.getRangeDataFromZone(e.getActiveSheetId(),t))}:t}let IJ=new Xl;function LJ(e,t){let n=IJ.smallUuid();return{...jJ(e,t),figureId:n,chartId:n}}function RJ(e,t){return{...jJ(e,t),figureId:IJ.smallUuid()}}function zJ(e,t){let n=PJ(e,jJ(e,t));return n.figureId=IJ.smallUuid(),n}function BJ(e,t){let n=b(t);n.sheetId=IJ.smallUuid();let r=t.name||e.getSheet(e.getActiveSheetId()).name,i=r.match(/(.+?)\d*$/)?.[1]||r;return n.name=e.getNextSheetName(i),n}function VJ(e,t){let n=e.getActivePosition();return{...jJ(e,t),base:t.dimension===`COL`?n.col:n.row}}function HJ(e,t){let n=e.getSelectedZone();return{...jJ(e,t),elements:t.dimension===`COL`?S(n.left,n.right+1):S(n.top,n.bottom+1)}}function UJ(e,t){let n=e.getSelectedZone();return{...b(t),zone:n}}function WJ(e,t){let n=b(t),{top:r,bottom:i,left:a,right:o}=e.getSelectedZone();return`cols`in n?n.cols=S(a,o+1):`rows`in n&&(n.rows=S(r,i+1)),n}function GJ(e,t){let n=e.getSelectedZone();return{...jJ(e,t),col:n.left,row:n.top,zone:n}}function KJ(e,t){return{type:`REPEAT_PASTE`,pasteOption:b(t.pasteOption),target:e.getSelectedZones()}}function qJ(e,t){let n=e.getSelectedZone();return{...jJ(e,t),start:t.dimension===`COL`?n.left:n.top,end:t.dimension===`COL`?n.right:n.bottom}}xq.add(`UPDATE_CELL`,JJ),xq.add(`CLEAR_CELL`,JJ),xq.add(`CLEAR_CELLS`,JJ),xq.add(`DELETE_CONTENT`,JJ),xq.add(`ADD_MERGE`,JJ),xq.add(`REMOVE_MERGE`,JJ),xq.add(`SET_FORMATTING`,JJ),xq.add(`CLEAR_FORMATTING`,JJ),xq.add(`SET_BORDER`,JJ),xq.add(`CREATE_TABLE`,JJ),xq.add(`REMOVE_TABLE`,JJ),xq.add(`HIDE_SHEET`,JJ),xq.add(`ADD_COLUMNS_ROWS`,VJ),xq.add(`REMOVE_COLUMNS_ROWS`,HJ),xq.add(`HIDE_COLUMNS_ROWS`,HJ),xq.add(`RESIZE_COLUMNS_ROWS`,HJ),xq.add(`CREATE_SHEET`,BJ),xq.add(`CREATE_FIGURE`,zJ),xq.add(`CREATE_CHART`,LJ),xq.add(`CREATE_IMAGE`,RJ),xq.add(`GROUP_HEADERS`,qJ),xq.add(`UNGROUP_HEADERS`,qJ),xq.add(`UNFOLD_HEADER_GROUPS_IN_ZONE`,NJ),xq.add(`FOLD_HEADER_GROUPS_IN_ZONE`,NJ),Sq.add(`PASTE`,KJ),Sq.add(`INSERT_CELL`,UJ),Sq.add(`DELETE_CELL`,UJ),Sq.add(`AUTORESIZE_COLUMNS`,WJ),Sq.add(`AUTORESIZE_ROWS`,WJ),Sq.add(`SORT_CELLS`,GJ),Sq.add(`SUM_SELECTION`,JJ),Sq.add(`SET_DECIMAL`,JJ),Sq.add(`DELETE_UNFILTERED_CONTENT`,JJ);function JJ(e,t){let n=b(t);for(let t of AJ)n=t(e,n);return n}let YJ=new class extends B{mapping={};uuidGenerator=new Xl;replace(e,t){let n={...t,id:this.uuidGenerator.uuidv4()};return super.replace(e,n)}getAllOrdered(){return this.getAll().sort((e,t)=>e.sequence-t.sequence)}};var XJ=class{listeners=[];async sendMessage(e){for(let{callback:t}of this.listeners)t(e)}onNewMessage(e,t){this.listeners.push({id:e,callback:t})}leave(e){this.listeners=this.listeners.filter(t=>t.id!==e)}},ZJ=class{fileStore;constructor(e){this.fileStore=e}async requestImage(){let e=await this.userImageUpload(),t=await this.fileStore.upload(e);return{path:t,size:await this.getImageOriginalSize(t),mimetype:e.type}}async uploadFile(e){let t=await this.fileStore.upload(e);return{path:t,size:await this.getImageOriginalSize(t),mimetype:e.type}}userImageUpload(){return new Promise((e,t)=>{let n=document.createElement(`input`);n.setAttribute(`type`,`file`),n.setAttribute(`accept`,`image/*`),n.addEventListener(`change`,async()=>{n.files===null||n.files.length!==1?t():e(n.files[0])}),n.click()})}getImageOriginalSize(e){return new Promise((t,n)=>{let r=new Image;r.addEventListener(`load`,()=>{t({width:r.width,height:r.height})}),r.addEventListener(`error`,n),r.src=e})}};let QJ=[{transform:`scale(0)`},{transform:`scale(0.8)`,offset:.33},{opacity:`0`,transform:`scale(1)`,offset:1}];var $J=class extends t.Component{static template=`o-spreadsheet-RippleEffect`;static props={x:String,y:String,color:String,opacity:Number,duration:Number,width:Number,height:Number,offsetY:Number,offsetX:Number,allowOverflow:Boolean,onAnimationEnd:Function,style:String};rippleRef=(0,t.useRef)(`ripple`);setup(){let e;(0,t.onMounted)(()=>{let t=this.rippleRef.el;!t||!t.animate||(e=t.animate(QJ,{duration:this.props.duration,easing:`ease-out`}),e.addEventListener(`finish`,this.props.onAnimationEnd))}),(0,t.onWillUnmount)(()=>{e?.removeEventListener(`finish`,this.props.onAnimationEnd)})}get rippleStyle(){let{x:e,y:t,width:n,height:r}=this.props,i=this.props.offsetX||0,a=this.props.offsetY||0;return U({transform:`scale(0)`,left:e,top:t,"margin-left":`${-n/2+i}px`,"margin-top":`${-r/2+a}px`,width:`${n}px`,height:`${r}px`,background:this.props.color,"border-radius":`100%`,opacity:`${this.props.opacity}`})}},eY=class extends t.Component{static template=`o-spreadsheet-Ripple`;static props={color:{type:String,optional:!0},opacity:{type:Number,optional:!0},duration:{type:Number,optional:!0},ignoreClickPosition:{type:Boolean,optional:!0},width:{type:Number,optional:!0},height:{type:Number,optional:!0},offsetY:{type:Number,optional:!0},offsetX:{type:Number,optional:!0},allowOverflow:{type:Boolean,optional:!0},enabled:{type:Boolean,optional:!0},onAnimationEnd:{type:Function,optional:!0},slots:Object,class:{type:String,optional:!0}};static components={RippleEffect:$J};static defaultProps={color:`#aaaaaa`,opacity:.4,duration:800,enabled:!0,onAnimationEnd:()=>{},class:``};childContainer=(0,t.useRef)(`childContainer`);state=(0,t.useState)({ripples:[]});currentId=1;onClick(e){if(!this.props.enabled||!this.childContainer.el)return;let{x:t,y:n,width:r,height:i}=this.getRippleChildRectInfo(),a=Math.max(r,i),o={x:e.clientX-t,y:e.clientY-n,width:this.props.width||a*2.85,height:this.props.height||a*2.85};this.state.ripples.push({rippleRect:o,id:this.currentId++})}getRippleStyle(){let e=this.childContainer.el;if(!e||e.childElementCount!==1||!e.firstElementChild)return``;let t=this.getRippleChildRectInfo();return U({top:t.marginTop+`px`,left:t.marginLeft+`px`,width:t.width+`px`,height:t.height+`px`})}getRippleChildRectInfo(){let e=this.childContainer.el;if(!e)throw Error(`No child container element found`);if(e.childElementCount!==1||!e.firstElementChild)return{...op(e),marginLeft:0,marginTop:0};let t=e.firstElementChild,n=sv(t);return{...op(t),marginLeft:n.left,marginTop:n.top}}removeRipple(e){let t=this.state.ripples.findIndex(t=>t.id===e);t!==-1&&this.state.ripples.splice(t,1)}getRippleEffectProps(e){let t=this.state.ripples.find(t=>t.id===e)?.rippleRect;if(!t)throw Error(`Cannot find a ripple with the id `+e);return{color:this.props.color,opacity:this.props.opacity,duration:this.props.duration,x:this.props.ignoreClickPosition?`50%`:t.x+`px`,y:this.props.ignoreClickPosition?`50%`:t.y+`px`,width:t.width,height:t.height,offsetX:this.props.offsetX||0,offsetY:this.props.offsetY||0,allowOverflow:this.props.allowOverflow||!1,style:this.getRippleStyle(),onAnimationEnd:()=>this.removeRipple(e)}}};function tY(e,t,n,r){let i=e.model.dispatch(`RENAME_SHEET`,{sheetId:t,newName:n,oldName:e.model.getters.getSheetName(t)});i.reasons.includes(`MissingSheetName`)?e.raiseError(k(`The sheet name cannot be empty.`),r):i.reasons.includes(`DuplicatedSheetName`)?e.raiseError(k(`A sheet with the name %s already exists. Please select another name.`,n),r):i.reasons.includes(`ForbiddenCharactersInSheetName`)&&e.raiseError(k(`Some used characters are not allowed in a sheet name (Forbidden characters are %s).`,Me.join(` `)),r)}let nY=(e,t)=>[[{backgroundColor:`light-dark(darkgrey, lightgrey)`}],{duration:e,iterations:t,easing:`cubic-bezier(1, 0, 0, 1)`}];var rY=class extends t.Component{static template=`o-spreadsheet-BottomBarSheet`;static props={sheetId:String,openContextMenu:Function,style:{type:String,optional:!0},onMouseDown:{type:Function,optional:!0}};static components={Ripple:eY,ColorPicker:VN};static defaultProps={onMouseDown:()=>{},style:``};state=(0,t.useState)({isEditing:!1,pickerOpened:!1});sheetDivRef=(0,t.useRef)(`sheetDiv`);iconRef=(0,t.useRef)(`icon`);sheetNameRef=(0,t.useRef)(`sheetNameSpan`);editionState=`initializing`;DOMFocusableElementStore;setup(){(0,t.onPatched)(()=>{this.sheetNameRef.el&&this.state.isEditing&&this.editionState===`initializing`&&(this.editionState=`editing`,this.focusInputAndSelectContent())}),this.DOMFocusableElementStore=D(LM),(0,t.useExternalListener)(window,`click`,this.onExternalClick.bind(this),{capture:!0}),(0,t.useEffect)(e=>{this.props.sheetId===e&&this.scrollToSheet()},()=>[this.env.model.getters.getActiveSheetId()]),(0,t.onMounted)(()=>{let e=ht(()=>this.sheetDivRef.el?.animate(...nY(200,1)).finished.then(()=>this.iconRef.el?.animate(...nY(200,2))),800);this.env.model.on(`command-rejected`,this,({command:t,result:n})=>{n.isCancelledBecause(`SheetLocked`)&&(!t||!Ms(t)&&this.isSheetActive||Ms(t)&&t.sheetId===this.props.sheetId)&&(this.scrollToSheet(),e())})}),(0,t.onWillUnmount)(()=>{this.env.model.off(`command-rejected`,this)})}onExternalClick(e){e.target.closest(`.o-color-picker`)||(this.state.pickerOpened=!1)}focusInputAndSelectContent(){if(!this.state.isEditing||!this.sheetNameRef.el)return;this.sheetNameRef.el.focus();let e=window.getSelection();e&&this.sheetNameRef.el.firstChild&&e.setBaseAndExtent(this.sheetNameRef.el.firstChild,0,this.sheetNameRef.el.firstChild,this.sheetNameRef.el.textContent?.length||0)}scrollToSheet(){this.sheetDivRef.el?.scrollIntoView?.({behavior:`smooth`,inline:`nearest`})}onFocusOut(){this.state.isEditing&&this.editionState!==`initializing`&&this.stopEdition()}onClick(){this.env.isMobile()&&this.activateSheet()}onMouseDown(e){this.env.isMobile()||(this.activateSheet(),this.props.onMouseDown(e))}activateSheet(){this.env.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:this.env.model.getters.getActiveSheetId(),sheetIdTo:this.props.sheetId}),this.scrollToSheet()}onDblClick(){this.env.model.getters.isReadonly()||this.isSheetLocked||this.startEdition()}onKeyDown(e){this.state.isEditing&&(e.key===`Enter`&&(e.preventDefault(),this.stopEdition(),this.DOMFocusableElementStore.focus()),e.key===`Escape`&&(this.cancelEdition(),this.DOMFocusableElementStore.focus()))}onMouseEventSheetName(e){this.state.isEditing&&e.stopPropagation()}startEdition(){this.state.isEditing=!0,this.editionState=`initializing`}stopEdition(){if(!this.state.isEditing||!this.sheetNameRef.el)return;this.state.isEditing=!1,this.editionState=`initializing`,this.sheetNameRef.el.blur();let e=this.getInputContent()||``;tY(this.env,this.props.sheetId,e,()=>this.startEdition())}cancelEdition(){this.state.isEditing=!1,this.editionState=`initializing`,this.sheetNameRef.el?.blur(),this.setInputContent(this.sheetName)}onIconClick(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}onContextMenu(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}getInputContent(){return this.sheetNameRef.el?.textContent}setInputContent(e){this.sheetNameRef.el&&(this.sheetNameRef.el.textContent=e)}onColorPicked(e){this.state.pickerOpened=!1,this.env.model.dispatch(`COLOR_SHEET`,{sheetId:this.props.sheetId,color:e})}get colorPickerAnchorRect(){let e=this.sheetDivRef.el;return op(e)}get contextMenuRegistry(){return OJ({renameSheetCallback:()=>{this.scrollToSheet(),this.startEdition()},openSheetColorPickerCallback:()=>{this.state.pickerOpened=!0;let e=this.env.model.getters.getSheet(this.props.sheetId);this.state.currentPickerColor=e.color}})}get isSheetActive(){return this.env.model.getters.getActiveSheetId()===this.props.sheetId}get sheetName(){return this.env.model.getters.getSheetName(this.props.sheetId)}get sheetColorStyle(){return U({background:this.env.model.getters.getSheet(this.props.sheetId).color||``})}get isSheetLocked(){return this.env.model.getters.isSheetLocked(this.props.sheetId)}};let iY=[{name:k(`Sum`),types:[`number`],compute:(e,t)=>Jm([[e]],t)},{name:k(`Avg`),types:[`number`],compute:(e,t)=>Em([[e]],t)},{name:k(`Min`),types:[`number`],compute:(e,t)=>Am([[e]],t).value},{name:k(`Max`),types:[`number`],compute:(e,t)=>km([[e]],t).value},{name:k(`Count`),types:[`number`,`text`,`boolean`,`error`],compute:e=>Om([[e]])},{name:k(`Count Numbers`),types:[`number`,`text`,`boolean`,`error`],compute:(e,t)=>Dm([[e]],t)}];var aY=class extends yr{statisticFnResults=this._computeStatisticFnResults();isDirty=!1;constructor(e){super(e),this.model.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.onDispose(()=>{this.model.selection.unobserve(this)})}handle(e){switch((Rs.has(e.type)||e.type===`UPDATE_CELL`&&(`content`in e||`format`in e))&&(this.isDirty=!0),e.type){case`HIDE_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`GROUP_HEADERS`:case`UNGROUP_HEADERS`:case`ACTIVATE_SHEET`:case`ACTIVATE_NEXT_SHEET`:case`ACTIVATE_PREVIOUS_SHEET`:case`EVALUATE_CELLS`:case`UNDO`:case`REDO`:this.isDirty=!0}}finalize(){this.isDirty&&(this.isDirty=!1,this.statisticFnResults=this._computeStatisticFnResults())}handleEvent(){this.getters.isGridSelectionActive()&&(this.statisticFnResults=this._computeStatisticFnResults())}_computeStatisticFnResults(){let e=this.getters,t=e.getActiveSheetId(),n=[],r=nn(e.getSelectedZones(),[]),i=this.getters.getSheetSize(t).numberOfRows-1,a=this.getters.getSheetSize(t).numberOfCols-1;for(let o of r)for(let r=o.left;r<=(o.right??a);r++)for(let a=o.top;a<=(o.bottom??i);a++){if(e.isRowHidden(t,a)||e.isColHidden(t,r))continue;let i=e.getEvaluatedCell({sheetId:t,col:r,row:a});i.type!==`empty`&&n.push(i)}let o=e.getLocale(),s={},c=At(e=>{let t=e.split(`,`);return n.filter(e=>t.includes(e.type))});for(let e of iY){let t,n=c(e.types.sort().join(`,`));n.length&&(t=_t(()=>e.compute(n,o))),s[e.name]=t}return s}},oY=class extends t.Component{static template=`o-spreadsheet-BottomBarStatistic`;static props={openContextMenu:Function,closeContextMenu:Function};static components={Ripple:eY};selectedStatisticFn=``;store;setup(){this.store=D(aY),(0,t.onWillUpdateProps)(()=>{Object.values(this.store.statisticFnResults).every(e=>e===void 0)&&this.props.closeContextMenu()})}getSelectedStatistic(){if(!Object.values(this.store.statisticFnResults).every(e=>e===void 0))return this.selectedStatisticFn===``&&(this.selectedStatisticFn=Object.keys(this.store.statisticFnResults)[0]),this.getComposedFnName(this.selectedStatisticFn)}listSelectionStatistics(e){let t=new bP,n=0;for(let[e]of Object.entries(this.store.statisticFnResults))t.add(e,{name:()=>this.getComposedFnName(e),sequence:n,isReadonlyAllowed:!0,execute:()=>{this.selectedStatisticFn=e}}),n++;let{top:r,left:i,width:a}=e.currentTarget.getBoundingClientRect();this.props.openContextMenu(i+a,r,t)}getComposedFnName(e){let t=this.env.model.getters.getLocale(),n=this.store.statisticFnResults[e];return e+`: `+(n===void 0?`__`:z(n(),{locale:t}))}},sY=class extends t.Component{static template=`o-spreadsheet-BottomBar`;static props={onClick:Function};static components={MenuPopover:Fv,Ripple:eY,BottomBarSheet:rY,BottomBarStatistic:oY};bottomBarRef=(0,t.useRef)(`bottomBar`);sheetListRef=(0,t.useRef)(`sheetList`);dragAndDrop=WN();targetScroll=void 0;state=(0,t.useState)({isSheetListScrollableLeft:!1,isSheetListScrollableRight:!1});menuMaxHeight=250;menuState=(0,t.useState)({isOpen:!1,menuId:void 0,anchorRect:null,menuItems:[]});sheetList=this.getVisibleSheets();setup(){(0,t.onWillUpdateProps)(()=>{this.updateScrollState();let e=this.getVisibleSheets();w(this.sheetList,e)||this.dragAndDrop.cancel(),this.sheetList=e})}clickAddSheet(e){let t=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getSheetIds().findIndex(e=>e===t)+1,r=this.env.model.uuidGenerator.smallUuid(),i=this.env.model.getters.getNextSheetName(k(`Sheet`));this.env.model.dispatch(`CREATE_SHEET`,{sheetId:r,position:n,name:i}),this.env.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:t,sheetIdTo:r})}getVisibleSheets(){return this.env.model.getters.getVisibleSheetIds().map(e=>{let t=this.env.model.getters.getSheet(e);return{id:t.id,name:t.name}})}clickListSheets(e){let t=new bP,n=this.env.model.getters.getActiveSheetId(),r=0;for(let e of this.env.model.getters.getSheetIds()){let i=this.env.model.getters.getSheet(e);t.add(e,{name:i.name,sequence:r,isReadonlyAllowed:!0,textColor:i.isVisible?void 0:`#808080`,execute:t=>{this.env.model.getters.isSheetVisible(e)||this.env.model.dispatch(`SHOW_SHEET`,{sheetId:e}),t.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:n,sheetIdTo:e})},isEnabled:e=>e.model.getters.isReadonly()?i.isVisible:!0,icon:i.color?`o-spreadsheet-Icon.SMALL_DOT_RIGHT_ALIGN`:void 0,iconColor:i.color,isEnabledOnLockedSheet:!0}),r++}let{left:i}=e.currentTarget.getBoundingClientRect(),a=this.bottomBarRef.el.getBoundingClientRect().top;this.openContextMenu(i,a,`listSheets`,t)}openContextMenu(e,t,n,r){this.menuState.isOpen=!0,this.menuState.menuId=n,this.menuState.menuItems=r.getMenuItems(),this.menuState.anchorRect={x:e,y:t,width:0,height:0}}onSheetContextMenu(e,t,n){let{top:r,left:i}=n.currentTarget.getBoundingClientRect();if(n.closedMenuId===e){this.closeMenu();return}this.openContextMenu(i,r,e,t)}closeMenu(){this.menuState.isOpen=!1,this.menuState.menuId=void 0,this.menuState.menuItems=[],this.menuState.anchorRect=null}closeContextMenuWithId(e){this.menuState.menuId===e&&this.closeMenu()}onWheel(e){this.targetScroll=void 0;let t=e.currentTarget;t.scrollLeft+=e.deltaY*.5}onScroll(){this.updateScrollState(),this.targetScroll===this.sheetListCurrentScroll&&(this.targetScroll=void 0)}onArrowLeft(e){if(!this.state.isSheetListScrollableLeft)return;this.targetScroll||=this.sheetListCurrentScroll;let t=this.targetScroll-this.sheetListWidth;this.scrollSheetListTo(Math.max(0,t))}onArrowRight(e){if(!this.state.isSheetListScrollableRight)return;this.targetScroll||=this.sheetListCurrentScroll;let t=this.targetScroll+this.sheetListWidth;this.scrollSheetListTo(Math.min(this.sheetListMaxScroll,t))}updateScrollState(){this.state.isSheetListScrollableLeft=this.sheetListCurrentScroll>0,this.state.isSheetListScrollableRight=this.sheetListCurrentScroll<this.sheetListMaxScroll}scrollSheetListTo(e){this.sheetListRef.el&&(this.targetScroll=e,this.sheetListRef.el.scrollTo({top:0,left:e,behavior:`smooth`}))}onSheetMouseDown(e,t){if(t.button!==0||this.env.model.getters.isReadonly()||(this.closeMenu(),this.env.isMobile()))return;let n=this.getVisibleSheets(),r=this.getSheetItemRects(),i=n.map((e,t)=>({id:e.id,size:r[t].width,position:r[t].x}));this.dragAndDrop.start(`horizontal`,{draggedItemId:e,initialMousePosition:t.clientX,items:i,scrollableContainerEl:this.sheetListRef.el,onDragEnd:(e,t)=>this.onDragEnd(e,t)})}onDragEnd(e,t){let n=t-this.getVisibleSheets().findIndex(t=>t.id===e);e&&n!==0&&this.env.model.dispatch(`MOVE_SHEET`,{sheetId:e,delta:n})}getSheetStyle(e){return this.dragAndDrop.itemsStyle[e]||``}getSheetItemRects(){return Array.from(this.bottomBarRef.el.querySelectorAll(`.o-sheet`)).map(e=>e.getBoundingClientRect()).map(e=>({x:e.x,width:e.width-1,y:e.y,height:e.height}))}get sheetListCurrentScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollLeft:0}get sheetListWidth(){return this.sheetListRef.el?this.sheetListRef.el.clientWidth:0}get sheetListMaxScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollWidth-this.sheetListRef.el.clientWidth:0}},cY=class extends yr{_clickableCells=(0,t.markRaw)({});_registryItems=(0,t.markRaw)(rJ.getAll().sort((e,t)=>e.sequence-t.sequence));handle(e){(Rs.has(e.type)||e.type===`EVALUATE_CELLS`||e.type===`UPDATE_CELL`&&(`content`in e||`format`in e))&&(this._clickableCells=(0,t.markRaw)({}),this._registryItems=(0,t.markRaw)(rJ.getAll().sort((e,t)=>e.sequence-t.sequence)))}getClickableItem(e){let{sheetId:t,col:n,row:r}=e,i=this._clickableCells,a=T(n,r);if(i[t]||(i[t]={}),!(a in i[t])){let n=this.findClickableItem(e);i[t][a]=n}return i[t][a]}findClickableItem(e){let t=this.getters;for(let n of this._registryItems)if(n.condition(e,t))return n}get clickableCells(){let e=[],t=this.getters;for(let n of this.getters.getVisibleCellPositions()){let r=this.getClickableItem(n);if(!r)continue;let i=typeof r.title==`function`?r.title(n,t):r.title,a=this.getClickableCellRect(n);a&&e.push({coordinates:a,position:n,action:r.execute,title:i||``,component:r.component,componentProps:r.componentProps?.(n,t)??{}})}return e}getClickableCellRect(e){let t=this.getters.expandZone(e.sheetId,E(e)),n=this.getters.getVisibleRect(t),r=this.getters.getCellIcons(e),i={center:r.find(e=>e.horizontalAlign===`center`),left:r.find(e=>e.horizontalAlign===`left`),right:r.find(e=>e.horizontalAlign===`right`)};if(!i.center?.onClick){if(i.right?.onClick){let e=this.getters.getRect(t),r=this.getters.getCellIconRect(i.right,e);n.width-=r.width+i.right.margin}if(i.left?.onClick){let e=this.getters.getRect(t),r=this.getters.getCellIconRect(i.left,e);n.x+=r.width+i.left.margin,n.width-=r.width+i.left.margin}return n}}},lY=class extends t.Component{static template=`o-spreadsheet-SpreadsheetDashboard`;static props={getGridSize:Function};static components={GridOverlay:fW,GridPopover:pW,Popover:jv,VerticalScrollBar:NW,HorizontalScrollBar:MW};cellPopovers;onMouseWheel;canvasPosition;hoveredCell;clickableCellsStore;gridRef;setup(){this.gridRef=(0,t.useRef)(`grid`),this.hoveredCell=D(Hv),this.clickableCellsStore=D(cY),(0,t.useChildSubEnv)({getPopoverContainerRect:()=>Op(this.env.model.getters.getViewportZoomLevel(),this.getGridRect())}),xW(`canvas`,this.env.model,()=>this.env.model.getters.getSheetViewDimension()),this.onMouseWheel=TW((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.clear()}),this.cellPopovers=D(sP),CW(this.gridRef,{updateScroll:this.moveCanvas.bind(this),canMoveUp:()=>{let{scrollY:e}=this.env.model.getters.getActiveSheetScrollInfo();return e>0},canMoveDown:()=>{let{maxOffsetY:e}=this.env.model.getters.getMaximumSheetOffset(),{scrollY:t}=this.env.model.getters.getActiveSheetScrollInfo();return t<e},getZoom:()=>this.env.model.getters.getViewportZoomLevel(),setZoom:e=>this.env.model.dispatch(`SET_ZOOM`,{zoom:e})})}get gridContainer(){return U({"max-width":`${this.getMaxSheetWidth()}px`})}get gridOverlayDimensions(){return U({height:`100%`,width:`100%`})}getCellClickableStyle(e){return U({top:`${e.y}px`,left:`${e.x}px`,width:`${e.width}px`,height:`${e.height}px`})}getClickableCells(){return(0,t.toRaw)(this.clickableCellsStore.clickableCells)}selectClickableCell(e,t){if(![0,1].includes(e.button))return;let{position:n,action:r}=t;r(n,this.env,gp(e))}onClosePopover(){this.cellPopovers.close()}onGridResized(){let{height:e,width:t}=this.props.getGridSize(),n=this.getMaxSheetWidth();this.env.model.dispatch(`RESIZE_SHEETVIEW`,{width:Math.min(n,t),height:e,gridOffsetX:0,gridOffsetY:0})}moveCanvas(e,t){let{scrollX:n,scrollY:r}=this.env.model.getters.getActiveSheetScrollInfo();this.env.model.dispatch(`SET_VIEWPORT_OFFSET`,{offsetX:n+e,offsetY:r+t})}getGridRect(){return{...ap(this.gridRef),...this.env.model.getters.getSheetViewDimensionWithHeaders()}}getMaxSheetWidth(){let e=this.env.model.getters.getActiveSheetId(),{right:t}=this.env.model.getters.getSheetZone(e);return this.env.model.getters.getColDimensions(e,t).end}get dashboardStyle(){return U({zoom:`${this.env.model.getters.getViewportZoomLevel()}`})}},uY=class extends t.Component{static template=`o-spreadsheet-HeaderGroup`;static props={group:Object,layerOffset:Number,openContextMenu:Function};toggleGroup(){let e=this.env.model.getters.getActiveSheetId(),{start:t,end:n}=this.props.group;dU(this.env,e,this.dimension,t,n)}get groupBoxStyle(){let e=this.groupBox;return U({top:`${e.groupRect.y}px`,left:`${e.groupRect.x}px`,width:`${e.groupRect.width}px`,height:`${e.groupRect.height}px`})}get groupButtonStyle(){return U({"background-color":this.isGroupFolded?`#333`:`#fff`,color:this.isGroupFolded?`#fff`:`#333`})}get groupButtonIcon(){return this.isGroupFolded?`o-spreadsheet-Icon.PLUS`:`o-spreadsheet-Icon.MINUS`}get isGroupFolded(){let e=this.env.model.getters.getActiveSheetId(),t=this.props.group;return this.env.model.getters.isGroupFolded(e,this.dimension,t.start,t.end)}onContextMenu(e){let t=this.env.model.getters.getActiveSheetId(),n={x:e.clientX,y:e.clientY},r=this.props.group,i=pU(t,this.dimension,r.start,r.end);this.props.openContextMenu(n,i)}},dY=class extends uY{dimension=`ROW`;get groupBorderStyle(){let e=this.groupBox;return this.groupBox.groupRect.height===0?``:U({top:`${e.headerRect.height/2}px`,left:`calc(50% - 1px)`,width:`30%`,height:`calc(100% - ${e.headerRect.height/2}px)`,"border-left":`1px solid`,"border-bottom":e.isEndHidden?``:`1px solid`})}get groupHeaderStyle(){return U({width:`100%`,height:`${this.groupBox.headerRect.height}px`})}get groupBox(){let e=this.env.model.getters.getActiveSheetId(),{start:t,end:n}=this.props.group,r=this.env.model.getters.getRowDimensions(e,t).start,i=this.env.model.getters.getRowDimensions(e,n).end,a=0,o=26;if(t!==0){let n=this.env.model.getters.getRowDimensions(e,t-1);a=26+n.start,o=n.end-n.start}let s={x:this.props.layerOffset,y:a,width:21,height:o};return{headerRect:s,groupRect:{x:this.props.layerOffset,y:s.y,width:21,height:s.height+(i-r)},isEndHidden:this.env.model.getters.isRowHidden(e,n)}}},fY=class extends uY{dimension=`COL`;get groupBorderStyle(){let e=this.groupBox;return e.groupRect.width===0?``:U({top:`calc(50% - 1px)`,left:`${e.headerRect.width/2}px`,width:`calc(100% - ${e.headerRect.width/2}px)`,height:`30%`,"border-top":`1px solid`,"border-right":e.isEndHidden?``:`1px solid`})}get groupHeaderStyle(){return U({width:`${this.groupBox.headerRect.width}px`,height:`100%`})}get groupBox(){let e=this.env.model.getters.getActiveSheetId(),{start:t,end:n}=this.props.group,r=this.env.model.getters.getColDimensions(e,t).start,i=this.env.model.getters.getColDimensions(e,n).end,a=0,o=48;if(t!==0){let n=this.env.model.getters.getColDimensions(e,t-1);a=48+n.start,o=n.end-n.start}let s={x:a,y:this.props.layerOffset,width:o,height:21};return{headerRect:s,groupRect:{x:s.x,y:this.props.layerOffset,width:s.width+(i-r),height:21},isEndHidden:this.env.model.getters.isColHidden(e,n)}}},pY=class extends t.Component{static template=`o-spreadsheet-HeaderGroupContainer`;static props={dimension:String,layers:Array};static components={RowGroup:dY,ColGroup:fY,MenuPopover:Fv};menu=(0,t.useState)({isOpen:!1,anchorRect:null,menuItems:[]});getLayerOffset(e){return e*21}onContextMenu(e){let t=this.env.model.getters.getActiveSheetId(),n={x:e.clientX,y:e.clientY},r=fU(t,this.props.dimension);this.openContextMenu(n,r)}openContextMenu(e,t){this.menu.isOpen=!0,this.menu.anchorRect={...e,width:0,height:0},this.menu.menuItems=t}closeMenu(){this.menu.isOpen=!1,this.menu.anchorRect=null,this.menu.menuItems=[]}get groupComponent(){return this.props.dimension===`ROW`?dY:fY}get hasFrozenPane(){let e=this.env.model.getters.getMainViewportCoordinates();return this.props.dimension===`COL`?e.x>0:e.y>0}get scrollContainerStyle(){let{scrollX:e,scrollY:t}=this.env.model.getters.getActiveSheetScrollInfo(),n={};return this.props.dimension===`COL`?n.left=`${-e-this.frozenPaneContainerSize}px`:n.top=`${-t-this.frozenPaneContainerSize}px`,U(n)}get frozenPaneContainerStyle(){let e={};return this.props.dimension===`COL`?e.width=`${this.frozenPaneContainerSize}px`:e.height=`${this.frozenPaneContainerSize}px`,U(e)}get frozenPaneContainerSize(){if(!this.hasFrozenPane)return 0;let e=this.env.model.getters.getMainViewportCoordinates();return this.props.dimension===`COL`?48+e.x:26+e.y}};function mY(){let e=kv();return{get isSmall(){return e.width<768}}}var hY=class extends t.Component{static template=`o-spreadsheet-SidePanel`;static props={panelContent:Object,panelProps:Object,onCloseSidePanel:Function,onStartHandleDrag:Function,onResetPanelSize:Function,isPinned:{type:Boolean,optional:!0},onTogglePinPanel:{type:Function,optional:!0},onToggleCollapsePanel:{type:Function,optional:!0},isCollapsed:{type:Boolean,optional:!0}};spreadsheetRect=kv();getTitle(){let e=this.props.panelContent;return typeof e.title==`function`?e.title(this.env,this.props.panelProps):e.title}},gY=class extends t.Component{static template=`o-spreadsheet-SidePanels`;static props={};static components={SidePanel:hY};sidePanelStore;spreadsheetRect=kv();setup(){this.sidePanelStore=D(SV),(0,t.useEffect)(()=>{this.sidePanelStore.mainPanel&&!this.sidePanelStore.isMainPanelOpen&&this.sidePanelStore.closeMainPanel(),this.sidePanelStore.secondaryPanel&&!this.sidePanelStore.isSecondaryPanelOpen&&this.sidePanelStore.close()},()=>[this.sidePanelStore.isMainPanelOpen,this.sidePanelStore.isSecondaryPanelOpen])}startHandleDrag(e,t){let n=document.body.style.cursor,r=e===`mainPanel`?this.sidePanelStore.mainPanel:this.sidePanelStore.secondaryPanel;if(!r)return;let i=r.size,a=t.clientX;BN(t=>{document.body.style.cursor=`col-resize`;let n=i+a-t.clientX;this.sidePanelStore.changePanelSize(e,n)},()=>{document.body.style.cursor=n})}get mainPanelProps(){let e=this.sidePanelStore.mainPanelProps;if(!(!this.sidePanelStore.mainPanel||!e))return{panelContent:bV.get(this.sidePanelStore.mainPanel.componentTag),panelProps:e,onCloseSidePanel:()=>this.sidePanelStore.closeMainPanel(),onTogglePinPanel:()=>this.sidePanelStore.togglePinPanel(),onStartHandleDrag:e=>this.startHandleDrag(`mainPanel`,e),onResetPanelSize:()=>this.sidePanelStore.resetPanelSize(`mainPanel`),isPinned:this.sidePanelStore.mainPanel?.isPinned,onToggleCollapsePanel:()=>this.sidePanelStore.toggleCollapsePanel(`mainPanel`),isCollapsed:this.sidePanelStore.mainPanel?.isCollapsed}}get secondaryPanelProps(){let e=this.sidePanelStore.secondaryPanelProps;if(!(!this.sidePanelStore.secondaryPanel||!e))return{panelContent:bV.get(this.sidePanelStore.secondaryPanel.componentTag),panelProps:e,onCloseSidePanel:()=>this.sidePanelStore.close(),onStartHandleDrag:e=>this.startHandleDrag(`secondaryPanel`,e),onResetPanelSize:()=>this.sidePanelStore.resetPanelSize(`secondaryPanel`),onToggleCollapsePanel:()=>this.sidePanelStore.toggleCollapsePanel(`secondaryPanel`),isCollapsed:this.sidePanelStore.secondaryPanel?.isCollapsed}}get panelList(){return[{key:this.sidePanelStore.secondaryPanelKey,props:this.secondaryPanelProps,style:this.sidePanelStore.secondaryPanel?U({width:`${this.sidePanelStore.secondaryPanel.size}px`}):``},{key:this.sidePanelStore.mainPanelKey,props:this.mainPanelProps,style:this.sidePanelStore.mainPanel?U({width:`${this.sidePanelStore.mainPanel.size}px`}):``}].filter(e=>e.key&&e.props)}},_Y=class extends t.Component{static template=`o-spreadsheet-RibbonMenu`;static props={onClose:Function};static components={Menu:Cv};rootItems=kJ.getMenuItems();menuRef=(0,t.useRef)(`menu`);containerRef=(0,t.useRef)(`container`);state=(0,t.useState)({menuItems:this.rootItems,title:k(`Menu Bar`),parentState:void 0});setup(){(0,t.useExternalListener)(window,`click`,this.onExternalClick,{capture:!0}),(0,t.onMounted)(this.updateShadows)}onExternalClick(e){this.menuRef.el?.contains(e.target)||this.props.onClose()}onClickMenu(e){let t=e.children(this.env);t.length?(this.state.parentState={...this.state},this.state.menuItems=t,this.state.title=e.name(this.env),this.containerRef.el?.scrollTo({top:0})):(this.state.menuItems=this.rootItems,this.state.title=void 0,this.state.parentState=void 0,e.execute?.(this.env),this.props.onClose())}get menuProps(){return{menuItems:g(this.env,this.state.menuItems),onClose:this.props.onClose,onClickMenu:this.onClickMenu.bind(this)}}get style(){return U({height:`${this.props.height}px`})}updateShadows(){if(!this.containerRef.el)return;this.containerRef.el.classList.remove(`scroll-top`,`scroll-bottom`);let e=this.containerRef.el.scrollHeight-this.containerRef.el.clientHeight||0;this.containerRef.el.scrollTop<e-1&&this.containerRef.el.classList.add(`scroll-bottom`),this.containerRef.el.scrollTop>0&&this.containerRef.el.classList.add(`scroll-top`)}onClickBack(){if(!this.state.parentState){this.props.onClose();return}this.state.menuItems=this.state.parentState.menuItems,this.state.title=this.state.parentState.title,this.state.parentState=this.state.parentState.parentState,this.containerRef.el?.scrollTo({top:0})}get backTitle(){return this.state.parentState?k(`Go to previous menu`):k(`Close menu bar`)}},vY=class extends t.Component{static components={Composer:$M,BottomBar:sY,Ripple:eY,RibbonMenu:_Y};static template=`o-spreadsheet-SmallBottomBar`;static props={onClick:Function};composerFocusStore;composerStore;composerInterface;composerRef=(0,t.useRef)(`bottombarComposer`);menuState=(0,t.useState)({isOpen:!1});setup(){this.composerFocusStore=D(xr);let e=D(KU);this.composerStore=e,this.composerInterface={id:`bottombarComposer`,get editionMode(){return e.editionMode},startEdition:this.composerStore.startEdition,setCurrentContent:this.composerStore.setCurrentContent,stopEdition:this.composerStore.stopEdition},(0,t.useEffect)(()=>{this.env.isMobile()&&!this.menuState.isOpen&&this.composerStore.editionMode!==`inactive`&&this.composerFocusStore.activeComposer!==this.composerInterface&&this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`contentFocus`})})}get focus(){return this.composerFocusStore.activeComposer===this.composerInterface?this.composerFocusStore.focusMode:`inactive`}get showFxIcon(){return this.focus===`inactive`&&!this.composerStore.currentContent&&!this.composerStore.placeholder}get rect(){return this.composerRef.el?op(this.composerRef.el):{x:0,y:0,width:0,height:0}}get composerProps(){let{width:e,height:t}=this.env.model.getters.getSheetViewDimensionWithHeaders();return{rect:{...this.rect},delimitation:{width:e,height:t},focus:this.focus,composerStore:this.composerStore,onComposerContentFocused:e=>this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`contentFocus`,selection:e}),isDefaultFocus:!1,inputStyle:U({height:this.focus===`inactive`?`26px`:`fit-content`,"max-height":`130px`}),showAssistant:!1,placeholder:this.composerStore.placeholder}}get symbols(){return[`=`,`(`,`)`,`:`,`-`,`/`,`*`,`,`,`+`,`$`,`.`]}insertSymbol(e){this.composerStore.replaceComposerCursorSelection(e),this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`contentFocus`})}toggleRibbon(){this.composerStore.cancelEdition(),this.menuState.isOpen=!this.menuState.isOpen}},yY=class extends t.Component{static template=`o-spreadsheet-TopBarComposer`;static props={};static components={Composer:$M};composerFocusStore;composerStore;composerInterface;setup(){this.composerFocusStore=D(xr);let e=D(KU);this.composerStore=e,this.composerInterface={id:`topbarComposer`,get editionMode(){return e.editionMode},startEdition:this.composerStore.startEdition,setCurrentContent:this.composerStore.setCurrentContent,stopEdition:this.composerStore.stopEdition}}get focus(){return this.composerFocusStore.activeComposer===this.composerInterface?this.composerFocusStore.focusMode:`inactive`}get showFxIcon(){return this.focus===`inactive`&&!this.composerStore.currentContent&&!this.composerStore.placeholder}get composerStyle(){let e={padding:`5px 0px 5px 8px`,"max-height":`300px`,"line-height":`24px`};return this.env.model.getters.isCurrentSheetLocked()&&(e[`pointer-events`]=`none`),e.height=this.focus===`inactive`?`34px`:`fit-content`,U(e)}onFocus(e){this.composerFocusStore.focusComposer(this.composerInterface,{selection:e})}},bY=class{mutators=[`closeDropdowns`,`openDropdown`];_currentDropdown=null;closeDropdowns(){this._currentDropdown=null}openDropdown(e){this._currentDropdown=e}get currentDropdown(){return this._currentDropdown}},xY=class{content={};add(e){if(e in this.content)throw Error(`${e} is already present in this registry!`);return this.content[e]=[],this}addChild(e,t){return this.content[e].push(t),this}getEntries(e){return this.content[e].sort((e,t)=>e.sequence-t.sequence)}getCategories(){return Object.keys(this.content)}};function SY(){let e=(0,t.useComponent)(),n=D(bY);return(0,t.onWillUnmount)(()=>{e===n.currentDropdown&&n.closeDropdowns()}),{closeDropdowns:()=>n.closeDropdowns(),openDropdown:()=>{n.openDropdown(e)},get isActive(){return n.currentDropdown===e}}}let CY=[[[`all`,`o-spreadsheet-Icon.BORDERS`],[`hv`,`o-spreadsheet-Icon.BORDER_HV`],[`h`,`o-spreadsheet-Icon.BORDER_H`],[`v`,`o-spreadsheet-Icon.BORDER_V`],[`external`,`o-spreadsheet-Icon.BORDER_EXTERNAL`]],[[`left`,`o-spreadsheet-Icon.BORDER_LEFT`],[`top`,`o-spreadsheet-Icon.BORDER_TOP`],[`right`,`o-spreadsheet-Icon.BORDER_RIGHT`],[`bottom`,`o-spreadsheet-Icon.BORDER_BOTTOM`],[`clear`,`o-spreadsheet-Icon.BORDER_CLEAR`]]];var wY=class extends t.Component{static template=`o-spreadsheet-BorderEditor`;static props={class:{type:String,optional:!0},currentBorderColor:{type:String,optional:!1},currentBorderStyle:{type:String,optional:!1},currentBorderPosition:{type:String,optional:!0},onBorderColorPicked:Function,onBorderStylePicked:Function,onBorderPositionPicked:Function,maxHeight:{type:Number,optional:!0},anchorRect:Object};static components={ColorPickerWidget:bI,Popover:jv};BORDER_POSITIONS=CY;lineStyleButtonRef=(0,t.useRef)(`lineStyleButton`);borderStyles=wa;state=(0,t.useState)({activeTool:void 0});toggleDropdownTool(e){let t=this.state.activeTool===e;this.state.activeTool=t?void 0:e}closeDropdown(){this.state.activeTool=void 0}setBorderPosition(e){this.props.onBorderPositionPicked(e),this.closeDropdown()}setBorderColor(e){this.props.onBorderColorPicked(e),this.closeDropdown()}setBorderStyle(e){this.props.onBorderStylePicked(e),this.closeDropdown()}get lineStylePickerPopoverProps(){return{anchorRect:this.lineStylePickerAnchorRect,positioning:`bottom-left`,verticalOffset:0}}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:`bottom-left`,verticalOffset:0}}get lineStylePickerAnchorRect(){let e=this.lineStyleButtonRef.el;if(e===null)return{x:0,y:0,width:0,height:0};let t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}},TY=class extends t.Component{static template=`o-spreadsheet-BorderEditorWidget`;static props={disabled:{type:Boolean,optional:!0},dropdownMaxHeight:{type:Number,optional:!0},class:{type:String,optional:!0}};static components={BorderEditor:wY};topBarToolStore;borderEditorButtonRef=(0,t.useRef)(`borderEditorButton`);state=(0,t.useState)({currentColor:Ee.color,currentStyle:Ee.style,currentPosition:void 0});setup(){this.topBarToolStore=SY(),(0,t.onWillUpdateProps)(()=>{this.isActive||(this.state.currentPosition=void 0)})}get dropdownMaxHeight(){return this.env.model.getters.getSheetViewDimension().height}get borderEditorAnchorRect(){let e=this.borderEditorButtonRef.el.getBoundingClientRect();return{x:e.x,y:e.y,width:e.width,height:e.height}}onBorderPositionPicked(e){this.state.currentPosition=e,this.updateBorder()}onBorderColorPicked(e){this.state.currentColor=e,this.updateBorder()}onBorderStylePicked(e){this.state.currentStyle=e,this.updateBorder()}get isActive(){return this.topBarToolStore.isActive}toggleBorderEditor(){this.isActive?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}updateBorder(){this.state.currentPosition!==void 0&&this.env.model.dispatch(`SET_ZONE_BORDERS`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),border:{position:this.state.currentPosition,color:this.state.currentColor,style:this.state.currentStyle}})}},EY=class extends t.Component{static template=`o-spreadsheet-PaintFormatButton`;static props={class:{type:String,optional:!0}};paintFormatStore;setup(){this.paintFormatStore=D(cW)}get isActive(){return this.paintFormatStore.isActive}onDblClick(){this.paintFormatStore.activate({persistent:!0})}togglePaintFormat(){this.isActive?this.paintFormatStore.cancel():this.paintFormatStore.activate({persistent:!1})}},DY=class extends t.Component{static template=`o-spreadsheet-TableDropdownButton`;static components={TableStylesPopover:sV,ActionButton:yI};static props={class:{type:String,optional:!0}};topBarToolStore;state=(0,t.useState)({popoverProps:void 0});setup(){this.topBarToolStore=SY()}onStylePicked(e){let t=this.env.model.getters.getActiveSheetId(),n={...this.tableConfig,styleId:e};WP(this.env,t,n).isSuccessful&&this.env.openSidePanel(`TableSidePanel`,{}),this.closePopover()}onClick(e){if(e.hasClosedTableStylesPopover||this.state.popoverProps){this.closePopover();return}let t=this.dynamicPivotIdInSelection;if(t){this.env.openSidePanel(`PivotSidePanel`,{pivotId:t,openTab:`design`});return}if(this.env.model.getters.getFirstTableInSelection()){this.topBarToolStore.closeDropdowns(),this.env.toggleSidePanel(`TableSidePanel`,{});return}let{left:n,bottom:r}=e.currentTarget.getBoundingClientRect();this.topBarToolStore.openDropdown(),this.state.popoverProps={anchorRect:{x:n,y:r,width:0,height:0},positioning:`bottom-left`,verticalOffset:0}}closePopover(){this.state.popoverProps=void 0}get action(){return this.dynamicPivotIdInSelection?{name:k(`Edit pivot style`),icon:`o-spreadsheet-Icon.EDIT_TABLE`}:{name:e=>e.model.getters.getFirstTableInSelection()?k(`Edit table`):k(`Insert table`),icon:e=>e.model.getters.getFirstTableInSelection()?`o-spreadsheet-Icon.EDIT_TABLE`:`o-spreadsheet-Icon.PAINT_TABLE`}}get tableConfig(){return{...WA,numberOfHeaders:1,bandedRows:!0}}get tableStyles(){return this.env.model.getters.getTableStyles()}get dynamicPivotIdInSelection(){let e=this.env.model.getters.getSelectedZones(),t=new Set(this.env.model.getters.getCellsWithTrackedFormula(`PIVOT`));if(t.size===0)return;let n=this.env.model.getters.getActiveSheetId();for(let r of e)for(let e of In(n,r)){let n=this.env.model.getters.getArrayFormulaSpreadingOn(e);if(!n)continue;let r=this.env.model.getters.getCell(n)?.id;if(r&&t.has(r)){let e=this.env.model.getters.getPivotIdFromPosition(n);if(e)return e}}}get class(){return`${this.props.class?this.props.class:``} ${this.env.model.getters.isCurrentSheetLocked()?`o-disabled`:``}`}},OY=class extends t.Component{static components={ColorPickerWidget:bI};static props={class:String,style:String,icon:String,title:String};static template=`o-spreadsheet-ColorEditor`;topBarToolStore;state=(0,t.useState)({isOpen:!1});setup(){this.topBarToolStore=SY()}get currentColor(){return this.env.model.getters.getCurrentStyle()[this.props.style]||(this.props.style===`textColor`?`#000000`:`#ffffff`)}setColor(e){KP(this.env,{[this.props.style]:e}),this.state.isOpen=!1}get isMenuOpen(){return this.topBarToolStore.isActive}onClick(){this.isMenuOpen?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}},kY=class extends t.Component{static template=`o-spreadsheet-DropdownAction`;static components={ActionButton:yI,Popover:jv};static props={parentAction:Object,childActions:Array,class:String,childClass:String};topBarToolStore;actionRef=(0,t.useRef)(`actionRef`);setup(){this.topBarToolStore=SY()}toggleDropdown(){this.isActive?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}get isActive(){return this.topBarToolStore.isActive}get popoverProps(){return{anchorRect:this.actionRef.el?this.actionRef.el.getBoundingClientRect():{x:0,y:0,width:0,height:0},positioning:`bottom-left`,verticalOffset:0,class:`rounded`}}},AY=class extends t.Component{static components={FontSizeEditor:SI};static props={class:String};static template=`o-spreadsheet-TopBarFontSizeEditor`;topBarToolStore;setup(){this.topBarToolStore=SY()}get currentFontSize(){return this.env.model.getters.getCurrentStyle().fontSize||we}setFontSize(e){KP(this.env,{fontSize:e})}onToggle(){this.isActive?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}onFocusInput(){this.topBarToolStore.openDropdown()}get isActive(){return this.topBarToolStore.isActive}get class(){return`${this.props.class} ${this.env.model.getters.isCurrentSheetLocked()?`o-disabled`:``}`}},jY=class extends t.Component{static template=`o-spreadsheet-NumberFormatsTool`;static components={MenuPopover:Fv,ActionButton:yI};static props={class:String};formatNumberMenuItemSpec=DJ;topBarToolStore;buttonRef=(0,t.useRef)(`buttonRef`);state=(0,t.useState)({anchorRect:{x:0,y:0,width:0,height:0},menuItems:[]});setup(){this.topBarToolStore=SY()}toggleMenu(){if(this.isActive)this.topBarToolStore.closeDropdowns();else{let e=h(this.formatNumberMenuItemSpec);this.state.menuItems=e.children(this.env).sort((e,t)=>e.sequence-t.sequence),this.state.anchorRect=op(this.buttonRef.el),this.topBarToolStore.openDropdown()}}get isActive(){return this.topBarToolStore.isActive}},MY=class extends t.Component{static template=`o-spreadsheet-TopBarZoom`;static components={NumberEditor:xI};static props={class:String};topBarToolStore;valueList=ve;setup(){this.topBarToolStore=SY()}get currentFontSize(){return(this.env.model.getters.getViewportZoomLevel()||1)*100}setZoom(e){this.env.model.dispatch(`SET_ZOOM`,{zoom:e/100})}toggle(){this.topBarToolStore.isActive?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}onFocusInput(){this.topBarToolStore.openDropdown()}};let NY=new xY;NY.add(`edit`).addChild(`edit`,{component:yI,props:{action:aH,class:`o-hoverable-button o-toolbar-button`},sequence:1}).addChild(`edit`,{component:yI,props:{action:oH,class:`o-hoverable-button o-toolbar-button`},sequence:2}).addChild(`edit`,{component:EY,props:{class:`o-hoverable-button o-toolbar-button o-mobile-disabled`},sequence:3}).addChild(`edit`,{component:yI,props:{action:zR,class:`o-hoverable-button o-toolbar-button`},sequence:4}).addChild(`edit`,{component:MY,props:{class:`o-menu-item-button o-hoverable-button o-toolbar-button`},sequence:5}).add(`numberFormat`).addChild(`numberFormat`,{component:yI,props:{action:YL,class:`o-hoverable-button o-toolbar-button`},sequence:1}).addChild(`numberFormat`,{component:yI,props:{action:uR,class:`o-hoverable-button o-toolbar-button`},sequence:2}).addChild(`numberFormat`,{component:yI,props:{action:lR,class:`o-hoverable-button o-toolbar-button`},sequence:3}).addChild(`numberFormat`,{component:jY,props:{class:`o-menu-item-button o-hoverable-button o-toolbar-button`},sequence:4}).add(`fontSize`).addChild(`fontSize`,{component:AY,props:{class:`o-hoverable-button o-toolbar-button`},sequence:3}).add(`textStyle`).addChild(`textStyle`,{component:yI,props:{action:dR,class:`o-hoverable-button o-toolbar-button`},sequence:1}).addChild(`textStyle`,{component:yI,props:{action:fR,class:`o-hoverable-button o-toolbar-button`},sequence:2}).addChild(`textStyle`,{component:yI,props:{action:SR,class:`o-hoverable-button o-toolbar-button`},sequence:3}).addChild(`textStyle`,{component:OY,props:{class:`o-hoverable-button o-menu-item-button o-toolbar-button`,style:`textColor`,icon:`o-spreadsheet-Icon.TEXT_COLOR`,title:k(`Text Color`)},sequence:4}).add(`cellStyle`).addChild(`cellStyle`,{component:OY,props:{class:`o-hoverable-button o-menu-item-button o-toolbar-button`,style:`fillColor`,icon:`o-spreadsheet-Icon.FILL_COLOR`,title:k(`Fill Color`)},sequence:1}).addChild(`cellStyle`,{component:TY,props:{class:`o-hoverable-button o-menu-item-button o-toolbar-button`},sequence:2}).addChild(`cellStyle`,{component:yI,props:{action:wH,class:`o-hoverable-button o-menu-item-button o-toolbar-button`},sequence:3}).add(`alignment`).addChild(`alignment`,{component:kY,props:{parentAction:TR,childActions:[ER,DR,OR],class:`o-hoverable-button o-toolbar-button`,childClass:`o-hoverable-button`},sequence:1}).addChild(`alignment`,{component:kY,props:{parentAction:kR,childActions:[AR,jR,MR],class:`o-hoverable-button o-menu-item-button o-toolbar-button`,childClass:`o-hoverable-button`},sequence:2}).addChild(`alignment`,{component:kY,props:{parentAction:PR,childActions:[FR,IR,LR],class:`o-hoverable-button o-menu-item-button o-toolbar-button`,childClass:`o-hoverable-button`},sequence:3}).addChild(`alignment`,{component:kY,props:{parentAction:mR,childActions:[_R,vR,yR,bR,xR],class:`o-hoverable-button o-menu-item-button o-toolbar-button`,childClass:`o-hoverable-button`},sequence:4}).add(`misc`).addChild(`misc`,{component:DY,props:{class:`o-toolbar-button o-hoverable-button o-menu-item-button o-mobile-disabled`},sequence:1}).addChild(`misc`,{component:yI,props:{action:aU,class:`o-hoverable-button o-menu-item-button o-toolbar-button`},sequence:2});var PY=class extends t.Component{static template=`o-spreadsheet-TopBar`;static props={onClick:Function,dropdownMaxHeight:Number};static components={MenuPopover:Fv,TopBarComposer:yY,Popover:jv};toolsCategories=NY.getCategories();state=(0,t.useState)({menuState:{isOpen:!1,anchorRect:null,menuItems:[]},invisibleToolsCategories:[],toolsPopoverState:{isOpen:!1}});isSelectingMenu=!1;openedEl=null;menus=[];toolbarMenuRegistry=NY;formatNumberMenuItemSpec=DJ;isntToolbarMenu=!1;composerFocusStore;fingerprints;topBarToolStore;toolBarContainerRef=(0,t.useRef)(`toolBarContainer`);toolbarRef=(0,t.useRef)(`toolBar`);moreToolsContainerRef=(0,t.useRef)(`moreToolsContainer`);moreToolsButtonRef=(0,t.useRef)(`moreToolsButton`);spreadsheetRect=kv();setup(){this.composerFocusStore=D(xr),this.fingerprints=D(TV),this.topBarToolStore=D(bY),(0,t.useExternalListener)(window,`click`,this.onExternalClick),(0,t.onWillStart)(()=>this.updateCellState()),(0,t.onWillUpdateProps)(()=>this.updateCellState()),(0,t.useEffect)(()=>{this.state.toolsPopoverState.isOpen=!1,this.setVisibilityToolsGroups()},()=>[this.spreadsheetRect.width])}setVisibilityToolsGroups(){if(this.env.model.getters.isReadonly())return;let e=[],{x:t}=this.toolbarRef.el.getBoundingClientRect(),{x:n}=this.toolBarContainerRef.el.getBoundingClientRect();this.moreToolsContainerRef.el?.classList.remove(`d-none`);let r=this.moreToolsButtonRef.el?.getBoundingClientRect().width||0,i=Math.round(this.spreadsheetRect.width)-r-(t-n)-16,a=document.querySelectorAll(`.tool-container`),o=0;for(let t=0;t<a.length;t++){let n=a[t];n.classList.remove(`d-none`);let{width:r}=n.getBoundingClientRect();o+=r,o>i&&(n.classList.add(`d-none`),e.push(this.toolsCategories[t]))}this.state.invisibleToolsCategories=e,e.length||this.moreToolsContainerRef.el?.classList.add(`d-none`)}get topbarComponents(){return YJ.getAllOrdered().filter(e=>!e.isVisible||e.isVisible(this.env))}get currentFontSize(){return this.env.model.getters.getCurrentStyle().fontSize||we}onExternalClick(e){this.openedEl!==e.target&&this.closeMenus()}onClick(){this.props.onClick(),this.closeMenus()}onMenuMouseOver(e,t){this.isSelectingMenu&&this.isntToolbarMenu&&this.openMenu(e,t)}toggleContextMenu(e,t){this.state.menuState.isOpen&&this.isntToolbarMenu?this.closeMenus():(this.openMenu(e,t),this.isntToolbarMenu=!0)}openMenu(e,t){this.topBarToolStore.currentDropdown&&this.topBarToolStore.closeDropdowns(),this.state.toolsPopoverState.isOpen=!1,this.state.menuState.isOpen=!0,this.state.menuState.anchorRect=op(t.currentTarget),this.state.menuState.menuItems=e.children(this.env).sort((e,t)=>e.sequence-t.sequence),this.state.menuState.parentMenu=e,this.isSelectingMenu=!0,this.openedEl=t.target,this.composerFocusStore.activeComposer.stopEdition()}closeMenus(){this.topBarToolStore.currentDropdown&&this.topBarToolStore.closeDropdowns(),this.state.toolsPopoverState.isOpen=!1,this.state.menuState.isOpen=!1,this.state.menuState.parentMenu=void 0,this.isSelectingMenu=!1,this.openedEl=null}updateCellState(){this.menus=kJ.getMenuItems()}getMenuName(e){return e.name(this.env)}setColor(e,t){KP(this.env,{[e]:t}),this.onClick()}setFontSize(e){KP(this.env,{fontSize:e})}toggleMoreTools(){this.topBarToolStore.currentDropdown&&this.topBarToolStore.closeDropdowns(),this.state.toolsPopoverState.isOpen=!this.state.toolsPopoverState.isOpen}get toolsPopoverProps(){return{anchorRect:this.moreToolsButtonRef.el?op(this.moreToolsButtonRef.el):{x:0,y:0,width:0,height:0},positioning:`bottom-left`,verticalOffset:0,class:`rounded`,maxWidth:300}}showDivider(e){return e<this.toolsCategories.length-1||this.state.invisibleToolsCategories.length>0}};function FY(){return new IY(navigator.clipboard)}var IY=class{clipboard;constructor(e){this.clipboard=e}async write(e){if(this.clipboard?.write)try{await this.clipboard?.write(this.getClipboardItems(e))}catch(t){console.log(`Failed to write on the clipboard, falling back to plain/html text. Error %s`,t);try{await this.clipboard?.write([new ClipboardItem({"text/plain":this.getBlob(e,`text/plain`),"text/html":this.getBlob(e,`text/html`)})])}catch{}}else await this.writeText(e[`text/plain`]??``)}async writeText(e){try{this.clipboard?.writeText(e)}catch{}}async read(){let e;try{e=await navigator.permissions.query({name:`clipboard-read`})}catch{}if(this.clipboard?.read)try{let e=await this.clipboard.read(),t={};for(let n of e)for(let e of n.types){let r=await n.getType(e);CP.includes(e)?t[e]=r:t[e]=await r.text()}return{status:`ok`,content:t}}catch{return{status:e?.state===`denied`?`permissionDenied`:`notImplemented`}}else return{status:`ok`,content:{"text/plain":await this.clipboard?.readText()}}}getClipboardItems(e){let t={};for(let n of Object.keys(e))t[n]=this.getBlob(e,n);return[new ClipboardItem(t)]}getBlob(e,t){let n=e[t];return n instanceof Blob||n instanceof File?n:new Blob([e[t]||``],{type:t})}},LY=class extends t.Component{static template=`o-spreadsheet-Spreadsheet`;static props={model:Object,notifyUser:{type:Function,optional:!0},raiseError:{type:Function,optional:!0},askConfirmation:{type:Function,optional:!0},colorScheme:{type:String,optional:!0}};static components={TopBar:PY,Grid:LW,BottomBar:sY,SmallBottomBar:vY,SidePanels:gY,SpreadsheetDashboard:lY,HeaderGroupContainer:pY,FullScreenFigure:BW};sidePanel;spreadsheetRef=(0,t.useRef)(`spreadsheet`);spreadsheetRect=kv();_focusGrid;isViewportTooSmall=!1;notificationStore;composerFocusStore;get model(){return this.props.model}getStyle(){let e={},t=this.env.model.getters.getScrollBarWidth();return this.env.isDashboard()?e[`grid-template-rows`]=`auto`:e[`grid-template-rows`]=`min-content auto min-content`,e[`grid-template-columns`]=`auto ${this.sidePanel.mainPanel?`${this.sidePanel.totalPanelSize||350}px`:`auto`}`,e[`--os-scrollbar-width`]=`${t}px`,e[`color-scheme`]=this.props.colorScheme,U(e)}setup(){if(!(`isSmall`in this.env)){let e=mY();(0,t.useSubEnv)({get isSmall(){return e.isSmall}})}let e=lr();e.inject(mr,this.model);let n=this.env;e.get(xV).setSmallThreshhold(()=>n.isSmall),this.notificationStore=D(kN),this.composerFocusStore=D(xr),this.sidePanel=D(SV);let r=this.model.config.external.fileStore;(0,t.useSubEnv)({model:this.model,imageProvider:r?new ZJ(r):void 0,loadCurrencies:this.model.config.external.loadCurrencies,loadLocales:this.model.config.external.loadLocales,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.sidePanel.open.bind(this.sidePanel),replaceSidePanel:this.sidePanel.replace.bind(this.sidePanel),toggleSidePanel:this.sidePanel.toggle.bind(this.sidePanel),clipboard:this.env.clipboard||FY(),startCellEdition:e=>this.composerFocusStore.focusActiveComposer({content:e}),notifyUser:e=>this.notificationStore.notifyUser(e),askConfirmation:(e,t,n)=>this.notificationStore.askConfirmation(e,t,n),raiseError:(e,t)=>this.notificationStore.raiseError(e,t),isMobile:Cp}),this.notificationStore.updateNotificationCallbacks({...this.props}),(0,t.useEffect)(()=>{!this.spreadsheetRef.el.contains(document.activeElement)&&document.activeElement?.contains(this.spreadsheetRef.el)&&this.focusGrid()}),(0,t.useExternalListener)(window,`resize`,()=>this.render(!0)),(0,t.useExternalListener)(document.body,`wheel`,()=>{}),(0,t.onWillUpdateProps)(e=>{if(e.model!==this.props.model)throw Error(`Changing the props model is not supported at the moment.`);(e.notifyUser!==this.props.notifyUser||e.askConfirmation!==this.props.askConfirmation||e.raiseError!==this.props.raiseError)&&this.notificationStore.updateNotificationCallbacks({...e})});let i=mt(this.render.bind(this,!0));(0,t.onMounted)(()=>{this.bindModelEvents(),this.checkViewportSize(),e.on(`store-updated`,this,i),a.observe(this.spreadsheetRef.el)}),(0,t.onWillUnmount)(()=>{this.unbindModelEvents(),e.off(`store-updated`,this),a.disconnect(),eu()}),(0,t.onPatched)(()=>{this.checkViewportSize()});let a=new ResizeObserver(()=>{this.sidePanel.changeSpreadsheetWidth(this.spreadsheetRect.width)})}bindModelEvents(){this.model.on(`update`,this,()=>this.render(!0)),this.model.on(`command-rejected`,this,({result:e})=>{e.isCancelledBecause(`SheetLocked`)&&this.notificationStore.notifyUser({type:`info`,text:k(`This sheet is locked and cannot be modified. Please unlock it first.`),sticky:!1})}),this.model.on(`notify-ui`,this,e=>this.notificationStore.notifyUser(e)),this.model.on(`raise-error-ui`,this,({text:e})=>this.notificationStore.raiseError(e))}unbindModelEvents(){this.model.off(`update`,this),this.model.off(`command-rejected`,this),this.model.off(`notify-ui`,this),this.model.off(`raise-error-ui`,this)}checkViewportSize(){let{xRatio:e,yRatio:t}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());if(!(!isFinite(e)||!isFinite(t)))if(t>.85||e>.85){if(this.isViewportTooSmall)return;this.notificationStore.notifyUser({text:k(`The current window is too small to display this sheet properly. Consider resizing your browser window or adjusting frozen rows and columns.`),type:`warning`,sticky:!1}),this.isViewportTooSmall=!0}else this.isViewportTooSmall=!1}focusGrid(){this._focusGrid&&this._focusGrid()}get gridHeight(){return this.env.model.getters.getSheetViewDimension().height}get gridContainerStyle(){let e=21*this.rowLayers.length,t=21*this.colLayers.length,n=this.env.model.getters.getViewportZoomLevel();return U({"grid-template-columns":`${e?e+2:0}px auto`,"grid-template-rows":`${t?t+2:0}px auto`,zoom:`${n}`})}get rowLayers(){let e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getVisibleGroupLayers(e,`ROW`)}get colLayers(){let e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getVisibleGroupLayers(e,`COL`)}getGridSize(){let e=this.spreadsheetRef.el;if(!e)return{width:0,height:0};let t=this.env.model.getters.getViewportZoomLevel(),n=this.env.model.getters.getScrollBarWidth(),r=n=>e.querySelector(n)&&ip(e.querySelector(n),t).height||0,i=n=>e.querySelector(n)&&ip(e.querySelector(n),t).width||0,a=e.getBoundingClientRect(),o=r(`.o-spreadsheet-topbar-wrapper`),s=r(`.o-spreadsheet-bottombar-wrapper`),c=r(`.o-column-groups`),l=i(`.o-grid`),u=a.height-c-o-s;return{width:Math.max(l/t-n,0),height:Math.max(u/t-n,0)}}getSpreadSheetClasses(){return[this.env.isSmall?`o-spreadsheet-mobile`:``,this.props.colorScheme===`dark`?`dark`:``].join(` `)}},RY=class{transportService;constructor(e){this.transportService=e}async sendMessage(e){(e.type===`CLIENT_JOINED`||e.type===`CLIENT_LEFT`||e.type===`CLIENT_MOVED`)&&await this.transportService.sendMessage(e)}onNewMessage(e,t){this.transportService.onNewMessage(e,t)}leave(e){this.transportService.leave(e)}};function zY(e){return oJ.get(e.type)(e)}var BY=class e{buildTransformation;operations;constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){let t=this.operations.find(t=>t.id===e);if(!t)throw Error(`Operation ${e} not found`);return t}getLastOperationId(){return this.operations[this.operations.length-1]?.id}getFirstOperationAmong(e,t){for(let n of this.operations){if(n.id===e)return e;if(n.id===t)return t}throw Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find(t=>t.id===e)}prepend(e){let t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map(e=>e.transformed(t))]}insert(e,t){let n=this.buildTransformation.with(e.data),{before:r,operation:i,after:a}=this.locateOperation(t);this.operations=[...r,i,e,...a.map(e=>e.transformed(n))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(t){let{after:n}=this.locateOperation(t);return new e(this.buildTransformation,n)}transform(e){this.operations=this.operations.map(t=>t.transformed(e))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){let{before:t,operation:n}=this.locateOperation(e);this.operations=t.concat([n])}locateOperation(e){let t=this.operations.findIndex(t=>t.id===e);if(t===-1)throw Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}},VY=class{id;data;constructor(e,t){this.id=e,this.data=t}transformed(e){return new HY(this.id,_t(()=>e(this.data)))}},HY=class e{id;lazyData;constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(t){return new e(this.id,this.lazyData.map(t))}},UY=class e{operations;constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(t){function*n(e,t){for(let n of e)if(yield n,n.operation.id===t)return}return new e(n(this.operations,t))}stopBefore(t){function*n(e,t){for(let n of e){if(n.operation.id===t)return;yield n}}return new e(n(this.operations,t))}startAfter(t){function*n(e,t){let n=!0;for(let r of e)n||(yield r),r.operation.id===t&&(n=!1)}return new e(n(this.operations,t))}},WY=class{buildTransformation;branches;branchingOperationIds=new Map;constructor(e,t){this.buildTransformation=e,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new UY(et(this._execution(e),this._execution(e)))}revertedExecution(e){return new UY(et(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){let n=e.getLastOperationId()||this.previousBranch(e)?.getLastOperationId();e.append(t),n&&this.insertPrevious(e,t,n)}insertOperationAfter(e,t,n){e.insert(t,n),this.updateNextWith(e,t,n),this.insertPrevious(e,t,n)}undo(e,t){let n=this.buildTransformation.without(t.data),r=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);let i=e.fork(t.id);r&&this.branchingOperationIds.set(i,r),this.insertBranchAfter(e,i),this.transform(i,n)}redo(e){let t=this.nextBranch(e);if(!t)return;let n=this.nextBranch(t);this.removeBranchFromTree(t);let r=this.branchingOperationIds.get(t);r?this.branchingOperationIds.set(e,r):this.branchingOperationIds.delete(e),n&&this.rebaseUp(n)}drop(e){for(let t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(let n of this.revertedExecution(e))if(n.operation.id===t)return n;throw Error(`Operation ${t} not found`)}rebaseUp(e){let{previousBranch:t,branchingOperation:n}=this.findPreviousBranchingOperation(e);if(!t||!n)return;let r=this.buildTransformation.without(n.data),i=t.fork(n.id);this.branchingOperationIds.set(i,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,i),i.transform(r);let a=this.nextBranch(i);a&&this.rebaseUp(a)}removeBranchFromTree(e){let t=this.branches.findIndex(t=>t===e);this.branches.splice(t,1)}insertBranchAfter(e,t){let n=this.branches.findIndex(t=>t===e);this.branches.splice(n+1,0,t)}updateNextWith(e,t,n){let r=this.branchingOperationIds.get(e),i=this.nextBranch(e);if(!(!r||!i))if(e.getFirstOperationAmong(n,r)===r){let a=this.addToNextBranch(e,i,r,t,n);this.updateNextWith(i,a,n)}else{let e=this.buildTransformation.with(t.data);this.transform(i,e)}}addToNextBranch(e,t,n,r,i){let a=r;return i===n?(a=this.getTransformedOperation(e,n,r),t.prepend(a)):t.contains(i)?(a=this.getTransformedOperation(e,n,r),t.insert(a,i)):t.append(r),a}getTransformedOperation(e,t,n){let r=e.getOperation(t),i=this.buildTransformation.without(r.data);return n.transformed(i)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);let n=this.nextBranch(e);n&&this.transform(n,t)}insertPrevious(e,t,n){let{previousBranch:r,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!r||!i)return;let a=this.buildTransformation.with(i.data),o=e.fork(n);o.transform(a),r.cutAfter(n),r.appendBranch(o);let s=t.transformed(a);this.insertPrevious(r,s,n)}findPreviousBranchingOperation(e){let t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};let n=this.branchingOperationIds.get(t);return n?{previousBranch:t,branchingOperation:t.getOperation(n)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){let t=this.branches.findIndex(t=>t===e);if(t!==-1)return this.branches[t+1]}previousBranch(e){let t=this.branches.findIndex(t=>t===e);if(t!==-1)return this.branches[t-1]}*_revertedExecution(e){let t=this.branchingOperationIds.get(e),n=!!t,r=e.getOperations();for(let i=r.length-1;i>=0;i--){let a=r[i];a.id===t&&(n=!1),n||(yield{operation:a,branch:e,isCancelled:!this.shouldExecute(e,a)})}let i=this.previousBranch(e);yield*i?this._revertedExecution(i):[]}*_execution(e){for(let t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){let t=this.nextBranch(e);yield*t?this._execution(t):[];return}if(!this.branchingOperationIds.get(e)){let t=this.nextBranch(e);yield*t?this._execution(t):[]}}},GY=class{HEAD_BRANCH;HEAD_OPERATION;tree;applyOperation;revertOperation;buildEmpty;buildTransformation;constructor(e){this.applyOperation=e.applyOperation,this.revertOperation=e.revertOperation,this.buildEmpty=e.buildEmpty,this.buildTransformation=e.buildTransformation,this.HEAD_BRANCH=new BY(this.buildTransformation),this.tree=new WY(this.buildTransformation,this.HEAD_BRANCH);let t=e.initialOperationId,n=new VY(t,this.buildEmpty(t));this.tree.insertOperationLast(this.HEAD_BRANCH,n),this.HEAD_OPERATION=n}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){let n=new VY(e,t),r=this.tree.getLastBranch();this.tree.insertOperationLast(r,n),this.HEAD_BRANCH=r,this.HEAD_OPERATION=n}insert(e,t,n){let r=new VY(e,t);this.revertTo(n),this.tree.insertOperationAfter(this.HEAD_BRANCH,r,n),this.fastForward()}undo(e,t,n){let{branch:r,operation:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(r,i),this.fastForward(),this.insert(t,this.buildEmpty(t),n)}redo(e,t,n){let{branch:r}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(r),this.fastForward(),this.insert(t,this.buildEmpty(t),n)}rebase(e){let t=this.get(e),n=[...this.tree.execution(this.HEAD_BRANCH).startAfter(e)];this.revertBefore(e);let r=this.HEAD_OPERATION.id;this.tree.drop(e),this.insert(e,t,r);for(let{operation:e}of n)this.insert(e.id,e.data,this.HEAD_OPERATION.id)}revertBefore(e){let t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){let t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(let{next:t,operation:n,isCancelled:r}of e)r||this.revertOperation(n.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){let e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(let{operation:t,branch:n,isCancelled:r}of e)r||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=n}};function KY(e){return new GY({initialOperationId:e.initialRevisionId,applyOperation:t=>{let n=t.commands.slice(),{changes:r}=e.recordChanges(()=>{for(let t of n)e.dispatch(t)});t.setChanges(r)},revertOperation:e=>qY([e]),buildEmpty:e=>new dq(e,`empty`,[]),buildTransformation:{with:e=>t=>new dq(t.id,t.clientId,tq(t.commands,e.commands),t.rootCommand,void 0,t.timestamp),without:e=>t=>new dq(t.id,t.clientId,tq(t.commands,e.commands.map(zY).flat()),t.rootCommand,void 0,t.timestamp)}})}function qY(e){for(let t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){let n=t.changes[e];JY(n)}}function JY(e){let t=e.target,n=e.key,r=e.before;r===void 0?delete t[n]:t[n]=r}var YY=class{getters;providers=[];isAdaptingRanges=!1;constructor(e){this.getters=e}static getters=[`copyFormulaStringForSheet`,`extendRange`,`getRangeString`,`getRangeFromSheetXC`,`createAdaptedRanges`,`getRangeData`,`getRangeDataFromXc`,`getRangeDataFromZone`,`getRangeFromRangeData`,`getRangeFromZone`,`getRangesUnion`,`recomputeRanges`,`isRangeValid`,`removeRangesSheetPrefix`];allowDispatch(e){return e.type===`MOVE_RANGES`?e.target.length===1?`Success`:`InvalidZones`:`Success`}beforeHandle(e){}handle(e){if(this.isAdaptingRanges)throw Error(`Plugins cannot dispatch commands during adaptRanges phase`);let t=sl(e);t&&this.executeOnAllRanges(t)}finalize(){}verifyRangeRemoved(e){return t=>{let n=e(t);return n.changeType!==`NONE`&&!_n(n.range.zone)?{range:n.range,changeType:`REMOVE`}:n}}executeOnAllRanges(e){this.isAdaptingRanges=!0;let t={applyChange:this.verifyRangeRemoved(e.applyChange),adaptRangeString:(t,n)=>Xu(t,n,e),adaptFormulaString:(t,n)=>Yu(t,n,e)};for(let n of this.providers)n(t,e.sheetId,e.sheetName);this.isAdaptingRanges=!1}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,n,r){return e.map(e=>{if(!_n(e.zone))return e;let i=e.prefixSheet?e.sheetId:r,a=$c(e),o=Qc(e),s={...e.unboundedZone,left:a&&!e.unboundedZone.hasHeader?e.unboundedZone.left:e.unboundedZone.left+(e.parts[0].colFixed?0:t),right:a?e.unboundedZone.right:e.unboundedZone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:o&&!e.unboundedZone.hasHeader?e.unboundedZone.top:e.unboundedZone.top+(e.parts[0].rowFixed?0:n),bottom:o?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:n)};return ol(Yc({...e,sheetId:i,zone:s},this.getters.getSheetSize))})}removeRangesSheetPrefix(e,t){return t.map(t=>t.prefixSheet&&t.sheetId===e?{...t,prefixSheet:!1}:t)}extendRange(e,t,n){let r=t===`COL`?e.zone.right+n:e.zone.right,i=t===`ROW`?e.zone.bottom+n:e.zone.bottom,a={left:e.zone.left,top:e.zone.top,right:$c(e)?void 0:r,bottom:Qc(e)?void 0:i};return Yc({...e,zone:a},this.getters.getSheetSize)}getRangeFromSheetXC(e,t){if(!Nc.test(t)||!this.getters.tryGetSheet(e))return Zc(t);let{sheetName:n}=zc(t);return Xc({xc:t,sheetId:this.getters.getSheetIdByName(n)||e,invalidSheetName:n&&!this.getters.getSheetIdByName(n)?n:void 0},this.getters.getSheetSize)}getRangeString(e,t,n={useBoundedReference:!1,useFixedReference:!1}){return e?e.invalidXc?e.invalidXc:this.getters.tryGetSheet(e.sheetId)?el(e,t,this.getters.getSheetName,n):A.InvalidReference:A.InvalidReference}getRangeDataFromXc(e,t){let n=this.getters.getRangeFromSheetXC(e,t);return this.getRangeDataFromZone(n.sheetId,n.unboundedZone)}getRangeDataFromZone(e,t){return t=this.getters.getUnboundedZone(e,t),{_sheetId:e,_zone:t}}getRangeData(e){return this.getRangeDataFromZone(e.sheetId,e.unboundedZone)}getRangeFromZone(e,t){return Yc({sheetId:e,zone:t,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}],prefixSheet:!1},this.getters.getSheetSize)}recomputeRanges(e,t){return nn(e.map(e=>e.unboundedZone),t.map(e=>e.unboundedZone)).map(t=>this.getRangeFromZone(e[0].sheetId,t))}getRangeFromRangeData(e){return this.getters.tryGetSheet(e._sheetId)?Yc({prefixSheet:!1,zone:e._zone,sheetId:e._sheetId,invalidSheetName:void 0,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}]},this.getters.getSheetSize):Zc(A.InvalidReference)}isRangeValid(e){if(!e)return!1;let{xc:t,sheetName:n}=zc(e);return t.match(Nc)!==null&&(!n||this.getters.getSheetIdByName(n)!==void 0)}getRangesUnion(e){let t=Tn(...e.map(e=>e.unboundedZone));return this.getRangeFromZone(e[0].sheetId,t)}copyFormulaStringForSheet(e,t,n,r){if(!n.startsWith(`=`))return n;let i=xz.Compile(n,e,this.getters),a=i.rangeDependencies.map(n=>r===`keepSameReference`?n:tl(e,t,n));return xz.CopyWithDependencies(i,t,a).toFormulaString(this.getters)}},XY=class{observers=new Map;defaultSubscription;mainSubscription;registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||=this.defaultSubscription}observe(e,t){this.observers.set(e,{owner:e,callbacks:t})}unobserve(e){this.observers.delete(e)}capture(e,t){if(this.observers.get(e))throw Error(`You are already subscribed forever`);this.mainSubscription?.owner&&this.mainSubscription.owner!==e&&this.mainSubscription.callbacks.release?.(),this.mainSubscription={owner:e,callbacks:t}}release(e){this.mainSubscription?.owner!==e||this.observers.get(e)||(this.mainSubscription=this.defaultSubscription)}getBackToDefault(){this.mainSubscription!==this.defaultSubscription&&(this.mainSubscription?.callbacks.release?.(),this.mainSubscription=this.defaultSubscription)}isListening(e){return this.mainSubscription?.owner===e}send(e){this.mainSubscription?.callbacks.handleEvent(e),this.observers.forEach(t=>t.callbacks.handleEvent(e))}},ZY=class{getters;stream;anchor;defaultAnchor;constructor(e){this.getters=e,this.stream=new XY,this.anchor={cell:{col:0,row:0},zone:E({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,n){this.stream.capture(e,n),this.anchor=t}registerAsDefault(e,t,n){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,n),this.defaultAnchor=t,this.capture(e,t,n)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}unobserve(e){this.stream.unobserve(e)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}modifyAnchor(e,t,n){let r=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(r,e.zone)},this.processEvent({options:n,anchor:e,mode:t})}selectZone(e,t={scrollIntoView:!0}){return this.modifyAnchor(e,`overrideSelection`,t)}selectCell(e,t){let n=E({col:e,row:t});return this.selectZone({zone:n,cell:{col:e,row:t}},{scrollIntoView:!0})}moveAnchorCell(e,t=1){if(t!==`end`&&t<=0)return new Ys(`InvalidSelectionStep`);let{col:n,row:r}=this.getNextAvailablePosition(e,t);return this.selectCell(n,r)}updateAnchorCell(e,t,n={scrollIntoView:!0}){return this.processEvent({mode:`updateAnchor`,anchor:{zone:this.anchor.zone,cell:{col:e,row:t}},options:n})}setAnchorCorner(e,t){let n=this.getters.getActiveSheetId(),{col:r,row:i}=this.anchor.cell,a={left:Math.min(r,e),top:Math.min(i,t),right:Math.max(r,e),bottom:Math.max(i,t)},o=this.getters.expandZone(n,a);if(Dn(this.anchor.zone,o))return new Ys(`NoChanges`);let s={zone:o,cell:{col:r,row:i}};return this.processEvent({mode:`updateAnchor`,anchor:s,options:{scrollIntoView:!1}})}addCellToSelection(e,t){let n=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:n,col:e,row:t}));let r=this.getters.expandZone(n,E({col:e,row:t}));return this.processEvent({options:{scrollIntoView:!0},anchor:{zone:r,cell:{col:e,row:t}},mode:`newAnchor`})}commitSelection(){return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:this.anchor,mode:`commitSelection`})}resizeAnchorZone(e,t=1){if(t!==`end`&&t<=0)return new Ys(`InvalidSelectionStep`);let n=this.getters.getActiveSheetId(),r=this.anchor,{col:i,row:a}=r.cell,{left:o,right:s,top:c,bottom:l}=r.zone,u=this.getStartingPosition(e),[d,f]=this.deltaToTarget(u,e,t);if(d===0&&f===0)return Ys.Success;let p=r.zone,m=e=>{e=Ln(e);let{left:t,right:r,top:i,bottom:a}=this.getters.expandZone(n,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(n)-1,r),top:Math.max(0,i),bottom:Math.min(this.getters.getNumberRows(n)-1,a)}},{cell:h,zone:g}=this.getReferenceAnchor(),{col:_,row:v}=h,y=0;for(;p!==null;){if(y++,d<0){let e=this.getNextAvailableCol(d,s-(y-1),v);p=g.right<=s-y?m({top:c,left:o,bottom:l,right:e}):null}if(d>0){let e=this.getNextAvailableCol(d,o+(y-1),v);p=o+y<=g.left?m({top:c,left:e,bottom:l,right:s}):null}if(f<0){let e=this.getNextAvailableRow(f,_,l-(y-1));p=g.bottom<=l-y?m({top:c,left:o,bottom:e,right:s}):null}if(f>0){let e=this.getNextAvailableRow(f,_,c+(y-1));p=c+y<=g.top?m({top:e,left:o,bottom:l,right:s}):null}if(p&&=Ln(p),p&&!Dn(p,r.zone))return this.processEvent({options:{scrollIntoView:!0},mode:`updateAnchor`,anchor:{zone:p,cell:{col:i,row:a}}})}p=m(wn({top:a,bottom:a,left:i,right:i},Ln({top:this.getNextAvailableRow(f,_,c),left:this.getNextAvailableCol(d,o,v),bottom:this.getNextAvailableRow(f,_,l),right:this.getNextAvailableCol(d,s,v)})));let ee={zone:p,cell:{col:i,row:a}};return this.processEvent({anchor:ee,mode:`updateAnchor`,options:{scrollIntoView:!0}})}selectColumn(e,t){let n=this.getters.getActiveSheetId(),r=this.getters.getNumberRows(n)-1,i={left:e,right:e,top:0,bottom:r},a=this.getters.findFirstVisibleColRowIndex(n,`ROW`),o,s;switch(t){case`overrideSelection`:case`newAnchor`:o=e,s=a;break;case`updateAnchor`:({col:o,row:s}=this.anchor.cell),i=wn(i,{left:o,right:o,top:a,bottom:r});break}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:i,cell:{col:o,row:s}},mode:t})}selectRow(e,t){let n=this.getters.getActiveSheetId(),r=this.getters.getNumberCols(n)-1,i={top:e,bottom:e,left:0,right:r},a=this.getters.findFirstVisibleColRowIndex(n,`COL`),o,s;switch(t){case`overrideSelection`:case`newAnchor`:o=a,s=e;break;case`updateAnchor`:({col:o,row:s}=this.anchor.cell),i=wn(i,{left:a,right:r,top:s,bottom:s});break}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:i,cell:{col:o,row:s}},mode:t})}loopSelection(){let e=this.getters.getActiveSheetId(),t=this.anchor;if(Dn(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:E(t.cell)},`updateAnchor`,{scrollIntoView:!1});let n=this.getters.getContiguousZone(e,t.zone);return w(n,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:n},`updateAnchor`,{scrollIntoView:!1})}selectTableAroundSelection(){let e=this.getters.getActiveSheetId(),t=this.getters.getContiguousZone(e,this.anchor.zone);return this.modifyAnchor({...this.anchor,zone:t},`updateAnchor`,{scrollIntoView:!1})}selectAll(){let e=this.getters.getActiveSheetId(),t={left:0,top:0,bottom:this.getters.getNumberRows(e)-1,right:this.getters.getNumberCols(e)-1};return this.processEvent({mode:`overrideSelection`,anchor:{zone:t,cell:this.anchor.cell},options:{scrollIntoView:!1}})}isListening(e){return this.stream.isListening(e)}processEvent(e){let t={...e,previousAnchor:b(this.anchor)},n=this.checkEventAnchorZone(t);return n===`Success`?(this.anchor=t.anchor,this.stream.send(t),Ys.Success):new Ys(n)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){let{cell:t,zone:n}=e;if(!An(t.col,t.row,n))return`InvalidAnchorZone`;let{left:r,right:i,top:a,bottom:o}=n,s=this.getters.getActiveSheetId(),c=this.getters.findVisibleHeader(s,`COL`,r,i);return this.getters.findVisibleHeader(s,`ROW`,a,o)===void 0||c===void 0?`SelectionOutOfBound`:`Success`}checkAnchorZoneOrThrow(e){if(this.checkAnchorZone(e)===`InvalidAnchorZone`)throw Error(`The provided anchor is invalid. The cell must be part of the zone.`)}getNextAvailablePosition(e,t=1){let{col:n,row:r}=this.anchor.cell,i=this.deltaToTarget({col:n,row:r},e,t);return{col:this.getNextAvailableCol(i[0],n,r),row:this.getNextAvailableRow(i[1],n,r)}}getNextAvailableCol(e,t,n){let r=this.getters.getActiveSheetId(),i={col:t,row:n};return this.getNextAvailableHeader(e,`COL`,t,i,e=>this.getters.isInSameMerge(r,t,n,e,n))}getNextAvailableRow(e,t,n){let r=this.getters.getActiveSheetId(),i={col:t,row:n};return this.getNextAvailableHeader(e,`ROW`,n,i,e=>this.getters.isInSameMerge(r,t,n,t,e))}getNextAvailableHeader(e,t,n,r,i){let a=this.getters.getActiveSheetId();if(e===0)return n;let o=Math.sign(e),s=n+e;for(;i(s);)s+=o;for(;this.getters.isHeaderHidden(a,t,s);)s+=o;return s<0||s>this.getters.getNumberHeaders(a,t)-1?this.getters.isHeaderHidden(a,t,n)?this.getNextAvailableHeader(-o,t,n,r,i):n:s}getReferenceAnchor(){let e=this.getters.getActiveSheetId(),t=this.anchor,{left:n,right:r,top:i,bottom:a}=t.zone,{col:o,row:s}=t.cell,c=this.getters.isColHidden(e,o)&&this.getters.findVisibleHeader(e,`COL`,n,r)||o,l=this.getters.isRowHidden(e,s)&&this.getters.findVisibleHeader(e,`ROW`,i,a)||s,u=this.getters.expandZone(e,{left:c,right:c,top:l,bottom:l});return{cell:{col:c,row:l},zone:u}}deltaToTarget(e,t,n){switch(t){case`up`:return n===`end`?[0,this.getEndOfCluster(e,`rows`,-1)-e.row]:[0,-n];case`down`:return n===`end`?[0,this.getEndOfCluster(e,`rows`,1)-e.row]:[0,n];case`left`:return n===`end`?[this.getEndOfCluster(e,`cols`,-1)-e.col,0]:[-n,0];case`right`:return n===`end`?[this.getEndOfCluster(e,`cols`,1)-e.col,0]:[n,0]}}getStartingPosition(e){let{col:t,row:n}=this.getPosition(),r=this.anchor.zone;switch(e){case`down`:case`up`:n=n===r.top?r.bottom:r.top;break;case`left`:case`right`:t=t===r.right?r.left:r.right;break}return{col:t,row:n}}getEndOfCluster(e,t,n){let r=this.getters.getActiveSheetId(),i=e,a=this.getNextCellPosition(e,t,n),o=!this.isCellSkippableInCluster({...i,sheetId:r})&&!this.isCellSkippableInCluster({...a,sheetId:r})?`endOfCluster`:`nextCluster`;for(;;){let e=this.getNextCellPosition(i,t,n);if(i.col===e.col&&i.row===e.row)break;let a=this.isCellSkippableInCluster({...e,sheetId:r});if(o===`endOfCluster`&&a)break;if(o===`nextCluster`&&!a){i=e;break}i=e}return t===`cols`?i.col:i.row}getNextCellPosition(e,t,n){let r=t===`cols`?`col`:`row`,i={...e};return i[r]=t===`cols`?this.getNextAvailableCol(n,i.col,i.row):this.getNextAvailableRow(n,i.col,i.row),{col:i.col,row:i.row}}getPosition(){return{...this.anchor.cell}}isCellSkippableInCluster(e){let t=this.getters.getMainCellPosition(e),n=this.getters.getEvaluatedCell(t);return n.type===`empty`||n.type===`text`&&n.value===``}},QY=class{changes;commands=[];recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){let t=e.pop(),n=e[0],r=e.at(-1),i=e.length-2;for(let t=1;t<=i;t++){let r=e[t];if(n[r]===void 0){let i=e[t+1];n[r]=Tl(i)}n=n[r]}n[r]!==t&&(this.changes?.push({key:r,target:n,before:n[r]}),t===void 0?delete n[r]:n[r]=t)}};let $Y=17781237,eX=17781238,tX=88853993,nX=88853994;function rX(e,t,n){let r=[[`xmlns:r`,gu],[`xmlns:a`,fu],[`xmlns:c`,pu]],i=iX({backgroundColor:e.data.backgroundColor,line:{color:`000000`}}),a=X``;if(e.data.title?.text){let t=V(fd(e.data.backgroundColor)),n=e.data.title.fontSize??16;a=X`
|
|
121
|
+
You can download it directly instead.`,5),sticky:!1,type:`warning`});return}r=await zq(t)}}if(r)return r instanceof File?r:new File([r],`image.png`,{type:`image/png`})}isCutOperation(){return this._isCutOperation??!1}getDeleteCellsTargets(e,t){let n=this.getters.getActiveSheetId(),r;return r=t===`COL`?{...e,left:e.right+1,right:this.getters.getNumberCols(n)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(n)-1},{cut:[r],paste:[e]}}getInsertCellsTargets(e,t){let n=this.getters.getActiveSheetId(),r,i;return t===`COL`?(r={...e,right:this.getters.getNumberCols(n)-1},i={...e,left:e.right+1,right:e.right+1}):(r={...e,bottom:this.getters.getNumberRows(n)-1},i={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(n)-1}),{cut:[r],paste:[i]}}getClipboardData(e){let t=this.getters.getActiveSheetId(),n=this.getters.getSelectedFigureId();if(n)return{figureId:n,sheetId:t};let r=wP(t,e);return this._isCutOperation||(r.rowsIndexes=r.rowsIndexes.filter(e=>!this.getters.isRowFiltered(t,e))),r}drawLayer(e){if(this.status!==`visible`||!this.copiedData)return;let{sheetId:t,zones:n}=this.copiedData;if(t!==this.getters.getActiveSheetId()||!n||!n.length)return;let{ctx:r,thinLineWidth:i}=e;r.setLineDash([8,5]),r.strokeStyle=ae,r.lineWidth=3.3*i;for(let e of n){let{x:t,y:n,width:i,height:a}=this.getters.getVisibleRect(e);i>0&&a>0&&r.strokeRect(t,n,i,a)}}};let Vq={filterType:`criterion`,type:`none`,values:[]};var Hq=class extends lK{static getters=[`getFilterValue`,`getFilterHiddenValues`,`getFilterCriterionValue`,`getFirstTableInSelection`,`isRowFiltered`,`isFilterActive`];filterValues={};hiddenRows={};isEvaluationDirty=!1;allowDispatch(e){switch(e.type){case`UPDATE_FILTER`:if(!this.getters.getFilterId(e))return`FilterNotFound`;break}return`Success`}handle(e){switch(e.type){case`UNDO`:case`REDO`:case`UPDATE_CELL`:case`EVALUATE_CELLS`:case`ACTIVATE_SHEET`:case`REMOVE_TABLE`:case`ADD_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:case`UPDATE_TABLE`:this.isEvaluationDirty=!0;break;case`START`:for(let e of this.getters.getSheetIds())this.filterValues[e]={};break;case`CREATE_SHEET`:this.filterValues[e.sheetId]={};break;case`HIDE_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`GROUP_HEADERS`:case`UNGROUP_HEADERS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_ALL_HEADER_GROUPS`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:this.updateHiddenRows(e.sheetId);break;case`UPDATE_FILTER`:this.updateFilter(e),this.updateHiddenRows(e.sheetId);break;case`DUPLICATE_SHEET`:this.filterValues[e.sheetIdTo]=b(this.filterValues[e.sheetId]);break}}finalize(){if(this.isEvaluationDirty){for(let e of this.getters.getSheetIds())this.updateHiddenRows(e);this.isEvaluationDirty=!1}}isRowFiltered(e,t){return!!this.hiddenRows[e]?.has(t)}getFilterValue(e){let t=this.getters.getFilterId(e),n=e.sheetId;return t?this.filterValues[n]?.[t]:void 0}getFilterHiddenValues(e){let t=this.getters.getFilterId(e),n=e.sheetId;if(!t||!this.filterValues[n])return[];let r=this.filterValues[n][t]||[];return r.filterType===`values`?r.hiddenValues:[]}getFilterCriterionValue(e){let t=this.getters.getFilterId(e),n=e.sheetId;if(!t||!this.filterValues[n])return Vq;let r=this.filterValues[n][t];return r&&r.filterType===`criterion`?r:Vq}isFilterActive(e){let t=this.getters.getFilterId(e);if(!t)return!1;let n=e.sheetId,r=this.filterValues[n]?.[t];return r?r.filterType===`values`?r.hiddenValues.length>0:r.type!==`none`:!1}getFirstTableInSelection(){let e=this.getters.getActiveSheetId(),t=this.getters.getSelectedZones();return this.getters.getTablesOverlappingZones(e,t)[0]}updateFilter({col:e,row:t,value:n,sheetId:r}){let i=this.getters.getFilterId({sheetId:r,col:e,row:t});i&&(this.filterValues[r]||(this.filterValues[r]={}),this.filterValues[r][i]=n)}updateHiddenRows(e){let t=this.getters.getFilters(e).sort((e,t)=>e.rangeWithHeaders.zone.top-t.rangeWithHeaders.zone.top),n=new Set;for(let r of t){let t=this.filterValues[e]?.[r.id],i=r.filteredRange?.zone;if(!(!t||!i||n.has(r.rangeWithHeaders.zone.top)||this.getters.isRowHiddenByUser(e,r.rangeWithHeaders.zone.top)))if(t.filterType===`values`){let a=t.hiddenValues?.map(Ul);if(!a)continue;let o=new Set(a);for(let t=i.top;t<=i.bottom;t++){let i=this.getCellValueAsString(e,r.col,t);o.has(i)&&n.add(t)}}else{if(t.type===`none`)continue;let a=Z.get(t.type),o=a.preComputeCriterion?.(t,[r.filteredRange],this.getters),s=t.values.map(t=>t.startsWith(`=`)?this.getters.evaluateFormula(e,t)??``:sc(t,R));if(s.some(wm))continue;let c={type:t.type,values:s.map(Sm),dateValue:t.dateValue};for(let t=i.top;t<=i.bottom;t++){let i={sheetId:e,col:r.col,row:t},s=this.getters.getEvaluatedCell(i).value??``;a.isValueValid(s,c,o)||n.add(t)}}}this.hiddenRows[e]=n}getCellValueAsString(e,t,n){let r=this.getters.getEvaluatedCell({sheetId:e,col:t,row:n}).formattedValue;return Ul(r)}exportForExcel(e){for(let t of e.sheets){let e=t.id;for(let n of t.tables){let r=mn(n.range),i=[],a=[];for(let n of S(0,Mn(r).numberOfCols)){let o={sheetId:t.id,col:r.left+n,row:r.top},s=this.getFilterHiddenValues(o),c=this.getters.getFilter(o),l=c?.filteredRange?Fn(c.filteredRange.zone).map(t=>this.getters.getEvaluatedCell({sheetId:e,...t}).formattedValue):[];if(s.length){let e=l.filter(e=>e).filter(e=>!s.includes(e));i.push({colId:n,displayedValues:[...new Set(e)],displayBlanks:!s.includes(``)&&l.some(e=>!e)})}let u=this.getters.getEvaluatedCell(o).formattedValue,d=this.getUniqueColNameForExcel(n,u,a);a.push(d);let f=T(o.col,o.row);t.cells[f]=d,t.cellValues[f]=d}n.filters=i}}}getUniqueColNameForExcel(e,t,n){return t||=`Column${e}`,Ht(t,n,{compute:(e,n)=>t+String(n),start:2})}},Uq=class extends lK{static getters=[`getColDimensions`,`getRowDimensions`,`getColRowOffset`];headerPositions={};isDirty=!0;handle(e){switch(Rs.has(e.type)&&(this.headerPositions={},this.isDirty=!0),e.type){case`START`:for(let e of this.getters.getSheetIds())this.headerPositions[e]=this.computeHeaderPositionsOfSheet(e);break;case`UPDATE_CELL`:this.headerPositions={},this.isDirty=!0;break;case`UPDATE_FILTER`:case`UPDATE_TABLE`:case`REMOVE_TABLE`:this.headerPositions={},this.isDirty=!0;break;case`REMOVE_COLUMNS_ROWS`:case`RESIZE_COLUMNS_ROWS`:case`HIDE_COLUMNS_ROWS`:case`ADD_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_ALL_HEADER_GROUPS`:case`UNGROUP_HEADERS`:case`GROUP_HEADERS`:case`CREATE_SHEET`:this.getters.tryGetSheet(e.sheetId)&&(this.headerPositions[e.sheetId]=this.computeHeaderPositionsOfSheet(e.sheetId));break;case`DUPLICATE_SHEET`:this.headerPositions[e.sheetIdTo]=b(this.headerPositions[e.sheetId]);break}}finalize(){for(let e of this.getters.getSheetIds())(this.isDirty||!this.headerPositions[e])&&(this.headerPositions[e]=this.computeHeaderPositionsOfSheet(e));this.isDirty=!1}getColDimensions(e,t){let n=this.headerPositions[e].COL[t],r=this.getters.getColSize(e,t);return{start:n,size:r,end:n+(this.getters.isColHidden(e,t)?0:r)}}getRowDimensions(e,t){let n=this.headerPositions[e].ROW[t],r=this.getters.getRowSize(e,t);return{start:n,size:r,end:n+(this.getters.isRowHidden(e,t)?0:r)}}getColRowOffset(e,t,n,r=this.getters.getActiveSheetId()){let i=this.headerPositions[r][e][t];return this.headerPositions[r][e][n]-i}computeHeaderPositionsOfSheet(e){return{COL:this.computePositions(e,`COL`),ROW:this.computePositions(e,`ROW`)}}computePositions(e,t){let n={},r=0;for(let i=0;i<this.getters.getNumberHeaders(e,t)+1;i++)n[i]=r,!this.getters.isHeaderHidden(e,t,i)&&(r+=this.getters.getHeaderSize(e,t,i));return n}},Wq=class extends lK{static layers=[`Selection`];static getters=[`getActiveSheet`,`getActiveSheetId`,`getActiveSheetName`,`getActiveCell`,`getActiveCols`,`getActiveRows`,`getCurrentStyle`,`getSelectedZones`,`getSelectedZone`,`getSelectedCells`,`getSelectedFigureId`,`getSelection`,`getActivePosition`,`getSheetPosition`,`isSingleColSelected`,`getElementsFromSelection`,`tryGetActiveSheetId`,`isGridSelectionActive`,`getSelectecUnboundedZone`,`getSelectionRangeString`];gridSelection={anchor:{cell:{col:0,row:0},zone:{top:0,left:0,bottom:0,right:0}},zones:[{top:0,left:0,bottom:0,right:0}]};selectedFigureId=null;sheetsData={};moveClient;isUnbounded;activeSheet=null;constructor(e){super(e),this.moveClient=e.moveClient,this.isUnbounded=!1}allowDispatch(e){switch(e.type){case`ACTIVATE_SHEET`:try{if(!this.getters.getSheet(e.sheetIdTo).isVisible)return`SheetIsHidden`;break}catch{return`InvalidSheetId`}case`MOVE_COLUMNS_ROWS`:return this.isMoveElementAllowed(e)}return`Success`}handleEvent(e){let t=e.anchor,n=[...this.gridSelection.zones];switch(this.isUnbounded=e.options?.unbounded||!1,e.mode){case`overrideSelection`:n=[t.zone];break;case`updateAnchor`:let r=n.findIndex(t=>Dn(t,e.previousAnchor.zone));r>=0&&(n[r]=t.zone);break;case`newAnchor`:n.push(t.zone);break;case`commitSelection`:let i=n.find(e=>jn(t.zone,e)&&!Dn(t.zone,e));if(n.filter(e=>Dn(t.zone,e)).length>1&&n.length>2)n=n.filter(e=>!Dn(e,t.zone));else if(i){let e=tr(t.zone,i);n=n.filter(e=>!Dn(e,t.zone)&&!Dn(e,i)).concat(e)}n=zn(n);let a=n[n.length-1];t={cell:An(t.cell.col,t.cell.row,a)?t.cell:{col:a.left,row:a.top},zone:a};break}this.setSelectionMixin(t,n),this.selection.resetDefaultAnchor(this,b(this.gridSelection.anchor));let{col:r,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:r,row:i}),this.selectedFigureId=null}handle(e){switch(e.type){case`ACTIVATE_SHEET`:this.selectedFigureId=null;break;case`DELETE_FIGURE`:this.selectedFigureId===e.figureId&&(this.selectedFigureId=null);break;case`DELETE_SHEET`:this.selectedFigureId&&this.getters.getFigure(e.sheetId,this.selectedFigureId)&&(this.selectedFigureId=null);break}switch(e.type){case`START`:let t=this.getters.getVisibleSheetIds()[0];this.activateSheet(t,t);let{col:n,row:r}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(n,r),this.selection.registerAsDefault(this,this.gridSelection.anchor,{handleEvent:this.handleEvent.bind(this)}),this.moveClient({sheetId:t,col:0,row:0});break;case`ACTIVATE_SHEET`:this.activateSheet(e.sheetIdFrom,e.sheetIdTo);break;case`REMOVE_COLUMNS_ROWS`:{let t=this.getters.getActiveSheetId();if(e.sheetId===t){e.dimension===`COL`?this.onColumnsRemoved(e):this.onRowsRemoved(e);let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:n,row:r})}break}case`ADD_COLUMNS_ROWS`:{let t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:n,row:r})}break}case`MOVE_COLUMNS_ROWS`:e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case`SELECT_FIGURE`:this.selectedFigureId=e.figureId;break;case`ACTIVATE_NEXT_SHEET`:this.activateNextSheet(`right`);break;case`ACTIVATE_PREVIOUS_SHEET`:this.activateNextSheet(`left`);break;case`HIDE_SHEET`:e.sheetId===this.getActiveSheetId()&&this.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:e.sheetId,sheetIdTo:this.getters.getVisibleSheetIds()[0]});break;case`UNDO`:case`REDO`:case`DELETE_SHEET`:let i=Object.keys(this.sheetsData).filter(e=>!this.getters.tryGetSheet(e));for(let e of i)delete this.sheetsData[e];for(let e in this.sheetsData){let t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:b(t)}}this.fallbackToVisibleSheet();let a=this.getters.getActiveSheetId();this.gridSelection.zones=this.gridSelection.zones.map(e=>this.getters.expandZone(a,e)),this.gridSelection.anchor.zone=this.getters.expandZone(a,this.gridSelection.anchor.zone),this.setSelectionMixin(this.gridSelection.anchor,this.gridSelection.zones),this.selectedFigureId=null;break}}finalize(){this.fallbackToVisibleSheet(),this.selection.resetDefaultAnchor(this,b(this.gridSelection.anchor))}isGridSelectionActive(){return this.selection.isListening(this)}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}getActiveSheetName(){return this.activeSheet.name}tryGetActiveSheetId(){return this.activeSheet?.id}getActiveCell(){return this.getters.getEvaluatedCell(this.getActivePosition())}getActiveCols(){let e=new Set;for(let t of this.gridSelection.zones)if(t.top===0&&t.bottom===this.getters.getNumberRows(this.getters.getActiveSheetId())-1)for(let n=t.left;n<=t.right;n++)e.add(n);return e}getActiveRows(){let e=new Set,t=this.getters.getActiveSheetId();for(let n of this.gridSelection.zones)if(n.left===0&&n.right===this.getters.getNumberCols(t)-1)for(let t=n.top;t<=n.bottom;t++)e.add(t);return e}getCurrentStyle(){let e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();return this.getters.getCellStyle({sheetId:t,col:e.left,row:e.top})}getSelectedZones(){return b(this.gridSelection.zones)}getSelectedZone(){return b(this.gridSelection.anchor.zone)}getSelectecUnboundedZone(){return b(this.isUnbounded?this.getters.getUnboundedZone(this.activeSheet.id,this.gridSelection.anchor.zone):this.gridSelection.anchor.zone)}getSelection(){return b(this.gridSelection)}getSelectedCells(){let e=this.getters.getActiveSheetId(),t=[];for(let n of this.gridSelection.zones)t.push(...this.getters.getEvaluatedCellsInZone(e,n));return t}getSelectedFigureId(){return this.selectedFigureId}getActivePosition(){return this.getters.getMainCellPosition({sheetId:this.getActiveSheetId(),col:this.gridSelection.anchor.cell.col,row:this.gridSelection.anchor.cell.row})}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getActivePosition();{let t=this.sheetsData[e];return t?{sheetId:e,col:t.gridSelection.anchor.cell.col,row:t.gridSelection.anchor.cell.row}:this.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0})}}isSingleColSelected(){let e=this.getters.getSelectedZones();return!(e.length!==1||e[0].left!==e[0].right)}getElementsFromSelection(e){if(e===`COL`&&this.getters.getActiveCols().size===0||e===`ROW`&&this.getters.getActiveRows().size===0)return[];let t=this.getters.getSelectedZones(),n=[],r=e===`COL`?`left`:`top`,i=e===`COL`?`right`:`bottom`;for(let e of t){let t=Array.from({length:e[i]-e[r]+1},(t,n)=>e[r]+n);n=n.concat(t)}return[...new Set(n)].sort()}getSelectionRangeString(e,t,{allowSpilledReferences:n}={allowSpilledReferences:!1}){let r=this.getters.expandZone(e.sheetId,e.zone),i=Yc({...e,zone:{...r,bottom:Qc(e)?void 0:r.bottom,right:$c(e)?void 0:r.right}},this.getters.getSheetSize),a=this.getters.getRangeString(i,t);if(this.getters.isSingleCellOrMerge(e.sheetId,e.zone)){let{sheetName:e,xc:t}=zc(a);return Bc(e,t.split(`:`)[0])}if(n){let e=this.getters.getArrayFormulaSpreadingOn({sheetId:i.sheetId,col:i.zone.left,row:i.zone.top}),t=e&&this.getters.getSpreadZone(e,{ignoreSpillError:!0});if(t&&Dn(t,i.zone)){let{sheetName:e,xc:t}=zc(a);return Bc(e,t.split(`:`)[0])+`#`}}return a}activateSheet(e,t){if(this.setActiveSheet(t),this.sheetsData[e]={gridSelection:b(this.gridSelection)},t in this.sheetsData)Object.assign(this,this.sheetsData[t]),this.selection.resetDefaultAnchor(this,b(this.gridSelection.anchor));else{let{col:e,row:n}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(e,n)}let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.activeSheet.id,col:n,row:r})}setSelectionMixin(e,t){let{anchor:n,zones:r}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=n,this.gridSelection.zones=r}selectCell(e,t){let n=this.getters.getActiveSheetId(),r=this.getters.expandZone(n,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:r,cell:{col:e,row:t}},[r])}setActiveSheet(e){this.activeSheet=this.getters.getSheet(e)}activateNextSheet(e){let t=this.getters.getSheetIds(),n=(t.findIndex(e=>e===this.activeSheet.id)+(e===`left`?t.length-1:1))%t.length;this.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[n]})}onColumnsRemoved(e){let{cell:t,zone:n}=this.gridSelection.anchor,r=Sn(n,`left`,[...e.elements]),i={left:t.col,right:t.col,top:t.row,bottom:t.row};i=Sn(i,`left`,[...e.elements]);let a={cell:{col:i.left,row:i.top},zone:r},o=this.gridSelection.zones.map(t=>Sn(t,`left`,[...e.elements]));this.setSelectionMixin(a,o)}onRowsRemoved(e){let{cell:t,zone:n}=this.gridSelection.anchor,r=Sn(n,`top`,[...e.elements]),i={left:t.col,right:t.col,top:t.row,bottom:t.row};i=Sn(i,`top`,[...e.elements]);let a={cell:{col:i.left,row:i.top},zone:r},o=this.gridSelection.zones.map(t=>Sn(t,`top`,[...e.elements]));this.setSelectionMixin(a,o)}onAddElements(e){let t=e.dimension===`COL`?`left`:`top`,n=xn(this.gridSelection.anchor.zone,t,e.base,e.position,e.quantity),r=this.gridSelection.zones.map(n=>xn(n,t,e.base,e.position,e.quantity)),i={cell:{col:n.left,row:n.top},zone:n};this.setSelectionMixin(i,r)}onMoveElements(e){let t=e.elements.length,n=this.getFiguresUpdates(e);this.dispatch(`ADD_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,sheetName:e.sheetName,base:e.base,quantity:t,position:e.position});let r=e.dimension===`COL`,i=e.elements[0],a=e.elements[t-1],o=e.base<i,s=o&&r?t:0,c=o&&!r?t:0,l=o?e.elements.map(e=>e+t):e.elements,u={};for(let t of l)u[t]=this.getters.getHeaderSize(e.sheetId,e.dimension,t);let d=[{left:r?i+s:0,right:r?a+s:this.getters.getNumberCols(e.sheetId)-1,top:r?0:i+c,bottom:r?this.getters.getNumberRows(e.sheetId)-1:a+c}],f=this.getActiveSheetId(),p=o?e.base:e.base+1,m=[{left:r?p:0,right:r?p+t-1:this.getters.getNumberCols(e.sheetId)-1,top:r?0:p,bottom:r?this.getters.getNumberRows(e.sheetId)-1:p+t-1}],h=oW.cellHandlers.getKeys().map(e=>[e,new(oW.cellHandlers.get(e))(this.getters,this.dispatch)]),g={};for(let[e,t]of h)g[e]=t.copy(wP(f,d),!1,`shiftCells`);for(let[e,t]of h)g[e]&&t.paste({zones:m,sheetId:f},g[e],{isCutOperation:!0});let _=m[0],v=_.left,y=_.top;this.setSelectionMixin({zone:_,cell:{col:v,row:y}},[_]);let ee=o?e.base:e.base+1,te={};for(let t of l){let n=u[t];n!==this.getters.getHeaderSize(e.sheetId,e.dimension,ee)&&(te[n]??=[],te[n].push(ee)),ee+=1}for(let t in te)this.dispatch(`RESIZE_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,size:parseInt(t,10),elements:te[t]});this.dispatch(`REMOVE_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,sheetName:e.sheetName,elements:l}),this.applyFigureUpdates(n)}getFiguresUpdates(e){let t=[],n={},r=e.elements[0]<e.base?e.base-e.elements.length+1:e.base;for(let t=0;t<e.elements.length;t++)n[e.elements[t]]=r+t;for(let r of this.getters.getFigures(e.sheetId))e.dimension===`COL`&&r.col in n&&t.push({type:`UPDATE_FIGURE`,sheetId:e.sheetId,figureId:r.id,col:n[r.col],row:r.row}),e.dimension===`ROW`&&r.row in n&&t.push({type:`UPDATE_FIGURE`,sheetId:e.sheetId,figureId:r.id,row:n[r.row],col:r.col});return t}applyFigureUpdates(e){for(let t of e)this.dispatch(t.type,{...t})}isMoveElementAllowed(e){let t=e.dimension===`COL`,n=e.elements[0],r=e.elements[e.elements.length-1],i=e.sheetId,a=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;if(a(i,n-1,n)||a(i,r,r+1)||a(i,e.base-1,e.base))return`WillRemoveExistingMerge`;let o=[e.base,...e.elements],s=t?this.getters.getNumberCols(i):this.getters.getNumberRows(i);return o.some(e=>e<0||e>=s)?`InvalidHeaderIndex`:!t&&!this.isTableRowMoveAllowed(i,e.elements)?`CannotMoveTableHeader`:`Success`}isTableRowMoveAllowed(e,t){let n=this.getters.getCoreTables(e);if(n.length===0)return!0;let r=new Set(t);return n.every(({range:{zone:e},config:n})=>{let{top:i,bottom:a}=e;if(n.numberOfHeaders===0)return!0;let o=i+n.numberOfHeaders-1;return t.some(e=>e>=i&&e<=o)?S(i,a+1).every(e=>r.has(e)):!0})}fallbackToVisibleSheet(){if(!this.getters.tryGetSheet(this.getters.getActiveSheetId())){let e=this.getters.getVisibleSheetIds();if(this.activeSheet=this.getters.getSheet(e[0]),this.activeSheet.id in this.sheetsData){let{anchor:e}=this.clipSelection(this.activeSheet.id,this.sheetsData[this.activeSheet.id].gridSelection);this.selectCell(e.cell.col,e.cell.row)}else this.selectCell(0,0);let{col:t,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:n})}}clipSelection(e,t){let n=this.getters.getNumberCols(e)-1,r=this.getters.getNumberRows(e)-1,i=t.zones.map(e=>({left:x(e.left,0,n),right:x(e.right,0,n),top:x(e.top,0,r),bottom:x(e.bottom,0,r)})),a=x(t.anchor.cell.col,0,n),o=x(t.anchor.cell.row,0,r),s={left:x(t.anchor.zone.left,0,n),right:x(t.anchor.zone.right,0,n),top:x(t.anchor.zone.top,0,r),bottom:x(t.anchor.zone.bottom,0,r)};return{zones:i,anchor:{cell:{col:a,row:o},zone:s}}}drawLayer(e){if(this.getters.isDashboard())return;let{ctx:t,thinLineWidth:n}=e,r=this.getSelectedZones();t.fillStyle=`#f3f7fe`,t.fillStyle=r.length===1&&r[0].left===r[0].right&&r[0].top===r[0].bottom?`#f3f7fe`:`#e9f0ff`,t.strokeStyle=ae,t.lineWidth=1.5*n;for(let e of r){let{x:n,y:r,width:i,height:a}=this.getters.getVisibleRect(e);t.globalCompositeOperation=`multiply`,t.fillRect(n,r,i,a),t.globalCompositeOperation=`source-over`,t.strokeRect(n,r,i,a)}t.globalCompositeOperation=`source-over`;let i=this.getActivePosition();t.strokeStyle=ae,t.lineWidth=3*n;let a;a=this.getters.isInMerge(i)?this.getters.getMerge(i):E(i);let{x:o,y:s,width:c,height:l}=this.getters.getVisibleRect(a);c>0&&l>0&&t.strokeRect(o,s,c,l)}},Gq=class{getters;sheetId;boundaries;top;bottom;left;right;offsetX;offsetY;canScrollVertically;canScrollHorizontally;viewportWidth;viewportHeight;offsetCorrectionX;offsetCorrectionY;constructor(e,t,n,r,i,a){if(this.getters=e,this.sheetId=t,this.boundaries=n,r.width<0||r.height<0)throw Error(`Viewport size cannot be negative`);this.viewportWidth=r.height&&r.width,this.viewportHeight=r.width&&r.height,this.top=n.top,this.bottom=n.bottom,this.left=n.left,this.right=n.right,this.offsetX=a.x,this.offsetY=a.y,this.canScrollVertically=i.canScrollVertically,this.canScrollHorizontally=i.canScrollHorizontally,this.offsetCorrectionX=this.getters.getColDimensions(this.sheetId,this.boundaries.left).start,this.offsetCorrectionY=this.getters.getRowDimensions(this.sheetId,this.boundaries.top).start,this.adjustViewportOffsetX(),this.adjustViewportOffsetY()}getMaxSize(){let e=this.getters.findLastVisibleColRowIndex(this.sheetId,`COL`,{first:this.boundaries.left,last:this.boundaries.right}),t=this.getters.findLastVisibleColRowIndex(this.sheetId,`ROW`,{first:this.boundaries.top,last:this.boundaries.bottom}),{end:n}=this.getters.getColDimensions(this.sheetId,e),{end:r}=this.getters.getRowDimensions(this.sheetId,t),i=n-this.offsetCorrectionX;this.canScrollHorizontally&&(i=Math.max(i,this.viewportWidth));let a=r-this.offsetCorrectionY;return this.canScrollVertically&&(a=Math.max(a,this.viewportHeight),r+46>a&&!this.getters.isReadonly()&&(a+=46)),{width:i,height:a}}getColIndex(e){return e<this.offsetCorrectionX||e>this.offsetCorrectionX+this.viewportWidth?-1:this.searchHeaderIndex(`COL`,e-this.offsetCorrectionX+this.snapCorrection.x,this.left)}getRowIndex(e){return e<this.offsetCorrectionY||e>this.offsetCorrectionY+this.viewportHeight?-1:this.searchHeaderIndex(`ROW`,e-this.offsetCorrectionY+this.snapCorrection.y,this.top)}adjustPosition(e){let t=this.sheetId,n=this.getters.getMainCellPosition({sheetId:t,...e}),{col:r,row:i}=this.getters.getNextVisibleCellPosition(n);An(r,this.boundaries.top,this.boundaries)&&this.adjustPositionX(r),An(this.boundaries.left,i,this.boundaries)&&this.adjustPositionY(i)}adjustPositionX(e){let t=this.sheetId,{start:n,end:r}=this.getters.getColDimensions(t,e);this.offsetX+this.viewportWidth+this.offsetCorrectionX<r?this.offsetX=r-this.viewportWidth-this.offsetCorrectionX:this.offsetX+this.offsetCorrectionX>n&&(this.offsetX=n-this.offsetCorrectionX),this.adjustViewportZoneX()}adjustPositionY(e){let t=this.sheetId,{start:n,end:r}=this.getters.getRowDimensions(t,e);this.offsetY+this.viewportHeight+this.offsetCorrectionY<r?this.offsetY=r-this.viewportHeight-this.offsetCorrectionY:this.offsetY+this.offsetCorrectionY>n&&(this.offsetY=n-this.offsetCorrectionY),this.adjustViewportZoneY()}willNewOffsetScrollViewport(e,t){return this.canScrollHorizontally&&this.offsetX!==e||this.canScrollVertically&&this.offsetY!==t}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}getVisibleRect(e){let t=En(e,this),n=this.snapCorrection.x,r=this.snapCorrection.y;if(t)return{x:this.getters.getColRowOffset(`COL`,this.left,t.left)+this.offsetCorrectionX-(this.left===t.left?0:n),y:this.getters.getColRowOffset(`ROW`,this.top,t.top)+this.offsetCorrectionY-(this.top===t.top?0:r),width:Math.min(this.getters.getColRowOffset(`COL`,t.left,t.right+1)-(this.left===t.left?n:0),this.viewportWidth),height:Math.min(this.getters.getColRowOffset(`ROW`,t.top,t.bottom+1)-(this.top===t.top?r:0),this.viewportHeight)}}getFullRect(e){let t=En(e,this.boundaries),n=this.snapCorrection.x,r=this.snapCorrection.y;if(t){let t=this.getters.getColRowOffset(`COL`,this.left,e.left)+this.offsetCorrectionX,i=this.getters.getColRowOffset(`ROW`,this.top,e.top)+this.offsetCorrectionY,a=this.getters.getColRowOffset(`COL`,e.left,e.right+1),o=this.getters.getColRowOffset(`ROW`,e.top,e.bottom+1);return{x:t-n,y:i-r,width:a,height:o}}}isVisible(e,t){return t<=this.bottom&&t>=this.top&&e>=this.left&&e<=this.right&&!this.getters.isColHidden(this.sheetId,e)&&!this.getters.isRowHidden(this.sheetId,t)}searchHeaderIndex(e,t,n=0){if(this.viewportWidth<=0||this.viewportHeight<=0)return-1;let r=this.sheetId,i=this.getters.getNumberHeaders(r,e),a=n,o=i;for(;a<=o&&a!==i&&o!==-1;){let i=Math.floor((a+o)/2),s=this.getters.getColRowOffset(e,n,i),c=this.getters.getHeaderSize(r,e,i);if(t>=s&&t<s+c)return i;t>=s+c?a=i+1:o=i-1}return-1}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){let{width:e}=this.getMaxSize();this.viewportWidth+this.offsetX>e&&(this.offsetX=Math.max(0,e-this.viewportWidth))}this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){let{height:e}=this.getMaxSize();this.viewportHeight+this.offsetY>e&&(this.offsetY=Math.max(0,e-this.viewportHeight))}this.adjustViewportZoneY()}adjustViewportZoneX(){this.left=this.searchHeaderIndex(`COL`,this.offsetX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex(`COL`,Math.max(this.viewportWidth+this.snapCorrection.x-.1),this.left)),this.viewportWidth&&(this.left===-1&&(this.left=this.boundaries.left),this.right===-1&&(this.right=this.boundaries.right))}adjustViewportZoneY(){this.top=this.searchHeaderIndex(`ROW`,this.offsetY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex(`ROW`,Math.max(this.viewportHeight+this.snapCorrection.y-.1,0),this.top)),this.viewportHeight&&(this.top===-1&&(this.top=this.boundaries.top),this.bottom===-1&&(this.bottom=this.boundaries.bottom))}get snapCorrection(){return{x:Math.abs(this.offsetX-this.getters.getColRowOffset(`COL`,this.boundaries.left,Math.max(0,this.left))),y:Math.abs(this.offsetY-this.getters.getColRowOffset(`ROW`,this.boundaries.top,Math.max(0,this.top)))}}},Kq=class extends lK{static getters=`getColIndex.getRowIndex.getActiveMainViewport.getSheetViewDimension.getSheetViewDimensionWithHeaders.getMainViewportRect.isVisibleInViewport.getEdgeScrollCol.getEdgeScrollRow.getVisibleFigures.getVisibleRect.getVisibleRectWithoutHeaders.getVisibleRectWithZoom.getVisibleCellPositions.getColRowOffsetInViewport.getMainViewportCoordinates.getActiveSheetScrollInfo.getSheetViewVisibleCols.getSheetViewVisibleRows.getFrozenSheetViewRatio.isPixelPositionVisible.getColDimensionsInViewport.getRowDimensionsInViewport.getAllActiveViewportsZonesAndRect.getRect.getFigureUI.getPositionAnchorOffset.getGridOffset.getViewportZoomLevel.getScrollBarWidth.getMaximumSheetOffset`.split(`.`);viewports={};sheetViewWidth=Fe();sheetViewHeight=Fe();gridOffsetX=0;gridOffsetY=0;zoomLevel=1;sheetsWithDirtyViewports=new Set;shouldAdjustViewports=!1;allowDispatch(e){switch(e.type){case`SET_VIEWPORT_OFFSET`:return this.chainValidations(this.checkScrollingDirection,this.checkIfViewportsWillChange)(e);case`RESIZE_SHEETVIEW`:return this.chainValidations(this.checkValuesAreDifferent,this.checkPositiveDimension)(e);case`SET_ZOOM`:return e.zoom>2||e.zoom<.5?`InvalidZoomLevel`:`Success`;default:return`Success`}}handleEvent(e){let t=this.getters.getActiveSheetId();if(e.options.scrollIntoView){let n=e.previousAnchor.zone,r=e.anchor.zone,i=e.mode===`updateAnchor`,a=Dn(n,r),{col:o,row:s}=i&&a?e.anchor.cell:Vn(n,r);if(i&&!a){let{top:e,bottom:i,left:a,right:c}=this.getMainInternalViewport(t);n.left===r.left&&n.right===r.right&&(o=a>o||o>c?a:o),n.top===r.top&&n.bottom===r.bottom&&(s=e>s||s>i?e:s)}o=Math.min(o,this.getters.getNumberCols(t)-1),s=Math.min(s,this.getters.getNumberRows(t)-1),this.sheetsWithDirtyViewports.has(t)||this.refreshViewport(this.getters.getActiveSheetId(),{col:o,row:s})}}handle(e){if(Rs.has(e.type))for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);switch(e.type){case`START`:this.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.resetViewports(this.getters.getActiveSheetId());break;case`UNDO`:case`REDO`:this.cleanViewports();for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);this.shouldAdjustViewports=!0;break;case`RESIZE_SHEETVIEW`:this.resizeSheetView(e.height,e.width,e.gridOffsetX,e.gridOffsetY);break;case`SET_VIEWPORT_OFFSET`:this.setSheetViewOffset(e.offsetX,e.offsetY);break;case`SET_ZOOM`:this.zoomLevel=e.zoom||1;break;case`SHIFT_VIEWPORT_DOWN`:let t=this.getters.getActiveSheetId(),{top:n,viewportHeight:r,offsetCorrectionY:i}=this.getMainInternalViewport(t),a=this.getters.getRowDimensions(t,n);this.shiftVertically(a.start+r-i);break;case`SHIFT_VIEWPORT_UP`:{let e=this.getters.getActiveSheetId(),{top:t,viewportHeight:n,offsetCorrectionY:r}=this.getMainInternalViewport(e),i=this.getters.getRowDimensions(e,t);this.shiftVertically(i.end-r-n);break}case`REMOVE_TABLE`:case`UPDATE_TABLE`:case`UPDATE_FILTER`:case`UNFREEZE_ROWS`:case`UNFREEZE_COLUMNS`:case`FREEZE_COLUMNS`:case`FREEZE_ROWS`:case`UNFREEZE_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:case`RESIZE_COLUMNS_ROWS`:case`HIDE_COLUMNS_ROWS`:case`ADD_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`UNGROUP_HEADERS`:case`GROUP_HEADERS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_ALL_HEADER_GROUPS`:this.sheetsWithDirtyViewports.add(e.sheetId);break;case`UPDATE_CELL`:case`SET_FORMATTING`:for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);break;case`DELETE_SHEET`:this.cleanViewports(),this.sheetsWithDirtyViewports.delete(e.sheetId);break;case`ACTIVATE_SHEET`:this.sheetsWithDirtyViewports.add(e.sheetIdTo);break;case`SCROLL_TO_CELL`:this.refreshViewport(this.getters.getActiveSheetId(),{col:e.col,row:e.row});break}}finalize(){for(let e of this.sheetsWithDirtyViewports)if(this.resetViewports(e),this.shouldAdjustViewports){let t=this.getters.getSheetPosition(e);this.getSubViewports(e).forEach(e=>{e.adjustPosition(t)})}this.sheetsWithDirtyViewports=new Set,this.shouldAdjustViewports=!1,this.setViewports()}setViewports(){let e=this.getters.getSheetIds();for(let t of e)this.viewports[t]?.bottomRight||this.resetViewports(t)}getColIndex(e){let t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map(t=>t.getColIndex(e)))}getRowIndex(e){let t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map(t=>t.getRowIndex(e)))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getGridOffset(){return{x:this.gridOffsetX,y:this.gridOffsetY}}getActiveMainViewport(){let e=this.getters.getActiveSheetId();return this.getMainViewport(e)}getActiveSheetScrollInfo(){let e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getSheetViewVisibleCols(){let e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map(e=>S(e.left,e.right+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`COL`,t))}getSheetViewVisibleRows(){let e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map(e=>S(e.top,e.bottom+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`ROW`,t))}getVisibleCellPositions(){let e=this.getSheetViewVisibleCols(),t=this.getSheetViewVisibleRows(),n=this.getters.getActiveSheetId(),r=[];for(let i of e)for(let e of t){let t={sheetId:n,col:i,row:e},a=this.getters.getMainCellPosition(t);a.row!==e||a.col!==i||r.push(t)}return r}getMainViewportRect(){let e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e),{xSplit:n,ySplit:r}=this.getters.getPaneDivisions(e),{width:i,height:a}=t.getMaxSize();return{x:this.getters.getColDimensions(e,n).start,y:this.getters.getRowDimensions(e,r).start,width:i,height:a}}getMaximumSheetOffset(){let e=this.getters.getActiveSheetId(),{width:t,height:n}=this.getMainViewportRect(),r=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-r.viewportWidth),maxOffsetY:Math.max(0,n-r.viewportHeight)}}getColRowOffsetInViewport(e,t,n){if(n<t)return-this.getColRowOffsetInViewport(e,n,t);let r=this.getters.getActiveSheetId(),i=e===`COL`?this.getters.getSheetViewVisibleCols():this.getters.getSheetViewVisibleRows(),a=i.findIndex(e=>t>=e),o=i.findIndex(e=>n<=e);o=o===-1?i.length:o;let s=i.slice(a,o),c=0;for(let t of s)c+=this.getters.getHeaderSize(r,e,t);return c*this.zoomLevel}isVisibleInViewport({sheetId:e,col:t,row:n}){return this.getSubViewports(e).some(e=>e.isVisible(t,n))}getScrollBarWidth(){return 15/this.zoomLevel}getEdgeScrollCol(e,t,n){let r=!1,i=0,a=0,{xSplit:o}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:s}=this.getSheetViewDimension(),{x:c}=this.getMainViewportCoordinates(),l=this.getActiveSheetScrollInfo().scrollX;return e>s?(r=!0,a=Ec(e-s),i=1):e<c&&n>=c&&l>0?(r=!0,a=Ec(c-e),i=-1):o&&t<c&&e>c&&(r=!0,a=Ec(e),i=`reset`),{canEdgeScroll:r,direction:i,delay:a}}getEdgeScrollRow(e,t,n){let r=!1,i=0,a=0,{ySplit:o}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:s}=this.getSheetViewDimension(),{y:c}=this.getMainViewportCoordinates(),l=this.getActiveSheetScrollInfo().scrollY;return e>s?(r=!0,a=Ec(e-s),i=1):e<c&&n>=c&&l>0?(r=!0,a=Ec(c-e),i=-1):o&&t<c&&e>c&&(r=!0,a=Ec(e),i=`reset`),{canEdgeScroll:r,direction:i,delay:a}}getVisibleRect(e){let t=this.getVisibleRectWithoutHeaders(e);return{...t,x:t.x+this.gridOffsetX,y:t.y+this.gridOffsetY}}getVisibleRectWithZoom(e){let t=this.getViewportZoomLevel(),n=this.getVisibleRectWithoutHeaders(e);return n.width*=t,n.height*=t,n.x=n.x*t+this.gridOffsetX*t,n.y=n.y*t+this.gridOffsetY*t,n}getVisibleRectWithoutHeaders(e){let t=this.getters.getActiveSheetId();return this.mapViewportsToRect(t,t=>t.getVisibleRect(e))}getRect(e){let t=this.getters.getActiveSheetId(),n=this.mapViewportsToRect(t,t=>t.getFullRect(e));return{...n,x:n.x+this.gridOffsetX,y:n.y+this.gridOffsetY}}getRectWithoutHeaders(e){let t=this.getters.getActiveSheetId();return this.mapViewportsToRect(t,t=>t.getFullRect(e))}getMainViewportCoordinates(){let e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,n).start}}getColDimensionsInViewport(e,t){let{top:n}=this.getMainInternalViewport(e),r={left:t,right:t,top:n,bottom:n},{x:i,width:a}=this.getVisibleRect(r),o=i-this.gridOffsetX;return{start:o,size:a,end:o+a}}getRowDimensionsInViewport(e,t){let{left:n}=this.getMainInternalViewport(e),r={left:0,right:n,top:t,bottom:t},{y:i,height:a}=this.getVisibleRect(r),o=i-this.gridOffsetY;return{start:o,size:a,end:o+a}}getAllActiveViewportsZonesAndRect(){let e=this.getters.getActiveSheetId();return this.getSubViewports(e).map(e=>({zone:e,rect:{x:e.offsetCorrectionX+this.gridOffsetX,y:e.offsetCorrectionY+this.gridOffsetY,...e.getMaxSize()}}))}getViewportZoomLevel(){return this.zoomLevel}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(C)}checkPositiveDimension(e){return e.width<0||e.height<0?`InvalidViewportSize`:`Success`}checkValuesAreDifferent(e){let{height:t,width:n}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===n&&e.height===t?`ValuesNotChanged`:`Success`}checkScrollingDirection({offsetX:e,offsetY:t}){let n=this.getMainInternalViewport(this.getters.getActiveSheetId());return!n.canScrollHorizontally&&e>0||!n.canScrollVertically&&t>0?`InvalidScrollingDirection`:`Success`}checkIfViewportsWillChange({offsetX:e,offsetY:t}){let n=this.getters.getActiveSheetId(),{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset();return this.getSubViewports(n).some(n=>n.willNewOffsetScrollViewport(x(e,0,r),x(t,0,i)))?`Success`:`ViewportScrollLimitsReached`}getMainViewport(e){let t=this.getMainInternalViewport(e);return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}getMainInternalViewport(e){return this.ensureMainViewportExist(e),this.viewports[e].bottomRight}cleanViewports(){let e={};for(let t of this.getters.getSheetIds())e[t]=this.viewports[t];this.viewports=e}resizeSheetView(e,t,n=0,r=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=n,this.gridOffsetY=r,this.recomputeViewports()}recomputeViewports(){for(let e of this.getters.getSheetIds())this.resetViewports(e)}setSheetViewOffset(e,t){let n=this.getters.getActiveSheetId(),{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset();this.getSubViewports(n).forEach(n=>n.setViewportOffset(x(e,0,r),x(t,0,i)))}getViewportOffset(e){return{x:this.viewports[e]?.bottomRight.offsetX||0,y:this.viewports[e]?.bottomRight.offsetY||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;let{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e),r=this.getters.getNumberCols(e),i=this.getters.getNumberRows(e),a=Math.min(this.getters.getColRowOffset(`COL`,0,t,e),this.sheetViewWidth),o=Math.min(this.getters.getColRowOffset(`ROW`,0,n,e),this.sheetViewHeight),s=Math.max(this.sheetViewWidth-a,0),c=Math.max(this.sheetViewHeight-o,0),{xRatio:l,yRatio:u}=this.getFrozenSheetViewRatio(e),d=l<1,f=u<1,p=this.getViewportOffset(e),m={topLeft:n&&t&&new Gq(this.getters,e,{left:0,right:t-1,top:0,bottom:n-1},{width:a,height:o},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:n&&new Gq(this.getters,e,{left:t,right:r-1,top:0,bottom:n-1},{width:s,height:o},{canScrollHorizontally:d,canScrollVertically:!1},{x:d?p.x:0,y:0})||void 0,bottomLeft:t&&new Gq(this.getters,e,{left:0,right:t-1,top:n,bottom:i-1},{width:a,height:c},{canScrollHorizontally:!1,canScrollVertically:f},{x:0,y:f?p.y:0})||void 0,bottomRight:new Gq(this.getters,e,{left:t,right:r-1,top:n,bottom:i-1},{width:s,height:c},{canScrollHorizontally:d,canScrollVertically:f},{x:d?p.x:0,y:f?p.y:0})};this.viewports[e]=m}refreshViewport(e,t){this.getSubViewports(e).forEach(e=>{e.adjustViewportZone(),e.adjustPosition(t)})}shiftVertically(e){let t=this.getters.getActiveSheetId(),{top:n}=this.getMainInternalViewport(t),{scrollX:r}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(r,e);let{anchor:i}=this.getters.getSelection();if(i.cell.row>=this.getters.getPaneDivisions(t).ySplit){let e=this.getMainInternalViewport(t).top-n;this.selection.selectCell(i.cell.col,i.cell.row+e)}}getColIndexLeftOfMainViewport(e){if(e>=0)return-1;let t=this.getters.getActiveSheetId(),n=this.getActiveMainViewport().left,r=-this.getActiveSheetScrollInfo().scrollX-this.getters.getColRowOffset(`COL`,n,0);for(;e<r;n--)r-=this.getters.getColSize(t,n-1);return Math.max(n,0)}getRowIndexTopOfMainViewport(e){if(e>=0)return-1;let t=this.getters.getActiveSheetId(),n=this.getActiveMainViewport().top,r=-this.getActiveSheetScrollInfo().scrollY-this.getters.getColRowOffset(`ROW`,n,0);for(;e<r;n--)r-=this.getters.getRowSize(t,n-1);return Math.max(n,0)}getVisibleFigures(){let e=this.getters.getActiveSheetId(),t=[],n=this.getters.getFigures(e),{scrollX:r,scrollY:i}=this.getters.getActiveSheetScrollInfo(),{x:a,y:o}=this.getMainViewportCoordinates(),{width:s,height:c}=this.getters.getSheetViewDimensionWithHeaders();for(let l of n){let n=this.getFigureUI(e,l),{x:u,y:d}=n;u>=a&&(u+l.width<r+a||u>s+r+a)||d>=o&&(d+l.height<i+o||d>c+i+o)||t.push(n)}return t}getFigureUI(e,t){let n=t.offset.x+this.getters.getColDimensions(e,t.col).start,r=t.offset.y+this.getters.getRowDimensions(e,t.row).start;return{...t,x:n,y:r}}getPositionAnchorOffset(e){let{scrollX:t,scrollY:n}=this.getters.getActiveSheetScrollInfo(),r=e.x-t,i=e.y-n,a=r>=0?this.getColIndex(r):this.getColIndexLeftOfMainViewport(r),o=i>=0?this.getRowIndex(i):this.getRowIndexTopOfMainViewport(i),{x:s,y:c}=this.getRect(E({col:a,row:o}));return{col:a,row:o,offset:{x:Math.max(r-s+this.gridOffsetX,0),y:Math.max(i-c+this.gridOffsetY,0)}}}isPixelPositionVisible(e){let{scrollX:t,scrollY:n}=this.getters.getActiveSheetScrollInfo(),{x:r,y:i}=this.getters.getMainViewportCoordinates(),{width:a,height:o}=this.getters.getSheetViewDimension();return!(e.x>=r&&(e.x<r+t||e.x>a+t+r)||e.y>=i&&(e.y<i+n||e.y>o+n+i))}getFrozenSheetViewRatio(e){let{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e),r=this.getters.getColDimensions(e,t).start,i=this.getters.getRowDimensions(e,n).start,a=this.sheetViewWidth+this.gridOffsetX,o=this.sheetViewHeight+this.gridOffsetY;return{xRatio:r/a,yRatio:i/o}}mapViewportsToRect(e,t){let n=1/0,r=1/0,i=0,a=0,o=!1;for(let s of this.getSubViewports(e)){let e=t(s);e&&(o=!0,n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x+e.width),a=Math.max(a,e.y+e.height))}return o?{x:n,y:r,width:i-n,height:a-r}:{x:0,y:0,width:0,height:0}}};let qq=new B().add(`settings`,uG).add(`sheet`,dG).add(`header grouping`,nG).add(`header visibility`,iG).add(`tables`,mG).add(`dataValidation`,eG).add(`cell`,XW).add(`merge`,oG).add(`headerSize`,rG).add(`borders`,WW).add(`conditional formatting`,$W).add(`figures`,tG).add(`chart`,ZW).add(`carousel`,GW).add(`image`,aG).add(`pivot_core`,lG).add(`spreadsheet_pivot_core`,fG).add(`tableStyle`,pG),Jq=new B().add(`ui_sheet`,Lq).add(`ui_options`,Iq).add(`autofill`,wK).add(`sort`,jq).add(`automatic_sum`,TK).add(`format`,_q).add(`insert_pivot`,bq).add(`pivot_presence`,Aq).add(`split_to_columns`,Mq).add(`subtotal_evaluation`,Nq).add(`collaborative`,mq).add(`history`,Dq).add(`table_autofill`,Pq).add(`table_ui_resize`,Fq).add(`datavalidation_insert`,hq).add(`checkbox_toggle`,AK).add(`dynamic_translate`,gq).add(`geo_features`,vq).add(`data_cleanup`,uK),Yq=new B().add(`selection`,Wq).add(`evaluation_filter`,Hq).add(`header_visibility_ui`,yq).add(`cell_computed_style`,kK).add(`table_computed_style`,EK).add(`header_positions`,Uq).add(`viewport`,Kq).add(`clipboard`,Bq).add(`carousel_ui`,Rq).add(`lock_sheet`,Oq),Xq=new B().add(`evaluation`,BG).add(`evaluation_chart`,JG).add(`evaluation_cf`,YG).add(`row_size`,eK).add(`data_validation_ui`,ZG).add(`dynamic_tables`,qG).add(`custom_colors`,KG).add(`pivot_ui`,aK).add(`cell_icon`,HG).add(`formula_tracker`,$G);EN.add(`dataValidation`,{displayAllOnInitialContent:!0,canBeToggled:!1,getProposals(e,t){if(Ut(t)||!this.composer.currentEditedCell)return[];let n=this.composer.currentEditedCell,r=this.getters.getValidationRuleForCell(n);if(!r||r.criterion.type!==`isValueInList`&&r.criterion.type!==`isValueInRange`)return[];let i=this.composer.currentEditedCell.sheetId,a=r.criterion.type===`isValueInRange`?this.getters.getDataValidationRangeValues(i,r.criterion):r.criterion.values.map(e=>({label:e,value:e}));if(r.criterion.displayStyle!==`chip`)return a.map(e=>({text:e.value,fuzzySearchKey:e.label,htmlContent:[{value:e.label}]}));let o=r.criterion.colors;return a.map(e=>{let t=o?.[e.value];return{text:e.value,htmlContent:[{value:e.label,color:qr(t||`#E7E9ED`),backgroundColor:t||`#E7E9ED`,classes:[`badge rounded-pill fs-6 fw-normal w-100 mt-1 text-start`]}],fuzzySearchKey:e.label}})},selectProposal(e,t){this.composer.setCurrentContent(t),this.composer.stopEdition()}}),EN.add(`functions`,{sequence:100,autoSelectFirstProposal:!0,maxDisplayedProposals:10,getProposals(e){if(e.type!==`SYMBOL`)return[];let t=e.value;return Ut(this.composer.currentContent)?Object.entries(fO.content).filter(([e,{hidden:t}])=>!t).map(([e,{description:n}])=>({text:e,description:n,htmlContent:oz(t,e,le,`o-semi-bold`)})).sort((e,t)=>e.text.length-t.text.length||e.text.localeCompare(t.text)):[]},selectProposal(e,t){let n=e.end,r=e.end;[`SYMBOL`,`FUNCTION`].includes(e.type)&&(n=e.start);let i=this.composer.currentTokens;t+=`(`;let a=i.map(e=>e.start).indexOf(e.start);a+1<i.length&&i[a+1]?.type===`LEFT_PAREN`&&r++,this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t)}});function Zq(e,t){for(let n=0;n<t.length;n++){let r=t[n].proposalValues;r===void 0||r.length===0||EN.add(`${e}_function_${t[n].name}_argument_proposals`,{sequence:50,autoSelectFirstProposal:!0,selectProposal:Qq,getProposals:t=>{let i=t.functionContext;if(!i||i.parent.toUpperCase()!==e.toUpperCase()||i.argPosition!==n)return;let a=[],o=``;for(let{value:e,label:t}of r){switch(typeof e){case`string`:o=`"${e}"`;break;case`number`:o=e.toString();break;case`boolean`:o=e?`TRUE`:`FALSE`;break;default:}a.push({text:o,description:t,htmlContent:[{value:o,color:typeof e==`string`?We.STRING:We.NUMBER}],fuzzySearchKey:o,alwaysExpanded:!0})}return a}})}}function Qq(e,t){let n=e.end,r=e.end;[`LEFT_PAREN`,`ARG_SEPARATOR`].includes(e.type)||(n=e.start),this.composer.stopComposerRangeSelection(),this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t)}fO.getAll().forEach(e=>Zq(e.name,e.args)),EN.add(`pivot_ids`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||![`PIVOT.VALUE`,`PIVOT.HEADER`,`PIVOT`].includes(t.parent.toUpperCase())||t.argPosition!==0)return;let n=this.getters.getPivotIds();if(!n.includes(e.value))return n.map(e=>{let t=this.getters.getPivotCoreDefinition(e),n=`${this.getters.getPivotFormulaId(e)}`;return{text:n,description:t.name,htmlContent:[{value:n,color:We.NUMBER}],fuzzySearchKey:n+t.name,alwaysExpanded:!0}}).filter(C)},selectProposal:Qq}),EN.add(`pivot_measures`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(t?.parent.toUpperCase()!==`PIVOT.VALUE`||t.argPosition!==1)return[];let n=wB(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return[];let i=this.getters.getPivot(r);return i.init(),i.isValid()?i.definition.measures.map(e=>{if(e.fieldName===`__count`){let e=`"__count"`;return{text:e,description:k(`Count`),htmlContent:[{value:e,color:We.STRING}],fuzzySearchKey:k(`Count`)+e}}return xB(e)}).filter(C):[]},selectProposal:Qq}),EN.add(`pivot_group_fields`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!$q(e)&&!eJ(e))return;let n=wB(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return;let i=this.getters.getPivot(r);i.init();let a=i.getFields(),{columns:o,rows:s}=i.definition,c=t.args;t?.parent.toUpperCase()===`PIVOT.VALUE`?(c=c.filter((e,t)=>t%2==0),c=c.slice(1,t.argPosition)):c=c.filter((e,t)=>t%2==1);let l=c.map(e=>e?.value).filter(C),u=o.map(e=>e.nameWithGranularity),d=s.map(e=>e.nameWithGranularity),f=[],p=[`ARG_SEPARATOR`,`SPACE`].includes(e.type)?l.at(-1):l.at(-2),m=RW.get(i.type);if(m&&p?.startsWith(`#`)&&(p=p.slice(1)),p===void 0&&(f.push(u[0]),f.push(d[0])),d.includes(p)){let e=d[d.indexOf(p)+1];f.push(e),f.push(u[0])}if(u.includes(p)){let e=u[u.indexOf(p)+1];f.push(e)}let h=f.filter(C);return h.map(e=>{let[t,n]=e.split(`:`),r=a[t];return r?bB(r,n):void 0}).concat(h.map(e=>{if(!m)return;let t=a[e.split(`:`)[0]];if(!t)return;let n=`"#${e}"`;return{text:n,description:k(`%s (positional)`,t.string)+(t.help?` (${t.help})`:``),htmlContent:[{value:n,color:We.STRING}],fuzzySearchKey:t.string+n}})).filter(C)},selectProposal:Qq});function $q(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==0}function eJ(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==1}EN.add(`pivot_group_values`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!e||!tJ(e)&&!nJ(e))return;let n=wB(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return;let i=this.getters.getPivot(r);if(!i.isValid())return;let a=t.argPosition,o=e.functionContext?.args[a-1]?.value;if(!o)return;let s;try{s=i.definition.getDimension(o)}catch{return}return s.granularity===`month_number`?Object.values(Wo).map((e,t)=>({text:`${t+1}`,fuzzySearchKey:e.toString(),description:e.toString(),htmlContent:[{value:`${t+1}`,color:We.NUMBER}]})):s.granularity===`quarter_number`?[1,2,3,4].map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:k(`Quarter %s`,e),htmlContent:[{value:`${e}`,color:We.NUMBER}]})):s.granularity===`day_of_month`?S(1,32).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:We.NUMBER}]})):s.granularity===`iso_week_number`?S(0,54).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:We.NUMBER}]})):s.granularity===`day_of_week`?S(1,8).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:We.NUMBER}]})):s.granularity===`hour_number`?S(0,24).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:We.NUMBER}]})):s.granularity===`minute_number`?S(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:We.NUMBER}]})):s.granularity===`second_number`?S(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:We.NUMBER}]})):i.getPossibleFieldValues(s).map(({value:e,label:t})=>{let n=typeof e==`string`,r=n?`"${e}"`:e.toString(),i=n?We.STRING:We.NUMBER,a=t===e?``:t;return{text:r,description:a,htmlContent:[{value:r,color:i}],fuzzySearchKey:r+a}})},selectProposal:Qq});function tJ(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==1}function nJ(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==0}EN.add(`sheet_names`,{sequence:150,autoSelectFirstProposal:!0,getProposals(e){return e.type===`SYMBOL`||e.type===`UNKNOWN`&&e.value.startsWith(`'`)?this.getters.getSheetIds().map(e=>{let t=Ze(this.getters.getSheetName(e));return{text:t,fuzzySearchKey:t.startsWith(`'`)?t:`'`+t}}):[]},selectProposal(e,t){let n=e.start,r=e.end;this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t+`!`)}});let rJ=new B;rJ.add(`link`,{condition:(e,t)=>!!t.getEvaluatedCell(e).link,execute:(e,t,n)=>ic(t.model.getters.getEvaluatedCell(e).link,t,n),title:(e,t)=>{let n=t.getEvaluatedCell(e).link;return n?n.isExternal?k(`Go to url: %(url)s`,{url:n.url}):k(`Go to %(label)s`,{label:n.label}):``},sequence:5}),rJ.add(`dashboard_pivot_sorting`,{condition:(e,t)=>{if(!t.isDashboard())return!1;let n=t.getPivotCellFromPosition(e);return HH(t,e)&&n.type===`MEASURE_HEADER`},execute:(e,t)=>{UH(t,e,aJ(t.model.getters,e))},component:zW,componentProps:(e,t)=>({position:e,sortDirection:t.getPivotCellSortDirection(e)}),sequence:2});let iJ={none:`asc`,asc:`desc`,desc:`none`};function aJ(e,t){return iJ[e.getPivotCellSortDirection(t)??`none`]}VG.add(`filter_icon`,(e,t)=>{if(e.isFilterHeader(t)){let n=e.isFilterActive(t),r=Nr(e.getCellComputedStyle(t).fillColor||`#fff`)<.45;return{type:`filter_icon`,svg:PO(n,r,!1),hoverSvg:PO(n,r,!0),priority:3,horizontalAlign:`right`,size:17,margin:2,position:t,onClick:(e,t)=>{let n=t.getStore(sP),r=n.persistentCellPopover;if(r.isOpen&&r.col===e.col&&r.row===e.row&&r.type===`FilterMenu`){n.close();return}n.open(e,`FilterMenu`)}}}});let oJ=new B().add(`ADD_COLUMNS_ROWS`,lJ).add(`REMOVE_COLUMNS_ROWS`,mJ).add(`ADD_MERGE`,uJ).add(`REMOVE_MERGE`,dJ).add(`CREATE_SHEET`,fJ).add(`DELETE_SHEET`,hJ).add(`DUPLICATE_SHEET`,pJ).add(`CREATE_FIGURE`,gJ).add(`CREATE_CHART`,_J).add(`HIDE_COLUMNS_ROWS`,vJ).add(`UNHIDE_COLUMNS_ROWS`,yJ).add(`CREATE_TABLE_STYLE`,bJ).add(`ADD_PIVOT`,cJ).add(`RENAME_SHEET`,xJ).add(`LOCK_SHEET`,SJ).add(`UNLOCK_SHEET`,CJ);for(let e of Ks.values())oJ.contains(e)||oJ.add(e,sJ);function sJ(e){return[e]}function cJ(e){return[{type:`REMOVE_PIVOT`,pivotId:e.pivotId}]}function lJ(e){let t=[],n=e.base;e.position===`after`&&n++;for(let r=0;r<e.quantity;r++)t.push(r+n);return[{type:`REMOVE_COLUMNS_ROWS`,dimension:e.dimension,elements:t,sheetId:e.sheetId,sheetName:e.sheetName}]}function uJ(e){return[{type:`REMOVE_MERGE`,sheetId:e.sheetId,target:e.target}]}function dJ(e){return[{type:`ADD_MERGE`,sheetId:e.sheetId,target:e.target}]}function fJ(e){return[{type:`DELETE_SHEET`,sheetId:e.sheetId,sheetName:e.name}]}function pJ(e){return[{type:`DELETE_SHEET`,sheetId:e.sheetIdTo,sheetName:``}]}function mJ(e){let t=[],n=[...e.elements].sort((e,t)=>e-t);for(let r of $e(n)){let n=r[0]===0?0:r[0]-1,i=r[0]===0?`before`:`after`;t.push({type:`ADD_COLUMNS_ROWS`,dimension:e.dimension,quantity:r.length,base:n,sheetId:e.sheetId,sheetName:e.sheetName,position:i})}return t}function hJ(e){return[{type:`CREATE_SHEET`,sheetId:e.sheetId,position:1,name:e.sheetName}]}function gJ(e){return[{type:`DELETE_FIGURE`,figureId:e.figureId,sheetId:e.sheetId}]}function _J(e){return[{type:`DELETE_CHART`,chartId:e.chartId,sheetId:e.sheetId},{type:`DELETE_FIGURE`,figureId:e.figureId,sheetId:e.sheetId}]}function vJ(e){return[{type:`UNHIDE_COLUMNS_ROWS`,sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}function yJ(e){return[{type:`HIDE_COLUMNS_ROWS`,sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}function bJ(e){return[{type:`REMOVE_TABLE_STYLE`,tableStyleId:e.tableStyleId}]}function xJ(e){return[{type:`RENAME_SHEET`,sheetId:e.sheetId,oldName:e.newName,newName:e.oldName}]}function SJ(e){return[{type:`UNLOCK_SHEET`,sheetId:e.sheetId}]}function CJ(e){return[{type:`LOCK_SHEET`,sheetId:e.sheetId}]}let wJ=new B;wJ.add(`format_number_automatic`,{...KL,id:`format_number_automatic`,sequence:10}).add(`format_number_plain_text`,{...qL,id:`format_number_plain_text`,sequence:15,separator:!0}).add(`format_number_number`,{...JL,id:`format_number_number`,sequence:20}).add(`format_number_percent`,{...XL,id:`format_number_percent`,sequence:30,separator:!1}).add(`format_number_scientific`,{...ZL,id:`format_number_scientific`,sequence:33,separator:!0}).add(`format_number_currency`,{...QL,id:`format_number_currency`,sequence:40}).add(`format_number_accounting`,{...eR,id:`format_number_accounting`,sequence:45}).add(`format_number_currency_rounded`,{...$L,id:`format_number_currency_rounded`,sequence:50,separator:!0}).add(`format_number_date`,{...rR,id:`format_number_date`,sequence:70}).add(`format_number_time`,{...iR,id:`format_number_time`,sequence:80}).add(`format_number_date_time`,{...aR,id:`format_number_date_time`,sequence:90}).add(`format_number_duration`,{...oR,id:`format_number_duration`,sequence:100,separator:!0}).add(`format_custom_currency`,{...nR,id:`format_custom_currency`,sequence:120}).add(`format_custom_date`,{...sR,id:`format_custom_date`,sequence:130}).add(`format_custom_number`,{...cR,id:`format_custom_number`,sequence:140});function TJ(e){let t=new Set(wJ.getAll().map(t=>typeof t.format==`function`?t.format(e):t.format)),n=new Map;for(let r of e.model.getters.getSheetIds()){let i=e.model.getters.getEvaluatedCells(r);for(let e in i){let r=i[e];if(r.format&&!n.has(r.format)&&!t.has(r.format)){let e=EJ(r.format);(e===`date`||e===`currency`)&&n.set(r.format,GL({descriptionValue:e===`currency`?1e3:tR,format:r.format,name:r.format}))}}}return[...n.values()]}let EJ=At(e=>os(e)?`date`:e.includes(`[$`)?`currency`:`number`),DJ={name:k(`More formats`),icon:`o-spreadsheet-Icon.NUMBER_FORMATS`,children:[e=>{let t=TJ(e).map(e=>({...e,sequence:110}));return t.length>0&&(t[t.length-1].separator=!0),[...wJ.getAll(),...t]}]};function OJ(e){let t=new bP;return t.add(`delete`,{...dP,sequence:10}).add(`hide_sheet`,{..._P,sequence:20}).add(`duplicate`,{...fP,sequence:30,separator:!0}).add(`rename`,{...pP(e),sequence:40}).add(`change_color`,{...mP(e),sequence:50,separator:!0}).add(`protect_sheet`,{...vP,sequence:60}).add(`remove_sheet_protection`,{...yP,sequence:70}).add(`move_right`,{...hP,sequence:80}).add(`move_left`,{...gP,sequence:90}),t}let kJ=new bP;kJ.add(`file`,{name:k(`File`),sequence:10}).addChild(`settings`,[`file`],{name:k(`Settings`),sequence:200,execute:e=>e.openSidePanel(`Settings`),isEnabled:e=>!e.isSmall,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.COG`}).add(`edit`,{name:k(`Edit`),sequence:20}).addChild(`undo`,[`edit`],{...aH,sequence:10}).addChild(`redo`,[`edit`],{...oH,sequence:20,separator:!0}).addChild(`copy`,[`edit`],{...sH,sequence:30}).addChild(`cut`,[`edit`],{...cH,sequence:40}).addChild(`paste`,[`edit`],{...lH,sequence:50}).addChild(`paste_special`,[`edit`],{...uH,sequence:60,separator:!0}).addChild(`paste_special_value`,[`edit`,`paste_special`],{...dH,sequence:10}).addChild(`paste_special_format`,[`edit`,`paste_special`],{...fH,sequence:20}).addChild(`edit_table`,[`edit`],{...TH,isVisible:TF,sequence:60}).addChild(`find_and_replace`,[`edit`],{...pH,sequence:65,separator:!0}).addChild(`delete`,[`edit`],{name:k(`Delete`),icon:`o-spreadsheet-Icon.TRASH`,sequence:70}).addChild(`edit_delete_cell_values`,[`edit`,`delete`],{...mH,sequence:10}).addChild(`edit_delete_row`,[`edit`,`delete`],{...hH,sequence:20}).addChild(`edit_delete_column`,[`edit`,`delete`],{...vH,sequence:30}).addChild(`edit_delete_cell_shift_up`,[`edit`,`delete`],{...SH,sequence:40}).addChild(`edit_delete_cell_shift_left`,[`edit`,`delete`],{...CH,sequence:50}).addChild(`edit_unhide_columns`,[`edit`],{...AV,sequence:80}).addChild(`edit_unhide_rows`,[`edit`],{...NV,sequence:80}).add(`view`,{name:k(`View`),sequence:30}).addChild(`unfreeze_panes`,[`view`],{...PV,sequence:4}).addChild(`freeze_panes`,[`view`],{...FV,sequence:5}).addChild(`unfreeze_rows`,[`view`,`freeze_panes`],{...IV,sequence:5}).addChild(`freeze_first_row`,[`view`,`freeze_panes`],{...LV,sequence:10}).addChild(`freeze_second_row`,[`view`,`freeze_panes`],{...RV,sequence:15}).addChild(`freeze_current_row`,[`view`,`freeze_panes`],{...zV,sequence:20,separator:!0}).addChild(`unfreeze_columns`,[`view`,`freeze_panes`],{...BV,sequence:25}).addChild(`freeze_first_col`,[`view`,`freeze_panes`],{...VV,sequence:30}).addChild(`freeze_second_col`,[`view`,`freeze_panes`],{...HV,sequence:35}).addChild(`freeze_current_col`,[`view`,`freeze_panes`],{...UV,sequence:40}).addChild(`group_headers`,[`view`],{name:k(`Group`),sequence:15,separator:!0,icon:`o-spreadsheet-Icon.PLUS_IN_BOX`,isVisible:jF}).addChild(`group_columns`,[`view`,`group_headers`],{...JV,sequence:5}).addChild(`ungroup_columns`,[`view`,`group_headers`],{...XV,isVisible:e=>eH(e,`COL`),sequence:10}).addChild(`group_rows`,[`view`,`group_headers`],{...YV,sequence:15}).addChild(`ungroup_rows`,[`view`,`group_headers`],{...ZV,isVisible:e=>eH(e,`ROW`),sequence:20}).addChild(`show`,[`view`],{name:k(`Show`),sequence:1,icon:`o-spreadsheet-Icon.SHOW`}).addChild(`view_gridlines`,[`view`,`show`],{...WV,sequence:5}).addChild(`view_formulas`,[`view`,`show`],{...qV,sequence:10}).addChild(`zoom`,[`view`],{name:k(`Zoom`),sequence:1,icon:`o-spreadsheet-Icon.ZOOM`}).addChild(`toggle_pin_panel`,[`view`],{...tH,sequence:6}).addChild(`view_irregularity_map`,[`view`],{...GV,sequence:40,separator:!0}).add(`insert`,{name:k(`Insert`),sequence:40}).addChild(`insert_row`,[`insert`],{...PF,sequence:10}).addChild(`insert_row_before`,[`insert`,`insert_row`],{...IF,sequence:10}).addChild(`insert_row_after`,[`insert`,`insert_row`],{...zF,sequence:20}).addChild(`insert_column`,[`insert`],{...BF,sequence:20}).addChild(`insert_column_before`,[`insert`,`insert_column`],{...HF,sequence:10}).addChild(`insert_column_after`,[`insert`,`insert_column`],{...GF,sequence:20}).addChild(`insert_cell`,[`insert`],{...KF,sequence:30}).addChild(`insert_cell_down`,[`insert`,`insert_cell`],{...qF,name:k(`Shift down`),sequence:10}).addChild(`insert_cell_right`,[`insert`,`insert_cell`],{...JF,name:k(`Shift right`),sequence:20}).addChild(`insert_sheet`,[`insert`],{...fI,sequence:40,separator:!0}).addChild(`insert_chart`,[`insert`],{...YF,sequence:50}).addChild(`insert_carousel`,[`insert`],{...XF,sequence:51}).addChild(`insert_pivot`,[`insert`],{...ZF,sequence:52}).addChild(`insert_image`,[`insert`],{...QF,sequence:55}).addChild(`insert_table`,[`insert`],{...$F,sequence:57}).addChild(`insert_function`,[`insert`],{...eI,sequence:60}).addChild(`insert_function_sum`,[`insert`,`insert_function`],{...tI,sequence:0}).addChild(`insert_function_average`,[`insert`,`insert_function`],{...nI,sequence:10}).addChild(`insert_function_count`,[`insert`,`insert_function`],{...rI,sequence:20}).addChild(`insert_function_max`,[`insert`,`insert_function`],{...iI,sequence:30}).addChild(`insert_function_min`,[`insert`,`insert_function`],{...aI,sequence:40,separator:!0}).addChild(`categorie_function_all`,[`insert`,`insert_function`],{...oI,sequence:50}).addChild(`categories_function_list`,[`insert`,`insert_function`],cI).addChild(`insert_link`,[`insert`],{...lI,separator:!0,sequence:70}).addChild(`insert_checkbox`,[`insert`],{...uI,sequence:80}).addChild(`insert_dropdown`,[`insert`],{...dI,separator:!0,sequence:90}).add(`format`,{name:k(`Format`),sequence:50}).addChild(`format_number`,[`format`],{...DJ,name:k(`Number`),sequence:10,separator:!0}).addChild(`format_bold`,[`format`],{...dR,sequence:20}).addChild(`format_italic`,[`format`],{...fR,sequence:30}).addChild(`format_underline`,[`format`],{...pR,sequence:40}).addChild(`format_strikethrough`,[`format`],{...SR,sequence:50,separator:!0}).addChild(`format_font_size`,[`format`],{...CR,sequence:60,separator:!0}).addChild(`format_alignment`,[`format`],{...wR,sequence:70}).addChild(`format_alignment_left`,[`format`,`format_alignment`],{...ER,sequence:10}).addChild(`format_alignment_center`,[`format`,`format_alignment`],{...DR,sequence:20}).addChild(`format_alignment_right`,[`format`,`format_alignment`],{...OR,sequence:30,separator:!0}).addChild(`format_alignment_top`,[`format`,`format_alignment`],{...AR,sequence:40}).addChild(`format_alignment_middle`,[`format`,`format_alignment`],{...jR,sequence:50}).addChild(`format_alignment_bottom`,[`format`,`format_alignment`],{...MR,sequence:60,separator:!0}).addChild(`format_wrapping`,[`format`],{...NR,sequence:80,separator:!0}).addChild(`format_wrapping_overflow`,[`format`,`format_wrapping`],{...FR,sequence:10}).addChild(`format_wrapping_wrap`,[`format`,`format_wrapping`],{...IR,sequence:20}).addChild(`format_wrapping_clip`,[`format`,`format_wrapping`],{...LR,sequence:30}).addChild(`format_cf`,[`format`],{...RR,sequence:90,separator:!0}).addChild(`format_clearFormat`,[`format`],{...zR,sequence:100,separator:!0}).add(`data`,{name:k(`Data`),sequence:60}).addChild(`sort_range`,[`data`],{...QH,sequence:10,separator:!0}).addChild(`sort_ascending`,[`data`,`sort_range`],{...$H,sequence:10}).addChild(`sort_descending`,[`data`,`sort_range`],{...rU,sequence:20}).addChild(`data_cleanup`,[`data`],{...eU,sequence:15}).addChild(`remove_duplicates`,[`data`,`data_cleanup`],{...tU,sequence:10}).addChild(`trim_whitespace`,[`data`,`data_cleanup`],{...nU,sequence:20}).addChild(`split_to_columns`,[`data`],{...oU,sequence:20}).addChild(`data_validation`,[`data`],{name:k(`Data Validation`),execute:e=>{e.openSidePanel(`DataValidation`)},isEnabled:e=>!e.isSmall,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.DATA_VALIDATION`,sequence:30,separator:!0}).addChild(`add_remove_data_filter`,[`data`],{...iU,sequence:40,separator:!0}).addChild(`pivot_data_sources`,[`data`],e=>{let t=e.model.getters.getPivotIds().length;return e.model.getters.getPivotIds().map((n,r)=>{let i={get highlights(){return nz(e.model.getters,n)}};return{id:`item_pivot_${e.model.getters.getPivotFormulaId(n)}`,name:e.model.getters.getPivotDisplayName(n),sequence:50+r/t,isReadonlyAllowed:!0,isEnabledOnLockedSheet:!0,execute:e=>e.openSidePanel(`PivotSidePanel`,{pivotId:n}),isEnabled:e=>!e.isSmall,onStartHover:e=>e.getStore(ON).register(i),onStopHover:e=>e.getStore(ON).unRegister(i),icon:`o-spreadsheet-Icon.PIVOT`,separator:r===e.model.getters.getPivotIds().length-1,secondaryIcon:e=>e.model.getters.isPivotUnused(n)?`o-spreadsheet-Icon.UNUSED_PIVOT_WARNING`:void 0}})}).addChild(`reinsert_dynamic_pivot`,[`data`],sU).addChild(`reinsert_static_pivot`,[`data`],cU),ve.forEach(e=>{kJ.addChild(`zoom${e}`,[`view`,`zoom`],KV(e))});let AJ=[jJ,MJ,PJ,FJ];function jJ(e,t){return`sheetId`in t?{...b(t),sheetId:e.getActiveSheetId()}:t}function MJ(e,t){return!(`target`in t)||!Array.isArray(t.target)?t:{...b(t),target:e.getSelectedZones()}}function NJ(e,t){return`zone`in t?{...b(t),zone:e.getSelectedZone()}:t}function PJ(e,t){if(!(`row`in t)||!(`col`in t))return t;let{col:n,row:r}=e.getActivePosition();return{...b(t),col:n,row:r}}function FJ(e,t){return`ranges`in t?{...b(t),ranges:e.getSelectedZones().map(t=>e.getRangeDataFromZone(e.getActiveSheetId(),t))}:t}let IJ=new Xl;function LJ(e,t){let n=IJ.smallUuid();return{...jJ(e,t),figureId:n,chartId:n}}function RJ(e,t){return{...jJ(e,t),figureId:IJ.smallUuid()}}function zJ(e,t){let n=PJ(e,jJ(e,t));return n.figureId=IJ.smallUuid(),n}function BJ(e,t){let n=b(t);n.sheetId=IJ.smallUuid();let r=t.name||e.getSheet(e.getActiveSheetId()).name,i=r.match(/(.+?)\d*$/)?.[1]||r;return n.name=e.getNextSheetName(i),n}function VJ(e,t){let n=e.getActivePosition();return{...jJ(e,t),base:t.dimension===`COL`?n.col:n.row}}function HJ(e,t){let n=e.getSelectedZone();return{...jJ(e,t),elements:t.dimension===`COL`?S(n.left,n.right+1):S(n.top,n.bottom+1)}}function UJ(e,t){let n=e.getSelectedZone();return{...b(t),zone:n}}function WJ(e,t){let n=b(t),{top:r,bottom:i,left:a,right:o}=e.getSelectedZone();return`cols`in n?n.cols=S(a,o+1):`rows`in n&&(n.rows=S(r,i+1)),n}function GJ(e,t){let n=e.getSelectedZone();return{...jJ(e,t),col:n.left,row:n.top,zone:n}}function KJ(e,t){return{type:`REPEAT_PASTE`,pasteOption:b(t.pasteOption),target:e.getSelectedZones()}}function qJ(e,t){let n=e.getSelectedZone();return{...jJ(e,t),start:t.dimension===`COL`?n.left:n.top,end:t.dimension===`COL`?n.right:n.bottom}}xq.add(`UPDATE_CELL`,JJ),xq.add(`CLEAR_CELL`,JJ),xq.add(`CLEAR_CELLS`,JJ),xq.add(`DELETE_CONTENT`,JJ),xq.add(`ADD_MERGE`,JJ),xq.add(`REMOVE_MERGE`,JJ),xq.add(`SET_FORMATTING`,JJ),xq.add(`CLEAR_FORMATTING`,JJ),xq.add(`SET_BORDER`,JJ),xq.add(`CREATE_TABLE`,JJ),xq.add(`REMOVE_TABLE`,JJ),xq.add(`HIDE_SHEET`,JJ),xq.add(`ADD_COLUMNS_ROWS`,VJ),xq.add(`REMOVE_COLUMNS_ROWS`,HJ),xq.add(`HIDE_COLUMNS_ROWS`,HJ),xq.add(`RESIZE_COLUMNS_ROWS`,HJ),xq.add(`CREATE_SHEET`,BJ),xq.add(`CREATE_FIGURE`,zJ),xq.add(`CREATE_CHART`,LJ),xq.add(`CREATE_IMAGE`,RJ),xq.add(`GROUP_HEADERS`,qJ),xq.add(`UNGROUP_HEADERS`,qJ),xq.add(`UNFOLD_HEADER_GROUPS_IN_ZONE`,NJ),xq.add(`FOLD_HEADER_GROUPS_IN_ZONE`,NJ),Sq.add(`PASTE`,KJ),Sq.add(`INSERT_CELL`,UJ),Sq.add(`DELETE_CELL`,UJ),Sq.add(`AUTORESIZE_COLUMNS`,WJ),Sq.add(`AUTORESIZE_ROWS`,WJ),Sq.add(`SORT_CELLS`,GJ),Sq.add(`SUM_SELECTION`,JJ),Sq.add(`SET_DECIMAL`,JJ),Sq.add(`DELETE_UNFILTERED_CONTENT`,JJ);function JJ(e,t){let n=b(t);for(let t of AJ)n=t(e,n);return n}let YJ=new class extends B{mapping={};uuidGenerator=new Xl;replace(e,t){let n={...t,id:this.uuidGenerator.uuidv4()};return super.replace(e,n)}getAllOrdered(){return this.getAll().sort((e,t)=>e.sequence-t.sequence)}};var XJ=class{listeners=[];async sendMessage(e){for(let{callback:t}of this.listeners)t(e)}onNewMessage(e,t){this.listeners.push({id:e,callback:t})}leave(e){this.listeners=this.listeners.filter(t=>t.id!==e)}},ZJ=class{fileStore;constructor(e){this.fileStore=e}async requestImage(){let e=await this.userImageUpload(),t=await this.fileStore.upload(e);return{path:t,size:await this.getImageOriginalSize(t),mimetype:e.type}}async uploadFile(e){let t=await this.fileStore.upload(e);return{path:t,size:await this.getImageOriginalSize(t),mimetype:e.type}}userImageUpload(){return new Promise((e,t)=>{let n=document.createElement(`input`);n.setAttribute(`type`,`file`),n.setAttribute(`accept`,`image/*`),n.addEventListener(`change`,async()=>{n.files===null||n.files.length!==1?t():e(n.files[0])}),n.click()})}getImageOriginalSize(e){return new Promise((t,n)=>{let r=new Image;r.addEventListener(`load`,()=>{t({width:r.width,height:r.height})}),r.addEventListener(`error`,n),r.src=e})}};let QJ=[{transform:`scale(0)`},{transform:`scale(0.8)`,offset:.33},{opacity:`0`,transform:`scale(1)`,offset:1}];var $J=class extends t.Component{static template=`o-spreadsheet-RippleEffect`;static props={x:String,y:String,color:String,opacity:Number,duration:Number,width:Number,height:Number,offsetY:Number,offsetX:Number,allowOverflow:Boolean,onAnimationEnd:Function,style:String};rippleRef=(0,t.useRef)(`ripple`);setup(){let e;(0,t.onMounted)(()=>{let t=this.rippleRef.el;!t||!t.animate||(e=t.animate(QJ,{duration:this.props.duration,easing:`ease-out`}),e.addEventListener(`finish`,this.props.onAnimationEnd))}),(0,t.onWillUnmount)(()=>{e?.removeEventListener(`finish`,this.props.onAnimationEnd)})}get rippleStyle(){let{x:e,y:t,width:n,height:r}=this.props,i=this.props.offsetX||0,a=this.props.offsetY||0;return U({transform:`scale(0)`,left:e,top:t,"margin-left":`${-n/2+i}px`,"margin-top":`${-r/2+a}px`,width:`${n}px`,height:`${r}px`,background:this.props.color,"border-radius":`100%`,opacity:`${this.props.opacity}`})}},eY=class extends t.Component{static template=`o-spreadsheet-Ripple`;static props={color:{type:String,optional:!0},opacity:{type:Number,optional:!0},duration:{type:Number,optional:!0},ignoreClickPosition:{type:Boolean,optional:!0},width:{type:Number,optional:!0},height:{type:Number,optional:!0},offsetY:{type:Number,optional:!0},offsetX:{type:Number,optional:!0},allowOverflow:{type:Boolean,optional:!0},enabled:{type:Boolean,optional:!0},onAnimationEnd:{type:Function,optional:!0},slots:Object,class:{type:String,optional:!0}};static components={RippleEffect:$J};static defaultProps={color:`#aaaaaa`,opacity:.4,duration:800,enabled:!0,onAnimationEnd:()=>{},class:``};childContainer=(0,t.useRef)(`childContainer`);state=(0,t.useState)({ripples:[]});currentId=1;onClick(e){if(!this.props.enabled||!this.childContainer.el)return;let{x:t,y:n,width:r,height:i}=this.getRippleChildRectInfo(),a=Math.max(r,i),o={x:e.clientX-t,y:e.clientY-n,width:this.props.width||a*2.85,height:this.props.height||a*2.85};this.state.ripples.push({rippleRect:o,id:this.currentId++})}getRippleStyle(){let e=this.childContainer.el;if(!e||e.childElementCount!==1||!e.firstElementChild)return``;let t=this.getRippleChildRectInfo();return U({top:t.marginTop+`px`,left:t.marginLeft+`px`,width:t.width+`px`,height:t.height+`px`})}getRippleChildRectInfo(){let e=this.childContainer.el;if(!e)throw Error(`No child container element found`);if(e.childElementCount!==1||!e.firstElementChild)return{...op(e),marginLeft:0,marginTop:0};let t=e.firstElementChild,n=sv(t);return{...op(t),marginLeft:n.left,marginTop:n.top}}removeRipple(e){let t=this.state.ripples.findIndex(t=>t.id===e);t!==-1&&this.state.ripples.splice(t,1)}getRippleEffectProps(e){let t=this.state.ripples.find(t=>t.id===e)?.rippleRect;if(!t)throw Error(`Cannot find a ripple with the id `+e);return{color:this.props.color,opacity:this.props.opacity,duration:this.props.duration,x:this.props.ignoreClickPosition?`50%`:t.x+`px`,y:this.props.ignoreClickPosition?`50%`:t.y+`px`,width:t.width,height:t.height,offsetX:this.props.offsetX||0,offsetY:this.props.offsetY||0,allowOverflow:this.props.allowOverflow||!1,style:this.getRippleStyle(),onAnimationEnd:()=>this.removeRipple(e)}}};function tY(e,t,n,r){let i=e.model.dispatch(`RENAME_SHEET`,{sheetId:t,newName:n,oldName:e.model.getters.getSheetName(t)});i.reasons.includes(`MissingSheetName`)?e.raiseError(k(`The sheet name cannot be empty.`),r):i.reasons.includes(`DuplicatedSheetName`)?e.raiseError(k(`A sheet with the name %s already exists. Please select another name.`,n),r):i.reasons.includes(`ForbiddenCharactersInSheetName`)&&e.raiseError(k(`Some used characters are not allowed in a sheet name (Forbidden characters are %s).`,Me.join(` `)),r)}let nY=(e,t)=>[[{backgroundColor:`light-dark(darkgrey, lightgrey)`}],{duration:e,iterations:t,easing:`cubic-bezier(1, 0, 0, 1)`}];var rY=class extends t.Component{static template=`o-spreadsheet-BottomBarSheet`;static props={sheetId:String,openContextMenu:Function,style:{type:String,optional:!0},onMouseDown:{type:Function,optional:!0}};static components={Ripple:eY,ColorPicker:VN};static defaultProps={onMouseDown:()=>{},style:``};state=(0,t.useState)({isEditing:!1,pickerOpened:!1});sheetDivRef=(0,t.useRef)(`sheetDiv`);iconRef=(0,t.useRef)(`icon`);sheetNameRef=(0,t.useRef)(`sheetNameSpan`);editionState=`initializing`;DOMFocusableElementStore;setup(){(0,t.onPatched)(()=>{this.sheetNameRef.el&&this.state.isEditing&&this.editionState===`initializing`&&(this.editionState=`editing`,this.focusInputAndSelectContent())}),this.DOMFocusableElementStore=D(LM),(0,t.useExternalListener)(window,`click`,this.onExternalClick.bind(this),{capture:!0}),(0,t.useEffect)(e=>{this.props.sheetId===e&&this.scrollToSheet()},()=>[this.env.model.getters.getActiveSheetId()]),(0,t.onMounted)(()=>{let e=ht(()=>this.sheetDivRef.el?.animate(...nY(200,1)).finished.then(()=>this.iconRef.el?.animate(...nY(200,2))),800);this.env.model.on(`command-rejected`,this,({command:t,result:n})=>{n.isCancelledBecause(`SheetLocked`)&&(!t||!Ms(t)&&this.isSheetActive||Ms(t)&&t.sheetId===this.props.sheetId)&&(this.scrollToSheet(),e())})}),(0,t.onWillUnmount)(()=>{this.env.model.off(`command-rejected`,this)})}onExternalClick(e){e.target.closest(`.o-color-picker`)||(this.state.pickerOpened=!1)}focusInputAndSelectContent(){if(!this.state.isEditing||!this.sheetNameRef.el)return;this.sheetNameRef.el.focus();let e=window.getSelection();e&&this.sheetNameRef.el.firstChild&&e.setBaseAndExtent(this.sheetNameRef.el.firstChild,0,this.sheetNameRef.el.firstChild,this.sheetNameRef.el.textContent?.length||0)}scrollToSheet(){this.sheetDivRef.el?.scrollIntoView?.({behavior:`smooth`,inline:`nearest`})}onFocusOut(){this.state.isEditing&&this.editionState!==`initializing`&&this.stopEdition()}onClick(){this.env.isMobile()&&this.activateSheet()}onMouseDown(e){this.env.isMobile()||(this.activateSheet(),this.props.onMouseDown(e))}activateSheet(){this.env.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:this.env.model.getters.getActiveSheetId(),sheetIdTo:this.props.sheetId}),this.scrollToSheet()}onDblClick(){this.env.model.getters.isReadonly()||this.isSheetLocked||this.startEdition()}onKeyDown(e){this.state.isEditing&&(e.key===`Enter`&&(e.preventDefault(),this.stopEdition(),this.DOMFocusableElementStore.focus()),e.key===`Escape`&&(this.cancelEdition(),this.DOMFocusableElementStore.focus()))}onMouseEventSheetName(e){this.state.isEditing&&e.stopPropagation()}startEdition(){this.state.isEditing=!0,this.editionState=`initializing`}stopEdition(){if(!this.state.isEditing||!this.sheetNameRef.el)return;this.state.isEditing=!1,this.editionState=`initializing`,this.sheetNameRef.el.blur();let e=this.getInputContent()||``;tY(this.env,this.props.sheetId,e,()=>this.startEdition())}cancelEdition(){this.state.isEditing=!1,this.editionState=`initializing`,this.sheetNameRef.el?.blur(),this.setInputContent(this.sheetName)}onIconClick(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}onContextMenu(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}getInputContent(){return this.sheetNameRef.el?.textContent}setInputContent(e){this.sheetNameRef.el&&(this.sheetNameRef.el.textContent=e)}onColorPicked(e){this.state.pickerOpened=!1,this.env.model.dispatch(`COLOR_SHEET`,{sheetId:this.props.sheetId,color:e})}get colorPickerAnchorRect(){let e=this.sheetDivRef.el;return op(e)}get contextMenuRegistry(){return OJ({renameSheetCallback:()=>{this.scrollToSheet(),this.startEdition()},openSheetColorPickerCallback:()=>{this.state.pickerOpened=!0;let e=this.env.model.getters.getSheet(this.props.sheetId);this.state.currentPickerColor=e.color}})}get isSheetActive(){return this.env.model.getters.getActiveSheetId()===this.props.sheetId}get sheetName(){return this.env.model.getters.getSheetName(this.props.sheetId)}get sheetColorStyle(){return U({background:this.env.model.getters.getSheet(this.props.sheetId).color||``})}get isSheetLocked(){return this.env.model.getters.isSheetLocked(this.props.sheetId)}};let iY=[{name:k(`Sum`),types:[`number`],compute:(e,t)=>Jm([[e]],t)},{name:k(`Avg`),types:[`number`],compute:(e,t)=>Em([[e]],t)},{name:k(`Min`),types:[`number`],compute:(e,t)=>Am([[e]],t).value},{name:k(`Max`),types:[`number`],compute:(e,t)=>km([[e]],t).value},{name:k(`Count`),types:[`number`,`text`,`boolean`,`error`],compute:e=>Om([[e]])},{name:k(`Count Numbers`),types:[`number`,`text`,`boolean`,`error`],compute:(e,t)=>Dm([[e]],t)}];var aY=class extends yr{statisticFnResults=this._computeStatisticFnResults();isDirty=!1;constructor(e){super(e),this.model.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.onDispose(()=>{this.model.selection.unobserve(this)})}handle(e){switch((Rs.has(e.type)||e.type===`UPDATE_CELL`&&(`content`in e||`format`in e))&&(this.isDirty=!0),e.type){case`HIDE_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`GROUP_HEADERS`:case`UNGROUP_HEADERS`:case`ACTIVATE_SHEET`:case`ACTIVATE_NEXT_SHEET`:case`ACTIVATE_PREVIOUS_SHEET`:case`EVALUATE_CELLS`:case`UNDO`:case`REDO`:this.isDirty=!0}}finalize(){this.isDirty&&(this.isDirty=!1,this.statisticFnResults=this._computeStatisticFnResults())}handleEvent(){this.getters.isGridSelectionActive()&&(this.statisticFnResults=this._computeStatisticFnResults())}_computeStatisticFnResults(){let e=this.getters,t=e.getActiveSheetId(),n=[],r=nn(e.getSelectedZones(),[]),i=this.getters.getSheetSize(t).numberOfRows-1,a=this.getters.getSheetSize(t).numberOfCols-1;for(let o of r)for(let r=o.left;r<=(o.right??a);r++)for(let a=o.top;a<=(o.bottom??i);a++){if(e.isRowHidden(t,a)||e.isColHidden(t,r))continue;let i=e.getEvaluatedCell({sheetId:t,col:r,row:a});i.type!==`empty`&&n.push(i)}let o=e.getLocale(),s={},c=At(e=>{let t=e.split(`,`);return n.filter(e=>t.includes(e.type))});for(let e of iY){let t,n=c(e.types.sort().join(`,`));n.length&&(t=_t(()=>e.compute(n,o))),s[e.name]=t}return s}},oY=class extends t.Component{static template=`o-spreadsheet-BottomBarStatistic`;static props={openContextMenu:Function,closeContextMenu:Function};static components={Ripple:eY};selectedStatisticFn=``;store;setup(){this.store=D(aY),(0,t.onWillUpdateProps)(()=>{Object.values(this.store.statisticFnResults).every(e=>e===void 0)&&this.props.closeContextMenu()})}getSelectedStatistic(){if(!Object.values(this.store.statisticFnResults).every(e=>e===void 0))return this.selectedStatisticFn===``&&(this.selectedStatisticFn=Object.keys(this.store.statisticFnResults)[0]),this.getComposedFnName(this.selectedStatisticFn)}listSelectionStatistics(e){let t=new bP,n=0;for(let[e]of Object.entries(this.store.statisticFnResults))t.add(e,{name:()=>this.getComposedFnName(e),sequence:n,isReadonlyAllowed:!0,execute:()=>{this.selectedStatisticFn=e}}),n++;let{top:r,left:i,width:a}=e.currentTarget.getBoundingClientRect();this.props.openContextMenu(i+a,r,t)}getComposedFnName(e){let t=this.env.model.getters.getLocale(),n=this.store.statisticFnResults[e];return e+`: `+(n===void 0?`__`:z(n(),{locale:t}))}},sY=class extends t.Component{static template=`o-spreadsheet-BottomBar`;static props={onClick:Function};static components={MenuPopover:Fv,Ripple:eY,BottomBarSheet:rY,BottomBarStatistic:oY};bottomBarRef=(0,t.useRef)(`bottomBar`);sheetListRef=(0,t.useRef)(`sheetList`);dragAndDrop=WN();targetScroll=void 0;state=(0,t.useState)({isSheetListScrollableLeft:!1,isSheetListScrollableRight:!1});menuMaxHeight=250;menuState=(0,t.useState)({isOpen:!1,menuId:void 0,anchorRect:null,menuItems:[]});sheetList=this.getVisibleSheets();setup(){(0,t.onWillUpdateProps)(()=>{this.updateScrollState();let e=this.getVisibleSheets();w(this.sheetList,e)||this.dragAndDrop.cancel(),this.sheetList=e})}clickAddSheet(e){let t=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getSheetIds().findIndex(e=>e===t)+1,r=this.env.model.uuidGenerator.smallUuid(),i=this.env.model.getters.getNextSheetName(k(`Sheet`));this.env.model.dispatch(`CREATE_SHEET`,{sheetId:r,position:n,name:i}),this.env.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:t,sheetIdTo:r})}getVisibleSheets(){return this.env.model.getters.getVisibleSheetIds().map(e=>{let t=this.env.model.getters.getSheet(e);return{id:t.id,name:t.name}})}clickListSheets(e){let t=new bP,n=this.env.model.getters.getActiveSheetId(),r=0;for(let e of this.env.model.getters.getSheetIds()){let i=this.env.model.getters.getSheet(e);t.add(e,{name:i.name,sequence:r,isReadonlyAllowed:!0,textColor:i.isVisible?void 0:`#808080`,execute:t=>{this.env.model.getters.isSheetVisible(e)||this.env.model.dispatch(`SHOW_SHEET`,{sheetId:e}),t.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:n,sheetIdTo:e})},isEnabled:e=>e.model.getters.isReadonly()?i.isVisible:!0,icon:i.color?`o-spreadsheet-Icon.SMALL_DOT_RIGHT_ALIGN`:void 0,iconColor:i.color,isEnabledOnLockedSheet:!0}),r++}let{left:i}=e.currentTarget.getBoundingClientRect(),a=this.bottomBarRef.el.getBoundingClientRect().top;this.openContextMenu(i,a,`listSheets`,t)}openContextMenu(e,t,n,r){this.menuState.isOpen=!0,this.menuState.menuId=n,this.menuState.menuItems=r.getMenuItems(),this.menuState.anchorRect={x:e,y:t,width:0,height:0}}onSheetContextMenu(e,t,n){let{top:r,left:i}=n.currentTarget.getBoundingClientRect();if(n.closedMenuId===e){this.closeMenu();return}this.openContextMenu(i,r,e,t)}closeMenu(){this.menuState.isOpen=!1,this.menuState.menuId=void 0,this.menuState.menuItems=[],this.menuState.anchorRect=null}closeContextMenuWithId(e){this.menuState.menuId===e&&this.closeMenu()}onWheel(e){this.targetScroll=void 0;let t=e.currentTarget;t.scrollLeft+=e.deltaY*.5}onScroll(){this.updateScrollState(),this.targetScroll===this.sheetListCurrentScroll&&(this.targetScroll=void 0)}onArrowLeft(e){if(!this.state.isSheetListScrollableLeft)return;this.targetScroll||=this.sheetListCurrentScroll;let t=this.targetScroll-this.sheetListWidth;this.scrollSheetListTo(Math.max(0,t))}onArrowRight(e){if(!this.state.isSheetListScrollableRight)return;this.targetScroll||=this.sheetListCurrentScroll;let t=this.targetScroll+this.sheetListWidth;this.scrollSheetListTo(Math.min(this.sheetListMaxScroll,t))}updateScrollState(){this.state.isSheetListScrollableLeft=this.sheetListCurrentScroll>0,this.state.isSheetListScrollableRight=this.sheetListCurrentScroll<this.sheetListMaxScroll}scrollSheetListTo(e){this.sheetListRef.el&&(this.targetScroll=e,this.sheetListRef.el.scrollTo({top:0,left:e,behavior:`smooth`}))}onSheetMouseDown(e,t){if(t.button!==0||this.env.model.getters.isReadonly()||(this.closeMenu(),this.env.isMobile()))return;let n=this.getVisibleSheets(),r=this.getSheetItemRects(),i=n.map((e,t)=>({id:e.id,size:r[t].width,position:r[t].x}));this.dragAndDrop.start(`horizontal`,{draggedItemId:e,initialMousePosition:t.clientX,items:i,scrollableContainerEl:this.sheetListRef.el,onDragEnd:(e,t)=>this.onDragEnd(e,t)})}onDragEnd(e,t){let n=t-this.getVisibleSheets().findIndex(t=>t.id===e);e&&n!==0&&this.env.model.dispatch(`MOVE_SHEET`,{sheetId:e,delta:n})}getSheetStyle(e){return this.dragAndDrop.itemsStyle[e]||``}getSheetItemRects(){return Array.from(this.bottomBarRef.el.querySelectorAll(`.o-sheet`)).map(e=>e.getBoundingClientRect()).map(e=>({x:e.x,width:e.width-1,y:e.y,height:e.height}))}get sheetListCurrentScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollLeft:0}get sheetListWidth(){return this.sheetListRef.el?this.sheetListRef.el.clientWidth:0}get sheetListMaxScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollWidth-this.sheetListRef.el.clientWidth:0}},cY=class extends yr{_clickableCells=(0,t.markRaw)({});_registryItems=(0,t.markRaw)(rJ.getAll().sort((e,t)=>e.sequence-t.sequence));handle(e){(Rs.has(e.type)||e.type===`EVALUATE_CELLS`||e.type===`UPDATE_CELL`&&(`content`in e||`format`in e))&&(this._clickableCells=(0,t.markRaw)({}),this._registryItems=(0,t.markRaw)(rJ.getAll().sort((e,t)=>e.sequence-t.sequence)))}getClickableItem(e){let{sheetId:t,col:n,row:r}=e,i=this._clickableCells,a=T(n,r);if(i[t]||(i[t]={}),!(a in i[t])){let n=this.findClickableItem(e);i[t][a]=n}return i[t][a]}findClickableItem(e){let t=this.getters;for(let n of this._registryItems)if(n.condition(e,t))return n}get clickableCells(){let e=[],t=this.getters;for(let n of this.getters.getVisibleCellPositions()){let r=this.getClickableItem(n);if(!r)continue;let i=typeof r.title==`function`?r.title(n,t):r.title,a=this.getClickableCellRect(n);a&&e.push({coordinates:a,position:n,action:r.execute,title:i||``,component:r.component,componentProps:r.componentProps?.(n,t)??{}})}return e}getClickableCellRect(e){let t=this.getters.expandZone(e.sheetId,E(e)),n=this.getters.getVisibleRect(t),r=this.getters.getCellIcons(e),i={center:r.find(e=>e.horizontalAlign===`center`),left:r.find(e=>e.horizontalAlign===`left`),right:r.find(e=>e.horizontalAlign===`right`)};if(!i.center?.onClick){if(i.right?.onClick){let e=this.getters.getRect(t),r=this.getters.getCellIconRect(i.right,e);n.width-=r.width+i.right.margin}if(i.left?.onClick){let e=this.getters.getRect(t),r=this.getters.getCellIconRect(i.left,e);n.x+=r.width+i.left.margin,n.width-=r.width+i.left.margin}return n}}},lY=class extends t.Component{static template=`o-spreadsheet-SpreadsheetDashboard`;static props={getGridSize:Function};static components={GridOverlay:fW,GridPopover:pW,Popover:jv,VerticalScrollBar:NW,HorizontalScrollBar:MW};cellPopovers;onMouseWheel;canvasPosition;hoveredCell;clickableCellsStore;gridRef;setup(){this.gridRef=(0,t.useRef)(`grid`),this.hoveredCell=D(Hv),this.clickableCellsStore=D(cY),(0,t.useChildSubEnv)({getPopoverContainerRect:()=>Op(this.env.model.getters.getViewportZoomLevel(),this.getGridRect())}),xW(`canvas`,this.env.model,()=>this.env.model.getters.getSheetViewDimension()),this.onMouseWheel=TW((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.clear()}),this.cellPopovers=D(sP),CW(this.gridRef,{updateScroll:this.moveCanvas.bind(this),canMoveUp:()=>{let{scrollY:e}=this.env.model.getters.getActiveSheetScrollInfo();return e>0},canMoveDown:()=>{let{maxOffsetY:e}=this.env.model.getters.getMaximumSheetOffset(),{scrollY:t}=this.env.model.getters.getActiveSheetScrollInfo();return t<e},getZoom:()=>this.env.model.getters.getViewportZoomLevel(),setZoom:e=>this.env.model.dispatch(`SET_ZOOM`,{zoom:e})})}get gridContainer(){return U({"max-width":`${this.getMaxSheetWidth()}px`})}get gridOverlayDimensions(){return U({height:`100%`,width:`100%`})}getCellClickableStyle(e){return U({top:`${e.y}px`,left:`${e.x}px`,width:`${e.width}px`,height:`${e.height}px`})}getClickableCells(){return(0,t.toRaw)(this.clickableCellsStore.clickableCells)}selectClickableCell(e,t){if(![0,1].includes(e.button))return;let{position:n,action:r}=t;r(n,this.env,gp(e))}onClosePopover(){this.cellPopovers.close()}onGridResized(){let{height:e,width:t}=this.props.getGridSize(),n=this.getMaxSheetWidth();this.env.model.dispatch(`RESIZE_SHEETVIEW`,{width:Math.min(n,t),height:e,gridOffsetX:0,gridOffsetY:0})}moveCanvas(e,t){let{scrollX:n,scrollY:r}=this.env.model.getters.getActiveSheetScrollInfo();this.env.model.dispatch(`SET_VIEWPORT_OFFSET`,{offsetX:n+e,offsetY:r+t})}getGridRect(){return{...ap(this.gridRef),...this.env.model.getters.getSheetViewDimensionWithHeaders()}}getMaxSheetWidth(){let e=this.env.model.getters.getActiveSheetId(),{right:t}=this.env.model.getters.getSheetZone(e);return this.env.model.getters.getColDimensions(e,t).end}get dashboardStyle(){return U({zoom:`${this.env.model.getters.getViewportZoomLevel()}`})}},uY=class extends t.Component{static template=`o-spreadsheet-HeaderGroup`;static props={group:Object,layerOffset:Number,openContextMenu:Function};toggleGroup(){let e=this.env.model.getters.getActiveSheetId(),{start:t,end:n}=this.props.group;dU(this.env,e,this.dimension,t,n)}get groupBoxStyle(){let e=this.groupBox;return U({top:`${e.groupRect.y}px`,left:`${e.groupRect.x}px`,width:`${e.groupRect.width}px`,height:`${e.groupRect.height}px`})}get groupButtonStyle(){return U({"background-color":this.isGroupFolded?`#333`:`#fff`,color:this.isGroupFolded?`#fff`:`#333`})}get groupButtonIcon(){return this.isGroupFolded?`o-spreadsheet-Icon.PLUS`:`o-spreadsheet-Icon.MINUS`}get isGroupFolded(){let e=this.env.model.getters.getActiveSheetId(),t=this.props.group;return this.env.model.getters.isGroupFolded(e,this.dimension,t.start,t.end)}onContextMenu(e){let t=this.env.model.getters.getActiveSheetId(),n={x:e.clientX,y:e.clientY},r=this.props.group,i=pU(t,this.dimension,r.start,r.end);this.props.openContextMenu(n,i)}},dY=class extends uY{dimension=`ROW`;get groupBorderStyle(){let e=this.groupBox;return this.groupBox.groupRect.height===0?``:U({top:`${e.headerRect.height/2}px`,left:`calc(50% - 1px)`,width:`30%`,height:`calc(100% - ${e.headerRect.height/2}px)`,"border-left":`1px solid`,"border-bottom":e.isEndHidden?``:`1px solid`})}get groupHeaderStyle(){return U({width:`100%`,height:`${this.groupBox.headerRect.height}px`})}get groupBox(){let e=this.env.model.getters.getActiveSheetId(),{start:t,end:n}=this.props.group,r=this.env.model.getters.getRowDimensions(e,t).start,i=this.env.model.getters.getRowDimensions(e,n).end,a=0,o=26;if(t!==0){let n=this.env.model.getters.getRowDimensions(e,t-1);a=26+n.start,o=n.end-n.start}let s={x:this.props.layerOffset,y:a,width:21,height:o};return{headerRect:s,groupRect:{x:this.props.layerOffset,y:s.y,width:21,height:s.height+(i-r)},isEndHidden:this.env.model.getters.isRowHidden(e,n)}}},fY=class extends uY{dimension=`COL`;get groupBorderStyle(){let e=this.groupBox;return e.groupRect.width===0?``:U({top:`calc(50% - 1px)`,left:`${e.headerRect.width/2}px`,width:`calc(100% - ${e.headerRect.width/2}px)`,height:`30%`,"border-top":`1px solid`,"border-right":e.isEndHidden?``:`1px solid`})}get groupHeaderStyle(){return U({width:`${this.groupBox.headerRect.width}px`,height:`100%`})}get groupBox(){let e=this.env.model.getters.getActiveSheetId(),{start:t,end:n}=this.props.group,r=this.env.model.getters.getColDimensions(e,t).start,i=this.env.model.getters.getColDimensions(e,n).end,a=0,o=48;if(t!==0){let n=this.env.model.getters.getColDimensions(e,t-1);a=48+n.start,o=n.end-n.start}let s={x:a,y:this.props.layerOffset,width:o,height:21};return{headerRect:s,groupRect:{x:s.x,y:this.props.layerOffset,width:s.width+(i-r),height:21},isEndHidden:this.env.model.getters.isColHidden(e,n)}}},pY=class extends t.Component{static template=`o-spreadsheet-HeaderGroupContainer`;static props={dimension:String,layers:Array};static components={RowGroup:dY,ColGroup:fY,MenuPopover:Fv};menu=(0,t.useState)({isOpen:!1,anchorRect:null,menuItems:[]});getLayerOffset(e){return e*21}onContextMenu(e){let t=this.env.model.getters.getActiveSheetId(),n={x:e.clientX,y:e.clientY},r=fU(t,this.props.dimension);this.openContextMenu(n,r)}openContextMenu(e,t){this.menu.isOpen=!0,this.menu.anchorRect={...e,width:0,height:0},this.menu.menuItems=t}closeMenu(){this.menu.isOpen=!1,this.menu.anchorRect=null,this.menu.menuItems=[]}get groupComponent(){return this.props.dimension===`ROW`?dY:fY}get hasFrozenPane(){let e=this.env.model.getters.getMainViewportCoordinates();return this.props.dimension===`COL`?e.x>0:e.y>0}get scrollContainerStyle(){let{scrollX:e,scrollY:t}=this.env.model.getters.getActiveSheetScrollInfo(),n={};return this.props.dimension===`COL`?n.left=`${-e-this.frozenPaneContainerSize}px`:n.top=`${-t-this.frozenPaneContainerSize}px`,U(n)}get frozenPaneContainerStyle(){let e={};return this.props.dimension===`COL`?e.width=`${this.frozenPaneContainerSize}px`:e.height=`${this.frozenPaneContainerSize}px`,U(e)}get frozenPaneContainerSize(){if(!this.hasFrozenPane)return 0;let e=this.env.model.getters.getMainViewportCoordinates();return this.props.dimension===`COL`?48+e.x:26+e.y}};function mY(){let e=kv();return{get isSmall(){return e.width<768}}}var hY=class extends t.Component{static template=`o-spreadsheet-SidePanel`;static props={panelContent:Object,panelProps:Object,onCloseSidePanel:Function,onStartHandleDrag:Function,onResetPanelSize:Function,isPinned:{type:Boolean,optional:!0},onTogglePinPanel:{type:Function,optional:!0},onToggleCollapsePanel:{type:Function,optional:!0},isCollapsed:{type:Boolean,optional:!0}};spreadsheetRect=kv();getTitle(){let e=this.props.panelContent;return typeof e.title==`function`?e.title(this.env,this.props.panelProps):e.title}},gY=class extends t.Component{static template=`o-spreadsheet-SidePanels`;static props={};static components={SidePanel:hY};sidePanelStore;spreadsheetRect=kv();setup(){this.sidePanelStore=D(SV),(0,t.useEffect)(()=>{this.sidePanelStore.mainPanel&&!this.sidePanelStore.isMainPanelOpen&&this.sidePanelStore.closeMainPanel(),this.sidePanelStore.secondaryPanel&&!this.sidePanelStore.isSecondaryPanelOpen&&this.sidePanelStore.close()},()=>[this.sidePanelStore.isMainPanelOpen,this.sidePanelStore.isSecondaryPanelOpen])}startHandleDrag(e,t){let n=document.body.style.cursor,r=e===`mainPanel`?this.sidePanelStore.mainPanel:this.sidePanelStore.secondaryPanel;if(!r)return;let i=r.size,a=t.clientX;BN(t=>{document.body.style.cursor=`col-resize`;let n=i+a-t.clientX;this.sidePanelStore.changePanelSize(e,n)},()=>{document.body.style.cursor=n})}get mainPanelProps(){let e=this.sidePanelStore.mainPanelProps;if(!(!this.sidePanelStore.mainPanel||!e))return{panelContent:bV.get(this.sidePanelStore.mainPanel.componentTag),panelProps:e,onCloseSidePanel:()=>this.sidePanelStore.closeMainPanel(),onTogglePinPanel:()=>this.sidePanelStore.togglePinPanel(),onStartHandleDrag:e=>this.startHandleDrag(`mainPanel`,e),onResetPanelSize:()=>this.sidePanelStore.resetPanelSize(`mainPanel`),isPinned:this.sidePanelStore.mainPanel?.isPinned,onToggleCollapsePanel:()=>this.sidePanelStore.toggleCollapsePanel(`mainPanel`),isCollapsed:this.sidePanelStore.mainPanel?.isCollapsed}}get secondaryPanelProps(){let e=this.sidePanelStore.secondaryPanelProps;if(!(!this.sidePanelStore.secondaryPanel||!e))return{panelContent:bV.get(this.sidePanelStore.secondaryPanel.componentTag),panelProps:e,onCloseSidePanel:()=>this.sidePanelStore.close(),onStartHandleDrag:e=>this.startHandleDrag(`secondaryPanel`,e),onResetPanelSize:()=>this.sidePanelStore.resetPanelSize(`secondaryPanel`),onToggleCollapsePanel:()=>this.sidePanelStore.toggleCollapsePanel(`secondaryPanel`),isCollapsed:this.sidePanelStore.secondaryPanel?.isCollapsed}}get panelList(){return[{key:this.sidePanelStore.secondaryPanelKey,props:this.secondaryPanelProps,style:this.sidePanelStore.secondaryPanel?U({width:`${this.sidePanelStore.secondaryPanel.size}px`}):``},{key:this.sidePanelStore.mainPanelKey,props:this.mainPanelProps,style:this.sidePanelStore.mainPanel?U({width:`${this.sidePanelStore.mainPanel.size}px`}):``}].filter(e=>e.key&&e.props)}},_Y=class extends t.Component{static template=`o-spreadsheet-RibbonMenu`;static props={onClose:Function};static components={Menu:Cv};rootItems=kJ.getMenuItems();menuRef=(0,t.useRef)(`menu`);containerRef=(0,t.useRef)(`container`);state=(0,t.useState)({menuItems:this.rootItems,title:k(`Menu Bar`),parentState:void 0});setup(){(0,t.useExternalListener)(window,`click`,this.onExternalClick,{capture:!0}),(0,t.onMounted)(this.updateShadows)}onExternalClick(e){this.menuRef.el?.contains(e.target)||this.props.onClose()}onClickMenu(e){let t=e.children(this.env);t.length?(this.state.parentState={...this.state},this.state.menuItems=t,this.state.title=e.name(this.env),this.containerRef.el?.scrollTo({top:0})):(this.state.menuItems=this.rootItems,this.state.title=void 0,this.state.parentState=void 0,e.execute?.(this.env),this.props.onClose())}get menuProps(){return{menuItems:g(this.env,this.state.menuItems),onClose:this.props.onClose,onClickMenu:this.onClickMenu.bind(this)}}get style(){return U({height:`${this.props.height}px`})}updateShadows(){if(!this.containerRef.el)return;this.containerRef.el.classList.remove(`scroll-top`,`scroll-bottom`);let e=this.containerRef.el.scrollHeight-this.containerRef.el.clientHeight||0;this.containerRef.el.scrollTop<e-1&&this.containerRef.el.classList.add(`scroll-bottom`),this.containerRef.el.scrollTop>0&&this.containerRef.el.classList.add(`scroll-top`)}onClickBack(){if(!this.state.parentState){this.props.onClose();return}this.state.menuItems=this.state.parentState.menuItems,this.state.title=this.state.parentState.title,this.state.parentState=this.state.parentState.parentState,this.containerRef.el?.scrollTo({top:0})}get backTitle(){return this.state.parentState?k(`Go to previous menu`):k(`Close menu bar`)}},vY=class extends t.Component{static components={Composer:$M,BottomBar:sY,Ripple:eY,RibbonMenu:_Y};static template=`o-spreadsheet-SmallBottomBar`;static props={onClick:Function};composerFocusStore;composerStore;composerInterface;composerRef=(0,t.useRef)(`bottombarComposer`);menuState=(0,t.useState)({isOpen:!1});setup(){this.composerFocusStore=D(xr);let e=D(KU);this.composerStore=e,this.composerInterface={id:`bottombarComposer`,get editionMode(){return e.editionMode},startEdition:this.composerStore.startEdition,setCurrentContent:this.composerStore.setCurrentContent,stopEdition:this.composerStore.stopEdition},(0,t.useEffect)(()=>{this.env.isMobile()&&!this.menuState.isOpen&&this.composerStore.editionMode!==`inactive`&&this.composerFocusStore.activeComposer!==this.composerInterface&&this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`contentFocus`})})}get focus(){return this.composerFocusStore.activeComposer===this.composerInterface?this.composerFocusStore.focusMode:`inactive`}get showFxIcon(){return this.focus===`inactive`&&!this.composerStore.currentContent&&!this.composerStore.placeholder}get rect(){return this.composerRef.el?op(this.composerRef.el):{x:0,y:0,width:0,height:0}}get composerProps(){let{width:e,height:t}=this.env.model.getters.getSheetViewDimensionWithHeaders();return{rect:{...this.rect},delimitation:{width:e,height:t},focus:this.focus,composerStore:this.composerStore,onComposerContentFocused:e=>this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`contentFocus`,selection:e}),isDefaultFocus:!1,inputStyle:U({height:this.focus===`inactive`?`26px`:`fit-content`,"max-height":`130px`}),showAssistant:!1,placeholder:this.composerStore.placeholder}}get symbols(){return[`=`,`(`,`)`,`:`,`-`,`/`,`*`,`,`,`+`,`$`,`.`]}insertSymbol(e){this.composerStore.replaceComposerCursorSelection(e),this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`contentFocus`})}toggleRibbon(){this.composerStore.cancelEdition(),this.menuState.isOpen=!this.menuState.isOpen}},yY=class extends t.Component{static template=`o-spreadsheet-TopBarComposer`;static props={};static components={Composer:$M};composerFocusStore;composerStore;composerInterface;setup(){this.composerFocusStore=D(xr);let e=D(KU);this.composerStore=e,this.composerInterface={id:`topbarComposer`,get editionMode(){return e.editionMode},startEdition:this.composerStore.startEdition,setCurrentContent:this.composerStore.setCurrentContent,stopEdition:this.composerStore.stopEdition}}get focus(){return this.composerFocusStore.activeComposer===this.composerInterface?this.composerFocusStore.focusMode:`inactive`}get showFxIcon(){return this.focus===`inactive`&&!this.composerStore.currentContent&&!this.composerStore.placeholder}get composerStyle(){let e={padding:`5px 0px 5px 8px`,"max-height":`300px`,"line-height":`24px`};return this.env.model.getters.isCurrentSheetLocked()&&(e[`pointer-events`]=`none`),e.height=this.focus===`inactive`?`34px`:`fit-content`,U(e)}onFocus(e){this.composerFocusStore.focusComposer(this.composerInterface,{selection:e})}},bY=class{mutators=[`closeDropdowns`,`openDropdown`];_currentDropdown=null;closeDropdowns(){this._currentDropdown=null}openDropdown(e){this._currentDropdown=e}get currentDropdown(){return this._currentDropdown}},xY=class{content={};add(e){if(e in this.content)throw Error(`${e} is already present in this registry!`);return this.content[e]=[],this}addChild(e,t){return this.content[e].push(t),this}getEntries(e){return this.content[e].sort((e,t)=>e.sequence-t.sequence)}getCategories(){return Object.keys(this.content)}};function SY(){let e=(0,t.useComponent)(),n=D(bY);return(0,t.onWillUnmount)(()=>{e===n.currentDropdown&&n.closeDropdowns()}),{closeDropdowns:()=>n.closeDropdowns(),openDropdown:()=>{n.openDropdown(e)},get isActive(){return n.currentDropdown===e}}}let CY=[[[`all`,`o-spreadsheet-Icon.BORDERS`],[`hv`,`o-spreadsheet-Icon.BORDER_HV`],[`h`,`o-spreadsheet-Icon.BORDER_H`],[`v`,`o-spreadsheet-Icon.BORDER_V`],[`external`,`o-spreadsheet-Icon.BORDER_EXTERNAL`]],[[`left`,`o-spreadsheet-Icon.BORDER_LEFT`],[`top`,`o-spreadsheet-Icon.BORDER_TOP`],[`right`,`o-spreadsheet-Icon.BORDER_RIGHT`],[`bottom`,`o-spreadsheet-Icon.BORDER_BOTTOM`],[`clear`,`o-spreadsheet-Icon.BORDER_CLEAR`]]];var wY=class extends t.Component{static template=`o-spreadsheet-BorderEditor`;static props={class:{type:String,optional:!0},currentBorderColor:{type:String,optional:!1},currentBorderStyle:{type:String,optional:!1},currentBorderPosition:{type:String,optional:!0},onBorderColorPicked:Function,onBorderStylePicked:Function,onBorderPositionPicked:Function,maxHeight:{type:Number,optional:!0},anchorRect:Object};static components={ColorPickerWidget:bI,Popover:jv};BORDER_POSITIONS=CY;lineStyleButtonRef=(0,t.useRef)(`lineStyleButton`);borderStyles=wa;state=(0,t.useState)({activeTool:void 0});toggleDropdownTool(e){let t=this.state.activeTool===e;this.state.activeTool=t?void 0:e}closeDropdown(){this.state.activeTool=void 0}setBorderPosition(e){this.props.onBorderPositionPicked(e),this.closeDropdown()}setBorderColor(e){this.props.onBorderColorPicked(e),this.closeDropdown()}setBorderStyle(e){this.props.onBorderStylePicked(e),this.closeDropdown()}get lineStylePickerPopoverProps(){return{anchorRect:this.lineStylePickerAnchorRect,positioning:`bottom-left`,verticalOffset:0}}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:`bottom-left`,verticalOffset:0}}get lineStylePickerAnchorRect(){let e=this.lineStyleButtonRef.el;if(e===null)return{x:0,y:0,width:0,height:0};let t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}},TY=class extends t.Component{static template=`o-spreadsheet-BorderEditorWidget`;static props={disabled:{type:Boolean,optional:!0},dropdownMaxHeight:{type:Number,optional:!0},class:{type:String,optional:!0}};static components={BorderEditor:wY};topBarToolStore;borderEditorButtonRef=(0,t.useRef)(`borderEditorButton`);state=(0,t.useState)({currentColor:Ee.color,currentStyle:Ee.style,currentPosition:void 0});setup(){this.topBarToolStore=SY(),(0,t.onWillUpdateProps)(()=>{this.isActive||(this.state.currentPosition=void 0)})}get dropdownMaxHeight(){return this.env.model.getters.getSheetViewDimension().height}get borderEditorAnchorRect(){let e=this.borderEditorButtonRef.el.getBoundingClientRect();return{x:e.x,y:e.y,width:e.width,height:e.height}}onBorderPositionPicked(e){this.state.currentPosition=e,this.updateBorder()}onBorderColorPicked(e){this.state.currentColor=e,this.updateBorder()}onBorderStylePicked(e){this.state.currentStyle=e,this.updateBorder()}get isActive(){return this.topBarToolStore.isActive}toggleBorderEditor(){this.isActive?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}updateBorder(){this.state.currentPosition!==void 0&&this.env.model.dispatch(`SET_ZONE_BORDERS`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),border:{position:this.state.currentPosition,color:this.state.currentColor,style:this.state.currentStyle}})}},EY=class extends t.Component{static template=`o-spreadsheet-PaintFormatButton`;static props={class:{type:String,optional:!0}};paintFormatStore;setup(){this.paintFormatStore=D(cW)}get isActive(){return this.paintFormatStore.isActive}onDblClick(){this.paintFormatStore.activate({persistent:!0})}togglePaintFormat(){this.isActive?this.paintFormatStore.cancel():this.paintFormatStore.activate({persistent:!1})}},DY=class extends t.Component{static template=`o-spreadsheet-TableDropdownButton`;static components={TableStylesPopover:sV,ActionButton:yI};static props={class:{type:String,optional:!0}};topBarToolStore;state=(0,t.useState)({popoverProps:void 0});setup(){this.topBarToolStore=SY()}onStylePicked(e){let t=this.env.model.getters.getActiveSheetId(),n={...this.tableConfig,styleId:e};WP(this.env,t,n).isSuccessful&&this.env.openSidePanel(`TableSidePanel`,{}),this.closePopover()}onClick(e){if(e.hasClosedTableStylesPopover||this.state.popoverProps){this.closePopover();return}let t=this.dynamicPivotIdInSelection;if(t){this.env.openSidePanel(`PivotSidePanel`,{pivotId:t,openTab:`design`});return}if(this.env.model.getters.getFirstTableInSelection()){this.topBarToolStore.closeDropdowns(),this.env.toggleSidePanel(`TableSidePanel`,{});return}let{left:n,bottom:r}=e.currentTarget.getBoundingClientRect();this.topBarToolStore.openDropdown(),this.state.popoverProps={anchorRect:{x:n,y:r,width:0,height:0},positioning:`bottom-left`,verticalOffset:0}}closePopover(){this.state.popoverProps=void 0}get action(){return this.dynamicPivotIdInSelection?{name:k(`Edit pivot style`),icon:`o-spreadsheet-Icon.EDIT_TABLE`}:{name:e=>e.model.getters.getFirstTableInSelection()?k(`Edit table`):k(`Insert table`),icon:e=>e.model.getters.getFirstTableInSelection()?`o-spreadsheet-Icon.EDIT_TABLE`:`o-spreadsheet-Icon.PAINT_TABLE`}}get tableConfig(){return{...WA,numberOfHeaders:1,bandedRows:!0}}get tableStyles(){return this.env.model.getters.getTableStyles()}get dynamicPivotIdInSelection(){let e=this.env.model.getters.getSelectedZones(),t=new Set(this.env.model.getters.getCellsWithTrackedFormula(`PIVOT`));if(t.size===0)return;let n=this.env.model.getters.getActiveSheetId();for(let r of e)for(let e of In(n,r)){let n=this.env.model.getters.getArrayFormulaSpreadingOn(e);if(!n)continue;let r=this.env.model.getters.getCell(n)?.id;if(r&&t.has(r)){let e=this.env.model.getters.getPivotIdFromPosition(n);if(e)return e}}}get class(){return`${this.props.class?this.props.class:``} ${this.env.model.getters.isCurrentSheetLocked()?`o-disabled`:``}`}},OY=class extends t.Component{static components={ColorPickerWidget:bI};static props={class:String,style:String,icon:String,title:String};static template=`o-spreadsheet-ColorEditor`;topBarToolStore;state=(0,t.useState)({isOpen:!1});setup(){this.topBarToolStore=SY()}get currentColor(){return this.env.model.getters.getCurrentStyle()[this.props.style]||(this.props.style===`textColor`?`#000000`:`#ffffff`)}setColor(e){KP(this.env,{[this.props.style]:e}),this.state.isOpen=!1}get isMenuOpen(){return this.topBarToolStore.isActive}onClick(){this.isMenuOpen?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}},kY=class extends t.Component{static template=`o-spreadsheet-DropdownAction`;static components={ActionButton:yI,Popover:jv};static props={parentAction:Object,childActions:Array,class:String,childClass:String};topBarToolStore;actionRef=(0,t.useRef)(`actionRef`);setup(){this.topBarToolStore=SY()}toggleDropdown(){this.isActive?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}get isActive(){return this.topBarToolStore.isActive}get popoverProps(){return{anchorRect:this.actionRef.el?this.actionRef.el.getBoundingClientRect():{x:0,y:0,width:0,height:0},positioning:`bottom-left`,verticalOffset:0,class:`rounded`}}},AY=class extends t.Component{static components={FontSizeEditor:SI};static props={class:String};static template=`o-spreadsheet-TopBarFontSizeEditor`;topBarToolStore;setup(){this.topBarToolStore=SY()}get currentFontSize(){return this.env.model.getters.getCurrentStyle().fontSize||we}setFontSize(e){KP(this.env,{fontSize:e})}onToggle(){this.isActive?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}onFocusInput(){this.topBarToolStore.openDropdown()}get isActive(){return this.topBarToolStore.isActive}get class(){return`${this.props.class} ${this.env.model.getters.isCurrentSheetLocked()?`o-disabled`:``}`}},jY=class extends t.Component{static template=`o-spreadsheet-NumberFormatsTool`;static components={MenuPopover:Fv,ActionButton:yI};static props={class:String};formatNumberMenuItemSpec=DJ;topBarToolStore;buttonRef=(0,t.useRef)(`buttonRef`);state=(0,t.useState)({anchorRect:{x:0,y:0,width:0,height:0},menuItems:[]});setup(){this.topBarToolStore=SY()}toggleMenu(){if(this.isActive)this.topBarToolStore.closeDropdowns();else{let e=h(this.formatNumberMenuItemSpec);this.state.menuItems=e.children(this.env).sort((e,t)=>e.sequence-t.sequence),this.state.anchorRect=op(this.buttonRef.el),this.topBarToolStore.openDropdown()}}get isActive(){return this.topBarToolStore.isActive}},MY=class extends t.Component{static template=`o-spreadsheet-TopBarZoom`;static components={NumberEditor:xI};static props={class:String};topBarToolStore;valueList=ve;setup(){this.topBarToolStore=SY()}get currentFontSize(){return(this.env.model.getters.getViewportZoomLevel()||1)*100}setZoom(e){this.env.model.dispatch(`SET_ZOOM`,{zoom:e/100})}toggle(){this.topBarToolStore.isActive?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}onFocusInput(){this.topBarToolStore.openDropdown()}};let NY=new xY;NY.add(`edit`).addChild(`edit`,{component:yI,props:{action:aH,class:`o-hoverable-button o-toolbar-button`},sequence:1}).addChild(`edit`,{component:yI,props:{action:oH,class:`o-hoverable-button o-toolbar-button`},sequence:2}).addChild(`edit`,{component:EY,props:{class:`o-hoverable-button o-toolbar-button o-mobile-disabled`},sequence:3}).addChild(`edit`,{component:yI,props:{action:zR,class:`o-hoverable-button o-toolbar-button`},sequence:4}).addChild(`edit`,{component:MY,props:{class:`o-menu-item-button o-hoverable-button o-toolbar-button`},sequence:5}).add(`numberFormat`).addChild(`numberFormat`,{component:yI,props:{action:YL,class:`o-hoverable-button o-toolbar-button`},sequence:1}).addChild(`numberFormat`,{component:yI,props:{action:uR,class:`o-hoverable-button o-toolbar-button`},sequence:2}).addChild(`numberFormat`,{component:yI,props:{action:lR,class:`o-hoverable-button o-toolbar-button`},sequence:3}).addChild(`numberFormat`,{component:jY,props:{class:`o-menu-item-button o-hoverable-button o-toolbar-button`},sequence:4}).add(`fontSize`).addChild(`fontSize`,{component:AY,props:{class:`o-hoverable-button o-toolbar-button`},sequence:3}).add(`textStyle`).addChild(`textStyle`,{component:yI,props:{action:dR,class:`o-hoverable-button o-toolbar-button`},sequence:1}).addChild(`textStyle`,{component:yI,props:{action:fR,class:`o-hoverable-button o-toolbar-button`},sequence:2}).addChild(`textStyle`,{component:yI,props:{action:SR,class:`o-hoverable-button o-toolbar-button`},sequence:3}).addChild(`textStyle`,{component:OY,props:{class:`o-hoverable-button o-menu-item-button o-toolbar-button`,style:`textColor`,icon:`o-spreadsheet-Icon.TEXT_COLOR`,title:k(`Text Color`)},sequence:4}).add(`cellStyle`).addChild(`cellStyle`,{component:OY,props:{class:`o-hoverable-button o-menu-item-button o-toolbar-button`,style:`fillColor`,icon:`o-spreadsheet-Icon.FILL_COLOR`,title:k(`Fill Color`)},sequence:1}).addChild(`cellStyle`,{component:TY,props:{class:`o-hoverable-button o-menu-item-button o-toolbar-button`},sequence:2}).addChild(`cellStyle`,{component:yI,props:{action:wH,class:`o-hoverable-button o-menu-item-button o-toolbar-button`},sequence:3}).add(`alignment`).addChild(`alignment`,{component:kY,props:{parentAction:TR,childActions:[ER,DR,OR],class:`o-hoverable-button o-toolbar-button`,childClass:`o-hoverable-button`},sequence:1}).addChild(`alignment`,{component:kY,props:{parentAction:kR,childActions:[AR,jR,MR],class:`o-hoverable-button o-menu-item-button o-toolbar-button`,childClass:`o-hoverable-button`},sequence:2}).addChild(`alignment`,{component:kY,props:{parentAction:PR,childActions:[FR,IR,LR],class:`o-hoverable-button o-menu-item-button o-toolbar-button`,childClass:`o-hoverable-button`},sequence:3}).addChild(`alignment`,{component:kY,props:{parentAction:mR,childActions:[_R,vR,yR,bR,xR],class:`o-hoverable-button o-menu-item-button o-toolbar-button`,childClass:`o-hoverable-button`},sequence:4}).add(`misc`).addChild(`misc`,{component:DY,props:{class:`o-toolbar-button o-hoverable-button o-menu-item-button o-mobile-disabled`},sequence:1}).addChild(`misc`,{component:yI,props:{action:aU,class:`o-hoverable-button o-menu-item-button o-toolbar-button`},sequence:2});var PY=class extends t.Component{static template=`o-spreadsheet-TopBar`;static props={onClick:Function,dropdownMaxHeight:Number};static components={MenuPopover:Fv,TopBarComposer:yY,Popover:jv};toolsCategories=NY.getCategories();state=(0,t.useState)({menuState:{isOpen:!1,anchorRect:null,menuItems:[]},invisibleToolsCategories:[],toolsPopoverState:{isOpen:!1}});isSelectingMenu=!1;openedEl=null;menus=[];toolbarMenuRegistry=NY;formatNumberMenuItemSpec=DJ;isntToolbarMenu=!1;composerFocusStore;fingerprints;topBarToolStore;toolBarContainerRef=(0,t.useRef)(`toolBarContainer`);toolbarRef=(0,t.useRef)(`toolBar`);moreToolsContainerRef=(0,t.useRef)(`moreToolsContainer`);moreToolsButtonRef=(0,t.useRef)(`moreToolsButton`);spreadsheetRect=kv();setup(){this.composerFocusStore=D(xr),this.fingerprints=D(TV),this.topBarToolStore=D(bY),(0,t.useExternalListener)(window,`click`,this.onExternalClick),(0,t.onWillStart)(()=>this.updateCellState()),(0,t.onWillUpdateProps)(()=>this.updateCellState()),(0,t.useEffect)(()=>{this.state.toolsPopoverState.isOpen=!1,this.setVisibilityToolsGroups()},()=>[this.spreadsheetRect.width])}setVisibilityToolsGroups(){if(this.env.model.getters.isReadonly())return;let e=[],{x:t}=this.toolbarRef.el.getBoundingClientRect(),{x:n}=this.toolBarContainerRef.el.getBoundingClientRect();this.moreToolsContainerRef.el?.classList.remove(`d-none`);let r=this.moreToolsButtonRef.el?.getBoundingClientRect().width||0,i=Math.round(this.spreadsheetRect.width)-r-(t-n)-16,a=document.querySelectorAll(`.tool-container`),o=0;for(let t=0;t<a.length;t++){let n=a[t];n.classList.remove(`d-none`);let{width:r}=n.getBoundingClientRect();o+=r,o>i&&(n.classList.add(`d-none`),e.push(this.toolsCategories[t]))}this.state.invisibleToolsCategories=e,e.length||this.moreToolsContainerRef.el?.classList.add(`d-none`)}get topbarComponents(){return YJ.getAllOrdered().filter(e=>!e.isVisible||e.isVisible(this.env))}get currentFontSize(){return this.env.model.getters.getCurrentStyle().fontSize||we}onExternalClick(e){this.openedEl!==e.target&&this.closeMenus()}onClick(){this.props.onClick(),this.closeMenus()}onMenuMouseOver(e,t){this.isSelectingMenu&&this.isntToolbarMenu&&this.openMenu(e,t)}toggleContextMenu(e,t){this.state.menuState.isOpen&&this.isntToolbarMenu?this.closeMenus():(this.openMenu(e,t),this.isntToolbarMenu=!0)}openMenu(e,t){this.topBarToolStore.currentDropdown&&this.topBarToolStore.closeDropdowns(),this.state.toolsPopoverState.isOpen=!1,this.state.menuState.isOpen=!0,this.state.menuState.anchorRect=op(t.currentTarget),this.state.menuState.menuItems=e.children(this.env).sort((e,t)=>e.sequence-t.sequence),this.state.menuState.parentMenu=e,this.isSelectingMenu=!0,this.openedEl=t.target,this.composerFocusStore.activeComposer.stopEdition()}closeMenus(){this.topBarToolStore.currentDropdown&&this.topBarToolStore.closeDropdowns(),this.state.toolsPopoverState.isOpen=!1,this.state.menuState.isOpen=!1,this.state.menuState.parentMenu=void 0,this.isSelectingMenu=!1,this.openedEl=null}updateCellState(){this.menus=kJ.getMenuItems()}getMenuName(e){return e.name(this.env)}setColor(e,t){KP(this.env,{[e]:t}),this.onClick()}setFontSize(e){KP(this.env,{fontSize:e})}toggleMoreTools(){this.topBarToolStore.currentDropdown&&this.topBarToolStore.closeDropdowns(),this.state.toolsPopoverState.isOpen=!this.state.toolsPopoverState.isOpen}get toolsPopoverProps(){return{anchorRect:this.moreToolsButtonRef.el?op(this.moreToolsButtonRef.el):{x:0,y:0,width:0,height:0},positioning:`bottom-left`,verticalOffset:0,class:`rounded`,maxWidth:300}}showDivider(e){return e<this.toolsCategories.length-1||this.state.invisibleToolsCategories.length>0}};function FY(){return new IY(navigator.clipboard)}var IY=class{clipboard;constructor(e){this.clipboard=e}async write(e){if(this.clipboard?.write)try{await this.clipboard?.write(this.getClipboardItems(e))}catch(t){console.log(`Failed to write on the clipboard, falling back to plain/html text. Error %s`,t);try{await this.clipboard?.write([new ClipboardItem({"text/plain":this.getBlob(e,`text/plain`),"text/html":this.getBlob(e,`text/html`)})])}catch{}}else await this.writeText(e[`text/plain`]??``)}async writeText(e){try{this.clipboard?.writeText(e)}catch{}}async read(){let e;try{e=await navigator.permissions.query({name:`clipboard-read`})}catch{}if(this.clipboard?.read)try{let e=await this.clipboard.read(),t={};for(let n of e)for(let e of n.types){let r=await n.getType(e);CP.includes(e)?t[e]=r:t[e]=await r.text()}return{status:`ok`,content:t}}catch{return{status:e?.state===`denied`?`permissionDenied`:`notImplemented`}}else return{status:`ok`,content:{"text/plain":await this.clipboard?.readText()}}}getClipboardItems(e){let t={};for(let n of Object.keys(e))t[n]=this.getBlob(e,n);return[new ClipboardItem(t)]}getBlob(e,t){let n=e[t];return n instanceof Blob||n instanceof File?n:new Blob([e[t]||``],{type:t})}},LY=class extends t.Component{static template=`o-spreadsheet-Spreadsheet`;static props={model:Object,notifyUser:{type:Function,optional:!0},raiseError:{type:Function,optional:!0},askConfirmation:{type:Function,optional:!0},colorScheme:{type:String,optional:!0}};static components={TopBar:PY,Grid:LW,BottomBar:sY,SmallBottomBar:vY,SidePanels:gY,SpreadsheetDashboard:lY,HeaderGroupContainer:pY,FullScreenFigure:BW};sidePanel;spreadsheetRef=(0,t.useRef)(`spreadsheet`);spreadsheetRect=kv();_focusGrid;isViewportTooSmall=!1;notificationStore;composerFocusStore;get model(){return this.props.model}getStyle(){let e={},t=this.env.model.getters.getScrollBarWidth();return this.env.isDashboard()?e[`grid-template-rows`]=`auto`:e[`grid-template-rows`]=`min-content auto min-content`,e[`grid-template-columns`]=`auto ${this.sidePanel.mainPanel?`${this.sidePanel.totalPanelSize||350}px`:`auto`}`,e[`--os-scrollbar-width`]=`${t}px`,e[`color-scheme`]=this.props.colorScheme,U(e)}setup(){if(!(`isSmall`in this.env)){let e=mY();(0,t.useSubEnv)({get isSmall(){return e.isSmall}})}let e=lr();e.inject(mr,this.model);let n=this.env;e.get(xV).setSmallThreshhold(()=>n.isSmall),this.notificationStore=D(kN),this.composerFocusStore=D(xr),this.sidePanel=D(SV);let r=this.model.config.external.fileStore;(0,t.useSubEnv)({model:this.model,imageProvider:r?new ZJ(r):void 0,loadCurrencies:this.model.config.external.loadCurrencies,loadLocales:this.model.config.external.loadLocales,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.sidePanel.open.bind(this.sidePanel),replaceSidePanel:this.sidePanel.replace.bind(this.sidePanel),toggleSidePanel:this.sidePanel.toggle.bind(this.sidePanel),clipboard:this.env.clipboard||FY(),startCellEdition:e=>this.composerFocusStore.focusActiveComposer({content:e}),notifyUser:e=>this.notificationStore.notifyUser(e),askConfirmation:(e,t,n)=>this.notificationStore.askConfirmation(e,t,n),raiseError:(e,t)=>this.notificationStore.raiseError(e,t),isMobile:Cp}),this.notificationStore.updateNotificationCallbacks({...this.props}),(0,t.useEffect)(()=>{!this.spreadsheetRef.el.contains(document.activeElement)&&document.activeElement?.contains(this.spreadsheetRef.el)&&this.focusGrid()}),(0,t.useExternalListener)(window,`resize`,()=>this.render(!0)),(0,t.useExternalListener)(document.body,`wheel`,()=>{}),(0,t.onWillUpdateProps)(e=>{if(e.model!==this.props.model)throw Error(`Changing the props model is not supported at the moment.`);(e.notifyUser!==this.props.notifyUser||e.askConfirmation!==this.props.askConfirmation||e.raiseError!==this.props.raiseError)&&this.notificationStore.updateNotificationCallbacks({...e})});let i=mt(this.render.bind(this,!0));(0,t.onMounted)(()=>{this.bindModelEvents(),this.checkViewportSize(),e.on(`store-updated`,this,i),a.observe(this.spreadsheetRef.el)}),(0,t.onWillUnmount)(()=>{this.unbindModelEvents(),e.off(`store-updated`,this),a.disconnect(),eu()}),(0,t.onPatched)(()=>{this.checkViewportSize()});let a=new ResizeObserver(()=>{this.sidePanel.changeSpreadsheetWidth(this.spreadsheetRect.width)})}bindModelEvents(){this.model.on(`update`,this,()=>this.render(!0)),this.model.on(`command-rejected`,this,({result:e})=>{e.isCancelledBecause(`SheetLocked`)&&this.notificationStore.notifyUser({type:`info`,text:k(`This sheet is locked and cannot be modified. Please unlock it first.`),sticky:!1})}),this.model.on(`notify-ui`,this,e=>this.notificationStore.notifyUser(e)),this.model.on(`raise-error-ui`,this,({text:e})=>this.notificationStore.raiseError(e))}unbindModelEvents(){this.model.off(`update`,this),this.model.off(`command-rejected`,this),this.model.off(`notify-ui`,this),this.model.off(`raise-error-ui`,this)}checkViewportSize(){let{xRatio:e,yRatio:t}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());if(!(!isFinite(e)||!isFinite(t)))if(t>.85||e>.85){if(this.isViewportTooSmall)return;this.notificationStore.notifyUser({text:k(`The current window is too small to display this sheet properly. Consider resizing your browser window or adjusting frozen rows and columns.`),type:`warning`,sticky:!1}),this.isViewportTooSmall=!0}else this.isViewportTooSmall=!1}focusGrid(){this._focusGrid&&this._focusGrid()}get gridHeight(){return this.env.model.getters.getSheetViewDimension().height}get gridContainerStyle(){let e=21*this.rowLayers.length,t=21*this.colLayers.length,n=this.env.model.getters.getViewportZoomLevel();return U({"grid-template-columns":`${e?e+2:0}px auto`,"grid-template-rows":`${t?t+2:0}px auto`,zoom:`${n}`})}get rowLayers(){let e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getVisibleGroupLayers(e,`ROW`)}get colLayers(){let e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getVisibleGroupLayers(e,`COL`)}getGridSize(){let e=this.spreadsheetRef.el;if(!e)return{width:0,height:0};let t=this.env.model.getters.getViewportZoomLevel(),n=this.env.model.getters.getScrollBarWidth(),r=n=>e.querySelector(n)&&ip(e.querySelector(n),t).height||0,i=n=>e.querySelector(n)&&ip(e.querySelector(n),t).width||0,a=e.getBoundingClientRect(),o=r(`.o-spreadsheet-topbar-wrapper`),s=r(`.o-spreadsheet-bottombar-wrapper`),c=r(`.o-column-groups`),l=i(`.o-grid`),u=a.height-c-o-s;return{width:Math.max(l/t-n,0),height:Math.max(u/t-n,0)}}getSpreadSheetClasses(){return[this.env.isSmall?`o-spreadsheet-mobile`:``,this.props.colorScheme===`dark`?`dark`:``].join(` `)}},RY=class{transportService;constructor(e){this.transportService=e}async sendMessage(e){(e.type===`CLIENT_JOINED`||e.type===`CLIENT_LEFT`||e.type===`CLIENT_MOVED`)&&await this.transportService.sendMessage(e)}onNewMessage(e,t){this.transportService.onNewMessage(e,t)}leave(e){this.transportService.leave(e)}};function zY(e){return oJ.get(e.type)(e)}var BY=class e{buildTransformation;operations;constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){let t=this.operations.find(t=>t.id===e);if(!t)throw Error(`Operation ${e} not found`);return t}getLastOperationId(){return this.operations[this.operations.length-1]?.id}getFirstOperationAmong(e,t){for(let n of this.operations){if(n.id===e)return e;if(n.id===t)return t}throw Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find(t=>t.id===e)}prepend(e){let t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map(e=>e.transformed(t))]}insert(e,t){let n=this.buildTransformation.with(e.data),{before:r,operation:i,after:a}=this.locateOperation(t);this.operations=[...r,i,e,...a.map(e=>e.transformed(n))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(t){let{after:n}=this.locateOperation(t);return new e(this.buildTransformation,n)}transform(e){this.operations=this.operations.map(t=>t.transformed(e))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){let{before:t,operation:n}=this.locateOperation(e);this.operations=t.concat([n])}locateOperation(e){let t=this.operations.findIndex(t=>t.id===e);if(t===-1)throw Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}},VY=class{id;data;constructor(e,t){this.id=e,this.data=t}transformed(e){return new HY(this.id,_t(()=>e(this.data)))}},HY=class e{id;lazyData;constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(t){return new e(this.id,this.lazyData.map(t))}},UY=class e{operations;constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(t){function*n(e,t){for(let n of e)if(yield n,n.operation.id===t)return}return new e(n(this.operations,t))}stopBefore(t){function*n(e,t){for(let n of e){if(n.operation.id===t)return;yield n}}return new e(n(this.operations,t))}startAfter(t){function*n(e,t){let n=!0;for(let r of e)n||(yield r),r.operation.id===t&&(n=!1)}return new e(n(this.operations,t))}},WY=class{buildTransformation;branches;branchingOperationIds=new Map;constructor(e,t){this.buildTransformation=e,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new UY(et(this._execution(e),this._execution(e)))}revertedExecution(e){return new UY(et(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){let n=e.getLastOperationId()||this.previousBranch(e)?.getLastOperationId();e.append(t),n&&this.insertPrevious(e,t,n)}insertOperationAfter(e,t,n){e.insert(t,n),this.updateNextWith(e,t,n),this.insertPrevious(e,t,n)}undo(e,t){let n=this.buildTransformation.without(t.data),r=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);let i=e.fork(t.id);r&&this.branchingOperationIds.set(i,r),this.insertBranchAfter(e,i),this.transform(i,n)}redo(e){let t=this.nextBranch(e);if(!t)return;let n=this.nextBranch(t);this.removeBranchFromTree(t);let r=this.branchingOperationIds.get(t);r?this.branchingOperationIds.set(e,r):this.branchingOperationIds.delete(e),n&&this.rebaseUp(n)}drop(e){for(let t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(let n of this.revertedExecution(e))if(n.operation.id===t)return n;throw Error(`Operation ${t} not found`)}rebaseUp(e){let{previousBranch:t,branchingOperation:n}=this.findPreviousBranchingOperation(e);if(!t||!n)return;let r=this.buildTransformation.without(n.data),i=t.fork(n.id);this.branchingOperationIds.set(i,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,i),i.transform(r);let a=this.nextBranch(i);a&&this.rebaseUp(a)}removeBranchFromTree(e){let t=this.branches.findIndex(t=>t===e);this.branches.splice(t,1)}insertBranchAfter(e,t){let n=this.branches.findIndex(t=>t===e);this.branches.splice(n+1,0,t)}updateNextWith(e,t,n){let r=this.branchingOperationIds.get(e),i=this.nextBranch(e);if(!(!r||!i))if(e.getFirstOperationAmong(n,r)===r){let a=this.addToNextBranch(e,i,r,t,n);this.updateNextWith(i,a,n)}else{let e=this.buildTransformation.with(t.data);this.transform(i,e)}}addToNextBranch(e,t,n,r,i){let a=r;return i===n?(a=this.getTransformedOperation(e,n,r),t.prepend(a)):t.contains(i)?(a=this.getTransformedOperation(e,n,r),t.insert(a,i)):t.append(r),a}getTransformedOperation(e,t,n){let r=e.getOperation(t),i=this.buildTransformation.without(r.data);return n.transformed(i)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);let n=this.nextBranch(e);n&&this.transform(n,t)}insertPrevious(e,t,n){let{previousBranch:r,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!r||!i)return;let a=this.buildTransformation.with(i.data),o=e.fork(n);o.transform(a),r.cutAfter(n),r.appendBranch(o);let s=t.transformed(a);this.insertPrevious(r,s,n)}findPreviousBranchingOperation(e){let t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};let n=this.branchingOperationIds.get(t);return n?{previousBranch:t,branchingOperation:t.getOperation(n)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){let t=this.branches.findIndex(t=>t===e);if(t!==-1)return this.branches[t+1]}previousBranch(e){let t=this.branches.findIndex(t=>t===e);if(t!==-1)return this.branches[t-1]}*_revertedExecution(e){let t=this.branchingOperationIds.get(e),n=!!t,r=e.getOperations();for(let i=r.length-1;i>=0;i--){let a=r[i];a.id===t&&(n=!1),n||(yield{operation:a,branch:e,isCancelled:!this.shouldExecute(e,a)})}let i=this.previousBranch(e);yield*i?this._revertedExecution(i):[]}*_execution(e){for(let t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){let t=this.nextBranch(e);yield*t?this._execution(t):[];return}if(!this.branchingOperationIds.get(e)){let t=this.nextBranch(e);yield*t?this._execution(t):[]}}},GY=class{HEAD_BRANCH;HEAD_OPERATION;tree;applyOperation;revertOperation;buildEmpty;buildTransformation;constructor(e){this.applyOperation=e.applyOperation,this.revertOperation=e.revertOperation,this.buildEmpty=e.buildEmpty,this.buildTransformation=e.buildTransformation,this.HEAD_BRANCH=new BY(this.buildTransformation),this.tree=new WY(this.buildTransformation,this.HEAD_BRANCH);let t=e.initialOperationId,n=new VY(t,this.buildEmpty(t));this.tree.insertOperationLast(this.HEAD_BRANCH,n),this.HEAD_OPERATION=n}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){let n=new VY(e,t),r=this.tree.getLastBranch();this.tree.insertOperationLast(r,n),this.HEAD_BRANCH=r,this.HEAD_OPERATION=n}insert(e,t,n){let r=new VY(e,t);this.revertTo(n),this.tree.insertOperationAfter(this.HEAD_BRANCH,r,n),this.fastForward()}undo(e,t,n){let{branch:r,operation:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(r,i),this.fastForward(),this.insert(t,this.buildEmpty(t),n)}redo(e,t,n){let{branch:r}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(r),this.fastForward(),this.insert(t,this.buildEmpty(t),n)}rebase(e){let t=this.get(e),n=[...this.tree.execution(this.HEAD_BRANCH).startAfter(e)];this.revertBefore(e);let r=this.HEAD_OPERATION.id;this.tree.drop(e),this.insert(e,t,r);for(let{operation:e}of n)this.insert(e.id,e.data,this.HEAD_OPERATION.id)}revertBefore(e){let t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){let t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(let{next:t,operation:n,isCancelled:r}of e)r||this.revertOperation(n.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){let e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(let{operation:t,branch:n,isCancelled:r}of e)r||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=n}};function KY(e){return new GY({initialOperationId:e.initialRevisionId,applyOperation:t=>{let n=t.commands.slice(),{changes:r}=e.recordChanges(()=>{for(let t of n)e.dispatch(t)});t.setChanges(r)},revertOperation:e=>qY([e]),buildEmpty:e=>new dq(e,`empty`,[]),buildTransformation:{with:e=>t=>new dq(t.id,t.clientId,tq(t.commands,e.commands),t.rootCommand,void 0,t.timestamp),without:e=>t=>new dq(t.id,t.clientId,tq(t.commands,e.commands.map(zY).flat()),t.rootCommand,void 0,t.timestamp)}})}function qY(e){for(let t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){let n=t.changes[e];JY(n)}}function JY(e){let t=e.target,n=e.key,r=e.before;r===void 0?delete t[n]:t[n]=r}var YY=class{getters;providers=[];isAdaptingRanges=!1;constructor(e){this.getters=e}static getters=[`copyFormulaStringForSheet`,`extendRange`,`getRangeString`,`getRangeFromSheetXC`,`createAdaptedRanges`,`getRangeData`,`getRangeDataFromXc`,`getRangeDataFromZone`,`getRangeFromRangeData`,`getRangeFromZone`,`getRangesUnion`,`recomputeRanges`,`isRangeValid`,`removeRangesSheetPrefix`];allowDispatch(e){return e.type===`MOVE_RANGES`?e.target.length===1?`Success`:`InvalidZones`:`Success`}beforeHandle(e){}handle(e){if(this.isAdaptingRanges)throw Error(`Plugins cannot dispatch commands during adaptRanges phase`);let t=sl(e);t&&this.executeOnAllRanges(t)}finalize(){}verifyRangeRemoved(e){return t=>{let n=e(t);return n.changeType!==`NONE`&&!_n(n.range.zone)?{range:n.range,changeType:`REMOVE`}:n}}executeOnAllRanges(e){this.isAdaptingRanges=!0;let t={applyChange:this.verifyRangeRemoved(e.applyChange),adaptRangeString:(t,n)=>Xu(t,n,e),adaptFormulaString:(t,n)=>Yu(t,n,e)};for(let n of this.providers)n(t,e.sheetId,e.sheetName);this.isAdaptingRanges=!1}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,n,r){return e.map(e=>{if(!_n(e.zone))return e;let i=e.prefixSheet?e.sheetId:r,a=$c(e),o=Qc(e),s={...e.unboundedZone,left:a&&!e.unboundedZone.hasHeader?e.unboundedZone.left:e.unboundedZone.left+(e.parts[0].colFixed?0:t),right:a?e.unboundedZone.right:e.unboundedZone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:o&&!e.unboundedZone.hasHeader?e.unboundedZone.top:e.unboundedZone.top+(e.parts[0].rowFixed?0:n),bottom:o?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:n)};return ol(Yc({...e,sheetId:i,zone:s},this.getters.getSheetSize))})}removeRangesSheetPrefix(e,t){return t.map(t=>t.prefixSheet&&t.sheetId===e?{...t,prefixSheet:!1}:t)}extendRange(e,t,n){let r=t===`COL`?e.zone.right+n:e.zone.right,i=t===`ROW`?e.zone.bottom+n:e.zone.bottom,a={left:e.zone.left,top:e.zone.top,right:$c(e)?void 0:r,bottom:Qc(e)?void 0:i};return Yc({...e,zone:a},this.getters.getSheetSize)}getRangeFromSheetXC(e,t){if(!Nc.test(t)||!this.getters.tryGetSheet(e))return Zc(t);let{sheetName:n}=zc(t);return Xc({xc:t,sheetId:this.getters.getSheetIdByName(n)||e,invalidSheetName:n&&!this.getters.getSheetIdByName(n)?n:void 0},this.getters.getSheetSize)}getRangeString(e,t,n={useBoundedReference:!1,useFixedReference:!1}){return e?e.invalidXc?e.invalidXc:this.getters.tryGetSheet(e.sheetId)?el(e,t,this.getters.getSheetName,n):A.InvalidReference:A.InvalidReference}getRangeDataFromXc(e,t){let n=this.getters.getRangeFromSheetXC(e,t);return this.getRangeDataFromZone(n.sheetId,n.unboundedZone)}getRangeDataFromZone(e,t){return t=this.getters.getUnboundedZone(e,t),{_sheetId:e,_zone:t}}getRangeData(e){return this.getRangeDataFromZone(e.sheetId,e.unboundedZone)}getRangeFromZone(e,t){return Yc({sheetId:e,zone:t,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}],prefixSheet:!1},this.getters.getSheetSize)}recomputeRanges(e,t){return nn(e.map(e=>e.unboundedZone),t.map(e=>e.unboundedZone)).map(t=>this.getRangeFromZone(e[0].sheetId,t))}getRangeFromRangeData(e){return this.getters.tryGetSheet(e._sheetId)?Yc({prefixSheet:!1,zone:e._zone,sheetId:e._sheetId,invalidSheetName:void 0,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}]},this.getters.getSheetSize):Zc(A.InvalidReference)}isRangeValid(e){if(!e)return!1;let{xc:t,sheetName:n}=zc(e);return t.match(Nc)!==null&&(!n||this.getters.getSheetIdByName(n)!==void 0)}getRangesUnion(e){let t=Tn(...e.map(e=>e.unboundedZone));return this.getRangeFromZone(e[0].sheetId,t)}copyFormulaStringForSheet(e,t,n,r){if(!n.startsWith(`=`))return n;let i=xz.Compile(n,e,this.getters),a=i.rangeDependencies.map(n=>r===`keepSameReference`?n:tl(e,t,n));return xz.CopyWithDependencies(i,t,a).toFormulaString(this.getters)}},XY=class{observers=new Map;defaultSubscription;mainSubscription;registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||=this.defaultSubscription}observe(e,t){this.observers.set(e,{owner:e,callbacks:t})}unobserve(e){this.observers.delete(e)}capture(e,t){if(this.observers.get(e))throw Error(`You are already subscribed forever`);this.mainSubscription?.owner&&this.mainSubscription.owner!==e&&this.mainSubscription.callbacks.release?.(),this.mainSubscription={owner:e,callbacks:t}}release(e){this.mainSubscription?.owner!==e||this.observers.get(e)||(this.mainSubscription=this.defaultSubscription)}getBackToDefault(){this.mainSubscription!==this.defaultSubscription&&(this.mainSubscription?.callbacks.release?.(),this.mainSubscription=this.defaultSubscription)}isListening(e){return this.mainSubscription?.owner===e}send(e){this.mainSubscription?.callbacks.handleEvent(e),this.observers.forEach(t=>t.callbacks.handleEvent(e))}},ZY=class{getters;stream;anchor;defaultAnchor;constructor(e){this.getters=e,this.stream=new XY,this.anchor={cell:{col:0,row:0},zone:E({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,n){this.stream.capture(e,n),this.anchor=t}registerAsDefault(e,t,n){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,n),this.defaultAnchor=t,this.capture(e,t,n)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}unobserve(e){this.stream.unobserve(e)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}modifyAnchor(e,t,n){let r=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(r,e.zone)},this.processEvent({options:n,anchor:e,mode:t})}selectZone(e,t={scrollIntoView:!0}){return this.modifyAnchor(e,`overrideSelection`,t)}selectCell(e,t){let n=E({col:e,row:t});return this.selectZone({zone:n,cell:{col:e,row:t}},{scrollIntoView:!0})}moveAnchorCell(e,t=1){if(t!==`end`&&t<=0)return new Ys(`InvalidSelectionStep`);let{col:n,row:r}=this.getNextAvailablePosition(e,t);return this.selectCell(n,r)}updateAnchorCell(e,t,n={scrollIntoView:!0}){return this.processEvent({mode:`updateAnchor`,anchor:{zone:this.anchor.zone,cell:{col:e,row:t}},options:n})}setAnchorCorner(e,t){let n=this.getters.getActiveSheetId(),{col:r,row:i}=this.anchor.cell,a={left:Math.min(r,e),top:Math.min(i,t),right:Math.max(r,e),bottom:Math.max(i,t)},o=this.getters.expandZone(n,a);if(Dn(this.anchor.zone,o))return new Ys(`NoChanges`);let s={zone:o,cell:{col:r,row:i}};return this.processEvent({mode:`updateAnchor`,anchor:s,options:{scrollIntoView:!1}})}addCellToSelection(e,t){let n=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:n,col:e,row:t}));let r=this.getters.expandZone(n,E({col:e,row:t}));return this.processEvent({options:{scrollIntoView:!0},anchor:{zone:r,cell:{col:e,row:t}},mode:`newAnchor`})}commitSelection(){return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:this.anchor,mode:`commitSelection`})}resizeAnchorZone(e,t=1){if(t!==`end`&&t<=0)return new Ys(`InvalidSelectionStep`);let n=this.getters.getActiveSheetId(),r=this.anchor,{col:i,row:a}=r.cell,{left:o,right:s,top:c,bottom:l}=r.zone,u=this.getStartingPosition(e),[d,f]=this.deltaToTarget(u,e,t);if(d===0&&f===0)return Ys.Success;let p=r.zone,m=e=>{e=Ln(e);let{left:t,right:r,top:i,bottom:a}=this.getters.expandZone(n,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(n)-1,r),top:Math.max(0,i),bottom:Math.min(this.getters.getNumberRows(n)-1,a)}},{cell:h,zone:g}=this.getReferenceAnchor(),{col:_,row:v}=h,y=0;for(;p!==null;){if(y++,d<0){let e=this.getNextAvailableCol(d,s-(y-1),v);p=g.right<=s-y?m({top:c,left:o,bottom:l,right:e}):null}if(d>0){let e=this.getNextAvailableCol(d,o+(y-1),v);p=o+y<=g.left?m({top:c,left:e,bottom:l,right:s}):null}if(f<0){let e=this.getNextAvailableRow(f,_,l-(y-1));p=g.bottom<=l-y?m({top:c,left:o,bottom:e,right:s}):null}if(f>0){let e=this.getNextAvailableRow(f,_,c+(y-1));p=c+y<=g.top?m({top:e,left:o,bottom:l,right:s}):null}if(p&&=Ln(p),p&&!Dn(p,r.zone))return this.processEvent({options:{scrollIntoView:!0},mode:`updateAnchor`,anchor:{zone:p,cell:{col:i,row:a}}})}p=m(wn({top:a,bottom:a,left:i,right:i},Ln({top:this.getNextAvailableRow(f,_,c),left:this.getNextAvailableCol(d,o,v),bottom:this.getNextAvailableRow(f,_,l),right:this.getNextAvailableCol(d,s,v)})));let ee={zone:p,cell:{col:i,row:a}};return this.processEvent({anchor:ee,mode:`updateAnchor`,options:{scrollIntoView:!0}})}selectColumn(e,t){let n=this.getters.getActiveSheetId(),r=this.getters.getNumberRows(n)-1,i={left:e,right:e,top:0,bottom:r},a=this.getters.findFirstVisibleColRowIndex(n,`ROW`),o,s;switch(t){case`overrideSelection`:case`newAnchor`:o=e,s=a;break;case`updateAnchor`:({col:o,row:s}=this.anchor.cell),i=wn(i,{left:o,right:o,top:a,bottom:r});break}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:i,cell:{col:o,row:s}},mode:t})}selectRow(e,t){let n=this.getters.getActiveSheetId(),r=this.getters.getNumberCols(n)-1,i={top:e,bottom:e,left:0,right:r},a=this.getters.findFirstVisibleColRowIndex(n,`COL`),o,s;switch(t){case`overrideSelection`:case`newAnchor`:o=a,s=e;break;case`updateAnchor`:({col:o,row:s}=this.anchor.cell),i=wn(i,{left:a,right:r,top:s,bottom:s});break}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:i,cell:{col:o,row:s}},mode:t})}loopSelection(){let e=this.getters.getActiveSheetId(),t=this.anchor;if(Dn(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:E(t.cell)},`updateAnchor`,{scrollIntoView:!1});let n=this.getters.getContiguousZone(e,t.zone);return w(n,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:n},`updateAnchor`,{scrollIntoView:!1})}selectTableAroundSelection(){let e=this.getters.getActiveSheetId(),t=this.getters.getContiguousZone(e,this.anchor.zone);return this.modifyAnchor({...this.anchor,zone:t},`updateAnchor`,{scrollIntoView:!1})}selectAll(){let e=this.getters.getActiveSheetId(),t={left:0,top:0,bottom:this.getters.getNumberRows(e)-1,right:this.getters.getNumberCols(e)-1};return this.processEvent({mode:`overrideSelection`,anchor:{zone:t,cell:this.anchor.cell},options:{scrollIntoView:!1}})}isListening(e){return this.stream.isListening(e)}processEvent(e){let t={...e,previousAnchor:b(this.anchor)},n=this.checkEventAnchorZone(t);return n===`Success`?(this.anchor=t.anchor,this.stream.send(t),Ys.Success):new Ys(n)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){let{cell:t,zone:n}=e;if(!An(t.col,t.row,n))return`InvalidAnchorZone`;let{left:r,right:i,top:a,bottom:o}=n,s=this.getters.getActiveSheetId(),c=this.getters.findVisibleHeader(s,`COL`,r,i);return this.getters.findVisibleHeader(s,`ROW`,a,o)===void 0||c===void 0?`SelectionOutOfBound`:`Success`}checkAnchorZoneOrThrow(e){if(this.checkAnchorZone(e)===`InvalidAnchorZone`)throw Error(`The provided anchor is invalid. The cell must be part of the zone.`)}getNextAvailablePosition(e,t=1){let{col:n,row:r}=this.anchor.cell,i=this.deltaToTarget({col:n,row:r},e,t);return{col:this.getNextAvailableCol(i[0],n,r),row:this.getNextAvailableRow(i[1],n,r)}}getNextAvailableCol(e,t,n){let r=this.getters.getActiveSheetId(),i={col:t,row:n};return this.getNextAvailableHeader(e,`COL`,t,i,e=>this.getters.isInSameMerge(r,t,n,e,n))}getNextAvailableRow(e,t,n){let r=this.getters.getActiveSheetId(),i={col:t,row:n};return this.getNextAvailableHeader(e,`ROW`,n,i,e=>this.getters.isInSameMerge(r,t,n,t,e))}getNextAvailableHeader(e,t,n,r,i){let a=this.getters.getActiveSheetId();if(e===0)return n;let o=Math.sign(e),s=n+e;for(;i(s);)s+=o;for(;this.getters.isHeaderHidden(a,t,s);)s+=o;return s<0||s>this.getters.getNumberHeaders(a,t)-1?this.getters.isHeaderHidden(a,t,n)?this.getNextAvailableHeader(-o,t,n,r,i):n:s}getReferenceAnchor(){let e=this.getters.getActiveSheetId(),t=this.anchor,{left:n,right:r,top:i,bottom:a}=t.zone,{col:o,row:s}=t.cell,c=this.getters.isColHidden(e,o)&&this.getters.findVisibleHeader(e,`COL`,n,r)||o,l=this.getters.isRowHidden(e,s)&&this.getters.findVisibleHeader(e,`ROW`,i,a)||s,u=this.getters.expandZone(e,{left:c,right:c,top:l,bottom:l});return{cell:{col:c,row:l},zone:u}}deltaToTarget(e,t,n){switch(t){case`up`:return n===`end`?[0,this.getEndOfCluster(e,`rows`,-1)-e.row]:[0,-n];case`down`:return n===`end`?[0,this.getEndOfCluster(e,`rows`,1)-e.row]:[0,n];case`left`:return n===`end`?[this.getEndOfCluster(e,`cols`,-1)-e.col,0]:[-n,0];case`right`:return n===`end`?[this.getEndOfCluster(e,`cols`,1)-e.col,0]:[n,0]}}getStartingPosition(e){let{col:t,row:n}=this.getPosition(),r=this.anchor.zone;switch(e){case`down`:case`up`:n=n===r.top?r.bottom:r.top;break;case`left`:case`right`:t=t===r.right?r.left:r.right;break}return{col:t,row:n}}getEndOfCluster(e,t,n){let r=this.getters.getActiveSheetId(),i=e,a=this.getNextCellPosition(e,t,n),o=!this.isCellSkippableInCluster({...i,sheetId:r})&&!this.isCellSkippableInCluster({...a,sheetId:r})?`endOfCluster`:`nextCluster`;for(;;){let e=this.getNextCellPosition(i,t,n);if(i.col===e.col&&i.row===e.row)break;let a=this.isCellSkippableInCluster({...e,sheetId:r});if(o===`endOfCluster`&&a)break;if(o===`nextCluster`&&!a){i=e;break}i=e}return t===`cols`?i.col:i.row}getNextCellPosition(e,t,n){let r=t===`cols`?`col`:`row`,i={...e};return i[r]=t===`cols`?this.getNextAvailableCol(n,i.col,i.row):this.getNextAvailableRow(n,i.col,i.row),{col:i.col,row:i.row}}getPosition(){return{...this.anchor.cell}}isCellSkippableInCluster(e){let t=this.getters.getMainCellPosition(e),n=this.getters.getEvaluatedCell(t);return n.type===`empty`||n.type===`text`&&n.value===``}},QY=class{changes;commands=[];recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){let t=e.pop(),n=e[0],r=e.at(-1),i=e.length-2;for(let t=1;t<=i;t++){let r=e[t];if(n[r]===void 0){let i=e[t+1];n[r]=Tl(i)}n=n[r]}n[r]!==t&&(this.changes?.push({key:r,target:n,before:n[r]}),t===void 0?delete n[r]:n[r]=t)}};let $Y=17781237,eX=17781238,tX=88853993,nX=88853994;function rX(e,t,n){let r=[[`xmlns:r`,gu],[`xmlns:a`,fu],[`xmlns:c`,pu]],i=iX({backgroundColor:e.data.backgroundColor,line:{color:`000000`}}),a=X``;if(e.data.title?.text){let t=V(fd(e.data.backgroundColor)),n=e.data.title.fontSize??16;a=X`
|
|
122
122
|
<c:title>
|
|
123
123
|
${sX(e.data.title.text,t,n,e.data.title)}
|
|
124
124
|
<c:overlay val="0" />
|
|
@@ -950,4 +950,4 @@ You can download it directly instead.`,5),sticky:!1,type:`warning`});return}r=aw
|
|
|
950
950
|
<Relationships xmlns="${du.Relationships}">
|
|
951
951
|
<Relationship ${J(e)} />
|
|
952
952
|
</Relationships>
|
|
953
|
-
`),`_rels/.rels`)}function LZ(e){let t={},n=[];for(let r of e.sheets){let e=r.name.slice(0,31);e=Ht(e,n,{compute:(e,t)=>e.slice(0,31-String(t).length)+t}),n.push(e),e!==r.name&&(t[r.name]=e,r.name=e)}if(!Object.keys(t).length)return e;let r=Object.keys(t).sort((e,t)=>t.length-e.length),i=JSON.stringify(e);for(let e of r){let n=RegExp(`'?${qe(e)}'?!`,`g`);i=i.replaceAll(n,n=>{let r=t[e];return n.replace(e,r)})}return JSON.parse(i)}function RZ(e){for(let t of e.sheets)t.tables=t.tables.filter(e=>Mn(mn(e.range)).numberOfRows>1);return e}var zZ=class e extends ir{corePlugins=[];statefulUIPlugins=[];range;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;coreViewPluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},t={},n=[],r=new Xl,i=!1){let a=performance.now();console.debug(`##### Model creation #####`),super(),pa(),n=oM(e,n);let o=Qj(e,i);this.state=new QY,this.uuidGenerator=r,this.config=this.setupConfig(t),this.session=this.setupSession(o.revisionId),this.coreGetters={},this.range=new YY(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeData=this.range.getRangeData.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.coreGetters.recomputeRanges=this.range.recomputeRanges.bind(this.range),this.coreGetters.isRangeValid=this.range.isRangeValid.bind(this.range),this.coreGetters.extendRange=this.range.extendRange.bind(this.range),this.coreGetters.getRangesUnion=this.range.getRangesUnion.bind(this.range),this.coreGetters.removeRangesSheetPrefix=this.range.removeRangesSheetPrefix.bind(this.range),this.coreGetters.copyFormulaStringForSheet=this.range.copyFormulaStringForSheet.bind(this.range),this.getters={isReadonly:()=>this.config.mode===`readonly`||this.config.mode===`dashboard`,isDashboard:()=>this.config.mode===`dashboard`},this.selection=new ZY(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.coreViewPluginConfig=this.setupCoreViewPluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of qq.getAll())this.setupCorePlugin(e,o);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(n);for(let e of Xq.getAll()){let t=this.setupCoreViewPlugin(e);this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of Yq.getAll()){let t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of Jq.getAll()){let t=this.setupUiPlugin(e);this.handlers.push(t),this.uiHandlers.push(t)}if(this.config.mode!==`export_verification`&&(this.dispatch(`START`),this.selection.observe(this,{handleEvent:()=>this.trigger(`update`)}),this.setupSessionEvents(),this.joinSession(),t.snapshotRequested||e[`[Content_Types].xml`]&&!this.getters.isReadonly())){let e=performance.now();console.debug(`Snapshot requested`),this.session.snapshot(this.exportData()),console.debug(`Snapshot taken in`,performance.now()-e,`ms`)}console.debug(`Model created in`,performance.now()-a,`ms`),console.debug(`######`)}joinSession(){this.session.join(this.config.client)}async leaveSession(){let e=this.getters.isReadonly()?void 0:_t(()=>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}setupCoreViewPlugin(e){let t=new e(this.coreViewPluginConfig);for(let n of e.getters){if(!(n in t))throw Error(`Invalid getter name: ${n} for plugin ${t.constructor}`);if(n in this.getters)throw Error(`Getter "${n}" is already defined.`);this.getters[n]=t[n].bind(t)}return t}setupCorePlugin(e,t){let n=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in n))throw Error(`Invalid getter name: ${t} for plugin ${n.constructor}`);if(t in this.coreGetters)throw Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=n[t].bind(n)}n.import(t),this.corePlugins.push(n),this.coreHandlers.push(n),this.handlers.push(n)}onRemoteRevisionReceived({commands:e}){for(let t of e){let e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new pq(KY({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{if(!this.checkDispatchAllowedRemoteCommand(e).isSuccessful){this.dispatchToHandlers(this.coreHandlers,{type:`UNDO`,commands:[e]});return}this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1}}),this.config.transportService,e)}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:k(`Anonymous`).toString()},n=e.transportService||new XJ,r=e.mode===`readonly`||e.mode===`dashboard`||e.mode===`export_verification`;return{...e,mode:e.mode||`normal`,custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:r?new RY(n):n,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger(`notify-ui`,e),raiseBlockingErrorUI:e=>this.trigger(`raise-error-ui`,{text:e}),customColors:e.customColors||[]}}setupExternalConfig(e){let t=e.loadLocales||(()=>Promise.resolve(ho));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,custom:this.config.custom,external:this.config.external}}setupCoreViewPluginConfig(){return{getters:this.getters,stateObserver:this.state,custom:this.config.custom,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,canDispatch:this.canDispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external}}checkDispatchAllowed(e){let t=qs(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return this.processCommandResults(t)}processCommandResults(e){return e.some(e=>e!==`Success`)?new Ys(e.flat()):Ys.Success}checkDispatchAllowedRemoteCommand(e){let t=this.coreHandlers.map(t=>t.allowDispatch(e));return this.processCommandResults(t)}checkDispatchAllowedCoreCommand(e){return this.handlers.map(t=>t.allowDispatch(e))}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map(t=>t.allowDispatch(e))}finalize(){this.status=3;for(let e of this.handlers)e.finalize();this.status=0,this.trigger(`command-finalized`)}canDispatch=(e,t)=>this.checkDispatchAllowed(BZ(e,t));dispatch=(e,t)=>{let n=BZ(e,t),r=this.status;if(this.getters.isReadonly()&&!Js(n))return new Ys(`Readonly`);if(!this.session.canApplyOptimisticUpdate())return new Ys(`WaitingSessionConfirmation`);switch(r){case 0:let t=this.checkDispatchAllowed(n);if(!t.isSuccessful)return this.trigger(`update`),this.trigger(`command-rejected`,{command:n,result:t}),t;this.status=1;let{changes:r,commands:i}=this.state.recordChanges(()=>{let t=performance.now();qs(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(qs(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(qs(n))throw Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,n)}return Ys.Success};dispatchFromCorePlugin=(e,t)=>{let n=BZ(e,t),r=this.status;this.status=2;let i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,n),this.status=r,Ys.Success};dispatchToHandlers(e,t){let n=qs(t);for(let r of e)!n&&r instanceof UW||r.beforeHandle(t);for(let r of e)!n&&r instanceof UW||r.handle(t);this.trigger(`command-dispatched`,t)}drawLayer(e,t){let n=this.renderers[t];if(n)for(let r of n)e.ctx.save(),r.drawLayer(e,t),e.ctx.restore()}exportData(){let t=this._exportData(!0),n=this._exportData(!1),r={...this.config,mode:`export_verification`,client:{id:`exporter`,name:`exporter`},snapshotRequested:!1,transportService:new XJ};return w(n,new e(b(t),r)._exportData(!1))?t:(n.isNotSquishable=!0,n)}_exportData(e){let t=pM();for(let n of this.handlers)n instanceof UW&&n.export(t,e);return t.revisionId=this.session.getRevisionId()||`START_REVISION`,t=b(t),t}updateMode(e){this.config.mode=e,this.trigger(`update`)}async exportXLSX(){this.dispatch(`EVALUATE_CELLS`);let e=hM();for(let t of this.handlers)t instanceof HW&&await t.exportForExcel(e);return e=b(e),OZ(e)}};function BZ(e,t={}){let n=b(t);return n.type=e,n}function VZ(e){return!qI.includes(e.horizontalGroupBy)||!qI.includes(e.verticalGroupBy)?`InvalidChartDefinition`:`Success`}var HZ=class e extends Ff{dataSets;labelRange;background;type=`calendar`;showValues;colorScale;axesDesign;horizontalGroupBy;verticalGroupBy;legendPosition;missingValueColor;constructor(e,t,n){super(e,t,n),this.dataSets=od(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=nl(n,t,e.labelRange),this.background=e.background,this.showValues=e.showValues,this.colorScale=e.colorScale,this.axesDesign=e.axesDesign,this.horizontalGroupBy=e.horizontalGroupBy,this.verticalGroupBy=e.verticalGroupBy,this.legendPosition=e.legendPosition,this.missingValueColor=e.missingValueColor}static transformDefinition(e,t,n){return ud(e,t,n)}static validateChartDefinition(e,t){return e.checkValidations(t,pd,md,VZ)}static getDefinitionFromContextCreation(e){let t=`left`;return e.legendPosition===`right`&&(t=`right`),{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,title:e.title||{text:``},type:`calendar`,labelRange:e.auxiliaryRange||void 0,showValues:e.showValues,axesDesign:e.axesDesign,legendPosition:t,horizontalGroupBy:`day_of_week`,verticalGroupBy:`month_number`}}getContextCreation(){let e=[{dataRange:this.getters.getRangeString(this.dataSets[0].dataRange,this.sheetId)}];return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(t){let n=rd(this.sheetId,t,this.dataSets),r=id(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){let r=e.map(e=>({dataRange:this.getters.getRangeString(e.dataRange,n||this.sheetId)}));return{type:`calendar`,background:this.background,dataSets:r,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,showValues:this.showValues,colorScale:this.colorScale,axesDesign:this.axesDesign,horizontalGroupBy:this.horizontalGroupBy,verticalGroupBy:this.verticalGroupBy,legendPosition:this.legendPosition,missingValueColor:this.missingValueColor}}getDefinitionForExcel(){}updateRanges({applyChange:t}){let{dataSets:n,labelRange:r,isStale:i}=nd(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function UZ(e,t){let n=e.getDefinition(),r=Xh(n,e.dataSets,e.labelRange,t),{labels:i,datasets:a}=nf(n,r);return{chartJsConfig:{type:`calendar`,data:{labels:i,datasets:a},options:{...Jp,indexAxis:`x`,layout:Pg(n,r),scales:zd(n,a),plugins:{title:$g(n,t),legend:{display:!1},tooltip:i_(n,r),chartShowValuesPlugin:Jg(n,r),chartColorScalePlugin:Bd(n,r),background:{color:e.background}}}}}}var WZ=class e extends Ff{dataSets;labelRange;background;legendPosition;aggregated;dataSetsHaveTitle;dataSetDesign;axesDesign;type=`combo`;showValues;hideDataMarkers;zoomable;constructor(e,t,n){super(e,t,n),this.dataSets=od(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=nl(n,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.showValues=e.showValues,this.hideDataMarkers=e.hideDataMarkers,this.zoomable=e.zoomable}static transformDefinition(e,t,n){return ud(e,t,n)}static validateChartDefinition(e,t){return e.checkValidations(t,pd,md)}getContextCreation(){let e=[];for(let[t,n]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(n.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){let r=[];for(let[t,i]of e.entries())r.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,n||this.sheetId),type:this.dataSetDesign?.[t]?.type??(t?`line`:`bar`)});return{type:`combo`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:r,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,aggregated:this.aggregated,axesDesign:this.axesDesign,showValues:this.showValues,hideDataMarkers:this.hideDataMarkers,zoomable:this.zoomable,humanize:this.humanize}}getDefinitionForExcel(){let{dataSets:e,labelRange:t}=this.getCommonDataSetAttributesForExcel(this.labelRange,this.dataSets,hd(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle)),n=this.getDefinition();return{...n,backgroundColor:V(this.background||`#FFFFFF`),fontColor:V(dd(this.background)),dataSets:e,labelRange:t,verticalAxis:_d(n)}}updateRanges({applyChange:t}){let{dataSets:n,labelRange:r,isStale:i}=nd(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}static getDefinitionFromContextCreation(e){let t=(e.range??[]).map((e,t)=>({...e,type:t?`line`:`bar`}));return{background:e.background,dataSets:t,dataSetsHaveTitle:e.dataSetsHaveTitle??!1,aggregated:e.aggregated,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},labelRange:e.auxiliaryRange||void 0,type:`combo`,axesDesign:e.axesDesign,showValues:e.showValues,hideDataMarkers:e.hideDataMarkers,zoomable:e.zoomable,humanize:e.humanize}}duplicateInDuplicatedSheet(t){let n=rd(this.sheetId,t,this.dataSets),r=id(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}};function GZ(e,t){let n=e.getDefinition(),r=qh(n,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:`bar`,data:{labels:r.labels,datasets:cf(n,r)},options:{...Jp,layout:Ng(n,r),scales:Rd(n,r),plugins:{title:$g(n,t),legend:Bg(n,r),tooltip:r_(n,r),chartShowValuesPlugin:qg(n,r),background:{color:e.background}}}}}}var KZ=class e extends Ff{dataSets;labelRange;background;legendPosition;aggregated;type=`funnel`;dataSetsHaveTitle;dataSetDesign;axesDesign;horizontal=!0;showValues;funnelColors;cumulative;constructor(e,t,n){super(e,t,n),this.dataSets=od(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=nl(n,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.showValues=e.showValues,this.horizontal=!0,this.funnelColors=e.funnelColors,this.cumulative=e.cumulative}static transformDefinition(e,t,n){return ud(e,t,n)}static validateChartDefinition(e,t){return e.checkValidations(t,pd,md)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,aggregated:e.aggregated??!1,legendPosition:`none`,title:e.title||{text:``},type:`funnel`,labelRange:e.auxiliaryRange||void 0,showValues:e.showValues,axesDesign:e.axesDesign,funnelColors:e.funnelColors,horizontal:!0,cumulative:e.cumulative,humanize:e.humanize}}getContextCreation(){let e=[];for(let[t,n]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(n.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(t){let n=rd(this.sheetId,t,this.dataSets),r=id(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){let r=[];for(let[t,i]of e.entries())r.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,n||this.sheetId)});return{type:`funnel`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:r,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,aggregated:this.aggregated,horizontal:this.horizontal,axesDesign:this.axesDesign,showValues:this.showValues,funnelColors:this.funnelColors,cumulative:this.cumulative,humanize:this.humanize}}getDefinitionForExcel(){}updateRanges({applyChange:t}){let{dataSets:n,labelRange:r,isStale:i}=nd(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function qZ(e,t){let n=e.getDefinition(),r=ng(n,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:`funnel`,data:{labels:r.labels,datasets:df(n,r)},options:{...Jp,indexAxis:`y`,layout:Ng(n,r),scales:qd(n,r),plugins:{title:$g(n,t),legend:{display:!1},tooltip:d_(n,r),chartShowValuesPlugin:qg(n,r),background:{color:e.background}}}}}}var JZ=class e extends Ff{dataSets;labelRange;background;legendPosition;type=`geo`;dataSetsHaveTitle;dataSetDesign;colorScale;missingValueColor;region;constructor(e,t,n){super(e,t,n),this.dataSets=od(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=nl(n,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.colorScale=e.colorScale,this.missingValueColor=e.missingValueColor,this.region=e.region}static transformDefinition(e,t,n){return ud(e,t,n)}static validateChartDefinition(e,t){return e.checkValidations(t,pd,md)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`geo`,labelRange:e.auxiliaryRange||void 0,humanize:e.humanize}}getContextCreation(){let e=[];for(let[t,n]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(n.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(t){let n=rd(this.sheetId,t,this.dataSets),r=id(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){let r=[];for(let[t,i]of e.entries())r.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,n||this.sheetId)});return{type:`geo`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:r,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,colorScale:this.colorScale,missingValueColor:this.missingValueColor,region:this.region,humanize:this.humanize}}getDefinitionForExcel(){}updateRanges({applyChange:t}){let{dataSets:n,labelRange:r,isStale:i}=nd(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function YZ(e,t){let n=e.getDefinition(),r=tg(n,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:`choropleth`,data:{datasets:uf(n,r)},options:{...Jp,layout:Ng(n,r),scales:Kd(n,r),plugins:{title:$g(n,t),tooltip:u_(n,r),legend:{display:!1},background:{color:e.background}}}}}}var XZ=class e extends Ff{dataSets;labelRange;background;legendPosition;aggregated;type=`pyramid`;dataSetsHaveTitle;dataSetDesign;axesDesign;horizontal=!0;stacked=!0;showValues;constructor(e,t,n){super(e,t,n),this.dataSets=od(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=nl(n,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.showValues=e.showValues}static transformDefinition(e,t,n){return ud(e,t,n)}static validateChartDefinition(e,t){return e.checkValidations(t,pd,md)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,aggregated:e.aggregated??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`pyramid`,labelRange:e.auxiliaryRange||void 0,axesDesign:e.axesDesign,horizontal:!0,stacked:!0,showValues:e.showValues,humanize:e.humanize}}getContextCreation(){let e=[];for(let[t,n]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(n.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(t){let n=rd(this.sheetId,t,this.dataSets),r=id(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){let r=[];for(let[t,i]of e.entries())r.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,n||this.sheetId)});return{type:`pyramid`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:r,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,aggregated:this.aggregated,axesDesign:this.axesDesign,horizontal:!0,stacked:!0,showValues:this.showValues,humanize:this.humanize}}getDefinitionForExcel(e){let{dataSets:t,labelRange:n}=this.getCommonDataSetAttributesForExcel(this.labelRange,this.dataSets,hd(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle)),r=this.getDefinition(),{dataSetsValues:i}=Zh(r,this.dataSets,this.labelRange,e),a=Math.max(...i.map(e=>Math.max(...e.data.map(Math.abs))));return{...r,horizontal:!0,backgroundColor:V(this.background||`#FFFFFF`),fontColor:V(dd(this.background)),dataSets:t,labelRange:n,verticalAxis:_d(r),maxValue:a}}updateRanges({applyChange:t}){let{dataSets:n,labelRange:r,isStale:i}=nd(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function ZZ(e,t){let n=e.getDefinition(),r=Zh(n,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:`bar`,data:{labels:r.labels,datasets:tf(n,r)},options:{...Jp,indexAxis:`y`,layout:Ng(n,r),scales:Wd(n,r),plugins:{title:$g(n,t),legend:Ig(n,r),tooltip:c_(n,r),chartShowValuesPlugin:Xg(n,r),background:{color:e.background}}}}}}var QZ=class e extends Ff{dataSets;labelRange;background;legendPosition;stacked;aggregated;type=`radar`;dataSetsHaveTitle;dataSetDesign;fillArea;showValues;hideDataMarkers;constructor(e,t,n){super(e,t,n),this.dataSets=od(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=nl(n,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.fillArea=e.fillArea,this.showValues=e.showValues,this.hideDataMarkers=e.hideDataMarkers}static transformDefinition(e,t,n){return ud(e,t,n)}static validateChartDefinition(e,t){return e.checkValidations(t,pd,md)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,stacked:e.stacked??!1,aggregated:e.aggregated??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`radar`,labelRange:e.auxiliaryRange||void 0,fillArea:e.fillArea??!1,showValues:e.showValues??!1,hideDataMarkers:e.hideDataMarkers,humanize:e.humanize}}getContextCreation(){let e=[];for(let[t,n]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(n.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(t){let n=rd(this.sheetId,t,this.dataSets),r=id(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){let r=[];for(let[t,i]of e.entries())r.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,n||this.sheetId)});return{type:`radar`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:r,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated,fillArea:this.fillArea,showValues:this.showValues,hideDataMarkers:this.hideDataMarkers,humanize:this.humanize}}getDefinitionForExcel(){let{dataSets:e,labelRange:t}=this.getCommonDataSetAttributesForExcel(this.labelRange,this.dataSets,hd(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:V(this.background||`#FFFFFF`),fontColor:V(dd(this.background)),dataSets:e,labelRange:t}}updateRanges({applyChange:t}){let{dataSets:n,labelRange:r,isStale:i}=nd(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function $Z(e,t){let n=e.getDefinition(),r=eg(n,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:`radar`,data:{labels:r.labels,datasets:lf(n,r)},options:{...Jp,layout:Ng(n,r),scales:Gd(n,r),plugins:{title:$g(n,t),legend:Hg(n,r),tooltip:l_(n,r),chartShowValuesPlugin:qg(n,r),background:{color:e.background}}}}}}var eQ=class e extends Ff{dataSets;labelRange;background;legendPosition;type=`sunburst`;dataSetsHaveTitle;showValues;showLabels;valuesDesign;groupColors;pieHolePercentage;constructor(e,t,n){super(e,t,n),this.dataSets=od(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=nl(n,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.showValues=e.showValues,this.showLabels=e.showLabels,this.valuesDesign=e.valuesDesign,this.groupColors=e.groupColors,this.pieHolePercentage=e.pieHolePercentage}static transformDefinition(e,t,n){return ud(e,t,n)}static validateChartDefinition(e,t){return e.checkValidations(t,pd,md)}static getDefinitionFromContextCreation(e){let t=[];return e.hierarchicalRanges?.length?t.push(...e.hierarchicalRanges):e.auxiliaryRange&&t.push({...e.range?.[0],dataRange:e.auxiliaryRange}),{background:e.background,dataSets:t,dataSetsHaveTitle:e.dataSetsHaveTitle??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`sunburst`,labelRange:e.range?.[0]?.dataRange,showValues:e.showValues,showLabels:e.showLabels,valuesDesign:e.valuesDesign,groupColors:e.groupColors,humanize:e.humanize}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){let e=this.dataSets.at(-1)?.dataRange;return{...this,range:this.labelRange?[{dataRange:this.getters.getRangeString(this.labelRange,this.sheetId)}]:[],auxiliaryRange:e?this.getters.getRangeString(e,this.sheetId):void 0,hierarchicalRanges:this.dataSets.map(e=>({dataRange:this.getters.getRangeString(e.dataRange,this.sheetId)}))}}getDefinitionWithSpecificDataSets(e,t,n){return{type:`sunburst`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:e.map(e=>({dataRange:this.getters.getRangeString(e.dataRange,n||this.sheetId)})),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,showValues:this.showValues,showLabels:this.showLabels,valuesDesign:this.valuesDesign,groupColors:this.groupColors,pieHolePercentage:this.pieHolePercentage,humanize:this.humanize}}duplicateInDuplicatedSheet(t){let n=rd(this.sheetId,t,this.dataSets),r=id(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinitionForExcel(){}updateRanges({applyChange:t}){let{dataSets:n,labelRange:r,isStale:i}=nd(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function tQ(e,t){let n=e.getDefinition(),r=rg(n,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:`doughnut`,data:{datasets:pf(n,r)},options:{cutout:e.pieHolePercentage===void 0?`25%`:`${e.pieHolePercentage}%`,...Jp,layout:Ng(n,r),plugins:{title:$g(n,t),legend:Ug(n,r),tooltip:f_(n,r),sunburstLabelsPlugin:Yg(n,r),sunburstHoverPlugin:{enabled:!0},background:{color:e.background}}}}}}var nQ=class e extends Ff{static defaults={background:oe,legendPosition:`top`,dataSetsHaveTitle:!1,showHeaders:!0,headersColor:`#000000`};dataSets;labelRange;background;legendPosition;type=`treemap`;dataSetsHaveTitle;showHeaders;headerDesign;showValues;showLabels;valuesDesign;coloringOptions;constructor(e,t,n){super(e,t,n),this.dataSets=od(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=nl(n,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.showHeaders=e.showHeaders,this.headerDesign=e.headerDesign,this.showValues=e.showValues,this.showLabels=e.showLabels,this.valuesDesign=e.valuesDesign,this.coloringOptions=e.coloringOptions}static transformDefinition(e,t,n){return ud(e,t,n)}static validateChartDefinition(e,t){return e.checkValidations(t,pd,md)}static getDefinitionFromContextCreation(e){let t=[];return e.hierarchicalRanges?.length?t.push(...e.hierarchicalRanges):e.auxiliaryRange&&t.push({...e.range?.[0],dataRange:e.auxiliaryRange}),{background:e.background,dataSets:t,dataSetsHaveTitle:e.dataSetsHaveTitle??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`treemap`,labelRange:e.range?.[0]?.dataRange,showValues:e.showValues,showHeaders:e.showHeaders,headerDesign:e.headerDesign,showLabels:e.showLabels,valuesDesign:e.valuesDesign,coloringOptions:e.treemapColoringOptions,humanize:e.humanize}}getContextCreation(){let e=this.dataSets.at(-1)?.dataRange;return{...this,range:this.labelRange?[{dataRange:this.getters.getRangeString(this.labelRange,this.sheetId)}]:[],auxiliaryRange:e?this.getters.getRangeString(e,this.sheetId):void 0,hierarchicalRanges:this.dataSets.map(e=>({dataRange:this.getters.getRangeString(e.dataRange,this.sheetId)}))}}duplicateInDuplicatedSheet(t){let n=rd(this.sheetId,t,this.dataSets),r=id(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){let r=e.map(e=>({dataRange:this.getters.getRangeString(e.dataRange,n||this.sheetId)}));return{type:`treemap`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:r,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,showValues:this.showValues,showHeaders:this.showHeaders,headerDesign:this.headerDesign,showLabels:this.showLabels,valuesDesign:this.valuesDesign,coloringOptions:this.coloringOptions,humanize:this.humanize}}getDefinitionForExcel(){}updateRanges({applyChange:t}){let{dataSets:n,labelRange:r,isStale:i}=nd(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function rQ(e,t){let n=e.getDefinition(),r=rg(n,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:`treemap`,data:{labels:r.labels,datasets:vf(n,r)},options:{...Jp,layout:Ng(n,r),plugins:{title:$g(n,t),legend:{display:!1},tooltip:p_(n,r),background:{color:e.background}}}}}}b_.add(`bar`,{match:e=>e===`bar`,createChart:(e,t,n)=>new v_(e,t,n),getChartRuntime:y_,validateChartDefinition:v_.validateChartDefinition,transformDefinition:v_.transformDefinition,getChartDefinitionFromContextCreation:v_.getDefinitionFromContextCreation,sequence:10}),b_.add(`combo`,{match:e=>e===`combo`,createChart:(e,t,n)=>new WZ(e,t,n),getChartRuntime:GZ,validateChartDefinition:WZ.validateChartDefinition,transformDefinition:WZ.transformDefinition,getChartDefinitionFromContextCreation:WZ.getDefinitionFromContextCreation,sequence:15}),b_.add(`line`,{match:e=>e===`line`,createChart:(e,t,n)=>new L_(e,t,n),getChartRuntime:R_,validateChartDefinition:L_.validateChartDefinition,transformDefinition:L_.transformDefinition,getChartDefinitionFromContextCreation:L_.getDefinitionFromContextCreation,sequence:20}),b_.add(`pie`,{match:e=>e===`pie`,createChart:(e,t,n)=>new z_(e,t,n),getChartRuntime:B_,validateChartDefinition:z_.validateChartDefinition,transformDefinition:z_.transformDefinition,getChartDefinitionFromContextCreation:z_.getDefinitionFromContextCreation,sequence:30}),b_.add(`scorecard`,{match:e=>e===`scorecard`,createChart:(e,t,n)=>new Gf(e,t,n),getChartRuntime:qf,validateChartDefinition:Gf.validateChartDefinition,transformDefinition:Gf.transformDefinition,getChartDefinitionFromContextCreation:Gf.getDefinitionFromContextCreation,sequence:40}),b_.add(`gauge`,{match:e=>e===`gauge`,createChart:(e,t,n)=>new j_(e,t,n),getChartRuntime:M_,validateChartDefinition:j_.validateChartDefinition,transformDefinition:j_.transformDefinition,getChartDefinitionFromContextCreation:j_.getDefinitionFromContextCreation,sequence:50}),b_.add(`scatter`,{match:e=>e===`scatter`,createChart:(e,t,n)=>new fL(e,t,n),getChartRuntime:pL,validateChartDefinition:fL.validateChartDefinition,transformDefinition:fL.transformDefinition,getChartDefinitionFromContextCreation:fL.getDefinitionFromContextCreation,sequence:60}),b_.add(`waterfall`,{match:e=>e===`waterfall`,createChart:(e,t,n)=>new V_(e,t,n),getChartRuntime:H_,validateChartDefinition:V_.validateChartDefinition,transformDefinition:V_.transformDefinition,getChartDefinitionFromContextCreation:V_.getDefinitionFromContextCreation,sequence:70}),b_.add(`pyramid`,{match:e=>e===`pyramid`,createChart:(e,t,n)=>new XZ(e,t,n),getChartRuntime:ZZ,validateChartDefinition:XZ.validateChartDefinition,transformDefinition:XZ.transformDefinition,getChartDefinitionFromContextCreation:XZ.getDefinitionFromContextCreation,sequence:80,dataSeriesLimit:2}),b_.add(`radar`,{match:e=>e===`radar`,createChart:(e,t,n)=>new QZ(e,t,n),getChartRuntime:$Z,validateChartDefinition:QZ.validateChartDefinition,transformDefinition:QZ.transformDefinition,getChartDefinitionFromContextCreation:QZ.getDefinitionFromContextCreation,sequence:80}),b_.add(`geo`,{match:e=>e===`geo`,createChart:(e,t,n)=>new JZ(e,t,n),getChartRuntime:YZ,validateChartDefinition:JZ.validateChartDefinition,transformDefinition:JZ.transformDefinition,getChartDefinitionFromContextCreation:JZ.getDefinitionFromContextCreation,sequence:90,dataSeriesLimit:1}),b_.add(`funnel`,{match:e=>e===`funnel`,createChart:(e,t,n)=>new KZ(e,t,n),getChartRuntime:qZ,validateChartDefinition:KZ.validateChartDefinition,transformDefinition:KZ.transformDefinition,getChartDefinitionFromContextCreation:KZ.getDefinitionFromContextCreation,sequence:100,dataSeriesLimit:1}),b_.add(`sunburst`,{match:e=>e===`sunburst`,createChart:(e,t,n)=>new eQ(e,t,n),getChartRuntime:tQ,validateChartDefinition:eQ.validateChartDefinition,transformDefinition:eQ.transformDefinition,getChartDefinitionFromContextCreation:eQ.getDefinitionFromContextCreation,sequence:30}),b_.add(`treemap`,{match:e=>e===`treemap`,createChart:(e,t,n)=>new nQ(e,t,n),getChartRuntime:rQ,validateChartDefinition:nQ.validateChartDefinition,transformDefinition:nQ.transformDefinition,getChartDefinitionFromContextCreation:nQ.getDefinitionFromContextCreation,sequence:100}),b_.add(`calendar`,{match:e=>e===`calendar`,createChart:(e,t,n)=>new HZ(e,t,n),getChartRuntime:(e,t)=>UZ(e,t),validateChartDefinition:HZ.validateChartDefinition,transformDefinition:HZ.transformDefinition,getChartDefinitionFromContextCreation:HZ.getDefinitionFromContextCreation,sequence:110,dataSeriesLimit:1}),ev.add(`line`,{matcher:e=>e.type===`line`&&!e.stacked&&!e.fillArea,displayName:k(`Line`),chartType:`line`,chartSubtype:`line`,subtypeDefinition:{stacked:!1,fillArea:!1},category:`line`,preview:`o-spreadsheet-ChartPreview.LINE_CHART`}).add(`stacked_line`,{matcher:e=>e.type===`line`&&!e.fillArea&&!!e.stacked,displayName:k(`Stacked Line`),chartType:`line`,chartSubtype:`stacked_line`,subtypeDefinition:{stacked:!0,fillArea:!1},category:`line`,preview:`o-spreadsheet-ChartPreview.STACKED_LINE_CHART`}).add(`area`,{matcher:e=>e.type===`line`&&!e.stacked&&!!e.fillArea,displayName:k(`Area`),chartType:`line`,chartSubtype:`area`,subtypeDefinition:{stacked:!1,fillArea:!0},category:`area`,preview:`o-spreadsheet-ChartPreview.AREA_CHART`}).add(`stacked_area`,{matcher:e=>e.type===`line`&&e.stacked&&!!e.fillArea,displayName:k(`Stacked Area`),chartType:`line`,chartSubtype:`stacked_area`,subtypeDefinition:{stacked:!0,fillArea:!0},category:`area`,preview:`o-spreadsheet-ChartPreview.STACKED_AREA_CHART`}).add(`scatter`,{displayName:k(`Scatter`),chartType:`scatter`,chartSubtype:`scatter`,category:`misc`,preview:`o-spreadsheet-ChartPreview.SCATTER_CHART`}).add(`column`,{matcher:e=>e.type===`bar`&&!e.stacked&&!e.horizontal,displayName:k(`Column`),chartType:`bar`,chartSubtype:`column`,subtypeDefinition:{stacked:!1,horizontal:!1},category:`column`,preview:`o-spreadsheet-ChartPreview.COLUMN_CHART`}).add(`stacked_column`,{matcher:e=>e.type===`bar`&&e.stacked&&!e.horizontal,displayName:k(`Stacked Column`),chartType:`bar`,chartSubtype:`stacked_column`,subtypeDefinition:{stacked:!0,horizontal:!1},category:`column`,preview:`o-spreadsheet-ChartPreview.STACKED_COLUMN_CHART`}).add(`bar`,{matcher:e=>e.type===`bar`&&!e.stacked&&!!e.horizontal,displayName:k(`Bar`),chartType:`bar`,chartSubtype:`bar`,subtypeDefinition:{horizontal:!0,stacked:!1},category:`bar`,preview:`o-spreadsheet-ChartPreview.BAR_CHART`}).add(`stacked_bar`,{matcher:e=>e.type===`bar`&&e.stacked&&!!e.horizontal,displayName:k(`Stacked Bar`),chartType:`bar`,chartSubtype:`stacked_bar`,subtypeDefinition:{horizontal:!0,stacked:!0},category:`bar`,preview:`o-spreadsheet-ChartPreview.STACKED_BAR_CHART`}).add(`combo`,{displayName:k(`Combo`),chartSubtype:`combo`,chartType:`combo`,category:`line`,preview:`o-spreadsheet-ChartPreview.COMBO_CHART`}).add(`pie`,{matcher:e=>e.type===`pie`&&!e.isDoughnut,displayName:k(`Pie`),chartSubtype:`pie`,chartType:`pie`,subtypeDefinition:{isDoughnut:!1},category:`pie`,preview:`o-spreadsheet-ChartPreview.PIE_CHART`}).add(`doughnut`,{matcher:e=>e.type===`pie`&&!!e.isDoughnut,displayName:k(`Doughnut`),chartSubtype:`doughnut`,chartType:`pie`,subtypeDefinition:{isDoughnut:!0},category:`pie`,preview:`o-spreadsheet-ChartPreview.DOUGHNUT_CHART`}).add(`gauge`,{displayName:k(`Gauge`),chartSubtype:`gauge`,chartType:`gauge`,category:`misc`,preview:`o-spreadsheet-ChartPreview.GAUGE_CHART`}).add(`scorecard`,{displayName:k(`Scorecard`),chartSubtype:`scorecard`,chartType:`scorecard`,category:`misc`,preview:`o-spreadsheet-ChartPreview.SCORECARD_CHART`}).add(`waterfall`,{displayName:k(`Waterfall`),chartSubtype:`waterfall`,chartType:`waterfall`,category:`misc`,preview:`o-spreadsheet-ChartPreview.WATERFALL_CHART`}).add(`pyramid`,{displayName:k(`Population Pyramid`),chartSubtype:`pyramid`,chartType:`pyramid`,category:`misc`,preview:`o-spreadsheet-ChartPreview.POPULATION_PYRAMID_CHART`}).add(`radar`,{matcher:e=>e.type===`radar`&&!e.fillArea,displayName:k(`Radar`),chartSubtype:`radar`,chartType:`radar`,subtypeDefinition:{fillArea:!1},category:`misc`,preview:`o-spreadsheet-ChartPreview.RADAR_CHART`}).add(`filled_radar`,{matcher:e=>e.type===`radar`&&!!e.fillArea,displayName:k(`Filled Radar`),chartType:`radar`,chartSubtype:`filled_radar`,subtypeDefinition:{fillArea:!0},category:`misc`,preview:`o-spreadsheet-ChartPreview.FILLED_RADAR_CHART`}).add(`geo`,{displayName:k(`Geo Chart`),chartSubtype:`geo`,chartType:`geo`,category:`misc`,preview:`o-spreadsheet-ChartPreview.GEO_CHART`}).add(`funnel`,{displayName:k(`Funnel`),chartSubtype:`funnel`,chartType:`funnel`,category:`misc`,preview:`o-spreadsheet-ChartPreview.FUNNEL_CHART`}).add(`sunburst`,{matcher:e=>e.type===`sunburst`,displayName:k(`Sunburst`),chartSubtype:`sunburst`,chartType:`sunburst`,category:`hierarchical`,preview:`o-spreadsheet-ChartPreview.SUNBURST_CHART`}).add(`treemap`,{matcher:e=>e.type===`treemap`,displayName:k(`Tree Map`),chartType:`treemap`,chartSubtype:`treemap`,category:`hierarchical`,preview:`o-spreadsheet-ChartPreview.TREE_MAP_CHART`}).add(`calendar`,{displayName:k(`Calendar`),chartSubtype:`calendar`,chartType:`calendar`,category:`misc`,preview:`o-spreadsheet-ChartPreview.CALENDAR_CHART`});var iQ=class extends sK{queuedBordersToAdd={};copy(e){let t=e.sheetId;if(e.zones.length===0)return;let{rowsIndexes:n,columnsIndexes:r}=e,i=[];for(let e of n){let n=[];for(let i of r){let r={col:i,row:e,sheetId:t};n.push(this.getters.getCellBorder(r))}i.push(n)}return{borders:i}}paste(e,t,n){let r=e.sheetId;if(n.pasteOption===`asValue`)return;let i=e.zones;if(!n.isCutOperation)this.pasteFromCopy(r,i,t.borders);else{let{left:e,top:n}=i[0];this.pasteZone(r,e,n,t.borders)}this.executeQueuedChanges(r)}pasteZone(e,t,n,r){for(let[i,a]of r.entries())for(let[r,o]of a.entries()){let a={col:t+r,row:n+i,sheetId:e};this.pasteBorder(o,a)}}pasteBorder(e,t){let n={...this.getters.getCellBorder(t),...e},r=JSON.stringify(n);this.queuedBordersToAdd[r]||(this.queuedBordersToAdd[r]=[]),this.queuedBordersToAdd[r].push(E(t))}executeQueuedChanges(e){for(let t in this.queuedBordersToAdd){let n=this.queuedBordersToAdd[t],r=JSON.parse(t),i=nn(n,[]);this.dispatch(`SET_BORDERS_ON_TARGET`,{sheetId:e,target:i,border:r})}this.queuedBordersToAdd={}}},aQ=class extends oK{copy(e){}},oQ=class extends aQ{copy(e){let t=e.sheetId,n=this.getters.getFigure(t,e.figureId);if(!n)throw Error(`No figure for the given id: ${e.figureId}`);if(n.tag!==`carousel`)return;let r={...n},i=this.getters.getCarousel(e.figureId),a={};for(let e of i.items)if(e.type===`chart`){let n=this.getters.getChart(e.chartId);if(!n)throw Error(`No chart for the given id: ${e.chartId}`);a[e.chartId]=n.copyInSheetId(t)}return{figureId:e.figureId,copiedFigure:r,copiedCarousel:i,copiedCharts:a,copiedSheetId:t}}getPasteTarget(e){return{zones:[],figureId:new Xl().smallUuid(),sheetId:e}}paste(e,t,n){if(!e.figureId)return;let{zones:r,figureId:i}=e,a=e.sheetId,{width:o,height:s}=t.copiedFigure,c=this.getters.getMaxAnchorOffset(a,s,o),{left:l,top:u}=r[0],d={x:0,y:0};l>c.col&&(l=c.col,d.x=c.offset.x),u>c.row&&(u=c.row,d.y=c.offset.y),this.dispatch(`CREATE_CAROUSEL`,{figureId:i,sheetId:a,definition:{items:[]},col:l,row:u,offset:d,size:{height:s,width:o}});let f=new Xl,p=b(t.copiedCarousel.items);for(let e of p){if(e.type!==`chart`)continue;let n=t.copiedCharts[e.chartId],r=f.smallUuid(),o=n.copyInSheetId(a).getDefinition();this.dispatch(`CREATE_CHART`,{figureId:i,chartId:r,sheetId:a,definition:o}),e.chartId=r}this.dispatch(`UPDATE_CAROUSEL`,{sheetId:a,figureId:i,definition:{...t.copiedCarousel,items:p}}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:t.copiedSheetId,figureId:t.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:i})}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},sQ=class extends aQ{copy(e){let t=e.sheetId,n=this.getters.getFigure(t,e.figureId);if(!n)throw Error(`No figure for the given id: ${e.figureId}`);if(n.tag!==`chart`)return;let r={...n},i=this.getters.getChartFromFigureId(e.figureId);if(!i)throw Error(`No chart for the given id: ${e.figureId}`);let a=i.copyInSheetId(t);return{figureId:e.figureId,copiedFigure:r,copiedChart:a}}getPasteTarget(e,t,n,r){return{zones:[],figureId:new Xl().smallUuid(),sheetId:e}}paste(e,t,n){if(!e.figureId)return;let{zones:r,figureId:i}=e,a=e.sheetId,{width:o,height:s}=t.copiedFigure,c=t.copiedChart.copyInSheetId(a),l=this.getters.getMaxAnchorOffset(a,s,o),{left:u,top:d}=r[0],f={x:0,y:0};u>l.col&&(u=l.col,f.x=l.offset.x),d>l.row&&(d=l.row,f.y=l.offset.y),this.dispatch(`CREATE_CHART`,{figureId:i,chartId:new Xl().smallUuid(),sheetId:a,definition:c.getDefinition(),col:u,row:d,offset:f,size:{height:s,width:o}}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:t.copiedChart.sheetId,figureId:t.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:i})}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},cQ=class extends sK{uuidGenerator=new Xl;queuedChanges={};copy(e){if(!e.zones.length)return;let{rowsIndexes:t,columnsIndexes:n}=e,r=e.sheetId,i=[];for(let e of t){let t=[];for(let i of n){let n=Array.from(this.getters.getRulesByCell(r,i,e));t.push({position:{col:i,row:e,sheetId:r},rules:n})}i.push(t)}return{cfRules:i}}paste(e,t,n){if(this.queuedChanges={},n.pasteOption===`asValue`)return;let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t):this.pasteFromCopy(i,r,t.cfRules,n),this.executeQueuedChanges()}pasteFromCut(e,t,n){let r=t[0];this.pasteZone(e,r.left,r.top,n.cfRules,{isCutOperation:!0})}pasteZone(e,t,n,r,i){for(let[a,o]of r.entries())for(let[r,s]of o.entries()){let o={col:t+r,row:n+a,sheetId:e};this.pasteCf(s,o,i?.isCutOperation)}}pasteCf(e,t,n){if(e?.rules&&e.rules.length>0){let r=E(e.position),i=E(t);for(let a of e.rules){let o=[];if(n&&o.push(r),e.position.sheetId===t.sheetId)this.adaptCFRules(e.position.sheetId,a,[i],o);else{this.adaptCFRules(e.position.sheetId,a,[],o);let n=this.getCFToCopyTo(t.sheetId,a);this.adaptCFRules(t.sheetId,n,[i],[])}}}}adaptCFRules(e,t,n,r){this.queuedChanges[e]||(this.queuedChanges[e]=[]);let i=this.queuedChanges[e].find(e=>e.cf.id===t.id);i?(i.toAdd.push(...n),i.toRemove.push(...r)):this.queuedChanges[e].push({toAdd:n,toRemove:r,cf:t})}executeQueuedChanges(){for(let e in this.queuedChanges)for(let{toAdd:t,toRemove:n,cf:r}of this.queuedChanges[e]){let i=this.getters.getAdaptedCfRanges(e,r,t,n);if(i){if(i.length===0){this.dispatch(`REMOVE_CONDITIONAL_FORMAT`,{id:r.id,sheetId:e});continue}this.dispatch(`ADD_CONDITIONAL_FORMAT`,{cf:{id:r.id,rule:r.rule,stopIfTrue:r.stopIfTrue},ranges:i,sheetId:e})}}}getCFToCopyTo(e,t){let n=this.getters.getConditionalFormats(e).find(e=>e.stopIfTrue===t.stopIfTrue&&w(e.rule,t.rule)),r=this.queuedChanges[e];return!n&&r&&(n=r.find(e=>e.cf.stopIfTrue===t.stopIfTrue&&w(e.cf.rule,t.rule))?.cf),n||{...t,id:this.uuidGenerator.smallUuid(),ranges:[]}}},lQ=class extends sK{uuidGenerator=new Xl;queuedChanges={};copy(e){let{rowsIndexes:t,columnsIndexes:n}=e,r=e.sheetId,i=[];for(let e of t){let t=[];for(let i of n){let n={sheetId:r,col:i,row:e},a=this.getters.getValidationRuleForCell(n);t.push({position:n,rule:a})}i.push(t)}return{dvRules:i}}paste(e,t,n){if(this.queuedChanges={},n.pasteOption)return;let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t):this.pasteFromCopy(i,r,t.dvRules),this.executeQueuedChanges()}pasteFromCut(e,t,n){let r=t[0];this.pasteZone(e,r.left,r.top,n.dvRules,{isCutOperation:!0})}pasteZone(e,t,n,r,i){for(let[a,o]of r.entries())for(let[r,s]of o.entries()){let o={col:t+r,row:n+a,sheetId:e};this.pasteDataValidation(s,o,i?.isCutOperation)}}pasteDataValidation(e,t,n){if(e){let r=E(t),i=E(e.position),a=e.rule;if(!a){let e=this.getters.getValidationRuleForCell(t);e&&this.adaptDataValidationRule(t.sheetId,e,[],[r]);return}let o=[];if(n&&o.push(i),e.position.sheetId===t.sheetId){let n=this.getDataValidationRuleToCopyTo(t.sheetId,a,!1);this.adaptDataValidationRule(e.position.sheetId,n,[r],o)}else{let n=this.getters.getValidationRuleForCell(e.position);n&&this.adaptDataValidationRule(e.position.sheetId,n,[],o);let i=this.getDataValidationRuleToCopyTo(t.sheetId,a);this.adaptDataValidationRule(t.sheetId,i,[r],[])}}}getDataValidationRuleToCopyTo(e,t,n=!0){let r=this.getters.getDataValidationRules(e).find(e=>w(t.criterion,e.criterion)&&t.isBlocking===e.isBlocking),i=this.queuedChanges[e];return!r&&i&&(r=i.find(e=>w(t.criterion,e.rule.criterion)&&t.isBlocking===e.rule.isBlocking)?.rule),r||{...t,id:n?this.uuidGenerator.smallUuid():t.id,ranges:[]}}adaptDataValidationRule(e,t,n,r){this.queuedChanges[e]||(this.queuedChanges[e]=[]);let i=this.queuedChanges[e].find(e=>e.rule.id===t.id);i?(i.toAdd.push(...n),i.toRemove.push(...r)):this.queuedChanges[e].push({toAdd:n,toRemove:r,rule:t})}executeQueuedChanges(){for(let e in this.queuedChanges)for(let{toAdd:t,toRemove:n,rule:r}of this.queuedChanges[e]){let i=nn([...nn(r.ranges.map(e=>e.zone),n),...t],[]);if(i.length===0){this.dispatch(`REMOVE_DATA_VALIDATION_RULE`,{sheetId:e,id:r.id});continue}this.dispatch(`ADD_DATA_VALIDATION_RULE`,{rule:{id:r.id,criterion:r.criterion,isBlocking:r.isBlocking},ranges:i.map(t=>this.getters.getRangeDataFromZone(e,t)),sheetId:e})}}},uQ=class extends aQ{copy(e){let t=e.sheetId,n=this.getters.getFigure(t,e.figureId);if(!n)throw Error(`No figure for the given id: ${e.figureId}`);let r={...n};if(n.tag!==`image`)return;let i=b(this.getters.getImage(e.figureId));return{figureId:e.figureId,copiedFigure:r,copiedImage:i,sheetId:t}}getPasteTarget(e,t,n,r){return{sheetId:e,zones:[],figureId:new Xl().smallUuid()}}paste(e,t,n){if(!e.figureId)return;let{zones:r,figureId:i}=e,a=this.getters.getActiveSheetId(),{width:o,height:s}=t.copiedFigure,c=b(t.copiedImage),l=this.getters.getMaxAnchorOffset(a,s,o),{left:u,top:d}=r[0],f={x:0,y:0};u>l.col&&(u=l.col,f.x=l.offset.x),d>l.row&&(d=l.row,f.y=l.offset.y),this.dispatch(`CREATE_IMAGE`,{figureId:i,sheetId:a,col:u,row:d,offset:f,size:{height:s,width:o},definition:c}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:t.sheetId,figureId:t.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:i})}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},dQ=class extends sK{copy(e){let t=this.getters.getActiveSheetId(),{rowsIndexes:n,columnsIndexes:r}=e,i=[];for(let e of n){let n=[];for(let i of r){let r={col:i,row:e,sheetId:t};n.push(this.getters.getMerge(r))}i.push(n)}return{merges:i,sheetId:t}}paste(e,t,n){if(n.isCutOperation){let e=t.merges.flat().filter(C);this.dispatch(`REMOVE_MERGE`,{sheetId:t.sheetId,target:e})}this.pasteFromCopy(e.sheetId,e.zones,t.merges,n)}pasteZone(e,t,n,r){for(let[i,a]of r.entries())for(let[r,o]of a.entries()){let a={col:t+r,row:n+i,sheetId:e};this.pasteMerge(o,a)}}pasteMerge(e,t){if(!e||this.getters.isInMerge(t))return;let{sheetId:n,col:r,row:i}=t;this.dispatch(`ADD_MERGE`,{sheetId:n,force:!0,target:[{left:r,top:i,right:r+e.right-e.left,bottom:i+e.bottom-e.top}]})}},fQ=class extends sK{copy(e){return{zones:e.clippedZones,sheetId:e.sheetId}}paste(e,t,n){if(n.isCutOperation){let n=e.zones[0];this.dispatch(`MOVE_RANGES`,{target:t.zones,sheetId:t.sheetId,sheetName:this.getters.getSheetName(t.sheetId),targetSheetId:e.sheetId,col:n.left,row:n.top})}}},pQ=class extends sK{isPasteAllowed(e,t,n,r){if(!(`cells`in n))return`Success`;let{xSplit:i,ySplit:a}=this.getters.getPaneDivisions(e);return qn(EP(t,n.cells),i,a)?`FrozenPaneOverlap`:`Success`}},mQ=class extends sK{copy(e,t,n=`copyPaste`){let r=e.sheetId,{rowsIndexes:i,columnsIndexes:a,zones:o}=e,s=new Set,c=[];for(let e of i){let l=[];c.push(l);for(let c of a){let a={col:c,row:e,sheetId:r},u=this.getters.getTable(a);if(!u){l.push({});continue}let d=this.getters.getCoreTable(a),f=d?.range.zone,p;if(!s.has(u.id)&&d&&f&&o.some(e=>jn(f,e))){s.add(u.id);let{numberOfRows:e}=Mn(f);for(let n=f.top;n<=f.bottom;n++)!t&&!i.includes(n)&&e--;let n=d.range,r=this.getters.extendRange(d.range,`ROW`,n.zone.top+e-1-n.zone.bottom);p={range:this.getters.getRangeData(r),config:d.config,type:d.type}}if(u.isPivotTable){let t=u.range.zone.top===e&&u.range.zone.left===c,n=o.some(e=>jn(u.range.zone,e));(t||n)&&s.add(u.id)}n!==`shiftCells`&&l.push({table:p,style:this.getTableStyleToCopy(a),isWholeTableCopied:s.has(u.id)})}}return{tableCells:c,sheetId:e.sheetId}}getTableStyleToCopy(e){let t=Ct({...this.getters.getCellTableStyle(e),hideGridLines:!1}),n=this.getters.getCellStyle(e),r=this.getters.getCellTableBorder(e),i=this.getters.getCellBorder(e);return{style:{...t,...Ct(n)},border:{...r,...Ct(i)}}}paste(e,t,n){let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t,n):this.pasteFromCopy(i,r,t.tableCells,n)}pasteFromCut(e,t,n,r){for(let e of n.tableCells)for(let t of e)t.table&&this.dispatch(`REMOVE_TABLE`,{sheetId:n.sheetId,target:[this.getters.getRangeFromRangeData(t.table.range).zone]});let i=t[0];this.pasteZone(e,i.left,i.top,n.tableCells,r)}pasteZone(e,t,n,r,i){for(let a=0;a<r.length;a++){let o=r[a];for(let r=0;r<o.length;r++){let s=o[r];if(!s)continue;let c={col:t+r,row:n+a,sheetId:e};this.pasteTableCell(e,s,c,i)}}if(r.length===1)for(let i=0;i<r[0].length;i++)this.dispatch(`AUTOFILL_TABLE_COLUMN`,{col:t+i,row:n,sheetId:e})}pasteTableCell(e,t,n,r){if(t.table&&!r?.pasteOption){let{range:r}=t.table,i=Mn(this.getters.getRangeFromRangeData(r).zone),a={left:n.col,top:n.row,right:n.col+i.numberOfCols-1,bottom:n.row+i.numberOfRows-1};this.dispatch(`CREATE_TABLE`,{sheetId:n.sheetId,ranges:[this.getters.getRangeDataFromZone(e,a)],config:t.table.config,tableType:t.table.type})}this.getters.getCoreTable(n)||r?.pasteOption===`asValue`||(!r?.pasteOption&&!t.isWholeTableCopied||r?.pasteOption===`onlyFormat`)&&(t.style?.style&&this.dispatch(`UPDATE_CELL`,{...n,style:t.style.style}),t.style?.border&&this.dispatch(`SET_BORDER`,{...n,border:t.style.border}))}};oW.figureHandlers.add(`chart`,sQ).add(`image`,uQ).add(`carousel`,oQ),oW.cellHandlers.add(`dataValidation`,lQ).add(`cell`,cK).add(`sheet`,pQ).add(`merge`,dQ).add(`border`,iQ).add(`table`,mQ).add(`conditionalFormat`,cQ).add(`references`,fQ);let hQ={},gQ={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:26,HEADER_WIDTH:48,DESKTOP_BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:96,DEFAULT_CELL_HEIGHT:23,SCROLLBAR_WIDTH:15},_Q={autoCompleteProviders:EN,autofillModifiersRegistry:dK,autofillRulesRegistry:fK,cellMenuRegistry:ZH,colMenuRegistry:lU,errorTypes:ha,linkMenuRegistry:xP,functionRegistry:fO,featurePluginRegistry:Jq,iconsOnCellRegistry:VG,statefulUIPluginRegistry:Yq,coreViewsPluginRegistry:Xq,corePluginRegistry:qq,rowMenuRegistry:gU,sidePanelRegistry:bV,figureRegistry:Bv,chartSidePanelComponentRegistry:wL,chartComponentRegistry:yv,chartRegistry:b_,chartSubtypeRegistry:ev,topbarMenuRegistry:kJ,topbarComponentRegistry:YJ,clickableCellRegistry:rJ,otRegistry:jK,inverseCommandRegistry:oJ,urlRegistry:$s,cellPopoverRegistry:xM,numberFormatMenuRegistry:wJ,repeatLocalCommandTransformRegistry:Sq,repeatCommandTransformRegistry:xq,clipboardHandlersRegistries:oW,pivotRegistry:fB,pivotTimeAdapterRegistry:Zm,pivotSidePanelRegistry:DB,pivotNormalizationValueRegistry:kh,supportedPivotPositionalFormulaRegistry:RW,pivotToFunctionValueRegistry:Ah,migrationStepRegistry:qj,chartJsExtensionRegistry:Zl},vQ={arg:W,isEvaluationError:M,toBoolean:F,toJsDate:I,toNumber:N,toString:P,toNormalizedPivotValue:Th,toFunctionPivotValue:Dh,toXC:T,toZone:mn,toUnboundedZone:pn,toCartesian:tn,numberToLetters:Kt,lettersToNumber:qt,UuidGenerator:Xl,formatValue:z,createCurrencyFormat:ps,ColorGenerator:ii,computeTextWidth:Ml,createEmptyWorkbookData:pM,createEmptySheet:fM,createEmptyExcelSheet:mM,rgbaToHex:Fr,colorToRGBA:Ir,positionToZone:E,isDefined:C,isMatrix:Ta,lazy:_t,genericRepeat:JJ,createAction:h,createActions:p,transformRangeData:rr,deepEquals:w,overlap:On,union:wn,isInside:An,deepCopy:b,expandZoneOnInsertion:bn,reduceZoneOnDeletion:Cn,unquote:Xe,getMaxObjectId:_h,getFirstPivotFunction:_B,getNumberOfPivotFunctions:yB,parseDimension:bh,isDateOrDatetimeField:xh,makeFieldProposal:bB,periodYearToComparable:Xm,insertTokenAfterArgSeparator:SB,insertTokenAfterLeftParenthesis:CB,mergeContiguousZones:er,getPivotHighlights:nz,pivotTimeAdapter:Qm,UNDO_REDO_PIVOT_COMMANDS:rK,createPivotFormula:wh,areDomainArgsFieldsValid:Ch,splitReference:zc,sanitizeSheetName:Qe,getUniqueText:Ht,isNumber:ra,isDateTime:Ti,createCustomFields:Ih,schemeToColorScale:Bm,isDateTimeFormat:os,jsDateToNumber:zi,numberToJsDate:Li,DateTime:O,parseFormat:Ao,isFormula:Ut,domainToColRowDomain:Lz,PositionMap:wV},yQ={isMarkdownLink:it,parseMarkdownLink:st,markdownLink:ot,openLink:ic,urlRepresentation:rc},bQ={Checkbox:nP,Section:Q,Select:OM,RoundColorPicker:HN,ChartDataSeries:DI,ChartErrorSection:kI,ChartLabelRange:AI,ChartTitle:PI,ChartPanel:OL,ChartFigure:Rv,ChartJsComponent:Pf,ClickableCellSortIcon:zW,ZoomableChartJsComponent:dv,Grid:LW,GridOverlay:fW,ScorecardChart:Ap,GaugeChartComponent:_v,LineConfigPanel:sL,BarConfigPanel:MI,PieChartDesignPanel:uL,GenericChartConfigPanel:jI,ChartWithAxisDesignPanel:WI,GenericZoomableChartDesignPanel:GI,LineChartDesignPanel:cL,GaugeChartConfigPanel:tL,GaugeChartDesignPanel:nL,ScorecardChartConfigPanel:hL,ScorecardChartDesignPanel:gL,GeoChartDesignPanel:aL,RadarChartDesignPanel:dL,WaterfallChartDesignPanel:CL,ComboChartDesignPanel:QI,FunnelChartDesignPanel:eL,SunburstChartDesignPanel:_L,TreeMapChartDesignPanel:SL,ChartTypePicker:EL,FigureComponent:Vv,MenuPopover:Fv,Popover:jv,SelectionInput:ZN,ValidationMessages:OI,AddDimensionButton:sz,PivotDimensionGranularity:lz,PivotDimensionOrder:uz,PivotDimension:cz,PivotLayoutConfigurator:jz,PivotHTMLRenderer:VW,PivotDeferUpdate:iz,PivotTitleSection:Mz,CogWheelMenu:wI,TextInput:vI,SidePanelCollapsible:DM,RadioSelection:II,GeoChartRegionSelectSection:rL,ChartDashboardMenu:Iv,FullScreenFigure:BW,NumberInput:BI,TopBar:PY,Composer:$M},xQ={useDragAndDropListItems:WN,useHighlights:FL,useHighlightsOnHover:PL},SQ={useStoreProvider:lr,DependencyContainer:ar,CellPopoverStore:sP,ComposerFocusStore:xr,CellComposerStore:KU,FindAndReplaceStore:HL,HighlightStore:ON,DelayedHoveredCellStore:Hv,HoveredTableStore:lW,ModelStore:mr,NotificationStore:kN,RendererStore:vr,SelectionInputStore:XN,SpreadsheetStore:yr,useStore:D,useLocalStore:ur,SidePanelStore:SV,PivotSidePanelStore:TB,PivotMeasureDisplayPanelStore:ez,ClientFocusStore:vU,GridRenderer:bW};function CQ(e,t){return fO.add(e,t),{addFunction:(e,t)=>CQ(e,t)}}let wQ={DEFAULT_LOCALE:R,HIGHLIGHT_COLOR:ee,PIVOT_STATIC_TABLE_CONFIG:Re,PIVOT_INSERT_TABLE_STYLE_ID:ze,ChartTerms:rm,FIGURE_ID_SPLITTER:`??`,GRID_ICON_EDGE_LENGTH:17,GRID_ICON_MARGIN:2},TQ={...U_,...__};e.AbstractCellClipboardHandler=sK,e.AbstractChart=Ff,e.AbstractFigureClipboardHandler=aQ,e.CellErrorType=A,e.ClientDisconnectedError=fq,e.CommandResult=Zs,e.CompiledFormula=xz,e.CorePlugin=UW,e.CoreViewPlugin=hG,e.DEFAULT_LOCALE=R,e.DEFAULT_LOCALES=ho,e.DispatchResult=Ys,e.EvaluationError=j,e.LocalTransportService=XJ,e.Model=zZ,e.PivotRuntimeDefinition=Nz,e.Registry=B,e.Revision=dq,e.SPREADSHEET_DIMENSIONS=gQ,e.Spreadsheet=LY,e.SpreadsheetPivotTable=eB,e.UIPlugin=lK,e.__info__=hQ,e.addFunction=CQ,e.addRenderingLayer=_r,e.astToFormula=HU,e.canExecuteInReadonly=Js,e.categories=pO,e.chartHelpers=TQ,e.components=bQ,e.constants=wQ,e.convertAstNodes=pN,e.coreTypes=Ks,e.createAutocompleteArgumentsProvider=Zq,e.findCellInNewZone=Vn,e.functionCache=yz,e.getCaretDownSvg=DO,e.getCaretUpSvg=OO,e.helpers=vQ,e.hooks=xQ,e.invalidateCFEvaluationCommands=Vs,e.invalidateChartEvaluationCommands=zs,e.invalidateDependenciesCommands=Bs,e.invalidateEvaluationCommands=Rs,e.isCoreCommand=qs,e.isSheetDependent=Ms,e.iterateAstNodes=mN,e.links=yQ,e.load=Qj,e.lockedSheetAllowedCommands=Gs,e.parse=dN,e.parseTokens=fN,e.readonlyAllowedCommands=Ws,e.registries=_Q,e.setDefaultSheetViewSize=Ie,e.setTranslationMethod=fa,e.stores=SQ,e.tokenColors=We,e.tokenize=Tu,hQ.version=`19.2.23`,hQ.date=`2026-07-30T06:54:20.810Z`,hQ.hash=`7914fd5`})(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|
|
953
|
+
`),`_rels/.rels`)}function LZ(e){let t={},n=[];for(let r of e.sheets){let e=r.name.slice(0,31);e=Ht(e,n,{compute:(e,t)=>e.slice(0,31-String(t).length)+t}),n.push(e),e!==r.name&&(t[r.name]=e,r.name=e)}if(!Object.keys(t).length)return e;let r=Object.keys(t).sort((e,t)=>t.length-e.length),i=JSON.stringify(e);for(let e of r){let n=RegExp(`'?${qe(e)}'?!`,`g`);i=i.replaceAll(n,n=>{let r=t[e];return n.replace(e,r)})}return JSON.parse(i)}function RZ(e){for(let t of e.sheets)t.tables=t.tables.filter(e=>Mn(mn(e.range)).numberOfRows>1);return e}var zZ=class e extends ir{corePlugins=[];statefulUIPlugins=[];range;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;coreViewPluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},t={},n=[],r=new Xl,i=!1){let a=performance.now();console.debug(`##### Model creation #####`),super(),pa(),n=oM(e,n);let o=Qj(e,i);this.state=new QY,this.uuidGenerator=r,this.config=this.setupConfig(t),this.session=this.setupSession(o.revisionId),this.coreGetters={},this.range=new YY(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeData=this.range.getRangeData.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.coreGetters.recomputeRanges=this.range.recomputeRanges.bind(this.range),this.coreGetters.isRangeValid=this.range.isRangeValid.bind(this.range),this.coreGetters.extendRange=this.range.extendRange.bind(this.range),this.coreGetters.getRangesUnion=this.range.getRangesUnion.bind(this.range),this.coreGetters.removeRangesSheetPrefix=this.range.removeRangesSheetPrefix.bind(this.range),this.coreGetters.copyFormulaStringForSheet=this.range.copyFormulaStringForSheet.bind(this.range),this.getters={isReadonly:()=>this.config.mode===`readonly`||this.config.mode===`dashboard`,isDashboard:()=>this.config.mode===`dashboard`},this.selection=new ZY(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.coreViewPluginConfig=this.setupCoreViewPluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of qq.getAll())this.setupCorePlugin(e,o);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(n);for(let e of Xq.getAll()){let t=this.setupCoreViewPlugin(e);this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of Yq.getAll()){let t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of Jq.getAll()){let t=this.setupUiPlugin(e);this.handlers.push(t),this.uiHandlers.push(t)}if(this.config.mode!==`export_verification`&&(this.dispatch(`START`),this.selection.observe(this,{handleEvent:()=>this.trigger(`update`)}),this.setupSessionEvents(),this.joinSession(),t.snapshotRequested||e[`[Content_Types].xml`]&&!this.getters.isReadonly())){let e=performance.now();console.debug(`Snapshot requested`),this.session.snapshot(this.exportData()),console.debug(`Snapshot taken in`,performance.now()-e,`ms`)}console.debug(`Model created in`,performance.now()-a,`ms`),console.debug(`######`)}joinSession(){this.session.join(this.config.client)}async leaveSession(){let e=this.getters.isReadonly()?void 0:_t(()=>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}setupCoreViewPlugin(e){let t=new e(this.coreViewPluginConfig);for(let n of e.getters){if(!(n in t))throw Error(`Invalid getter name: ${n} for plugin ${t.constructor}`);if(n in this.getters)throw Error(`Getter "${n}" is already defined.`);this.getters[n]=t[n].bind(t)}return t}setupCorePlugin(e,t){let n=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in n))throw Error(`Invalid getter name: ${t} for plugin ${n.constructor}`);if(t in this.coreGetters)throw Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=n[t].bind(n)}n.import(t),this.corePlugins.push(n),this.coreHandlers.push(n),this.handlers.push(n)}onRemoteRevisionReceived({commands:e}){for(let t of e){let e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new pq(KY({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{if(!this.checkDispatchAllowedRemoteCommand(e).isSuccessful){this.dispatchToHandlers(this.coreHandlers,{type:`UNDO`,commands:[e]});return}this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1}}),this.config.transportService,e)}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:k(`Anonymous`).toString()},n=e.transportService||new XJ,r=e.mode===`readonly`||e.mode===`dashboard`||e.mode===`export_verification`;return{...e,mode:e.mode||`normal`,custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:r?new RY(n):n,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger(`notify-ui`,e),raiseBlockingErrorUI:e=>this.trigger(`raise-error-ui`,{text:e}),customColors:e.customColors||[]}}setupExternalConfig(e){let t=e.loadLocales||(()=>Promise.resolve(ho));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,custom:this.config.custom,external:this.config.external}}setupCoreViewPluginConfig(){return{getters:this.getters,stateObserver:this.state,custom:this.config.custom,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,canDispatch:this.canDispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external}}checkDispatchAllowed(e){let t=qs(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return this.processCommandResults(t)}processCommandResults(e){return e.some(e=>e!==`Success`)?new Ys(e.flat()):Ys.Success}checkDispatchAllowedRemoteCommand(e){let t=this.coreHandlers.map(t=>t.allowDispatch(e));return this.processCommandResults(t)}checkDispatchAllowedCoreCommand(e){return this.handlers.map(t=>t.allowDispatch(e))}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map(t=>t.allowDispatch(e))}finalize(){this.status=3;for(let e of this.handlers)e.finalize();this.status=0,this.trigger(`command-finalized`)}canDispatch=(e,t)=>this.checkDispatchAllowed(BZ(e,t));dispatch=(e,t)=>{let n=BZ(e,t),r=this.status;if(this.getters.isReadonly()&&!Js(n))return new Ys(`Readonly`);if(!this.session.canApplyOptimisticUpdate())return new Ys(`WaitingSessionConfirmation`);switch(r){case 0:let t=this.checkDispatchAllowed(n);if(!t.isSuccessful)return this.trigger(`update`),this.trigger(`command-rejected`,{command:n,result:t}),t;this.status=1;let{changes:r,commands:i}=this.state.recordChanges(()=>{let t=performance.now();qs(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(qs(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(qs(n))throw Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,n)}return Ys.Success};dispatchFromCorePlugin=(e,t)=>{let n=BZ(e,t),r=this.status;this.status=2;let i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,n),this.status=r,Ys.Success};dispatchToHandlers(e,t){let n=qs(t);for(let r of e)!n&&r instanceof UW||r.beforeHandle(t);for(let r of e)!n&&r instanceof UW||r.handle(t);this.trigger(`command-dispatched`,t)}drawLayer(e,t){let n=this.renderers[t];if(n)for(let r of n)e.ctx.save(),r.drawLayer(e,t),e.ctx.restore()}exportData(){let t=this._exportData(!0),n=this._exportData(!1),r={...this.config,mode:`export_verification`,client:{id:`exporter`,name:`exporter`},snapshotRequested:!1,transportService:new XJ};return w(n,new e(b(t),r)._exportData(!1))?t:(n.isNotSquishable=!0,n)}_exportData(e){let t=pM();for(let n of this.handlers)n instanceof UW&&n.export(t,e);return t.revisionId=this.session.getRevisionId()||`START_REVISION`,t=b(t),t}updateMode(e){this.config.mode=e,this.trigger(`update`)}async exportXLSX(){this.dispatch(`EVALUATE_CELLS`);let e=hM();for(let t of this.handlers)t instanceof HW&&await t.exportForExcel(e);return e=b(e),OZ(e)}};function BZ(e,t={}){let n=b(t);return n.type=e,n}function VZ(e){return!qI.includes(e.horizontalGroupBy)||!qI.includes(e.verticalGroupBy)?`InvalidChartDefinition`:`Success`}var HZ=class e extends Ff{dataSets;labelRange;background;type=`calendar`;showValues;colorScale;axesDesign;horizontalGroupBy;verticalGroupBy;legendPosition;missingValueColor;constructor(e,t,n){super(e,t,n),this.dataSets=od(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=nl(n,t,e.labelRange),this.background=e.background,this.showValues=e.showValues,this.colorScale=e.colorScale,this.axesDesign=e.axesDesign,this.horizontalGroupBy=e.horizontalGroupBy,this.verticalGroupBy=e.verticalGroupBy,this.legendPosition=e.legendPosition,this.missingValueColor=e.missingValueColor}static transformDefinition(e,t,n){return ud(e,t,n)}static validateChartDefinition(e,t){return e.checkValidations(t,pd,md,VZ)}static getDefinitionFromContextCreation(e){let t=`left`;return e.legendPosition===`right`&&(t=`right`),{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,title:e.title||{text:``},type:`calendar`,labelRange:e.auxiliaryRange||void 0,showValues:e.showValues,axesDesign:e.axesDesign,legendPosition:t,horizontalGroupBy:`day_of_week`,verticalGroupBy:`month_number`}}getContextCreation(){let e=[{dataRange:this.getters.getRangeString(this.dataSets[0].dataRange,this.sheetId)}];return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(t){let n=rd(this.sheetId,t,this.dataSets),r=id(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){let r=e.map(e=>({dataRange:this.getters.getRangeString(e.dataRange,n||this.sheetId)}));return{type:`calendar`,background:this.background,dataSets:r,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,showValues:this.showValues,colorScale:this.colorScale,axesDesign:this.axesDesign,horizontalGroupBy:this.horizontalGroupBy,verticalGroupBy:this.verticalGroupBy,legendPosition:this.legendPosition,missingValueColor:this.missingValueColor}}getDefinitionForExcel(){}updateRanges({applyChange:t}){let{dataSets:n,labelRange:r,isStale:i}=nd(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function UZ(e,t){let n=e.getDefinition(),r=Xh(n,e.dataSets,e.labelRange,t),{labels:i,datasets:a}=nf(n,r);return{chartJsConfig:{type:`calendar`,data:{labels:i,datasets:a},options:{...Jp,indexAxis:`x`,layout:Pg(n,r),scales:zd(n,a),plugins:{title:$g(n,t),legend:{display:!1},tooltip:i_(n,r),chartShowValuesPlugin:Jg(n,r),chartColorScalePlugin:Bd(n,r),background:{color:e.background}}}}}}var WZ=class e extends Ff{dataSets;labelRange;background;legendPosition;aggregated;dataSetsHaveTitle;dataSetDesign;axesDesign;type=`combo`;showValues;hideDataMarkers;zoomable;constructor(e,t,n){super(e,t,n),this.dataSets=od(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=nl(n,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.showValues=e.showValues,this.hideDataMarkers=e.hideDataMarkers,this.zoomable=e.zoomable}static transformDefinition(e,t,n){return ud(e,t,n)}static validateChartDefinition(e,t){return e.checkValidations(t,pd,md)}getContextCreation(){let e=[];for(let[t,n]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(n.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){let r=[];for(let[t,i]of e.entries())r.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,n||this.sheetId),type:this.dataSetDesign?.[t]?.type??(t?`line`:`bar`)});return{type:`combo`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:r,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,aggregated:this.aggregated,axesDesign:this.axesDesign,showValues:this.showValues,hideDataMarkers:this.hideDataMarkers,zoomable:this.zoomable,humanize:this.humanize}}getDefinitionForExcel(){let{dataSets:e,labelRange:t}=this.getCommonDataSetAttributesForExcel(this.labelRange,this.dataSets,hd(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle)),n=this.getDefinition();return{...n,backgroundColor:V(this.background||`#FFFFFF`),fontColor:V(dd(this.background)),dataSets:e,labelRange:t,verticalAxis:_d(n)}}updateRanges({applyChange:t}){let{dataSets:n,labelRange:r,isStale:i}=nd(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}static getDefinitionFromContextCreation(e){let t=(e.range??[]).map((e,t)=>({...e,type:t?`line`:`bar`}));return{background:e.background,dataSets:t,dataSetsHaveTitle:e.dataSetsHaveTitle??!1,aggregated:e.aggregated,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},labelRange:e.auxiliaryRange||void 0,type:`combo`,axesDesign:e.axesDesign,showValues:e.showValues,hideDataMarkers:e.hideDataMarkers,zoomable:e.zoomable,humanize:e.humanize}}duplicateInDuplicatedSheet(t){let n=rd(this.sheetId,t,this.dataSets),r=id(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}};function GZ(e,t){let n=e.getDefinition(),r=qh(n,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:`bar`,data:{labels:r.labels,datasets:cf(n,r)},options:{...Jp,layout:Ng(n,r),scales:Rd(n,r),plugins:{title:$g(n,t),legend:Bg(n,r),tooltip:r_(n,r),chartShowValuesPlugin:qg(n,r),background:{color:e.background}}}}}}var KZ=class e extends Ff{dataSets;labelRange;background;legendPosition;aggregated;type=`funnel`;dataSetsHaveTitle;dataSetDesign;axesDesign;horizontal=!0;showValues;funnelColors;cumulative;constructor(e,t,n){super(e,t,n),this.dataSets=od(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=nl(n,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.showValues=e.showValues,this.horizontal=!0,this.funnelColors=e.funnelColors,this.cumulative=e.cumulative}static transformDefinition(e,t,n){return ud(e,t,n)}static validateChartDefinition(e,t){return e.checkValidations(t,pd,md)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,aggregated:e.aggregated??!1,legendPosition:`none`,title:e.title||{text:``},type:`funnel`,labelRange:e.auxiliaryRange||void 0,showValues:e.showValues,axesDesign:e.axesDesign,funnelColors:e.funnelColors,horizontal:!0,cumulative:e.cumulative,humanize:e.humanize}}getContextCreation(){let e=[];for(let[t,n]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(n.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(t){let n=rd(this.sheetId,t,this.dataSets),r=id(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){let r=[];for(let[t,i]of e.entries())r.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,n||this.sheetId)});return{type:`funnel`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:r,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,aggregated:this.aggregated,horizontal:this.horizontal,axesDesign:this.axesDesign,showValues:this.showValues,funnelColors:this.funnelColors,cumulative:this.cumulative,humanize:this.humanize}}getDefinitionForExcel(){}updateRanges({applyChange:t}){let{dataSets:n,labelRange:r,isStale:i}=nd(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function qZ(e,t){let n=e.getDefinition(),r=ng(n,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:`funnel`,data:{labels:r.labels,datasets:df(n,r)},options:{...Jp,indexAxis:`y`,layout:Ng(n,r),scales:qd(n,r),plugins:{title:$g(n,t),legend:{display:!1},tooltip:d_(n,r),chartShowValuesPlugin:qg(n,r),background:{color:e.background}}}}}}var JZ=class e extends Ff{dataSets;labelRange;background;legendPosition;type=`geo`;dataSetsHaveTitle;dataSetDesign;colorScale;missingValueColor;region;constructor(e,t,n){super(e,t,n),this.dataSets=od(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=nl(n,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.colorScale=e.colorScale,this.missingValueColor=e.missingValueColor,this.region=e.region}static transformDefinition(e,t,n){return ud(e,t,n)}static validateChartDefinition(e,t){return e.checkValidations(t,pd,md)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`geo`,labelRange:e.auxiliaryRange||void 0,humanize:e.humanize}}getContextCreation(){let e=[];for(let[t,n]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(n.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(t){let n=rd(this.sheetId,t,this.dataSets),r=id(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){let r=[];for(let[t,i]of e.entries())r.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,n||this.sheetId)});return{type:`geo`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:r,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,colorScale:this.colorScale,missingValueColor:this.missingValueColor,region:this.region,humanize:this.humanize}}getDefinitionForExcel(){}updateRanges({applyChange:t}){let{dataSets:n,labelRange:r,isStale:i}=nd(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function YZ(e,t){let n=e.getDefinition(),r=tg(n,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:`choropleth`,data:{datasets:uf(n,r)},options:{...Jp,layout:Ng(n,r),scales:Kd(n,r),plugins:{title:$g(n,t),tooltip:u_(n,r),legend:{display:!1},background:{color:e.background}}}}}}var XZ=class e extends Ff{dataSets;labelRange;background;legendPosition;aggregated;type=`pyramid`;dataSetsHaveTitle;dataSetDesign;axesDesign;horizontal=!0;stacked=!0;showValues;constructor(e,t,n){super(e,t,n),this.dataSets=od(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=nl(n,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.showValues=e.showValues}static transformDefinition(e,t,n){return ud(e,t,n)}static validateChartDefinition(e,t){return e.checkValidations(t,pd,md)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,aggregated:e.aggregated??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`pyramid`,labelRange:e.auxiliaryRange||void 0,axesDesign:e.axesDesign,horizontal:!0,stacked:!0,showValues:e.showValues,humanize:e.humanize}}getContextCreation(){let e=[];for(let[t,n]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(n.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(t){let n=rd(this.sheetId,t,this.dataSets),r=id(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){let r=[];for(let[t,i]of e.entries())r.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,n||this.sheetId)});return{type:`pyramid`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:r,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,aggregated:this.aggregated,axesDesign:this.axesDesign,horizontal:!0,stacked:!0,showValues:this.showValues,humanize:this.humanize}}getDefinitionForExcel(e){let{dataSets:t,labelRange:n}=this.getCommonDataSetAttributesForExcel(this.labelRange,this.dataSets,hd(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle)),r=this.getDefinition(),{dataSetsValues:i}=Zh(r,this.dataSets,this.labelRange,e),a=Math.max(...i.map(e=>Math.max(...e.data.map(Math.abs))));return{...r,horizontal:!0,backgroundColor:V(this.background||`#FFFFFF`),fontColor:V(dd(this.background)),dataSets:t,labelRange:n,verticalAxis:_d(r),maxValue:a}}updateRanges({applyChange:t}){let{dataSets:n,labelRange:r,isStale:i}=nd(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function ZZ(e,t){let n=e.getDefinition(),r=Zh(n,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:`bar`,data:{labels:r.labels,datasets:tf(n,r)},options:{...Jp,indexAxis:`y`,layout:Ng(n,r),scales:Wd(n,r),plugins:{title:$g(n,t),legend:Ig(n,r),tooltip:c_(n,r),chartShowValuesPlugin:Xg(n,r),background:{color:e.background}}}}}}var QZ=class e extends Ff{dataSets;labelRange;background;legendPosition;stacked;aggregated;type=`radar`;dataSetsHaveTitle;dataSetDesign;fillArea;showValues;hideDataMarkers;constructor(e,t,n){super(e,t,n),this.dataSets=od(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=nl(n,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.fillArea=e.fillArea,this.showValues=e.showValues,this.hideDataMarkers=e.hideDataMarkers}static transformDefinition(e,t,n){return ud(e,t,n)}static validateChartDefinition(e,t){return e.checkValidations(t,pd,md)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,stacked:e.stacked??!1,aggregated:e.aggregated??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`radar`,labelRange:e.auxiliaryRange||void 0,fillArea:e.fillArea??!1,showValues:e.showValues??!1,hideDataMarkers:e.hideDataMarkers,humanize:e.humanize}}getContextCreation(){let e=[];for(let[t,n]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(n.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(t){let n=rd(this.sheetId,t,this.dataSets),r=id(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){let r=[];for(let[t,i]of e.entries())r.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,n||this.sheetId)});return{type:`radar`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:r,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated,fillArea:this.fillArea,showValues:this.showValues,hideDataMarkers:this.hideDataMarkers,humanize:this.humanize}}getDefinitionForExcel(){let{dataSets:e,labelRange:t}=this.getCommonDataSetAttributesForExcel(this.labelRange,this.dataSets,hd(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:V(this.background||`#FFFFFF`),fontColor:V(dd(this.background)),dataSets:e,labelRange:t}}updateRanges({applyChange:t}){let{dataSets:n,labelRange:r,isStale:i}=nd(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function $Z(e,t){let n=e.getDefinition(),r=eg(n,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:`radar`,data:{labels:r.labels,datasets:lf(n,r)},options:{...Jp,layout:Ng(n,r),scales:Gd(n,r),plugins:{title:$g(n,t),legend:Hg(n,r),tooltip:l_(n,r),chartShowValuesPlugin:qg(n,r),background:{color:e.background}}}}}}var eQ=class e extends Ff{dataSets;labelRange;background;legendPosition;type=`sunburst`;dataSetsHaveTitle;showValues;showLabels;valuesDesign;groupColors;pieHolePercentage;constructor(e,t,n){super(e,t,n),this.dataSets=od(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=nl(n,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.showValues=e.showValues,this.showLabels=e.showLabels,this.valuesDesign=e.valuesDesign,this.groupColors=e.groupColors,this.pieHolePercentage=e.pieHolePercentage}static transformDefinition(e,t,n){return ud(e,t,n)}static validateChartDefinition(e,t){return e.checkValidations(t,pd,md)}static getDefinitionFromContextCreation(e){let t=[];return e.hierarchicalRanges?.length?t.push(...e.hierarchicalRanges):e.auxiliaryRange&&t.push({...e.range?.[0],dataRange:e.auxiliaryRange}),{background:e.background,dataSets:t,dataSetsHaveTitle:e.dataSetsHaveTitle??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`sunburst`,labelRange:e.range?.[0]?.dataRange,showValues:e.showValues,showLabels:e.showLabels,valuesDesign:e.valuesDesign,groupColors:e.groupColors,humanize:e.humanize}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){let e=this.dataSets.at(-1)?.dataRange;return{...this,range:this.labelRange?[{dataRange:this.getters.getRangeString(this.labelRange,this.sheetId)}]:[],auxiliaryRange:e?this.getters.getRangeString(e,this.sheetId):void 0,hierarchicalRanges:this.dataSets.map(e=>({dataRange:this.getters.getRangeString(e.dataRange,this.sheetId)}))}}getDefinitionWithSpecificDataSets(e,t,n){return{type:`sunburst`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:e.map(e=>({dataRange:this.getters.getRangeString(e.dataRange,n||this.sheetId)})),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,showValues:this.showValues,showLabels:this.showLabels,valuesDesign:this.valuesDesign,groupColors:this.groupColors,pieHolePercentage:this.pieHolePercentage,humanize:this.humanize}}duplicateInDuplicatedSheet(t){let n=rd(this.sheetId,t,this.dataSets),r=id(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinitionForExcel(){}updateRanges({applyChange:t}){let{dataSets:n,labelRange:r,isStale:i}=nd(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function tQ(e,t){let n=e.getDefinition(),r=rg(n,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:`doughnut`,data:{datasets:pf(n,r)},options:{cutout:e.pieHolePercentage===void 0?`25%`:`${e.pieHolePercentage}%`,...Jp,layout:Ng(n,r),plugins:{title:$g(n,t),legend:Ug(n,r),tooltip:f_(n,r),sunburstLabelsPlugin:Yg(n,r),sunburstHoverPlugin:{enabled:!0},background:{color:e.background}}}}}}var nQ=class e extends Ff{static defaults={background:oe,legendPosition:`top`,dataSetsHaveTitle:!1,showHeaders:!0,headersColor:`#000000`};dataSets;labelRange;background;legendPosition;type=`treemap`;dataSetsHaveTitle;showHeaders;headerDesign;showValues;showLabels;valuesDesign;coloringOptions;constructor(e,t,n){super(e,t,n),this.dataSets=od(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=nl(n,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.showHeaders=e.showHeaders,this.headerDesign=e.headerDesign,this.showValues=e.showValues,this.showLabels=e.showLabels,this.valuesDesign=e.valuesDesign,this.coloringOptions=e.coloringOptions}static transformDefinition(e,t,n){return ud(e,t,n)}static validateChartDefinition(e,t){return e.checkValidations(t,pd,md)}static getDefinitionFromContextCreation(e){let t=[];return e.hierarchicalRanges?.length?t.push(...e.hierarchicalRanges):e.auxiliaryRange&&t.push({...e.range?.[0],dataRange:e.auxiliaryRange}),{background:e.background,dataSets:t,dataSetsHaveTitle:e.dataSetsHaveTitle??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`treemap`,labelRange:e.range?.[0]?.dataRange,showValues:e.showValues,showHeaders:e.showHeaders,headerDesign:e.headerDesign,showLabels:e.showLabels,valuesDesign:e.valuesDesign,coloringOptions:e.treemapColoringOptions,humanize:e.humanize}}getContextCreation(){let e=this.dataSets.at(-1)?.dataRange;return{...this,range:this.labelRange?[{dataRange:this.getters.getRangeString(this.labelRange,this.sheetId)}]:[],auxiliaryRange:e?this.getters.getRangeString(e,this.sheetId):void 0,hierarchicalRanges:this.dataSets.map(e=>({dataRange:this.getters.getRangeString(e.dataRange,this.sheetId)}))}}duplicateInDuplicatedSheet(t){let n=rd(this.sheetId,t,this.dataSets),r=id(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){let r=e.map(e=>({dataRange:this.getters.getRangeString(e.dataRange,n||this.sheetId)}));return{type:`treemap`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:r,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,showValues:this.showValues,showHeaders:this.showHeaders,headerDesign:this.headerDesign,showLabels:this.showLabels,valuesDesign:this.valuesDesign,coloringOptions:this.coloringOptions,humanize:this.humanize}}getDefinitionForExcel(){}updateRanges({applyChange:t}){let{dataSets:n,labelRange:r,isStale:i}=nd(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function rQ(e,t){let n=e.getDefinition(),r=rg(n,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:`treemap`,data:{labels:r.labels,datasets:vf(n,r)},options:{...Jp,layout:Ng(n,r),plugins:{title:$g(n,t),legend:{display:!1},tooltip:p_(n,r),background:{color:e.background}}}}}}b_.add(`bar`,{match:e=>e===`bar`,createChart:(e,t,n)=>new v_(e,t,n),getChartRuntime:y_,validateChartDefinition:v_.validateChartDefinition,transformDefinition:v_.transformDefinition,getChartDefinitionFromContextCreation:v_.getDefinitionFromContextCreation,sequence:10}),b_.add(`combo`,{match:e=>e===`combo`,createChart:(e,t,n)=>new WZ(e,t,n),getChartRuntime:GZ,validateChartDefinition:WZ.validateChartDefinition,transformDefinition:WZ.transformDefinition,getChartDefinitionFromContextCreation:WZ.getDefinitionFromContextCreation,sequence:15}),b_.add(`line`,{match:e=>e===`line`,createChart:(e,t,n)=>new L_(e,t,n),getChartRuntime:R_,validateChartDefinition:L_.validateChartDefinition,transformDefinition:L_.transformDefinition,getChartDefinitionFromContextCreation:L_.getDefinitionFromContextCreation,sequence:20}),b_.add(`pie`,{match:e=>e===`pie`,createChart:(e,t,n)=>new z_(e,t,n),getChartRuntime:B_,validateChartDefinition:z_.validateChartDefinition,transformDefinition:z_.transformDefinition,getChartDefinitionFromContextCreation:z_.getDefinitionFromContextCreation,sequence:30}),b_.add(`scorecard`,{match:e=>e===`scorecard`,createChart:(e,t,n)=>new Gf(e,t,n),getChartRuntime:qf,validateChartDefinition:Gf.validateChartDefinition,transformDefinition:Gf.transformDefinition,getChartDefinitionFromContextCreation:Gf.getDefinitionFromContextCreation,sequence:40}),b_.add(`gauge`,{match:e=>e===`gauge`,createChart:(e,t,n)=>new j_(e,t,n),getChartRuntime:M_,validateChartDefinition:j_.validateChartDefinition,transformDefinition:j_.transformDefinition,getChartDefinitionFromContextCreation:j_.getDefinitionFromContextCreation,sequence:50}),b_.add(`scatter`,{match:e=>e===`scatter`,createChart:(e,t,n)=>new fL(e,t,n),getChartRuntime:pL,validateChartDefinition:fL.validateChartDefinition,transformDefinition:fL.transformDefinition,getChartDefinitionFromContextCreation:fL.getDefinitionFromContextCreation,sequence:60}),b_.add(`waterfall`,{match:e=>e===`waterfall`,createChart:(e,t,n)=>new V_(e,t,n),getChartRuntime:H_,validateChartDefinition:V_.validateChartDefinition,transformDefinition:V_.transformDefinition,getChartDefinitionFromContextCreation:V_.getDefinitionFromContextCreation,sequence:70}),b_.add(`pyramid`,{match:e=>e===`pyramid`,createChart:(e,t,n)=>new XZ(e,t,n),getChartRuntime:ZZ,validateChartDefinition:XZ.validateChartDefinition,transformDefinition:XZ.transformDefinition,getChartDefinitionFromContextCreation:XZ.getDefinitionFromContextCreation,sequence:80,dataSeriesLimit:2}),b_.add(`radar`,{match:e=>e===`radar`,createChart:(e,t,n)=>new QZ(e,t,n),getChartRuntime:$Z,validateChartDefinition:QZ.validateChartDefinition,transformDefinition:QZ.transformDefinition,getChartDefinitionFromContextCreation:QZ.getDefinitionFromContextCreation,sequence:80}),b_.add(`geo`,{match:e=>e===`geo`,createChart:(e,t,n)=>new JZ(e,t,n),getChartRuntime:YZ,validateChartDefinition:JZ.validateChartDefinition,transformDefinition:JZ.transformDefinition,getChartDefinitionFromContextCreation:JZ.getDefinitionFromContextCreation,sequence:90,dataSeriesLimit:1}),b_.add(`funnel`,{match:e=>e===`funnel`,createChart:(e,t,n)=>new KZ(e,t,n),getChartRuntime:qZ,validateChartDefinition:KZ.validateChartDefinition,transformDefinition:KZ.transformDefinition,getChartDefinitionFromContextCreation:KZ.getDefinitionFromContextCreation,sequence:100,dataSeriesLimit:1}),b_.add(`sunburst`,{match:e=>e===`sunburst`,createChart:(e,t,n)=>new eQ(e,t,n),getChartRuntime:tQ,validateChartDefinition:eQ.validateChartDefinition,transformDefinition:eQ.transformDefinition,getChartDefinitionFromContextCreation:eQ.getDefinitionFromContextCreation,sequence:30}),b_.add(`treemap`,{match:e=>e===`treemap`,createChart:(e,t,n)=>new nQ(e,t,n),getChartRuntime:rQ,validateChartDefinition:nQ.validateChartDefinition,transformDefinition:nQ.transformDefinition,getChartDefinitionFromContextCreation:nQ.getDefinitionFromContextCreation,sequence:100}),b_.add(`calendar`,{match:e=>e===`calendar`,createChart:(e,t,n)=>new HZ(e,t,n),getChartRuntime:(e,t)=>UZ(e,t),validateChartDefinition:HZ.validateChartDefinition,transformDefinition:HZ.transformDefinition,getChartDefinitionFromContextCreation:HZ.getDefinitionFromContextCreation,sequence:110,dataSeriesLimit:1}),ev.add(`line`,{matcher:e=>e.type===`line`&&!e.stacked&&!e.fillArea,displayName:k(`Line`),chartType:`line`,chartSubtype:`line`,subtypeDefinition:{stacked:!1,fillArea:!1},category:`line`,preview:`o-spreadsheet-ChartPreview.LINE_CHART`}).add(`stacked_line`,{matcher:e=>e.type===`line`&&!e.fillArea&&!!e.stacked,displayName:k(`Stacked Line`),chartType:`line`,chartSubtype:`stacked_line`,subtypeDefinition:{stacked:!0,fillArea:!1},category:`line`,preview:`o-spreadsheet-ChartPreview.STACKED_LINE_CHART`}).add(`area`,{matcher:e=>e.type===`line`&&!e.stacked&&!!e.fillArea,displayName:k(`Area`),chartType:`line`,chartSubtype:`area`,subtypeDefinition:{stacked:!1,fillArea:!0},category:`area`,preview:`o-spreadsheet-ChartPreview.AREA_CHART`}).add(`stacked_area`,{matcher:e=>e.type===`line`&&e.stacked&&!!e.fillArea,displayName:k(`Stacked Area`),chartType:`line`,chartSubtype:`stacked_area`,subtypeDefinition:{stacked:!0,fillArea:!0},category:`area`,preview:`o-spreadsheet-ChartPreview.STACKED_AREA_CHART`}).add(`scatter`,{displayName:k(`Scatter`),chartType:`scatter`,chartSubtype:`scatter`,category:`misc`,preview:`o-spreadsheet-ChartPreview.SCATTER_CHART`}).add(`column`,{matcher:e=>e.type===`bar`&&!e.stacked&&!e.horizontal,displayName:k(`Column`),chartType:`bar`,chartSubtype:`column`,subtypeDefinition:{stacked:!1,horizontal:!1},category:`column`,preview:`o-spreadsheet-ChartPreview.COLUMN_CHART`}).add(`stacked_column`,{matcher:e=>e.type===`bar`&&e.stacked&&!e.horizontal,displayName:k(`Stacked Column`),chartType:`bar`,chartSubtype:`stacked_column`,subtypeDefinition:{stacked:!0,horizontal:!1},category:`column`,preview:`o-spreadsheet-ChartPreview.STACKED_COLUMN_CHART`}).add(`bar`,{matcher:e=>e.type===`bar`&&!e.stacked&&!!e.horizontal,displayName:k(`Bar`),chartType:`bar`,chartSubtype:`bar`,subtypeDefinition:{horizontal:!0,stacked:!1},category:`bar`,preview:`o-spreadsheet-ChartPreview.BAR_CHART`}).add(`stacked_bar`,{matcher:e=>e.type===`bar`&&e.stacked&&!!e.horizontal,displayName:k(`Stacked Bar`),chartType:`bar`,chartSubtype:`stacked_bar`,subtypeDefinition:{horizontal:!0,stacked:!0},category:`bar`,preview:`o-spreadsheet-ChartPreview.STACKED_BAR_CHART`}).add(`combo`,{displayName:k(`Combo`),chartSubtype:`combo`,chartType:`combo`,category:`line`,preview:`o-spreadsheet-ChartPreview.COMBO_CHART`}).add(`pie`,{matcher:e=>e.type===`pie`&&!e.isDoughnut,displayName:k(`Pie`),chartSubtype:`pie`,chartType:`pie`,subtypeDefinition:{isDoughnut:!1},category:`pie`,preview:`o-spreadsheet-ChartPreview.PIE_CHART`}).add(`doughnut`,{matcher:e=>e.type===`pie`&&!!e.isDoughnut,displayName:k(`Doughnut`),chartSubtype:`doughnut`,chartType:`pie`,subtypeDefinition:{isDoughnut:!0},category:`pie`,preview:`o-spreadsheet-ChartPreview.DOUGHNUT_CHART`}).add(`gauge`,{displayName:k(`Gauge`),chartSubtype:`gauge`,chartType:`gauge`,category:`misc`,preview:`o-spreadsheet-ChartPreview.GAUGE_CHART`}).add(`scorecard`,{displayName:k(`Scorecard`),chartSubtype:`scorecard`,chartType:`scorecard`,category:`misc`,preview:`o-spreadsheet-ChartPreview.SCORECARD_CHART`}).add(`waterfall`,{displayName:k(`Waterfall`),chartSubtype:`waterfall`,chartType:`waterfall`,category:`misc`,preview:`o-spreadsheet-ChartPreview.WATERFALL_CHART`}).add(`pyramid`,{displayName:k(`Population Pyramid`),chartSubtype:`pyramid`,chartType:`pyramid`,category:`misc`,preview:`o-spreadsheet-ChartPreview.POPULATION_PYRAMID_CHART`}).add(`radar`,{matcher:e=>e.type===`radar`&&!e.fillArea,displayName:k(`Radar`),chartSubtype:`radar`,chartType:`radar`,subtypeDefinition:{fillArea:!1},category:`misc`,preview:`o-spreadsheet-ChartPreview.RADAR_CHART`}).add(`filled_radar`,{matcher:e=>e.type===`radar`&&!!e.fillArea,displayName:k(`Filled Radar`),chartType:`radar`,chartSubtype:`filled_radar`,subtypeDefinition:{fillArea:!0},category:`misc`,preview:`o-spreadsheet-ChartPreview.FILLED_RADAR_CHART`}).add(`geo`,{displayName:k(`Geo Chart`),chartSubtype:`geo`,chartType:`geo`,category:`misc`,preview:`o-spreadsheet-ChartPreview.GEO_CHART`}).add(`funnel`,{displayName:k(`Funnel`),chartSubtype:`funnel`,chartType:`funnel`,category:`misc`,preview:`o-spreadsheet-ChartPreview.FUNNEL_CHART`}).add(`sunburst`,{matcher:e=>e.type===`sunburst`,displayName:k(`Sunburst`),chartSubtype:`sunburst`,chartType:`sunburst`,category:`hierarchical`,preview:`o-spreadsheet-ChartPreview.SUNBURST_CHART`}).add(`treemap`,{matcher:e=>e.type===`treemap`,displayName:k(`Tree Map`),chartType:`treemap`,chartSubtype:`treemap`,category:`hierarchical`,preview:`o-spreadsheet-ChartPreview.TREE_MAP_CHART`}).add(`calendar`,{displayName:k(`Calendar`),chartSubtype:`calendar`,chartType:`calendar`,category:`misc`,preview:`o-spreadsheet-ChartPreview.CALENDAR_CHART`});var iQ=class extends sK{queuedBordersToAdd={};copy(e){let t=e.sheetId;if(e.zones.length===0)return;let{rowsIndexes:n,columnsIndexes:r}=e,i=[];for(let e of n){let n=[];for(let i of r){let r={col:i,row:e,sheetId:t};n.push(this.getters.getCellBorder(r))}i.push(n)}return{borders:i}}paste(e,t,n){let r=e.sheetId;if(n.pasteOption===`asValue`)return;let i=e.zones;if(!n.isCutOperation)this.pasteFromCopy(r,i,t.borders);else{let{left:e,top:n}=i[0];this.pasteZone(r,e,n,t.borders)}this.executeQueuedChanges(r)}pasteZone(e,t,n,r){for(let[i,a]of r.entries())for(let[r,o]of a.entries()){let a={col:t+r,row:n+i,sheetId:e};this.pasteBorder(o,a)}}pasteBorder(e,t){let n={...this.getters.getCellBorder(t),...e},r=JSON.stringify(n);this.queuedBordersToAdd[r]||(this.queuedBordersToAdd[r]=[]),this.queuedBordersToAdd[r].push(E(t))}executeQueuedChanges(e){for(let t in this.queuedBordersToAdd){let n=this.queuedBordersToAdd[t],r=JSON.parse(t),i=nn(n,[]);this.dispatch(`SET_BORDERS_ON_TARGET`,{sheetId:e,target:i,border:r})}this.queuedBordersToAdd={}}},aQ=class extends oK{copy(e){}},oQ=class extends aQ{copy(e){let t=e.sheetId,n=this.getters.getFigure(t,e.figureId);if(!n)throw Error(`No figure for the given id: ${e.figureId}`);if(n.tag!==`carousel`)return;let r={...n},i=this.getters.getCarousel(e.figureId),a={};for(let e of i.items)if(e.type===`chart`){let n=this.getters.getChart(e.chartId);if(!n)throw Error(`No chart for the given id: ${e.chartId}`);a[e.chartId]=n.copyInSheetId(t)}return{figureId:e.figureId,copiedFigure:r,copiedCarousel:i,copiedCharts:a,copiedSheetId:t}}getPasteTarget(e){return{zones:[],figureId:new Xl().smallUuid(),sheetId:e}}paste(e,t,n){if(!e.figureId)return;let{zones:r,figureId:i}=e,a=e.sheetId,{width:o,height:s}=t.copiedFigure,c=this.getters.getMaxAnchorOffset(a,s,o),{left:l,top:u}=r[0],d={x:0,y:0};l>c.col&&(l=c.col,d.x=c.offset.x),u>c.row&&(u=c.row,d.y=c.offset.y),this.dispatch(`CREATE_CAROUSEL`,{figureId:i,sheetId:a,definition:{items:[]},col:l,row:u,offset:d,size:{height:s,width:o}});let f=new Xl,p=b(t.copiedCarousel.items);for(let e of p){if(e.type!==`chart`)continue;let n=t.copiedCharts[e.chartId],r=f.smallUuid(),o=n.copyInSheetId(a).getDefinition();this.dispatch(`CREATE_CHART`,{figureId:i,chartId:r,sheetId:a,definition:o}),e.chartId=r}this.dispatch(`UPDATE_CAROUSEL`,{sheetId:a,figureId:i,definition:{...t.copiedCarousel,items:p}}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:t.copiedSheetId,figureId:t.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:i})}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},sQ=class extends aQ{copy(e){let t=e.sheetId,n=this.getters.getFigure(t,e.figureId);if(!n)throw Error(`No figure for the given id: ${e.figureId}`);if(n.tag!==`chart`)return;let r={...n},i=this.getters.getChartFromFigureId(e.figureId);if(!i)throw Error(`No chart for the given id: ${e.figureId}`);let a=i.copyInSheetId(t);return{figureId:e.figureId,copiedFigure:r,copiedChart:a}}getPasteTarget(e,t,n,r){return{zones:[],figureId:new Xl().smallUuid(),sheetId:e}}paste(e,t,n){if(!e.figureId)return;let{zones:r,figureId:i}=e,a=e.sheetId,{width:o,height:s}=t.copiedFigure,c=t.copiedChart.copyInSheetId(a),l=this.getters.getMaxAnchorOffset(a,s,o),{left:u,top:d}=r[0],f={x:0,y:0};u>l.col&&(u=l.col,f.x=l.offset.x),d>l.row&&(d=l.row,f.y=l.offset.y),this.dispatch(`CREATE_CHART`,{figureId:i,chartId:new Xl().smallUuid(),sheetId:a,definition:c.getDefinition(),col:u,row:d,offset:f,size:{height:s,width:o}}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:t.copiedChart.sheetId,figureId:t.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:i})}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},cQ=class extends sK{uuidGenerator=new Xl;queuedChanges={};copy(e){if(!e.zones.length)return;let{rowsIndexes:t,columnsIndexes:n}=e,r=e.sheetId,i=[];for(let e of t){let t=[];for(let i of n){let n=Array.from(this.getters.getRulesByCell(r,i,e));t.push({position:{col:i,row:e,sheetId:r},rules:n})}i.push(t)}return{cfRules:i}}paste(e,t,n){if(this.queuedChanges={},n.pasteOption===`asValue`)return;let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t):this.pasteFromCopy(i,r,t.cfRules,n),this.executeQueuedChanges()}pasteFromCut(e,t,n){let r=t[0];this.pasteZone(e,r.left,r.top,n.cfRules,{isCutOperation:!0})}pasteZone(e,t,n,r,i){for(let[a,o]of r.entries())for(let[r,s]of o.entries()){let o={col:t+r,row:n+a,sheetId:e};this.pasteCf(s,o,i?.isCutOperation)}}pasteCf(e,t,n){if(e?.rules&&e.rules.length>0){let r=E(e.position),i=E(t);for(let a of e.rules){let o=[];if(n&&o.push(r),e.position.sheetId===t.sheetId)this.adaptCFRules(e.position.sheetId,a,[i],o);else{this.adaptCFRules(e.position.sheetId,a,[],o);let n=this.getCFToCopyTo(t.sheetId,a);this.adaptCFRules(t.sheetId,n,[i],[])}}}}adaptCFRules(e,t,n,r){this.queuedChanges[e]||(this.queuedChanges[e]=[]);let i=this.queuedChanges[e].find(e=>e.cf.id===t.id);i?(i.toAdd.push(...n),i.toRemove.push(...r)):this.queuedChanges[e].push({toAdd:n,toRemove:r,cf:t})}executeQueuedChanges(){for(let e in this.queuedChanges)for(let{toAdd:t,toRemove:n,cf:r}of this.queuedChanges[e]){let i=this.getters.getAdaptedCfRanges(e,r,t,n);if(i){if(i.length===0){this.dispatch(`REMOVE_CONDITIONAL_FORMAT`,{id:r.id,sheetId:e});continue}this.dispatch(`ADD_CONDITIONAL_FORMAT`,{cf:{id:r.id,rule:r.rule,stopIfTrue:r.stopIfTrue},ranges:i,sheetId:e})}}}getCFToCopyTo(e,t){let n=this.getters.getConditionalFormats(e).find(e=>e.stopIfTrue===t.stopIfTrue&&w(e.rule,t.rule)),r=this.queuedChanges[e];return!n&&r&&(n=r.find(e=>e.cf.stopIfTrue===t.stopIfTrue&&w(e.cf.rule,t.rule))?.cf),n||{...t,id:this.uuidGenerator.smallUuid(),ranges:[]}}},lQ=class extends sK{uuidGenerator=new Xl;queuedChanges={};copy(e){let{rowsIndexes:t,columnsIndexes:n}=e,r=e.sheetId,i=[];for(let e of t){let t=[];for(let i of n){let n={sheetId:r,col:i,row:e},a=this.getters.getValidationRuleForCell(n);t.push({position:n,rule:a})}i.push(t)}return{dvRules:i}}paste(e,t,n){if(this.queuedChanges={},n.pasteOption)return;let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t):this.pasteFromCopy(i,r,t.dvRules),this.executeQueuedChanges()}pasteFromCut(e,t,n){let r=t[0];this.pasteZone(e,r.left,r.top,n.dvRules,{isCutOperation:!0})}pasteZone(e,t,n,r,i){for(let[a,o]of r.entries())for(let[r,s]of o.entries()){let o={col:t+r,row:n+a,sheetId:e};this.pasteDataValidation(s,o,i?.isCutOperation)}}pasteDataValidation(e,t,n){if(e){let r=E(t),i=E(e.position),a=e.rule;if(!a){let e=this.getters.getValidationRuleForCell(t);e&&this.adaptDataValidationRule(t.sheetId,e,[],[r]);return}let o=[];if(n&&o.push(i),e.position.sheetId===t.sheetId){let n=this.getDataValidationRuleToCopyTo(t.sheetId,a,!1);this.adaptDataValidationRule(e.position.sheetId,n,[r],o)}else{let n=this.getters.getValidationRuleForCell(e.position);n&&this.adaptDataValidationRule(e.position.sheetId,n,[],o);let i=this.getDataValidationRuleToCopyTo(t.sheetId,a);this.adaptDataValidationRule(t.sheetId,i,[r],[])}}}getDataValidationRuleToCopyTo(e,t,n=!0){let r=this.getters.getDataValidationRules(e).find(e=>w(t.criterion,e.criterion)&&t.isBlocking===e.isBlocking),i=this.queuedChanges[e];return!r&&i&&(r=i.find(e=>w(t.criterion,e.rule.criterion)&&t.isBlocking===e.rule.isBlocking)?.rule),r||{...t,id:n?this.uuidGenerator.smallUuid():t.id,ranges:[]}}adaptDataValidationRule(e,t,n,r){this.queuedChanges[e]||(this.queuedChanges[e]=[]);let i=this.queuedChanges[e].find(e=>e.rule.id===t.id);i?(i.toAdd.push(...n),i.toRemove.push(...r)):this.queuedChanges[e].push({toAdd:n,toRemove:r,rule:t})}executeQueuedChanges(){for(let e in this.queuedChanges)for(let{toAdd:t,toRemove:n,rule:r}of this.queuedChanges[e]){let i=nn([...nn(r.ranges.map(e=>e.zone),n),...t],[]);if(i.length===0){this.dispatch(`REMOVE_DATA_VALIDATION_RULE`,{sheetId:e,id:r.id});continue}this.dispatch(`ADD_DATA_VALIDATION_RULE`,{rule:{id:r.id,criterion:r.criterion,isBlocking:r.isBlocking},ranges:i.map(t=>this.getters.getRangeDataFromZone(e,t)),sheetId:e})}}},uQ=class extends aQ{copy(e){let t=e.sheetId,n=this.getters.getFigure(t,e.figureId);if(!n)throw Error(`No figure for the given id: ${e.figureId}`);let r={...n};if(n.tag!==`image`)return;let i=b(this.getters.getImage(e.figureId));return{figureId:e.figureId,copiedFigure:r,copiedImage:i,sheetId:t}}getPasteTarget(e,t,n,r){return{sheetId:e,zones:[],figureId:new Xl().smallUuid()}}paste(e,t,n){if(!e.figureId)return;let{zones:r,figureId:i}=e,a=this.getters.getActiveSheetId(),{width:o,height:s}=t.copiedFigure,c=b(t.copiedImage),l=this.getters.getMaxAnchorOffset(a,s,o),{left:u,top:d}=r[0],f={x:0,y:0};u>l.col&&(u=l.col,f.x=l.offset.x),d>l.row&&(d=l.row,f.y=l.offset.y),this.dispatch(`CREATE_IMAGE`,{figureId:i,sheetId:a,col:u,row:d,offset:f,size:{height:s,width:o},definition:c}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:t.sheetId,figureId:t.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:i})}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},dQ=class extends sK{copy(e){let t=this.getters.getActiveSheetId(),{rowsIndexes:n,columnsIndexes:r}=e,i=[];for(let e of n){let n=[];for(let i of r){let r={col:i,row:e,sheetId:t};n.push(this.getters.getMerge(r))}i.push(n)}return{merges:i,sheetId:t}}paste(e,t,n){if(n.isCutOperation){let e=t.merges.flat().filter(C);this.dispatch(`REMOVE_MERGE`,{sheetId:t.sheetId,target:e})}this.pasteFromCopy(e.sheetId,e.zones,t.merges,n)}pasteZone(e,t,n,r){for(let[i,a]of r.entries())for(let[r,o]of a.entries()){let a={col:t+r,row:n+i,sheetId:e};this.pasteMerge(o,a)}}pasteMerge(e,t){if(!e||this.getters.isInMerge(t))return;let{sheetId:n,col:r,row:i}=t;this.dispatch(`ADD_MERGE`,{sheetId:n,force:!0,target:[{left:r,top:i,right:r+e.right-e.left,bottom:i+e.bottom-e.top}]})}},fQ=class extends sK{copy(e){return{zones:e.clippedZones,sheetId:e.sheetId}}paste(e,t,n){if(n.isCutOperation){let n=e.zones[0];this.dispatch(`MOVE_RANGES`,{target:t.zones,sheetId:t.sheetId,sheetName:this.getters.getSheetName(t.sheetId),targetSheetId:e.sheetId,col:n.left,row:n.top})}}},pQ=class extends sK{isPasteAllowed(e,t,n,r){if(!(`cells`in n))return`Success`;let{xSplit:i,ySplit:a}=this.getters.getPaneDivisions(e);return qn(EP(t,n.cells),i,a)?`FrozenPaneOverlap`:`Success`}},mQ=class extends sK{copy(e,t,n=`copyPaste`){let r=e.sheetId,{rowsIndexes:i,columnsIndexes:a,zones:o}=e,s=new Set,c=[];for(let e of i){let l=[];c.push(l);for(let c of a){let a={col:c,row:e,sheetId:r},u=this.getters.getTable(a);if(!u){l.push({});continue}let d=this.getters.getCoreTable(a),f=d?.range.zone,p;if(!s.has(u.id)&&d&&f&&o.some(e=>jn(f,e))){s.add(u.id);let{numberOfRows:e}=Mn(f);for(let n=f.top;n<=f.bottom;n++)!t&&!i.includes(n)&&e--;let n=d.range,r=this.getters.extendRange(d.range,`ROW`,n.zone.top+e-1-n.zone.bottom);p={range:this.getters.getRangeData(r),config:d.config,type:d.type}}if(u.isPivotTable){let t=u.range.zone.top===e&&u.range.zone.left===c,n=o.some(e=>jn(u.range.zone,e));(t||n)&&s.add(u.id)}n!==`shiftCells`&&l.push({table:p,style:this.getTableStyleToCopy(a),isWholeTableCopied:s.has(u.id)})}}return{tableCells:c,sheetId:e.sheetId}}getTableStyleToCopy(e){let t=Ct({...this.getters.getCellTableStyle(e),hideGridLines:!1}),n=this.getters.getCellStyle(e),r=this.getters.getCellTableBorder(e),i=this.getters.getCellBorder(e);return{style:{...t,...Ct(n)},border:{...r,...Ct(i)}}}paste(e,t,n){let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t,n):this.pasteFromCopy(i,r,t.tableCells,n)}pasteFromCut(e,t,n,r){for(let e of n.tableCells)for(let t of e)t.table&&this.dispatch(`REMOVE_TABLE`,{sheetId:n.sheetId,target:[this.getters.getRangeFromRangeData(t.table.range).zone]});let i=t[0];this.pasteZone(e,i.left,i.top,n.tableCells,r)}pasteZone(e,t,n,r,i){for(let a=0;a<r.length;a++){let o=r[a];for(let r=0;r<o.length;r++){let s=o[r];if(!s)continue;let c={col:t+r,row:n+a,sheetId:e};this.pasteTableCell(e,s,c,i)}}if(r.length===1)for(let i=0;i<r[0].length;i++)this.dispatch(`AUTOFILL_TABLE_COLUMN`,{col:t+i,row:n,sheetId:e})}pasteTableCell(e,t,n,r){if(t.table&&!r?.pasteOption){let{range:r}=t.table,i=Mn(this.getters.getRangeFromRangeData(r).zone),a={left:n.col,top:n.row,right:n.col+i.numberOfCols-1,bottom:n.row+i.numberOfRows-1};this.dispatch(`CREATE_TABLE`,{sheetId:n.sheetId,ranges:[this.getters.getRangeDataFromZone(e,a)],config:t.table.config,tableType:t.table.type})}this.getters.getCoreTable(n)||r?.pasteOption===`asValue`||(!r?.pasteOption&&!t.isWholeTableCopied||r?.pasteOption===`onlyFormat`)&&(t.style?.style&&this.dispatch(`UPDATE_CELL`,{...n,style:t.style.style}),t.style?.border&&this.dispatch(`SET_BORDER`,{...n,border:t.style.border}))}};oW.figureHandlers.add(`chart`,sQ).add(`image`,uQ).add(`carousel`,oQ),oW.cellHandlers.add(`dataValidation`,lQ).add(`cell`,cK).add(`sheet`,pQ).add(`merge`,dQ).add(`border`,iQ).add(`table`,mQ).add(`conditionalFormat`,cQ).add(`references`,fQ);let hQ={},gQ={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:26,HEADER_WIDTH:48,DESKTOP_BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:96,DEFAULT_CELL_HEIGHT:23,SCROLLBAR_WIDTH:15},_Q={autoCompleteProviders:EN,autofillModifiersRegistry:dK,autofillRulesRegistry:fK,cellMenuRegistry:ZH,colMenuRegistry:lU,errorTypes:ha,linkMenuRegistry:xP,functionRegistry:fO,featurePluginRegistry:Jq,iconsOnCellRegistry:VG,statefulUIPluginRegistry:Yq,coreViewsPluginRegistry:Xq,corePluginRegistry:qq,rowMenuRegistry:gU,sidePanelRegistry:bV,figureRegistry:Bv,chartSidePanelComponentRegistry:wL,chartComponentRegistry:yv,chartRegistry:b_,chartSubtypeRegistry:ev,topbarMenuRegistry:kJ,topbarComponentRegistry:YJ,clickableCellRegistry:rJ,otRegistry:jK,inverseCommandRegistry:oJ,urlRegistry:$s,cellPopoverRegistry:xM,numberFormatMenuRegistry:wJ,repeatLocalCommandTransformRegistry:Sq,repeatCommandTransformRegistry:xq,clipboardHandlersRegistries:oW,pivotRegistry:fB,pivotTimeAdapterRegistry:Zm,pivotSidePanelRegistry:DB,pivotNormalizationValueRegistry:kh,supportedPivotPositionalFormulaRegistry:RW,pivotToFunctionValueRegistry:Ah,migrationStepRegistry:qj,chartJsExtensionRegistry:Zl},vQ={arg:W,isEvaluationError:M,toBoolean:F,toJsDate:I,toNumber:N,toString:P,toNormalizedPivotValue:Th,toFunctionPivotValue:Dh,toXC:T,toZone:mn,toUnboundedZone:pn,toCartesian:tn,numberToLetters:Kt,lettersToNumber:qt,UuidGenerator:Xl,formatValue:z,createCurrencyFormat:ps,ColorGenerator:ii,computeTextWidth:Ml,createEmptyWorkbookData:pM,createEmptySheet:fM,createEmptyExcelSheet:mM,rgbaToHex:Fr,colorToRGBA:Ir,positionToZone:E,isDefined:C,isMatrix:Ta,lazy:_t,genericRepeat:JJ,createAction:h,createActions:p,transformRangeData:rr,deepEquals:w,overlap:On,union:wn,isInside:An,deepCopy:b,expandZoneOnInsertion:bn,reduceZoneOnDeletion:Cn,unquote:Xe,getMaxObjectId:_h,getFirstPivotFunction:_B,getNumberOfPivotFunctions:yB,parseDimension:bh,isDateOrDatetimeField:xh,makeFieldProposal:bB,periodYearToComparable:Xm,insertTokenAfterArgSeparator:SB,insertTokenAfterLeftParenthesis:CB,mergeContiguousZones:er,getPivotHighlights:nz,pivotTimeAdapter:Qm,UNDO_REDO_PIVOT_COMMANDS:rK,createPivotFormula:wh,areDomainArgsFieldsValid:Ch,splitReference:zc,sanitizeSheetName:Qe,getUniqueText:Ht,isNumber:ra,isDateTime:Ti,createCustomFields:Ih,schemeToColorScale:Bm,isDateTimeFormat:os,jsDateToNumber:zi,numberToJsDate:Li,DateTime:O,parseFormat:Ao,isFormula:Ut,domainToColRowDomain:Lz,PositionMap:wV},yQ={isMarkdownLink:it,parseMarkdownLink:st,markdownLink:ot,openLink:ic,urlRepresentation:rc},bQ={Checkbox:nP,Section:Q,Select:OM,RoundColorPicker:HN,ChartDataSeries:DI,ChartErrorSection:kI,ChartLabelRange:AI,ChartTitle:PI,ChartPanel:OL,ChartFigure:Rv,ChartJsComponent:Pf,ClickableCellSortIcon:zW,ZoomableChartJsComponent:dv,Grid:LW,GridOverlay:fW,ScorecardChart:Ap,GaugeChartComponent:_v,LineConfigPanel:sL,BarConfigPanel:MI,PieChartDesignPanel:uL,GenericChartConfigPanel:jI,ChartWithAxisDesignPanel:WI,GenericZoomableChartDesignPanel:GI,LineChartDesignPanel:cL,GaugeChartConfigPanel:tL,GaugeChartDesignPanel:nL,ScorecardChartConfigPanel:hL,ScorecardChartDesignPanel:gL,GeoChartDesignPanel:aL,RadarChartDesignPanel:dL,WaterfallChartDesignPanel:CL,ComboChartDesignPanel:QI,FunnelChartDesignPanel:eL,SunburstChartDesignPanel:_L,TreeMapChartDesignPanel:SL,ChartTypePicker:EL,FigureComponent:Vv,MenuPopover:Fv,Popover:jv,SelectionInput:ZN,ValidationMessages:OI,AddDimensionButton:sz,PivotDimensionGranularity:lz,PivotDimensionOrder:uz,PivotDimension:cz,PivotLayoutConfigurator:jz,PivotHTMLRenderer:VW,PivotDeferUpdate:iz,PivotTitleSection:Mz,CogWheelMenu:wI,TextInput:vI,SidePanelCollapsible:DM,RadioSelection:II,GeoChartRegionSelectSection:rL,ChartDashboardMenu:Iv,FullScreenFigure:BW,NumberInput:BI,TopBar:PY,Composer:$M},xQ={useDragAndDropListItems:WN,useHighlights:FL,useHighlightsOnHover:PL},SQ={useStoreProvider:lr,DependencyContainer:ar,CellPopoverStore:sP,ComposerFocusStore:xr,CellComposerStore:KU,FindAndReplaceStore:HL,HighlightStore:ON,DelayedHoveredCellStore:Hv,HoveredTableStore:lW,ModelStore:mr,NotificationStore:kN,RendererStore:vr,SelectionInputStore:XN,SpreadsheetStore:yr,useStore:D,useLocalStore:ur,SidePanelStore:SV,PivotSidePanelStore:TB,PivotMeasureDisplayPanelStore:ez,ClientFocusStore:vU,GridRenderer:bW};function CQ(e,t){return fO.add(e,t),{addFunction:(e,t)=>CQ(e,t)}}let wQ={DEFAULT_LOCALE:R,HIGHLIGHT_COLOR:ee,PIVOT_STATIC_TABLE_CONFIG:Re,PIVOT_INSERT_TABLE_STYLE_ID:ze,ChartTerms:rm,FIGURE_ID_SPLITTER:`??`,GRID_ICON_EDGE_LENGTH:17,GRID_ICON_MARGIN:2},TQ={...U_,...__};e.AbstractCellClipboardHandler=sK,e.AbstractChart=Ff,e.AbstractFigureClipboardHandler=aQ,e.CellErrorType=A,e.ClientDisconnectedError=fq,e.CommandResult=Zs,e.CompiledFormula=xz,e.CorePlugin=UW,e.CoreViewPlugin=hG,e.DEFAULT_LOCALE=R,e.DEFAULT_LOCALES=ho,e.DispatchResult=Ys,e.EvaluationError=j,e.LocalTransportService=XJ,e.Model=zZ,e.PivotRuntimeDefinition=Nz,e.Registry=B,e.Revision=dq,e.SPREADSHEET_DIMENSIONS=gQ,e.Spreadsheet=LY,e.SpreadsheetPivotTable=eB,e.UIPlugin=lK,e.__info__=hQ,e.addFunction=CQ,e.addRenderingLayer=_r,e.astToFormula=HU,e.canExecuteInReadonly=Js,e.categories=pO,e.chartHelpers=TQ,e.components=bQ,e.constants=wQ,e.convertAstNodes=pN,e.coreTypes=Ks,e.createAutocompleteArgumentsProvider=Zq,e.findCellInNewZone=Vn,e.functionCache=yz,e.getCaretDownSvg=DO,e.getCaretUpSvg=OO,e.helpers=vQ,e.hooks=xQ,e.invalidateCFEvaluationCommands=Vs,e.invalidateChartEvaluationCommands=zs,e.invalidateDependenciesCommands=Bs,e.invalidateEvaluationCommands=Rs,e.isCoreCommand=qs,e.isSheetDependent=Ms,e.iterateAstNodes=mN,e.links=yQ,e.load=Qj,e.lockedSheetAllowedCommands=Gs,e.parse=dN,e.parseTokens=fN,e.readonlyAllowedCommands=Ws,e.registries=_Q,e.setDefaultSheetViewSize=Ie,e.setTranslationMethod=fa,e.stores=SQ,e.tokenColors=We,e.tokenize=Tu,hQ.version=`19.2.24`,hQ.date=`2026-08-10T12:32:26.974Z`,hQ.hash=`31fa530`})(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|