@odoo/o-spreadsheet 17.4.0-alpha.0 → 17.4.0-alpha.1
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,t){"use strict";const o=.5,s="#37A850",i="#f5f5f5",n="#F8F9FA",r="#E8EAED",a="#595959",l="#666666",c="#c9ccd2",h="#3266ca",d="#FFFFFF",u="#EBEBEB",g="#CACACA",p=11982760,m="#017E84",f="#188038",b="#E0E2E4",v="#4A4F59",S="#999",C="#E2E3E3",y="#BCBCBC",E="#9B359B",x="#006FBE",w="#E40000",I="#AAAAAA",R=20,T=22,A=["#000000","#434343","#666666","#999999","#B7B7B7","#CCCCCC","#D9D9D9","#EFEFEF","#F3F3F3","#FFFFFF","#980000","#FF0000","#FF9900","#FFFF00","#00FF00","#00FFFF","#4A86E8","#0000FF","#9900FF","#FF00FF","#E6B8AF","#F4CCCC","#FCE5CD","#FFF2CC","#D9EAD3","#D0E0E3","#C9DAF8","#CFE2F3","#D9D2E9","#EAD1DC","#DD7E6B","#EA9999","#F9CB9C","#FFE599","#B6D7A8","#A2C4C9","#A4C2F4","#9FC5E8","#B4A7D6","#D5A6BD","#CC4125","#E06666","#F6B26B","#FFD966","#93C47D","#76A5AF","#6D9EEB","#6FA8DC","#8E7CC3","#C27BA0","#A61C00","#CC0000","#E69138","#F1C232","#6AA84F","#45818E","#3C78D8","#3D85C6","#674EA7","#A64D79","#85200C","#990000","#B45F06","#BF9000","#38761D","#134F5C","#1155CC","#0B5394","#351C75","#741B47","#5B0F00","#660000","#783F04","#7F6000","#274E13","#0C343D","#1C4587","#073763","#20124D","#4C1130"],O=26,_=48,D=96,M=23,F=15,N=4,P=N,L=21,k=17,V=2*M,U=250,B={align:"left",verticalAlign:"bottom",wrapping:"overflow",bold:!1,italic:!1,strikethrough:!1,underline:!1,fontSize:10,fillColor:"",textColor:"#000000"},H=B.verticalAlign,z=B.wrapping,$="400",G=B.fontSize,W="'Roboto', arial",q="thin",Z="#000000",Y="START_REVISION",j=1,X=20,K="??",Q="difference",J="#6AA84F",ee="#E06666",te=.4,oe=["'","*","?","/","\\","[","]"],se=/'|\*|\?|\/|\\|\[|\]/,ie="|";var ne;!function(e){e[e.Grid=0]="Grid",e[e.Highlight=5]="Highlight",e[e.HeaderGroupingButton=6]="HeaderGroupingButton",e[e.Figure=10]="Figure",e[e.ScrollBar=15]="ScrollBar",e[e.GridPopover=19]="GridPopover",e[e.GridComposer=20]="GridComposer",e[e.Dropdown=21]="Dropdown",e[e.IconPicker=25]="IconPicker",e[e.TopBarComposer=30]="TopBarComposer",e[e.Popover=35]="Popover",e[e.FigureAnchor=1e3]="FigureAnchor",e[e.FigureSnapLine=1001]="FigureSnapLine"}(ne||(ne={}));let re=0;function ae(){return re}const le="\n",ce=[6,7,8,9,10,11,12,14,18,24,36],he={hasFilters:!1,totalRow:!1,firstColumn:!0,lastColumn:!1,numberOfHeaders:1,bandedRows:!0,bandedColumns:!1,styleId:"TableStyleMedium5"};function de(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function ue(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ge(e){const t=Array.isArray(e)?[]:{};switch(typeof e){case"object":if(null===e)return e;if(function(e){return"clone"in e&&e.clone instanceof Function}(e))return e.clone();if(!(function(e){return"object"==typeof e&&e?.constructor===Object}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");for(const o in e)t[o]=ge(e[o]);return t;case"number":case"string":case"boolean":case"function":case"undefined":return e;default:throw new Error("Unsupported type: "+typeof e)}}function pe(e){return me(e,"'")}function me(e,t='"'){return e.startsWith(t)&&(e=e.slice(1)),e.endsWith(t)&&(e=e.slice(0,-1)),e}function fe(e){return e.match(/\w/g)?.length!==e.length&&(e=`'${e}'`),e}function be(e,t,o){return e<t?t:e>o?o:e}function ve(e,t,o=1){if(t<=e&&o>0)return[];if(0===o)throw new Error("range() step must not be zero");const s=Math.ceil(Math.abs((t-e)/o)),i=Array(s);for(let t=0;t<s;t++)i[t]=e+t*o;return i}function Se(e){return e.reduce(((e,t,o,s)=>{if(1===Math.abs(t-s[o-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*Ce(e,t){t.next();for(const o of e){const e=t.next();yield{...o,next:e.done?void 0:e.value}}}const ye=/^\[(.+)\]\((.+)\)$/,Ee=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function xe(e){return ye.test(e)}function we(e){return Ee.test(e)}function Ie(e,t){return`[${e}](${t})`}function Re(e){const t=e.match(ye)||[],o=t[1],s=t[2];if(!o||!s)throw new Error(`Could not parse markdown link ${e}.`);return{label:o,url:s}}const Te="o-spreadsheet://";function Ae(e){return e.startsWith(Te)}function Oe(e){return`${Te}${e}`}function _e(e){if(e.startsWith(Te))return e.substr(Te.length);throw new Error(`${e} is not a valid sheet link`)}function De(e){return void 0!==e}function Me(e){return null!==e}function Fe(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?Fe(e):!e))}function Ne(e,t){for(const o in t)if(Be(t[o],e))return parseInt(o,10);const o=Object.keys(t),s=0===o.length?0:Je(o.map((e=>parseInt(e,10))));return t[s+1]=e,s+1}function Pe(e,t,o){let s;const i=function(){const i=this,n=Array.from(arguments);const r=o&&!s;clearTimeout(s),s=setTimeout((function(){s=void 0,o||e.apply(i,n)}),t),r&&e.apply(i,n)};return i.isDebouncePending=()=>void 0!==s,i.stopDebounce=()=>{clearTimeout(s)},i}function Le(e){let t="";for(let o=0,s=e.length;o<s;o++)t+=e[o];return t}function ke(e){let t,o=!1;const s=()=>(o||(t=e instanceof Function?e():e,o=!0),t);return s.map=e=>ke((()=>e(s()))),s}function Ve(e,t){let o=e.slice(t).find((e=>e));return o||(o=e.slice(0,t).reverse().find((e=>e))),o||""}function Ue(e,t){return"after"===e?t+1:t}function Be(e,t,o){if(e===t)return!0;if(e&&!t||t&&!e)return!1;if(typeof e!=typeof t)return!1;if("object"!=typeof e)return!1;for(const o in t)if(!(o in e)&&void 0!==t[o])return!1;for(const s in e){const i=typeof e[s];if(i!==typeof t[s])return!1;if("object"===i){if(!Be(e[s],t[s],o))return!1}else{if(o&&"function"===i)continue;if(e[s]!==t[s])return!1}}return!0}function He(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(!Be(e[o],t[o]))return!1;return!0}function ze(e,t){return t.every((t=>e.includes(t)))}function $e(e){if(!e)return e;const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}const Ge=["\t","\f","\v",String.fromCharCode(parseInt("00a0",16)),String.fromCharCode(parseInt("1680",16)),String.fromCharCode(parseInt("2000",16)),String.fromCharCode(parseInt("200a",16)),String.fromCharCode(parseInt("2028",16)),String.fromCharCode(parseInt("2029",16)),String.fromCharCode(parseInt("202f",16)),String.fromCharCode(parseInt("205f",16)),String.fromCharCode(parseInt("3000",16)),String.fromCharCode(parseInt("feff",16))],We=new RegExp(Ge.join("|")+"|(\r\n|\r|\n)","g");function qe(e){return e?We.test(e)?e.replace(We,((e,t)=>t?le:" ")):e:""}function Ze(e){const t=Array.from(e).sort(((e,t)=>e-t));for(let e=1;e<t.length;e++)if(t[e]-t[e-1]!=1)return!1;return!0}function Ye(e){const t=new Map,o=e.name?e.name+" (memoized)":"memoized";return{[o]:(...o)=>(t.has(o[0])||t.set(o[0],e(...o)),t.get(o[0]))}[o]}function je(e,t){return e.filter(((e,o)=>!t.includes(o)))}function Xe(e){return e.split("\n").map((e=>e.replace(/\s+/g," ").trim())).join("\n")}function Ke(e,t,o){return t>o?Ke(e,o,t):e>=t&&e<=o}function Qe(e,t){let o=ue(e);const s=t.matchCase?"":"i";return t.exactMatch&&(o=`^${o}$`),RegExp(o,s)}function Je(e){let t=e.length;if(t<1e5)return Math.max(...e);let o=-1/0;for(;t--;)o=e[t]>o?e[t]:o;return o}function et(e){let t=e.length;if(t<1e5)return Math.min(...e);let o=1/0;for(;t--;)o=e[t]<o?e[t]:o;return o}const tt=/rgba?\(|\s+|\)/gi,ot=/^#([A-F\d]{2}){3,4}$/,st=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function it(e){return nt(e.toString(16).padStart(6,"0"))}function nt(e){let t=e;if(e.startsWith("rgb")?t=function(e){const t=e.replace(tt,"").split(",");let o=255;if(3!==t.length&&4!==t.length)throw new Error("invalid color");if(4===t.length){const e=parseFloat(t.pop()||"1");o=Math.round(255*(e||1))}const s=t.map((e=>parseInt(e,10)));255!==o&&s.push(o);return"#"+Le(s.map((e=>e.toString(16).padStart(2,"0")))).toUpperCase()}(e):(t=e.replace("#","").toUpperCase(),3!==t.length&&4!==t.length||(t=t.split("").reduce(((e,t)=>e+t+t),"")),t=`#${t}`),!ot.test(t))throw new Error(`invalid color input: ${e}`);return t}function rt(e){try{return nt(e),!0}catch(e){return!1}}const at=e=>e>=0&&e<=255;function lt(e,t,o,s=1){if(!at(e)||!at(t)||!at(o)||s<0||s>1)throw new Error(`Invalid RGBA values ${[e,t,o,s]}`);return{a:s,b:o,g:t,r:e}}function ct(e){let{r:t,g:o,b:s}=dt(e);t/=255,o/=255,s/=255;const i=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*i(t)+.7152*i(o)+.0722*i(s)}function ht(e){let t=e.r.toString(16),o=e.g.toString(16),s=e.b.toString(16),i=Math.round(255*e.a).toString(16);return 1===t.length&&(t="0"+t),1===o.length&&(o="0"+o),1===s.length&&(s="0"+s),1===i.length&&(i="0"+i),"ff"===i&&(i=""),("#"+t+o+s+i).toUpperCase()}function dt(e){let t,o,s,i;if(7===(e=nt(e)).length)t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),s=parseInt(e[5]+e[6],16),i=255;else{if(9!==e.length)throw new Error("Invalid color");t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),s=parseInt(e[5]+e[6],16),i=parseInt(e[7]+e[8],16)}return i=+(i/255).toFixed(3),{a:i,r:t,g:o,b:s}}function ut(e){(e={...e}).s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,o=t*(1-Math.abs(e.h/60%2-1)),s=e.l-t/2,i=0,n=0,r=0;return 0<=e.h&&e.h<60?(i=t,n=o,r=0):60<=e.h&&e.h<120?(i=o,n=t,r=0):120<=e.h&&e.h<180?(i=0,n=t,r=o):180<=e.h&&e.h<240?(i=0,n=o,r=t):240<=e.h&&e.h<300?(i=o,n=0,r=t):300<=e.h&&e.h<360&&(i=t,n=0,r=o),i=Math.round(255*(i+s)),n=Math.round(255*(n+s)),r=Math.round(255*(r+s)),{a:e.a,r:i,g:n,b:r}}function gt(e){const t=e.r/255,o=e.g/255,s=e.b/255;let i=Math.min(t,o,s),n=Math.max(t,o,s),r=n-i,a=0,l=0,c=0;return a=0===r?0:n===t?(o-s)/r%6:n===o?(s-t)/r+2:(t-o)/r+4,a=Math.round(60*a),a<0&&(a+=360),c=(n+i)/2,l=0===r?0:r/(1-Math.abs(2*c-1)),l=+(100*l).toFixed(1),c=+(100*c).toFixed(1),{a:e.a,h:a,s:l,l:c}}function pt(e){return ht(ut(e))}function mt(e){return gt(dt(e))}function ft(e,t){const o=mt(e);return 1===t?"#fff":(o.l=t*(100-o.l)+o.l,pt(o))}function bt(e,t){const o=mt(e);return 1===t?"#000":(o.l=o.l-t*o.l,pt(o))}const vt=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];function St(e){return vt[e%vt.length]}class Ct{currentColorIndex=0;colors;constructor(e=[]){this.colors=e}next(){return this.colors?.[this.currentColorIndex]?this.colors[this.currentColorIndex++]:St(this.currentColorIndex++)}}function yt(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):yt(Math.floor(e/26)-1)+yt(e%26)}const Et={};for(const e of"ABCDEFGHIJKLMNOPQRSTUVWXYZ"){const t=e.charCodeAt(0)-64;Et[e]=t,Et[e.toLowerCase()]=t}function xt(e){let t=-1;let o=1;for(let s=e.length-1;s>=0;s--){t+=Et[e[s]]*o,o*=26}return t}function wt(e){return e>="A"&&e<="Z"||e>="a"&&e<="z"}function It(e){return e>="0"&&e<="9"}function Rt(e){let t;e=e.trim();for(let o=0;o<e.length;o++){const s=e[o];if(!t){if("$"===s&&0===o||wt(s))continue;t=o}if(!It(s)){if("$"===s&&o===t)continue;throw new Error(`Invalid cell description: ${e}`)}}if(!t||t===e.length)throw new Error(`Invalid cell description: ${e}`);const o="$"===e[0]?e.slice(1,t):e.slice(0,t),s="$"===e[t]?e.slice(t+1):e.slice(t);if(o.length<1||o.length>3||s.length<1||s.length>7)throw new Error(`Invalid cell description: ${e}`);const i=xt(o),n=Number(s)-1;if(isNaN(n))throw new Error(`Invalid cell description: ${e}`);return{col:i,row:n}}function Tt(e,t,o={colFixed:!1,rowFixed:!1}){return(o.colFixed?"$":"")+yt(e)+(o.rowFixed?"$":"")+String(t+1)}class At{jsDate;constructor(e,t,o,s=0,i=0,n=0){this.jsDate=new Date(Date.UTC(e,t,o,s,i,n,0))}static fromTimestamp(e){const t=new Date(e);return new At(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds())}static now(){const e=new Date;return new At(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.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(){const e=new Date(this.jsDate.getTime()),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);const o=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-o.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)}}const Ot=new At(1899,11,30),_t=864e5,Dt=2e3,Mt=At.now().getFullYear(),Ft=At.now().getMonth(),Nt=At.fromTimestamp(0).getTime()-Ot.getTime(),Pt=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,Lt=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,kt=/\/|-|\s/,Vt=/^(\d{1,4})[\/-\s](\d{1,4})([\/-\s](\d{1,4}))?$/,Ut=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function Bt(e,t){switch(typeof e){case"number":return e;case"string":return Ht(e,t)?$t(e,t)?.value:!e||isNaN(Number(e))?void 0:Number(e);default:return}}function Ht(e,t){return null!==$t(e,t)}const zt=new Map;function $t(e,t){return zt.has(t)||zt.set(t,new Map),zt.get(t).has(e)||zt.get(t).set(e,function(e,t){e=e.trim();let o=null;const s=e.match(Ut);if(s){if(o=function(e){if(e=e.trim(),Ut.test(e)){const t=/AM/i.test(e),o=/PM/i.test(e),s=(t||o?e.substring(0,e.length-2).trim():e).split(/:/),i=s.length>=2,n=3===s.length;let r=Number(s[0]),a=i?Number(s[1]):0,l=n?Number(s[2]):0,c=n?"hh:mm:ss":"hh:mm";if(t||o)c+=" a";else if(!i)return null;r>=12&&t?r-=12:r<12&&o&&(r+=12),a+=Math.floor(l/60),l%=60,r+=Math.floor(a/60),a%=60,r>=24&&(c="hhhh:mm:ss");return{value:r/24+a/1440+l/86400,format:c,jsDate:new At(1899,11,30,r,a,l)}}return null}(s[0]),null===o)return null;e=e.replace(s[0],"").trim()}let i=null;const n=function(e,t){const o=e.match(Vt);if(!o)return null;const[,s,i,,n]=o;if(s.length>2&&n&&n.length>2)return null;if(s.length>2)return{year:s,month:i,day:n,dateString:e,type:"ymd"};const r=function(e){switch(e.dateFormat[0]){case"d":return"dmy";case"m":return"mdy";case"y":return"ymd"}throw new Error("Invalid date format in locale")}(t);if(!n)return i.length>2?{month:s,year:i,day:void 0,dateString:e,type:r}:"dmy"===r?{day:s,month:i,year:n,dateString:e,type:"dmy"}:{month:s,day:i,year:n,dateString:e,type:"mdy"};if(n.length>2)return"mdy"===r?{month:s,day:i,year:n,dateString:e,type:"mdy"}:{day:s,month:i,year:n,dateString:e,type:"dmy"};if("mdy"===r)return{month:s,day:i,year:n,dateString:e,type:"mdy"};if("ymd"===r)return{year:s,month:i,day:n,dateString:e,type:"ymd"};if("dmy"===r)return{day:s,month:i,year:n,dateString:e,type:"dmy"};return null}(e,t);if(n){const t=n.dateString.match(kt)[0];if(i=function(e,t){let{year:o,month:s,day:i}=e;const n=function(e){if(!e)return Ft;const t=Number(e);if(t>=1&&t<=12)return t-1;return null}(s),r=function(e){if(!e)return 1;const t=Number(e);if(t>=0&&t<=31)return t;return null}(i),a=function(e){if(!e)return Mt;const t=Number(e);switch(e.length){case 1:return Dt+t;case 2:return Dt+(Dt+t>Mt+10?-100:0)+t;case 3:case 4:return t}return null}(o);if(null===a||null===n||null===r)return null;const l=2===s?.length&&n+1<10||2===i?.length&&r<10,c=2!==o?.length,h=new At(a,n,r);if(h.getMonth()!==n||h.getDate()!==r)return null;const d=h.getTime()-Ot.getTime(),u=function(e,t,o,s){const i=e.year?s?"yyyy":"yy":void 0,n=e.month?o?"mm":"m":void 0,r=e.day?o?"dd":"d":void 0;switch(e.type){case"mdy":return[n,r,i].filter(De).join(t);case"ymd":return[i,n,r].filter(De).join(t);case"dmy":return[r,n,i].filter(De).join(t)}}(e,t,l,c);return{value:Math.round(d/_t),format:u,jsDate:h}}(n,t),null===i)return null;e=e.replace(n.dateString,"").trim()}if(""!==e||!i&&!o)return null;if(i&&i.jsDate&&o&&o.jsDate)return{value:i.value+o.value,format:i.format+" "+("hhhh:mm:ss"===o.format?"hh:mm:ss":o.format),jsDate:new At(i.jsDate.getFullYear()+o.jsDate.getFullYear()-1899,i.jsDate.getMonth()+o.jsDate.getMonth()-11,i.jsDate.getDate()+o.jsDate.getDate()-30,i.jsDate.getHours()+o.jsDate.getHours(),i.jsDate.getMinutes()+o.jsDate.getMinutes(),i.jsDate.getSeconds()+o.jsDate.getSeconds())};return i||o}(e,t)),zt.get(t).get(e)}function Gt(e){const t=Math.trunc(e);let o=At.fromTimestamp(t*_t-Nt),s=e-t;s=s<0?1+s:s;const i=Math.round(24*s),n=Math.round(24*(s-i/24)*60),r=Math.round(24*(s-i/24-n/24/60)*60*60);return o.setHours(i),o.setMinutes(n),o.setSeconds(r),o}function Wt(e){return Math.round(qt(e))}function qt(e){return(e.getTime()-Ot.getTime())/_t}function Zt(e){return new At(e.getFullYear(),e.getMonth()+1,0).getDate()}function Yt(e){return Zt(e)===e.getDate()}function jt(e,t,o){const s=e.getFullYear(),i=e.getMonth(),n=e.getDate(),r=new At(s,i+t,1);return o&&n===Zt(e)||n>Zt(r)?r.setDate(Zt(r)):r.setDate(n),r}function Xt(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function Kt(e,t,o){if(e===t)return 0;if(e>t){const o=t;t=e,e=o}const s=Gt(e),i=Gt(t);let n=s.getDate(),r=i.getDate();const a=s.getMonth(),l=i.getMonth(),c=s.getFullYear(),h=i.getFullYear();let d=0,u=0;switch(o){case 0:31===n&&(n=30),30===n&&31===r&&(r=30),1===a&&n===(Xt(c)?29:28)&&(n=30,1===l&&r===(Xt(h)?29:28)&&(r=30)),d=c+(30*a+n)/360,u=h+(30*l+r)/360;break;case 1:let o=365;const s=c===h;if(!s&&!(c+1===h)||!s&&a<l||!s&&a===l&&n<r){let e=0,t=0;for(let o=c;o<=h;o++)e++,t+=Xt(o)?366:365;o=t/e}else s?Xt(c)&&(o=366):(Xt(c)&&a<2&&(o=366),Xt(h)&&(l>1||1===l&&29===r)&&(o=366));d=e/o,u=t/o;break;case 2:d=e/360,u=t/360;break;case 3:d=e/365,u=t/365;break;case 4:31===n&&(n=30),31===r&&(r=30),d=c+(30*a+n)/360,u=h+(30*l+r)/360}return u-d}function Qt(e,t){const o=12*(t.getFullYear()-e.getFullYear())+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?o-1:o}function Jt(e,t){const o=e.getTime(),s=t.getTime();return Math.floor((s-o)/_t)}function eo(e,t){const o=t.getFullYear()-e.getFullYear(),s=e.getMonth(),i=t.getMonth(),n=e.getDate(),r=t.getDate();return i>s||i===s&&r>=n?o:o-1}function to(e,t,o){return t>o?to(e,o,t):(e=Math.trunc(e),t=Math.trunc(t),o=Math.trunc(o),e>=t&&e<=o)}const oo=Ye((function(e){return e=ue(e),new RegExp(`(^-?\\d+(${e}?\\d*(e\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)})),so=Ye((function(e){const t=ue(e.decimalSeparator),o="(\\s*"+`(\\d+(${ue(e.thousandsSeparator)}\\d{3,})*(${t}\\d*)?)`+"|"+`(${t}\\d+)`+")(e(\\+|-)?\\d+)?(\\s*%)?",s="(\\s*-)?",i="(\\s*[\\$€])?",n="^(("+[s+i+o,s+o+i,i+s+o].join(")|(")+"))$";return new RegExp(n,"i")}));function io(e,t){return!!e&&so(t).test(e.trim())}const no=Ye((function(e){return new RegExp(`[$€${ue(e.thousandsSeparator)}]`,"g")}));function ro(e,t){"."!==t.decimalSeparator&&(e=e.replace(t.decimalSeparator,".")),e=e.replace(no(t),"");let o=Number(e);return isNaN(o)&&e.includes("%")&&(o=Number(e.split("%")[0]),!isNaN(o))?o/100:o}function ao(e,t,o){const s=[...e].sort(((e,t)=>e-t));let i=(s.length+(o?-1:1))*t;if(o||i--,Number.isInteger(i))return s[i];const n=Math.ceil(i),r=Math.floor(i);return s[n]*(i-r)+s[r]*(n-i)}let lo=e=>e,co=()=>!1;function ho(e,...t){if(1!==t.length||"object"!=typeof t[0]||t[0]instanceof String)t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));else{const o=t[0];e=e.replace(/\%\(([^\)]+)\)s/g,((e,t)=>o[t]))}return e}const uo=function(e,...t){return co()?ho(lo(e),...t):new go(e,t)};class go extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return co()?ho(lo(e),...this.values):ho(e,...this.values)}toString(){return this.valueOf()}}var po,mo;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(po||(po={})),function(e){e.PlainText="text/plain",e.Html="text/html"}(mo||(mo={}));const fo=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"]),bo=new Set(["MOVE_RANGES"]),vo=new Set(["DUPLICATE_SHEET","EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","CHANGE_CONDITIONAL_FORMAT_PRIORITY"]),So=new Set(["AUTOFILL_CELL","SET_BORDER","SET_ZONE_BORDERS"]),Co=new Set(["START","ACTIVATE_SHEET","COPY","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","EVALUATE_CELLS","SET_FORMULA_VISIBILITY","UPDATE_FILTER"]),yo=new Set(["UPDATE_CELL","UPDATE_CELL_POSITION","CLEAR_CELL","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","HIDE_SHEET","SHOW_SHEET","MOVE_RANGES","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","CHANGE_CONDITIONAL_FORMAT_PRIORITY","CREATE_FIGURE","DELETE_FIGURE","UPDATE_FIGURE","SET_FORMATTING","CLEAR_FORMATTING","SET_BORDER","SET_ZONE_BORDERS","CREATE_CHART","UPDATE_CHART","CREATE_TABLE","REMOVE_TABLE","UPDATE_TABLE","CREATE_TABLE_STYLE","REMOVE_TABLE_STYLE","CREATE_IMAGE","GROUP_HEADERS","UNGROUP_HEADERS","UNFOLD_HEADER_GROUP","FOLD_HEADER_GROUP","FOLD_ALL_HEADER_GROUPS","UNFOLD_ALL_HEADER_GROUPS","UNFOLD_HEADER_GROUPS_IN_ZONE","FOLD_HEADER_GROUPS_IN_ZONE","ADD_DATA_VALIDATION_RULE","REMOVE_DATA_VALIDATION_RULE","UPDATE_LOCALE","ADD_PIVOT","UPDATE_PIVOT","INSERT_PIVOT","RENAME_PIVOT","REMOVE_PIVOT","DUPLICATE_PIVOT"]);function Eo(e){return yo.has(e.type)}class xo{reasons;constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>"Success"!==e))}static get Success(){return wo}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}const wo=new xo;var Io;e.CommandResult=void 0,(Io=e.CommandResult||(e.CommandResult={})).Success="Success",Io.CancelledForUnknownReason="CancelledForUnknownReason",Io.WillRemoveExistingMerge="WillRemoveExistingMerge",Io.MergeIsDestructive="MergeIsDestructive",Io.CellIsMerged="CellIsMerged",Io.InvalidTarget="InvalidTarget",Io.EmptyUndoStack="EmptyUndoStack",Io.EmptyRedoStack="EmptyRedoStack",Io.NotEnoughElements="NotEnoughElements",Io.NotEnoughSheets="NotEnoughSheets",Io.MissingSheetName="MissingSheetName",Io.UnchangedSheetName="UnchangedSheetName",Io.DuplicatedSheetName="DuplicatedSheetName",Io.DuplicatedSheetId="DuplicatedSheetId",Io.ForbiddenCharactersInSheetName="ForbiddenCharactersInSheetName",Io.WrongSheetMove="WrongSheetMove",Io.WrongSheetPosition="WrongSheetPosition",Io.InvalidAnchorZone="InvalidAnchorZone",Io.SelectionOutOfBound="SelectionOutOfBound",Io.TargetOutOfSheet="TargetOutOfSheet",Io.WrongCutSelection="WrongCutSelection",Io.WrongPasteSelection="WrongPasteSelection",Io.WrongPasteOption="WrongPasteOption",Io.WrongFigurePasteOption="WrongFigurePasteOption",Io.EmptyClipboard="EmptyClipboard",Io.EmptyRange="EmptyRange",Io.InvalidRange="InvalidRange",Io.InvalidZones="InvalidZones",Io.InvalidSheetId="InvalidSheetId",Io.InvalidFigureId="InvalidFigureId",Io.InputAlreadyFocused="InputAlreadyFocused",Io.MaximumRangesReached="MaximumRangesReached",Io.MinimumRangesReached="MinimumRangesReached",Io.InvalidChartDefinition="InvalidChartDefinition",Io.InvalidDataSet="InvalidDataSet",Io.InvalidLabelRange="InvalidLabelRange",Io.InvalidScorecardKeyValue="InvalidScorecardKeyValue",Io.InvalidScorecardBaseline="InvalidScorecardBaseline",Io.InvalidGaugeDataRange="InvalidGaugeDataRange",Io.EmptyGaugeRangeMin="EmptyGaugeRangeMin",Io.GaugeRangeMinNaN="GaugeRangeMinNaN",Io.EmptyGaugeRangeMax="EmptyGaugeRangeMax",Io.GaugeRangeMaxNaN="GaugeRangeMaxNaN",Io.GaugeRangeMinBiggerThanRangeMax="GaugeRangeMinBiggerThanRangeMax",Io.GaugeLowerInflectionPointNaN="GaugeLowerInflectionPointNaN",Io.GaugeUpperInflectionPointNaN="GaugeUpperInflectionPointNaN",Io.GaugeLowerBiggerThanUpper="GaugeLowerBiggerThanUpper",Io.InvalidAutofillSelection="InvalidAutofillSelection",Io.MinBiggerThanMax="MinBiggerThanMax",Io.LowerBiggerThanUpper="LowerBiggerThanUpper",Io.MidBiggerThanMax="MidBiggerThanMax",Io.MinBiggerThanMid="MinBiggerThanMid",Io.FirstArgMissing="FirstArgMissing",Io.SecondArgMissing="SecondArgMissing",Io.MinNaN="MinNaN",Io.MidNaN="MidNaN",Io.MaxNaN="MaxNaN",Io.ValueUpperInflectionNaN="ValueUpperInflectionNaN",Io.ValueLowerInflectionNaN="ValueLowerInflectionNaN",Io.MinInvalidFormula="MinInvalidFormula",Io.MidInvalidFormula="MidInvalidFormula",Io.MaxInvalidFormula="MaxInvalidFormula",Io.ValueUpperInvalidFormula="ValueUpperInvalidFormula",Io.ValueLowerInvalidFormula="ValueLowerInvalidFormula",Io.InvalidSortZone="InvalidSortZone",Io.WaitingSessionConfirmation="WaitingSessionConfirmation",Io.MergeOverlap="MergeOverlap",Io.TooManyHiddenElements="TooManyHiddenElements",Io.Readonly="Readonly",Io.InvalidViewportSize="InvalidViewportSize",Io.InvalidScrollingDirection="InvalidScrollingDirection",Io.ViewportScrollLimitsReached="ViewportScrollLimitsReached",Io.FigureDoesNotExist="FigureDoesNotExist",Io.InvalidConditionalFormatId="InvalidConditionalFormatId",Io.InvalidCellPopover="InvalidCellPopover",Io.EmptyTarget="EmptyTarget",Io.InvalidFreezeQuantity="InvalidFreezeQuantity",Io.FrozenPaneOverlap="FrozenPaneOverlap",Io.ValuesNotChanged="ValuesNotChanged",Io.InvalidFilterZone="InvalidFilterZone",Io.TableNotFound="TableNotFound",Io.TableOverlap="TableOverlap",Io.InvalidTableConfig="InvalidTableConfig",Io.InvalidTableStyle="InvalidTableStyle",Io.FilterNotFound="FilterNotFound",Io.MergeInTable="MergeInTable",Io.NonContinuousTargets="NonContinuousTargets",Io.DuplicatedFigureId="DuplicatedFigureId",Io.InvalidSelectionStep="InvalidSelectionStep",Io.DuplicatedChartId="DuplicatedChartId",Io.ChartDoesNotExist="ChartDoesNotExist",Io.InvalidHeaderIndex="InvalidHeaderIndex",Io.InvalidQuantity="InvalidQuantity",Io.MoreThanOneColumnSelected="MoreThanOneColumnSelected",Io.EmptySplitSeparator="EmptySplitSeparator",Io.SplitWillOverwriteContent="SplitWillOverwriteContent",Io.NoSplitSeparatorInSelection="NoSplitSeparatorInSelection",Io.NoActiveSheet="NoActiveSheet",Io.InvalidLocale="InvalidLocale",Io.AlreadyInPaintingFormatMode="AlreadyInPaintingFormatMode",Io.MoreThanOneRangeSelected="MoreThanOneRangeSelected",Io.NoColumnsProvided="NoColumnsProvided",Io.ColumnsNotIncludedInZone="ColumnsNotIncludedInZone",Io.DuplicatesColumnsSelected="DuplicatesColumnsSelected",Io.InvalidHeaderGroupStartEnd="InvalidHeaderGroupStartEnd",Io.HeaderGroupAlreadyExists="HeaderGroupAlreadyExists",Io.UnknownHeaderGroup="UnknownHeaderGroup",Io.UnknownDataValidationRule="UnknownDataValidationRule",Io.UnknownDataValidationCriterionType="UnknownDataValidationCriterionType",Io.InvalidDataValidationCriterionValue="InvalidDataValidationCriterionValue",Io.InvalidNumberOfCriterionValues="InvalidNumberOfCriterionValues",Io.InvalidCopyPasteSelection="InvalidCopyPasteSelection",Io.NoChanges="NoChanges",Io.InvalidInputId="InvalidInputId",Io.SheetIsHidden="SheetIsHidden",Io.InvalidTableResize="InvalidTableResize",Io.PivotIdNotFound="PivotIdNotFound",Io.EmptyName="EmptyName";const Ro="@",To=[{name:"English (US)",code:"en_US",thousandsSeparator:",",decimalSeparator:".",dateFormat:"m/d/yyyy",timeFormat:"hh:mm:ss a",formulaArgSeparator:","},{name:"French",code:"fr_FR",thousandsSeparator:" ",decimalSeparator:",",dateFormat:"dd/mm/yyyy",timeFormat:"hh:mm:ss",formulaArgSeparator:";"}],Ao=To[0],Oo=["thin","medium","thick","dashed","dotted"];function _o(e){return Array.isArray(e)&&Array.isArray(e[0])}var Do;!function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(Do||(Do={}));const Mo={Background:0,Highlights:1,Clipboard:2,Chart:4,Autofill:5,Selection:6,Headers:100},Fo=Ye((()=>Object.keys(Mo).sort(((e,t)=>Mo[e]-Mo[t]))));const No={NotAvailable:"#N/A",InvalidReference:"#REF",BadExpression:"#BAD_EXPR",CircularDependency:"#CYCLE",UnknownFunction:"#NAME?",DivisionByZero:"#DIV/0!",SpilledBlocked:"#SPILL!",GenericError:"#ERROR"},Po=new Set(Object.values(No));class Lo extends Error{value;constructor(e=uo("Error"),t=No.GenericError){super(e),this.value=t}}class ko extends Lo{constructor(e=uo("Invalid expression")){super(e,No.BadExpression)}}class Vo extends Lo{constructor(e=uo("Invalid reference")){super(e,No.InvalidReference)}}class Uo extends Lo{constructor(e=uo("Data not available")){super(e,No.NotAvailable)}}class Bo extends Lo{constructor(e=uo("Unknown function")){super(e,No.UnknownFunction)}}class Ho extends Lo{constructor(e=uo("Spill range is not empty")){super(e,No.SpilledBlocked)}}const zo=["number","string","boolean","undefined"];function $o(e,t,o){if(!e())throw new Lo(t,o)}function Go(e){if(void 0!==e)return _o(e)?e[0][0]?.format:e.format}function Wo(e){return"string"==typeof e&&Po.has(e)}const qo=e=>uo("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Zo(e,t){const o=rs(e);switch(typeof o){case"number":return o;case"boolean":return o?1:0;case"string":if(io(o,t)||""===o)return ro(o,t);const e=$t(o,t);if(e)return e.value;throw new Lo(qo(o));default:return 0}}function Yo(e,t){try{return Zo(e,t)}catch(e){return}}function jo(e,t){return Rs(e).map((e=>e.map((e=>{if("number"!=typeof e.value)throw new Lo(uo("Function [[FUNCTION_NAME]] expects number values for %s, but got a %s.",t,typeof e.value));return e.value}))))}function Xo(e,t){const o=rs(e);if(""===o)throw new Lo(qo(o));return Zo(o,t)}function Ko(e,t){return Math.trunc(Zo(e,t))}function Qo(e,t){return Math.trunc(Xo(e,t))}function Jo(e){$o((()=>e>=1),uo("The function [[FUNCTION_NAME]] expects a number value to be greater than or equal to 1, but receives %s.",e.toString()))}function es(e){$o((()=>0!==e),uo("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."),No.DivisionByZero)}function ts(e){const t=rs(e);switch(typeof t){case"string":return t;case"number":return t.toString();case"boolean":return t?"TRUE":"FALSE";default:return""}}const os=Ye((function(e){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")})),ss=e=>uo("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a boolean.",e);function is(e){const t=rs(e);switch(typeof t){case"boolean":return t;case"string":if(t){let e=t.toUpperCase();if("TRUE"===e)return!0;if("FALSE"===e)return!1;throw new Lo(ss(t))}return!1;case"number":return!!t;default:return!1}}function ns(e,t){return Gt(Zo(rs(e),t))}function rs(e){if("object"==typeof e&&null!==e&&"value"in e){if(Wo(e.value))throw e;return e.value}if(Wo(e))throw new Lo("",e);return e}function as(e,t,o){for(let s of e)if(_o(s)){const e=s.length,o=s[0].length;for(let i=0;i<o;i++)for(let o=0;o<e;o++)t(s[o][i])}else o(s)}function ls(e,t){as(e,(e=>{if(Wo(e.value))throw e;t(e)}),(e=>{if(Wo(e?.value))throw e;t(e)}))}function cs(e,t,o){as(e,(e=>{const o=e?.value;if("number"==typeof o&&t(o),Wo(o))throw e}),(e=>{t(Xo(e,o))}))}function hs(e,t,o,s,i="rowFirst"){let n=s;for(let s of e)if(_o(s)){const e=s.length,o=s[0].length;if("rowFirst"===i)for(let i=0;i<o;i++)for(let o=0;o<e;o++)n=t(n,s[o][i]);else for(let i=0;i<e;i++)for(let e=0;e<o;e++)n=t(n,s[i][e])}else n=o(n,s);return n}function ds(e,t,o,s="rowFirst"){return hs(e,t,t,o,s)}function us(e,t,o,s){return hs(e,((e,o)=>{const s=o?.value;if("number"==typeof s)return t(e,s);if(Wo(s))throw o;return e}),((e,o)=>t(e,Xo(o,s))),o)}function gs(e,t,o,s){return hs(e,((e,o)=>{const i=o?.value;if(null!=i){if("number"==typeof i)return t(e,i);if("boolean"==typeof i)return t(e,Zo(i,s));if(Wo(i))throw o;return t(e,0)}return e}),((e,o)=>t(e,Zo(o,s))),o)}function ps(e,t,o){const s=Array(e);for(let i=0;i<e;i++){s[i]=Array(t);for(let e=0;e<t;e++)s[i][e]=o(i,e)}return s}function ms(e,t){return 0===e.length?[]:ps(e.length,e[0].length,((o,s)=>t(e[o][s])))}function fs(e){return e.length?ps(e[0].length,e.length,((t,o)=>e[o][t])):[]}function bs(e,t){return function(e,t,o){for(let s of e)if(_o(s)){const e=s.length,o=s[0].length;for(let i=0;i<o;i++)for(let o=0;o<e;o++)if(!t(s[o][i]??void 0))return}else if(!o(s))return}(e,(e=>{const o=e?.value;if("boolean"==typeof o)return t(o);if("number"==typeof o)return t(!!o);if(Wo(o))throw e;return!0}),(e=>void 0===e||null===e.value||t(function(e){const t=rs(e);if(""===t)throw new Lo(ss(t));return is(t)}(e))))}function vs(e,t){let o,s,i=e.substring(0,2);return"<="===i||">="===i||"<>"===i?(o=i,s=e.substring(2)):(i=e.substring(0,1),"<"===i||">"===i||"="===i?(o=i,s=e.substring(1)):(o="=",s=e)),io(s,t)?s=Zo(s,t):"TRUE"!==s&&"FALSE"!==s||(s=is(s)),{operator:o,operand:s}}const Ss=Ye((function(e){let t="",o="";for(let s of e)"?"===s&&"~"!==o?t+=".":"*"===s&&"~"!==o?t+=".*":("*"!==s&&"?"!==s||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(s)&&(t+="\\"),t+=s),o=s;return new RegExp("^"+t+"$","i")}));function Cs(e,t){const{operator:o,operand:s}=t;if(void 0===e||void 0===s||null===e||null===s)return!1;if("number"==typeof s&&"="===o)return ts(e)===ts(s);if("<>"===o||"="===o){let t;return t=typeof e==typeof s&&("string"==typeof e&&"string"==typeof s?Ss(s).test(e):e===s),"="===o?t:!t}if(typeof e==typeof s)switch(o){case"<":return e<s;case">":return e>s;case"<=":return e<=s;case">=":return e>=s}return!1}function ys(e,t,o,s=!1){const i=e.length;if(i%2==1)throw new Lo(uo("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const n=e[0].length,r=e[0][0].length;let a=[];for(let t=0;t<i-1;t+=2){const i=e[t];if(!_o(i)||i.length!==n||i[0].length!==r)throw new Lo(uo("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const l=vs(ts(e[t+1]),o);s&&"string"==typeof l.operand&&(l.operand+="*"),a.push(l)}for(let o=0;o<n;o++)for(let s=0;s<r;s++){let n=!0;for(let t=0;t<i-1;t+=2){if(n=Cs(e[t][o][s].value??void 0,a[t/2]),!n)break}n&&t(o,s)}}function Es(e,t,o,s,i,n){if(void 0===t||null===t.value)return-1;if(Wo(t.value))throw t;const r=ws(t.value),a=typeof r;let l,c,h,d,u,g,p=0,m=i-1;for(;m-p>=0;){for(h=Math.floor((p+m)/2),d=h,u=ws(n(e,d)),g=typeof u;p<d&&a!==g;)d--,u=ws(n(e,d)),g=typeof u;g===a&&null!=u?("strict"===o&&u===r?(l=u,c=d):"nextSmaller"===o&&u<=r?(null==l||l<u||l===u&&"asc"===s&&c<d||l===u&&"desc"===s&&c>d)&&(l=u,c=d):"nextGreater"===o&&u>=r&&(void 0===l||l>u||l===u&&"asc"===s&&c<d||l===u&&"desc"===s&&c>d)&&(l=u,c=d),"asc"===s&&u>r||"desc"===s&&u<=r?m=d-1:p=h+1):p=h+1}return void 0!==c?c:-1}function xs(e,t,o,s,i,n=!1){if(void 0===t||null===t.value)return-1;if(Wo(t.value))throw t;const r=ws(t.value),a=n?(e,t)=>i(e,s-t-1):i;let l,c=t=>ws(a(e,t))===r;if("wildcard"===o&&"string"==typeof r&&(r.includes("*")||r.includes("?"))){const t=Ss(r);c=o=>{const s=ws(a(e,o));return"string"==typeof s&&t.test(s)}}let h=-1;"nextSmaller"===o&&(c=t=>{const o=ws(a(e,t));return(!l&&Is(r,o)>=0||Is(r,o)>=0&&Is(o,l)>0)&&(l=o,h=t),o===r}),"nextGreater"===o&&(c=t=>{const o=ws(a(e,t));return(!l&&Is(r,o)<=0||Is(r,o)<=0&&Is(o,l)<0)&&(l=o,h=t),o===r});for(let e=0;e<s;e++)if(c(e))return n?s-e-1:e;return n?s-h-1:h}function ws(e){return"string"==typeof e?os(e):e}function Is(e,t){let o=zo.indexOf(typeof e)-zo.indexOf(typeof t);return 0===o&&("string"==typeof e&&"string"==typeof t?o=e.localeCompare(t):"number"==typeof e&&"number"==typeof t?o=e-t:"boolean"==typeof e&&"boolean"==typeof t&&(o=Number(e)-Number(t))),o}function Rs(e){return void 0===e?[[]]:_o(e)?e:[[e]]}function Ts(e,t){return ds(e,((e,o)=>(e.push(t(o)),e)),[],"rowFirst")}function As(e){if(void 0===e)return!1;const{value:t}=e;return null!==t&&""!==t}function Os(e){const t=At.now();switch(e){case"today":return qt(t);case"yesterday":return qt(At.fromTimestamp(t.setDate(t.getDate()-1)));case"tomorrow":return qt(At.fromTimestamp(t.setDate(t.getDate()+1)));case"lastWeek":return qt(At.fromTimestamp(t.setDate(t.getDate()-7)));case"lastMonth":return qt(At.fromTimestamp(t.setMonth(t.getMonth()-1)));case"lastYear":return qt(At.fromTimestamp(t.setFullYear(t.getFullYear()-1)))}}function _s(e,t){return"dateValue"in e&&"exactDate"!==e.dateValue?[Os(e.dateValue)]:e.values.map((e=>Bt(e,t)))}function Ds(e,t){return e.values.map((e=>Yo(e,t)))}function Ms(e){return 20+120*Math.exp(-.035*(e-1))}const Fs=20,Ns=11,Ps=/(\d+?)(?=(\d{3})+(?!\d)|$)/g,Ls=/0/g,ks={0:uo("January"),1:uo("February"),2:uo("March"),3:uo("April"),4:uo("May"),5:uo("June"),6:uo("July"),7:uo("August"),8:uo("September"),9:uo("October"),10:uo("November"),11:uo("December")},Vs={0:uo("Sunday"),1:uo("Monday"),2:uo("Tuesday"),3:uo("Wednesday"),4:uo("Thursday"),5:uo("Friday"),6:uo("Saturday")},Us={};function Bs(e){let t=Us[e];return void 0===t&&(t=function(e){if(""===e)throw new Error("A format cannot be empty");let t=0,o=[];for(;t<e.length;){let s;if("["===e.charAt(t)){if("$"!==e.charAt(t+1))throw new Error(`Currency formats have to be prefixed by a $: ${e}`);if(s=e.substring(t+1).indexOf("]")+t+2,0===s)throw new Error(`Invalid currency brackets format: ${e}`);const i=e.substring(t+2,s-1);if(i.includes("["))throw new Error(`Invalid currency format: ${e}`);o.push({type:"STRING",format:i})}else{const i=e.substring(t).indexOf("[");s=i>-1?i+t:e.length;const n=e.substring(t,s);Ys(n)?o.push({type:"DATE",format:n}):o.push({type:"NUMBER",format:ui(n)})}t=s}return o}(e),Us[e]=t),t}function Hs(e,{format:t,locale:o}){if(t===Ro)return ts(e)||"";switch(typeof e){case"string":return e.includes('\\"')?e.replace(/\\"/g,'"'):e;case"boolean":return e?"TRUE":"FALSE";case"number":t||(t=ei(e));return function(e,t,o){if("DATE"===t[0].type)return Xs(e,t[0].format);let s=e<0?"-":"";for(let i of t)switch(i.type){case"NUMBER":s+=zs(Math.abs(e),i.format,o);break;case"STRING":s+=i.format}return s}(e,Bs(t),o);case"object":return""}}function zs(e,t,o){if(e===1/0)return"∞"+(t.isPercent?"%":"");t.isPercent&&(e*=100),e/=t.magnitude;let s=0;void 0!==t.decimalPart&&(s=t.decimalPart.length);const{integerDigits:i,decimalDigits:n}=Gs(e,s);let r=function(e,t,o){const s="0"===e?"":e;let i=s;const n=t.length-s.length;if(n>0){const e=(t.substring(0,n).match(Ls)||[]).length;i="0".repeat(e)+i}o&&(i=i.match(Ps)?.join(o)||i);return i}(i,t.integerPart,t.thousandsSeparator?o.thousandsSeparator:void 0);return void 0!==t.decimalPart&&(r+=o.decimalSeparator+function(e,t){let o=e;if(t.length-e.length>0){const s=(t.substring(e.length,t.length+1).match(Ls)||[]).length;o+="0".repeat(s)}return o}(n||"",t.decimalPart)),t.isPercent&&(r+="%"),r}const $s=[];function Gs(e,t=Fs){const o=e.toString();if(o.includes("e"))return function(e,t=Fs){let o=$s[t];o||(o=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),$s[t]=o);const[s,i]=o.format(e).split(".");return{integerDigits:s,decimalDigits:i}}(e,t);if(Number.isInteger(e))return{integerDigits:o,decimalDigits:void 0};const s=o.indexOf(".");let i=o.substring(0,s),n=o.substring(s+1);if(0===t)return Number(n[0])>=5&&(i=(Number(i)+1).toString()),{integerDigits:i,decimalDigits:void 0};if(n.length>t){const{integerDigits:e,decimalDigits:o}=function(e,t){let o="0",s=e,i=e.slice(0,t);const n=t;if(Number(e[n])<5)return{integerDigits:o,decimalDigits:i};const r=i.match(qs)?.[0]||"",a=(Number(i)+1).toString(),l=i.slice(r.length),c=a.length>l.length;c&&!r?(o="1",s=void 0):s=c?r.slice(0,-1)+a:r+a;return{integerDigits:o,decimalDigits:s}}(n,t);n=o,"0"!==e&&(i=(Number(i)+Number(e)).toString())}return{integerDigits:i,decimalDigits:Ws(n||"")}}function Ws(e){let t=e.length-1;for(;t>=0&&"0"===e[t];)t--;return e.slice(0,t+1)||void 0}const qs=/^0+/;function Zs(e,t){const{integerDigits:o,decimalDigits:s}=Gs(e,20);return s?o+t+s:o}function Ys(e){if(!js.has(e[0]))return!1;try{return Xs(1,e),!0}catch(e){return!1}}const js=new Set(["h","m","y","d","q"]);function Xs(e,t){const o=Gt(e),s=t.indexOf("h");let i="",n="";return s>0?(i=Ks(o,t.substring(0,s-1)),n=Qs(o,t.substring(s))):0===s?n=Qs(o,t):s<0&&(i=Ks(o,t)),i+(i&&n?" ":"")+n}function Ks(e,t){const o=t.match(/\/|-|\s/)?.[0];return(o?t.split(o):[t]).map((o=>{switch(o){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"ddd":return Vs[e.getDay()].slice(0,3);case"dddd":return Vs[e.getDay()];case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"mmm":return ks[e.getMonth()].slice(0,3);case"mmmm":return ks[e.getMonth()];case"mmmmm":return ks[e.getMonth()].slice(0,1);case"qq":return uo("Q%(quarter)s",{quarter:e.getQuarter()});case"qqqq":return uo("Quarter %(quarter)s",{quarter:e.getQuarter()});case"yy":const o=String(e.getFullYear()).replace("-","").padStart(2,"0");return o.slice(o.length-2);case"yyyy":return e.getFullYear();default:throw new Error(`invalid format: ${t}`)}})).join(o)}function Qs(e,t){let o=t.split(/:|\s/);const s=e.getHours(),i="a"===o[o.length-1];let n=s,r="";return i&&(n=0===n?12:n>12?n-12:n,r=s>=12?" PM":" AM",o.pop()),o.map((o=>{switch(o){case"hhhh":return Math.floor((e.getTime()-Ot.getTime())/36e5).toString();case"hh":return n.toString().padStart(2,"0");case"mm":return e.getMinutes().toString().padStart(2,"0");case"ss":return e.getSeconds().toString().padStart(2,"0");default:throw new Error(`invalid format: ${t}`)}})).join(":")+r}const Js=Ye((function(e){return new RegExp(`[0-9]+${ue(e.decimalSeparator)}[0-9]`)}));function ei(e){let{integerDigits:t,decimalDigits:o}=Gs(e);if(!o)return"0";const s=t.replace("-","").length;if(s+2>Ns)return"0";const i=Ns-s-1;return({decimalDigits:o}=Gs(e,Math.min(i,o.length))),o?"0."+"0".repeat(o.length):"0"}function ti(e,t){if(!Ht(e,t))return;return $t(e,t).format}function oi(e){if(!io(e,Ao))return;const t=e.includes(".")?"0.00":"0",o=e.match(/[\$€]/);if(o){const s=e.match(/[\d]/),i="[$"+o.values().next().value+"]";return s.index<o.index?"#,##"+t+i:i+"#,##"+t}return e.includes("%")?t+"%":void 0}function si(e){const t=e.decimalPlaces??2,o=e.position??"before",s=e.code??"",i=e.symbol??"",n="#,##0"+(t?"."+"0".repeat(t):"");let r=`${s} ${i}`.trim();return"after"===o&&s&&(r=" "+r),function(e,t,o){const s=`[$${e}]`;return"before"===t?s+o:o+s}(r,o,n)}function ii(e){return pi(Bs(e).map((e=>"NUMBER"===e.type?{type:e.type,format:{...e.format,decimalPart:void 0}}:e)))}function ni({value:e,format:t},o){return Hs(e,{format:ri({value:e,format:t},void 0,o),locale:o})}function ri(e,t,o){let s=0;try{s=Math.abs(Zo(e?.value,o))}catch(e){return""}const i=e?.format;if(void 0!==t){const e=t?.value;switch(e){case"k":return ai(i,1e3,"k");case"m":return ai(i,1e6,"m");case"b":return ai(i,1e9,"b");default:throw new Lo(uo("The formatting unit should be 'k', 'm' or 'b'."))}}return s<1e5?ai(i,0,""):s<1e8?ai(i,1e3,"k"):s<1e11?ai(i,1e6,"m"):ai(i,1e9,"b")}function ai(e,t,o,s){const i=Bs(e||"#,##0"),n=[];for(let e=0;e<i.length;e++){const s=i[e];if("NUMBER"!==s.type){n.push(s);continue}n.push({...s,format:{...s.format,magnitude:t,decimalPart:void 0}}),n.push({type:"STRING",format:o});const r=i[e+1];"STRING"===r?.type&&["k","m","b"].includes(r.format)&&e++}return pi(n)}function li(e,t,o){const s=Bs(e).map((e=>"NUMBER"===e.type?{...e,format:hi(e.format,t)}:e)),i=pi(s);return Us[i]=s,i}function ci(e){const t=Bs(e);for(let e of t)if("DATE"===e.type&&e.format.includes("q"))return!1;return!0}function hi(e,t){const o={...e},s=Math.sign(t),i=o.decimalPart?.length||0,n=Math.min(Math.max(0,i+s),Fs);return o.decimalPart="0".repeat(n),""===o.decimalPart&&delete o.decimalPart,o}const di=/,*?$/;function ui(e){if(function(e){return Boolean(e.replace(gi,""))}(e=e.trim()))throw new Error(`Invalid number format: ${e}`);const t=e.includes("%"),o=e.match(di)?.[0]||"",s=o?1e3**o.length:1;let i=e.slice(0,e.length-(o.length||0));const n=i.includes(",");if(/\..*,/.test(i))throw new Error("A format can't contain ',' symbol in the decimal part");i=i.replace("%","").replace(",","");const r=i.match(/[\%|,]/);if(r)throw new Error(`A format can only contain a single '${r[0]}' symbol`);const[a,l]=i.split(".");if(l&&l.length>20)throw new Error("A format can't contain more than 20 decimal places");return void 0!==l?{integerPart:a,isPercent:t,thousandsSeparator:n,decimalPart:l,magnitude:s}:{integerPart:a,isPercent:t,thousandsSeparator:n,magnitude:s}}const gi=/[,#0.%@]/g;function pi(e){let t="";for(let o of e){let e;switch(o.type){case"NUMBER":const t=o.format;e=t.integerPart,t.thousandsSeparator&&(e=e.slice(0,-3)+","+e.slice(-3)),void 0!==t.decimalPart&&(e+="."+t.decimalPart),t.isPercent&&(e+="%"),t.magnitude&&(e+=",".repeat(Math.log10(t.magnitude)/3));break;case"STRING":e=`[$${o.format}]`;break;case"DATE":e=o.format}t+=e}return t}const mi=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),fi=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),bi=new RegExp(/^\$?([A-Z]{1,3})+$/,"i"),vi=new RegExp(/^\$?([0-9]{1,7})+$/,"i"),Si=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),Ci=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),yi=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[mi.source,/(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*:\s*(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*/i.source,/\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*:\s*\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*/i.source].join("|")+")"+/$/.source,"i");function Ei(e){return Si.test(e)}function xi(e){return Ci.test(e)}function wi(e){return bi.test(e)}function Ii(e){return vi.test(e)}function Ri(e){return fi.test(e)}function Ti(e){if(!e.includes("!"))return{xc:e};const t=e.split("!"),o=t.pop();return{sheetName:pe(t.join("!"))||void 0,xc:o}}function Ai(e,t){return void 0!==e?`${fe(e)}!${t}`:t}function Oi(e,t=[]){if(e.length<=1&&0===t.length)return e;const o=[0],s=new Map([[0,[]]]);return _i(o,s,e,!1),_i(o,s,t,!0),function(e,t){const o=[];let s=[];for(let i=0;i<e.length;i++){const n=e[i],r=t.get(n);if(!r||0===r.length){o.push(...s),s=[];continue}let a=e[i+1];void 0!==a&&a--;const l=[];for(let e=0;e<r.length;e+=2){const t=r[e];let o=r[e+1];void 0!==o&&o--;const i={top:t,left:n,bottom:o,right:a,hasHeader:void 0===o&&0!==t||void 0===a&&0!==n};let c=!1;for(let e=s.length-1;e>=0;e--){const t=s[e];if(t.top===i.top&&t.bottom===i.bottom){t.right=i.right,s.splice(e,1),l.push(t),c=!0;break}}c||l.push(i)}o.push(...s),s=l}return o.push(...s),o}(o,s)}function _i(e,t,o,s=!1){for(const i of o){const o=i.left,n=void 0===i.right?void 0:i.right+1,r=Di(e,t,o,!0,0),a=Di(e,t,n,!1,r);for(let o=r;o<=a;o++){Mi(t.get(e[o]),i,s)}Fi(e,t,r,a)}}function Di(e,t,o,s,i){if(void 0===o)return e.length-1;const n=Ni(e,o,i);return o!=e[n]?(e.splice(n+1,0,o),t.set(o,[...t.get(e[n])]),s?n+1:n):s?n:n-1}function Mi(e,t,o=!1){const s=t.top,i=void 0===t.bottom?void 0:t.bottom+1,n=[],r=Ni(e,s,0,!1);if((r%2!=0&&!o||r%2==0&&o)&&n.push(s),void 0===i)return e.splice(r+1),void e.push(...n);const a=function(e,t,o=0,s=!0){let i=e.length-1,n=e.length;for(;o<=i;){const r=Math.floor((o+i)/2);if(e[r]===t&&s)return r;e[r]>t?(n=r,i=r-1):o=r+1}return n}(e,i,0,!1);(a%2==0&&!o||a%2!=0&&o)&&n.push(i),e.splice(r+1,a-r-1,...n)}function Fi(e,t,o,s){const i=o-1==-1?0:o-1;for(let o=s===e.length-1?s:s+1;o>i;o--)He(t.get(e[o]),t.get(e[o-1]))&&(t.delete(e[o]),e.splice(o,1))}function Ni(e,t,o=0,s=!0){let i=e.length-1,n=-1;for(;o<=i;){const r=Math.floor((o+i)/2);if(e[r]===t&&s)return r;e[r]<t?(n=r,o=r+1):i=r-1}return n}function Pi(e){const t=function(e){e.includes("!")&&(e=e.split("!").at(-1)),e.includes("$")&&(e=e.replaceAll("$",""));let t,o,s,i,n,r="";e.includes(":")?([r,t]=e.split(":"),r=r.trim(),t=t.trim()):r=e.trim();let a=!1,l=!1,c=!1;if(Ei(r))i=n=xt(r),o=s=0,a=!0;else if(xi(r))o=s=parseInt(r,10)-1,i=n=0,l=!0;else{const e=Rt(r);i=n=e.col,o=s=e.row,c=!0}if(t)if(Ei(t))n=xt(t),a=!0;else if(xi(t))s=parseInt(t,10)-1,l=!0;else{const e=Rt(t);n=e.col,s=e.row,o=a?s:o,i=l?n:i,c=!0}if(a&&l)throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");const h={top:o,left:i,bottom:a?void 0:s,right:l?void 0:n};return c=c&&(l||a),c&&(h.hasHeader=c),h}(e);if(void 0!==t.right&&t.right<t.left){const e=t.left;t.left=t.right,t.right=e}if(void 0!==t.bottom&&t.bottom<t.top){const e=t.top;t.top=t.bottom,t.bottom=e}return t}function Li(e){const t=Pi(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function ki(e){const{bottom:t,top:o,left:s,right:i}=e;return!(void 0!==t&&isNaN(t)||isNaN(o)||isNaN(s)||void 0!==i&&isNaN(i))&&(Vi(e)&&e.top>=0&&e.left>=0)}function Vi(e){return(void 0===e.bottom||e.bottom>=e.top&&e.bottom>=0)&&(void 0===e.right||e.right>=e.left&&e.right>=0)}function Ui(e){const{top:t,bottom:o,left:s,right:i}=e,n="hasHeader"in e&&e.hasHeader,r=t===o&&s===i;if(void 0===o&&void 0!==i)return 0!==t||n?`${Tt(s,t)}:${yt(i)}`:`${yt(s)}:${yt(i)}`;if(void 0===i&&void 0!==o)return 0!==s||n?`${Tt(s,t)}:${o+1}`:`${t+1}:${o+1}`;if(void 0!==o&&void 0!==i)return r?Tt(s,t):`${Tt(s,t)}:${Tt(i,o)}`;throw new Error(uo("Bad zone format"))}function Bi(e,t,o,s,i){const n="left"===t?"columns":"rows",r="before"===s?o-1:o,a=e["left"===t?"right":"bottom"];return e[t]<=r&&a&&a>r?en(e,n,"RESIZE",i):r<e[t]?en(e,n,"MOVE",i):{...e}}function Hi(e,t,o,s,i){const n="left"===t?"columns":"rows",r="before"===s?o-1:o,a="left"===t?"right":"bottom";return e[t]<=r&&e[a]>r?en(e,n,"RESIZE",i):r<e[t]?en(e,n,"MOVE",i):{...e}}function zi(e,t,o){const s="left"===t?"right":"bottom";let i=e[t],n=e[s];for(let r of o.sort(((e,t)=>t-e)))e[t]>r&&(i--,n--),e[t]<r&&e[s]>=r&&n--;return{...e,[t]:i,[s]:n}}function $i(e,t,o){const s="left"===t?"right":"bottom";let i=e[t],n=e[s];const r=e[s];for(let s of o.sort(((e,t)=>t-e)))e[t]>s&&(i--,void 0!==n&&n--),void 0!==r&&void 0!==n&&e[t]<=s&&r>=s&&n--;if(!(void 0!==n&&i>n))return{...e,[t]:i,[s]:n}}function Gi(...e){return{top:Math.min(...e.map((e=>e.top))),left:Math.min(...e.map((e=>e.left))),bottom:Math.max(...e.map((e=>e.bottom))),right:Math.max(...e.map((e=>e.right)))}}function Wi(e,t){if(Zi(e,t))return{top:Math.max(e.top,t.top),left:Math.max(e.left,t.left),bottom:Math.min(e.bottom,t.bottom),right:Math.min(e.right,t.right)}}function qi(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function Zi(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function Yi(e,t,o){const{left:s,right:i,top:n,bottom:r}=o;return e>=s&&e<=i&&t>=n&&t<=r}function ji(e,t){return qi(Gi(t,e),t)}function Xi(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function Ki(e){const{numberOfCols:t,numberOfRows:o}=Xi(e);return 1===t||1===o}function Qi(e){const t=[],{left:o,right:s,top:i,bottom:n}=Ji(e);for(const e of ve(o,s+1))for(const o of ve(i,n+1))t.push({col:e,row:o});return t}function Ji(e){return e.left>e.right&&(e={left:e.right,right:e.left,top:e.top,bottom:e.bottom}),e.top>e.bottom&&(e={left:e.left,right:e.right,top:e.bottom,bottom:e.top}),e}function en(e,t,o,s){const i="both"===t?s[0]:"columns"===t?s:0,n="both"===t?s[1]:"rows"===t?s:0,r="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||r?!(nn(e)&&!r)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===o&&(l.left+=i,l.top+=n),void 0!==l.right&&(l.right+=i),void 0!==l.bottom&&(l.bottom+=n),l}function tn(e,t){let o,s;const{left:i,right:n,top:r,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return o=l!=i?l:c!=n?c:l,s=h!=r?h:d!=a?d:h,{col:o,row:s}}function on(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function sn(e){return{...e,right:e.left,bottom:e.top}}function nn(e){return void 0===e.right}function rn(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function an(e){return e.length<2||1===Oi(e).length}function ln(e,t){const o=Gi(e,t);return e.right+1===t.left||e.left===t.right+1?cn(o)<=cn(e)+cn(t):(e.bottom+1===t.top||e.top===t.bottom+1)&&hn(o)<=hn(e)+hn(t)}function cn(e){return e.bottom-e.top+1}function hn(e){return e.right-e.left+1}function dn(e){const t=[...e];let o=!0;for(;o;){o=!1;for(let e=0;e<t.length;e++){const s=t[e],i=t.findIndex(((t,o)=>e!==o&&(ln(t,s)||Zi(t,s))));if(-1!==i){t[e]=Gi(t[i],s),t.splice(i,1),o=!0;break}}}return t}class un{getSheetSize;_zone;parts;invalidXc;prefixSheet=!1;sheetId;invalidSheetName;constructor(e,t){this.getSheetSize=t,this._zone=e.zone,this.prefixSheet=e.prefixSheet,this.invalidXc=e.invalidXc,this.sheetId=e.sheetId,this.invalidSheetName=e.invalidSheetName;let o=[...e.parts];1===e.parts.length&&rn(this.zone)>1?o.push({...e.parts[0]}):2===e.parts.length&&1===rn(this.zone)&&o.pop(),this.parts=o}static fromRange(e,t){return e instanceof un?e:new un(e,t.getSheetSize)}get unboundedZone(){return this._zone}get zone(){const{left:e,top:t,bottom:o,right:s}=this._zone;if(void 0!==s&&void 0!==o)return this._zone;if(void 0===o&&void 0!==s)return{right:s,top:t,left:e,bottom:this.getSheetSize(this.sheetId).numberOfRows-1};if(void 0===s&&void 0!==o)return{bottom:o,left:e,top:t,right:this.getSheetSize(this.sheetId).numberOfCols-1};throw new Error(uo("Bad zone format"))}static getRangeParts(e,t){const o=e.split(":").map((e=>{const t=xi(e);return{colFixed:!t&&e.startsWith("$"),rowFixed:t?e.startsWith("$"):e.includes("$",1)}})),s=void 0===t.bottom,i=void 0===t.right;return s&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed),i&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed),o}get isFullCol(){return void 0===this._zone.bottom}get isFullRow(){return void 0===this._zone.right}get rangeData(){return{_zone:this._zone,_sheetId:this.sheetId}}orderZone(){if(Vi(this._zone))return this;const e={...this._zone};let t=this.parts;if(void 0!==e.right&&e.right<e.left){let o=e.right;e.right=e.left,e.left=o,t=[{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1},{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1}]}if(void 0!==e.bottom&&e.bottom<e.top){let o=e.bottom;e.bottom=e.top,e.top=o,t=[{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1},{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1}]}return this.clone({zone:e,parts:t})}clone(e){return new un({zone:e?.zone?e.zone:{...this._zone},sheetId:e?.sheetId?e.sheetId:this.sheetId,invalidSheetName:e&&"invalidSheetName"in e?e.invalidSheetName:this.invalidSheetName,invalidXc:e&&"invalidXc"in e?e.invalidXc:this.invalidXc,parts:e?.parts?e.parts:this.parts.map((e=>({rowFixed:e.rowFixed,colFixed:e.colFixed}))),prefixSheet:void 0!==e?.prefixSheet?e.prefixSheet:this.prefixSheet},this.getSheetSize)}}function gn(e,t,o){const s=o.sheetId===e?t:o.sheetId;return o.clone({sheetId:s})}function pn(e,t,o){if(!o)return;const s=e.getRangeFromSheetXC(t,o);return s.invalidSheetName||s.invalidXc?void 0:s}function mn(e){const t=[];for(const o of e)for(const e of Qi(o.zone))t.push({...e,sheetId:o.sheetId});return t}function fn(e,t,o){const s=[];return t.forEach((t=>{const i=function(e,t){e=e.toLocaleLowerCase();let o=0,s=0,i=(t=t.toLocaleLowerCase()).length,n=0;for(let r=0;r<i;r++)t[r]===e[n]?(n++,s+=100+s-r/200):s=0,o+=s;return n===e.length?o:0}(e,o(t));i>0&&s.push({score:i,elem:t})})),s.sort(((e,t)=>t.score-e.score)),s.map((e=>e.elem))}function bn(e){const t=[];for(let o=0;o<e;o++){const e={cells:{}};t.push(e)}return t}function vn(e,t,o){return o.map((o=>o>=e?o+t:o))}function Sn(e,t){return e=[...e].sort(((e,t)=>t-e)),t.map((t=>{for(const o of e)if(t>o)t--;else if(t===o)return;return t})).filter(De)}function Cn(e,t=1){return t*(e+N)-N}function yn(e,t=!1,o=!1){return`${o?"italic":""} ${t?"bold":""} ${e}px ${W}`}const En={};function xn(e,t,o,s="pt"){const i=An(o,s);e.save(),e.font=i;const n=wn(e,t);return e.restore(),n}function wn(e,t){const o=e.font;if(En[o]||(En[o]={}),void 0===En[o][t]){const s=e.measureText(t).width;En[o][t]=s}return En[o][t]}const In={};function Rn(e,t,o,s="pt"){const i=An(o,s);e.save(),e.font=i;const n=function(e,t){const o=e.font;In[o]||(In[o]={});if(void 0===In[o][t]){const s=e.measureText(t),i=s.width,n=s.fontBoundingBoxAscent+s.fontBoundingBoxDescent;In[o][t]={width:i,height:n}}return In[o][t]}(e,t);return e.restore(),n}function Tn(e){return Math.round(96*e/72)}function An(e,t="pt"){return`${e.italic?"italic ":""}${e.bold?"bold":$} ${("pt"===t?On(e):e.fontSize)??G}px ${W}`}function On(e){return Tn(e?.fontSize||G)}function _n(e,t,o,s){if(xn(e,t,s)<=o)return[t];const i=[];let n="";for(let r of t){xn(e,n+r,s)>o?(i.push(n),n=r):n+=r}return i.push(n),i}function Dn(e,t,o,s){o||(o={});const i=[],n=t.includes(le)?t.split(le):[t];for(const t of n){const n=t.includes(" ")?t.split(" "):[t];if(!s){i.push(t);continue}let r="",a=s;for(let t of n){const n=_n(e,t,s,o),l=n.pop(),c=xn(e,l,o);if(n.length)""!==r&&(i.push(r),r="",a=s),n.forEach((e=>{i.push(e)})),r=l,a=s-c;else{const t=""===r?l:" "+l,n=xn(e,t,o);n<=a?(r+=t,a-=n):(i.push(r),r=l,a=s-c)}}""!==r&&i.push(r)}return i}function Mn(e,t,o,s=.25){let i=1;if(o(i)>e)return i;if(o(t)<e)return t;let n=(i+t)/2,r=o(n),a=0;for(;Math.abs(r-e)>s&&a<20;)r>=e?t=(i+t)/2:i=(i+t)/2,n=(i+t)/2,r=o(n),a++;return n}function Fn(e){return e?e.toLowerCase():""}const Nn=/([0-9\.]*)px/;function Pn(e,t,o){let s=wn(e,t);if(s<=o)return t;const i=wn(e,t);if(s<=i)return t;let n=t.length;for(;s>=o-i&&n-- >0;)s=wn(e,t=t.substring(0,n));return t+"…"}function Ln(e){let t="";for(;" "===e[0];)t+=" ",e=e.slice(1);const o=e.length,s=Math.floor(o/2),i=e.substring(0,s).lastIndexOf(" "),n=e.substring(s).indexOf(" ")+s;return-1===i&&n===s-1?[t+e,""]:i>o-n||n===s-1?[t+e.slice(0,i),t+e.slice(i+1)]:[t+e.slice(0,n),t+e.slice(n+1)]}function kn(e,t,o,s=!1,i=!1,n=function(e){return Number(e.match(Nn)?.[1])}(e.font)/10){if(e.fillText(t,o.x,o.y),!s&&!i)return;const r=e.measureText(t),a=r.width,l=r.actualBoundingBoxAscent+r.actualBoundingBoxDescent,c=r.fontBoundingBoxAscent+r.fontBoundingBoxDescent;let{x:h,y:d}=o,u=d,g=d;switch(e.textAlign){case"center":h-=a/2;break;case"right":h-=a}switch(e.textBaseline){case"top":g+=c-2*n,u+=c/2-n;break;case"middle":g+=c/2-n;break;case"alphabetic":g+=2*n,u-=3*n;break;case"bottom":g=d,u-=l/2-n/2}s&&(e.lineWidth=n,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(h,g),e.lineTo(h+a,g),e.stroke()),i&&(e.lineWidth=n,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(h,u),e.lineTo(h+a,u),e.stroke())}class Vn{isFastIdStrategy=!1;fastIdStart=0;setIsFastStrategy(e){this.isFastIdStrategy=e}uuidv4(){return this.isFastIdStrategy?(this.fastIdStart++,String(this.fastIdStart)):window.crypto&&window.crypto.getRandomValues?([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))):"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}}function Un(e){return e.map(Hn).sort(((e,t)=>e.sequence-t.sequence))}const Bn=new Vn;function Hn(e){const t=e.name,o=e.children,s=e.description,i=e.icon,n=e.secondaryIcon;return{id:e.id||Bn.uuidv4(),name:"function"==typeof t?t:()=>t,isVisible:e.isVisible?e.isVisible:()=>!0,isEnabled:e.isEnabled?e.isEnabled:()=>!0,isActive:e.isActive,execute:e.execute,children:o?e=>o.map((t=>"function"==typeof t?t(e):t)).flat().map(Hn):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:"function"==typeof i?i:()=>i||"",secondaryIcon:"function"==typeof n?n:()=>n||"",description:"function"==typeof s?s:()=>s||"",textColor:e.textColor,sequence:e.sequence||0,onStartHover:e.onStartHover,onStopHover:e.onStopHover}}class zn{content={};add(e,t){return this.content[e]=t,this}get(e){const t=this.content[e];if(!t&&!(e in this.content))throw new 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 $n(e){const t=new Set(e.map((e=>e.left))),o=new Set(e.map((e=>e.right))),s=new Set(e.map((e=>e.top))),i=new Set(e.map((e=>e.bottom))),n=1===s.size&&1===i.size||1===t.size&&1===o.size?function(e){return e.reduce(((e,t)=>{const o=e.length;for(let s=0;s<o;s++)if(Zi(e[s],t))return e[s]=Gi(e[s],t),e;return e[o]=t,e}),[])}(e):[e[e.length-1]],r=n.map((e=>Qi(e))).flat();return{zones:e,clippedZones:n,columnsIndexes:[...new Set(r.map((e=>e.col)))].sort(((e,t)=>e-t)),rowsIndexes:[...new Set(r.map((e=>e.row)))].sort(((e,t)=>e-t))}}function Gn(e,t){if(!t.length||!t[0].length)return e;const o=t[0].length,s=t.length;return e.map((e=>function(e,t,o){const s=Math.max(e.right-t+1,e.left),i=Math.max(e.bottom-o+1,e.top),n=[];for(let r=e.left;r<=s;r+=t)for(let s=e.top;s<=i;s+=o)n.push({left:r,top:s,bottom:s+o-1,right:r+t-1});return n}(e,o,s))).flat()}class Wn{getters;dispatch;constructor(e,t){this.getters=e,this.dispatch=t}copy(e){}paste(e,t,o){}isPasteAllowed(e,t,o,s){return"Success"}isCutAllowed(e){return"Success"}getPasteTarget(e,t,o){return{zones:[]}}convertOSClipboardData(e){}}class qn extends Wn{copy(e){}pasteFromCopy(e,t,o,s){if(1===t.length)for(const i of Gn(t,o))this.pasteZone(e,i.left,i.top,o,s);else for(const i of Oi(t))for(let t=i.left;t<=i.right;t++)for(let n=i.top;n<=i.bottom;n++)this.pasteZone(e,t,n,o,s)}pasteZone(e,t,o,s,i){}}const Zn=["%"],Yn="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(Zn);function jn(e,t=Ao){e=qe(e);const o=new lr(e),s=[];for(;!o.isOver();){let e=rr(o)||Jn(o,t)||Qn(o)||er(o)||sr(o)||Xn(o)||ar(o)||or(o,t)||nr(o);e||(e={type:"UNKNOWN",value:o.shift()}),s.push(e)}return s}function Xn(e){return"?"===e.current?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const Kn={"(":{type:"LEFT_PAREN",value:"("},")":{type:"RIGHT_PAREN",value:")"}};function Qn(e){if("("===e.current||")"===e.current){const t=e.shift();return Kn[t]}return null}function Jn(e,t){if(e.current===t.formulaArgSeparator){return{type:"ARG_SEPARATOR",value:e.shift()}}return null}function er(e){for(let t of Yn)if(e.currentStartsWith(t))return e.advanceBy(t.length),{type:"OPERATOR",value:t};return null}const tr=new Set("0123456789");function or(e,t){if(!tr.has(e.current)&&e.current!==t.decimalSeparator)return null;const o=e.remaining().match(oo(t.decimalSeparator));return o?(e.advanceBy(o[0].length),{type:"NUMBER",value:o[0]}):null}function sr(e){if('"'===e.current){const t=e.shift();let o=t;for(;e.current&&(e.current!==t||"\\"===o[o.length-1]);)o+=e.shift();return'"'===e.current&&(o+=e.shift()),{type:"STRING",value:o}}return null}const ir=new Set("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.!$");function nr(e){let t="";if("'"===e.current){let o=e.shift();for(t+=o;e.current;)if(o=e.shift(),t+=o,"'"===o){if(!e.current||"'"!==e.current)break;o=e.shift(),t+=o}if("'"!==o)return{type:"UNKNOWN",value:t}}for(;e.current&&ir.has(e.current);)t+=e.shift();if(t.length){const e=t;return yi.test(e)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}function rr(e){let t=0;for(;e.current===le;)t++,e.shift();if(t)return{type:"SPACE",value:le.repeat(t)};for(;" "===e.current;)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function ar(e){return e.currentStartsWith(No.InvalidReference)?(e.advanceBy(No.InvalidReference.length),{type:"INVALID_REFERENCE",value:No.InvalidReference}):null}class lr{text;currentIndex=0;current;constructor(e){this.text=e,this.current=e[0]}shift(){const e=this.current,t=this.text[++this.currentIndex];return this.current=t,e}advanceBy(e){this.currentIndex+=e,this.current=this.text[this.currentIndex]}isOver(){return this.currentIndex>=this.text.length}remaining(){return this.text.substring(this.currentIndex)}currentStartsWith(e){if(this.current!==e[0])return!1;for(let t=1;t<e.length;t++)if(this.text[this.currentIndex+t]!==e[t])return!1;return!0}}function cr(e){if(!e||"object"!=typeof e||"string"!=typeof e.name||"string"!=typeof e.code||"string"!=typeof e.thousandsSeparator||"string"!=typeof e.decimalSeparator||"string"!=typeof e.dateFormat||"string"!=typeof e.timeFormat||"string"!=typeof e.formulaArgSeparator)return!1;if(!Object.values(e).every((e=>e)))return!1;if(e.formulaArgSeparator===e.decimalSeparator)return!1;if(e.thousandsSeparator===e.decimalSeparator)return!1;try{Hs(1,{locale:e,format:"#,##0.00"}),Hs(1,{locale:e,format:e.dateFormat}),Hs(1,{locale:e,format:e.timeFormat})}catch{return!1}return!0}function hr(e,t){return e.startsWith("=")?gr(e,t):fr(e,t)}function dr(e,t){return e.startsWith("=")?gr(e,t):function(e,t){if(Ht(e,t)){const o=Zo(e,t);let s=Ao.dateFormat;return Number.isInteger(o)||(s+=" "+Ao.timeFormat),Hs(o,{locale:Ao,format:s})}return fr(e,t)}(e,t)}function ur(e,t){return e.startsWith("=")?pr(e,t):function(e,t){if(Ht(e,Ao)){const o=Zo(e,Ao);let s=t.dateFormat;return Number.isInteger(o)||(s+=" "+t.timeFormat),Hs(o,{locale:t,format:s})}return function(e,t){if("."===t.decimalSeparator||!io(e,Ao))return e;const o=Js(Ao),s=e.replace(o,(e=>e.replace(".",t.decimalSeparator)));return s}(e,t)}(e,t)}function gr(e,t){return mr(e,t,Ao)}function pr(e,t){return mr(e,Ao,t)}function mr(e,t,o){if(t.formulaArgSeparator===o.formulaArgSeparator&&t.decimalSeparator===o.decimalSeparator)return e;const s=jn(e,t);let i="";for(const e of s)"NUMBER"===e.type?i+=e.value.replace(t.decimalSeparator,o.decimalSeparator):"ARG_SEPARATOR"===e.type?i+=o.formulaArgSeparator:i+=e.value;return i}function fr(e,t){return"."!==t.decimalSeparator&&io(e,t)?e.replace(t.thousandsSeparator,"").replace(t.decimalSeparator,"."):e}function br(e,t){return Cr(e,(e=>dr(e,t)))}function vr(e,t){return Cr(e,(e=>ur(e,t)))}function Sr(e,t){const o=ge(e);return o.criterion.values=o.criterion.values.map((e=>ur(e,t))),o}function Cr(e,t){switch((e=ge(e)).type){case"CellIsRule":switch(e.operator){case"Between":case"NotBetween":case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return e.values=e.values.map((e=>t(e))),e;case"BeginsWith":case"ContainsText":case"EndsWith":case"NotContains":case"IsEmpty":case"IsNotEmpty":return e}break;case"ColorScaleRule":return e.minimum=yr(e.minimum,t),e.maximum=yr(e.maximum,t),e.midpoint&&(e.midpoint=yr(e.midpoint,t)),e;case"IconSetRule":return e.lowerInflectionPoint.value=t(e.lowerInflectionPoint.value),e.upperInflectionPoint.value=t(e.upperInflectionPoint.value),e}}function yr(e,t){if(!e?.value)return e;const o=t("formula"===e.type?"="+e.value:e.value),s="formula"===e.type?o.slice(1):o;return{...e,value:s}}function Er(e){return e.dateFormat+" "+e.timeFormat}function xr(e,t){return e.startsWith("=")?function(e,t){return function(e,t,o){if(t.formulaArgSeparator===o.formulaArgSeparator&&t.decimalSeparator===o.decimalSeparator)return e;const s=jn(e,t);let i="";for(const e of s)"NUMBER"===e.type?i+=e.value.replace(t.decimalSeparator,o.decimalSeparator):"ARG_SEPARATOR"===e.type?i+=o.formulaArgSeparator:i+=e.value;return i}(e,t,Ao)}(e,t):fr(e,t)}class wr extends qn{isCutAllowed(e){return 1!==e.zones.length?"WrongCutSelection":"Success"}copy(e){if(!("zones"in e)||!e.zones.length)return;const t=this.getters.getActiveSheetId();if(!e.zones.length)return{cells:[[]],zones:[],sheetId:t};const{clippedZones:o,rowsIndexes:s,columnsIndexes:i}=e,n=[];for(let e of s){let o=[];for(let n of i){const r={col:n,row:e,sheetId:t},a=this.getters.getArrayFormulaSpreadingOn(r);let l=this.getters.getCell(r);const c=this.getters.getEvaluatedCell(r);if(a&&!Be(a,r)){const e=s.includes(a.row)&&i.includes(a.col)?"":Hs(c.value,{locale:this.getters.getLocale()});l={id:l?.id||"",style:l?.style,format:c.format,content:e,isFormula:!1}}o.push({cell:l,border:this.getters.getCellBorder(r)||void 0,evaluatedCell:c,position:r})}n.push(o)}return{cells:n,zones:o,sheetId:this.getters.getActiveSheetId()}}isPasteAllowed(e,t,o,s){return"cells"in o?s?.isCutOperation&&void 0!==s?.pasteOption?"WrongPasteOption":t.length>1&&(o.cells.length>1||o.cells[0].length>1)?"WrongPasteSelection":"Success":"Success"}paste(e,t,o){if(!("cells"in t)||!("zones"in e)||!e.zones.length)return;const s=e.zones,i=this.getters.getActiveSheetId();o?.isCutOperation?this.pasteFromCut(i,s,t,o):this.pasteFromCopy(i,s,t.cells,o)}getPasteTarget(e,t,o){const s=t.cells[0].length,i=t.cells.length;return o?.isCutOperation?{zones:[{left:e[0].left,top:e[0].top,right:e[0].left+s-1,bottom:e[0].top+i-1}]}:1===s&&1===i?{zones:[]}:{zones:Gn(e,t.cells)}}pasteFromCut(e,t,o,s){this.clearClippedZones(o);const i=t[0];this.pasteZone(e,i.left,i.top,o.cells,s),this.dispatch("MOVE_RANGES",{target:o.zones,sheetId:o.sheetId,targetSheetId:e,col:i.left,row:i.top})}clearClippedZones(e){for(const t of e.cells)for(const e of t)e.cell&&this.dispatch("CLEAR_CELL",e.position);this.dispatch("CLEAR_FORMATTING",{sheetId:e.sheetId,target:e.zones})}pasteZone(e,t,o,s,i){for(const[n,r]of s.entries())for(const[s,a]of r.entries()){if(!a)continue;const r={col:t+s,row:o+n,sheetId:e};this.pasteCell(a,r,i)}}pasteCell(e,t,o){const{sheetId:s,col:i,row:n}=t,r=this.getters.getEvaluatedCell(t),a=e.cell?.format??e.evaluatedCell.format;if("asValue"===o?.pasteOption){const o=this.getters.getLocale(),s=Hs(e.evaluatedCell.value,{locale:o});return void this.dispatch("UPDATE_CELL",{...t,content:s,format:a})}if("onlyFormat"===o?.pasteOption)return void this.dispatch("UPDATE_CELL",{...t,style:e.cell?.style??null,format:a??r.format});let l=e.cell?.content;e.cell?.isFormula&&!o?.isCutOperation?l=this.getters.getTranslatedCellFormula(s,i-e.position.col,n-e.position.row,e.cell.compiledFormula):e.cell?.isFormula&&(l=this.getters.getFormulaMovedInSheet(s,e.cell.compiledFormula)),""!==l||e.cell?.format||e.cell?.style?this.dispatch("UPDATE_CELL",{...t,content:l,style:e.cell?.style||null,format:e.cell?.format}):r&&this.dispatch("CLEAR_CELL",t)}convertOSClipboardData(e){const t=this.getters.getLocale(),o={cells:[]},s=[];let i=0;for(const[t,o]of e.replace(/\r/g,"").split("\n").entries())s.push(o.split("\t")),s[t].length>i&&(i=s[t].length);for(const e of s){const s=[];for(let o=0;o<i;o++){const i=xr(e[o]||"",t);s.push({cell:{isFormula:!1,content:i},evaluatedCell:{formattedValue:i}})}o.cells.push(s)}return o}}class Ir extends Wn{copy(e){}}const Rr={figureHandlers:new zn,cellHandlers:new zn};function Tr(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?$i(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?Bi(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function Ar(e,t){const o="DELETE_SHEET"===t.type&&t.sheetId;if("sheetId"in t&&e._sheetId!==t.sheetId)return e;{const s=Tr(e._zone,t);if(s&&o!==e._sheetId)return{...e,_zone:s}}}Rr.figureHandlers.add("chart",class extends Ir{copy(e){const t=this.getters.getActiveSheetId(),o=this.getters.getFigure(t,e.figureId);if(!o)throw new Error(`No figure for the given id: ${e.figureId}`);if("chart"!==o.tag)return;const s={...o},i=this.getters.getChart(e.figureId);if(!i)throw new Error(`No chart for the given id: ${e.figureId}`);const n=i.copyInSheetId(t);return{figureId:e.figureId,copiedFigure:s,copiedChart:n}}getPasteTarget(e,t,o){if(!t?.copiedFigure||!t?.copiedChart)return{zones:[]};return{zones:[],figureId:(new Vn).uuidv4()}}paste(e,t,o){if(!t?.copiedFigure||!t?.copiedChart||!e.figureId)return;const{zones:s,figureId:i}=e,n=this.getters.getActiveSheetId(),r=this.getters.getNumberCols(n),a=this.getters.getNumberRows(n),l=this.getters.getColDimensions(n,s[0].left).start,c=this.getters.getRowDimensions(n,s[0].top).start,h=this.getters.getColDimensions(n,r-1).end,d=this.getters.getRowDimensions(n,a-1).end,{width:u,height:g}=t.copiedFigure,p={x:h<u?0:Math.min(l,h-u),y:d<g?0:Math.min(c,d-g)},m=t.copiedChart.copyInSheetId(n);this.dispatch("CREATE_CHART",{id:i,sheetId:n,position:p,size:{height:g,width:u},definition:m.getDefinition()}),o?.isCutOperation&&this.dispatch("DELETE_FIGURE",{sheetId:t.copiedChart.sheetId,id:t.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:i})}isPasteAllowed(e,t,o,s){return 0===t.length?"EmptyTarget":void 0!==s?.pasteOption?"WrongFigurePasteOption":"Success"}}).add("image",class extends Ir{copy(e){const t=this.getters.getActiveSheetId(),o=this.getters.getFigure(t,e.figureId);if(!o)throw new Error(`No figure for the given id: ${e.figureId}`);const s={...o};if("image"!==o.tag)return;const i=ge(this.getters.getImage(e.figureId));return{figureId:e.figureId,copiedFigure:s,copiedImage:i,sheetId:t}}getPasteTarget(e,t,o){if(!t?.copiedFigure||!t?.copiedImage)return{zones:[]};return{zones:[],figureId:(new Vn).uuidv4()}}paste(e,t,o){if(!t?.copiedFigure||!t?.copiedImage||!e.figureId)return;const{zones:s,figureId:i}=e,n=this.getters.getActiveSheetId(),r=this.getters.getNumberCols(n),a=this.getters.getNumberRows(n),l=this.getters.getColDimensions(n,s[0].left).start,c=this.getters.getRowDimensions(n,s[0].top).start,h=this.getters.getColDimensions(n,r-1).end,d=this.getters.getRowDimensions(n,a-1).end,{width:u,height:g}=t.copiedFigure,p={x:h<u?0:Math.min(l,h-u),y:d<g?0:Math.min(c,d-g)},m=ge(t.copiedImage);this.dispatch("CREATE_IMAGE",{figureId:i,sheetId:n,position:p,size:{height:g,width:u},definition:m}),o?.isCutOperation&&this.dispatch("DELETE_FIGURE",{sheetId:t.sheetId,id:t.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:i})}isPasteAllowed(e,t,o,s){return 0===t.length?"EmptyTarget":void 0!==s?.pasteOption?"WrongFigurePasteOption":"Success"}}),Rr.cellHandlers.add("dataValidation",class extends qn{uuidGenerator=new Vn;copy(e){if(!e.zones.length)return;const{rowsIndexes:t,columnsIndexes:o}=e,s=this.getters.getActiveSheetId();return{cellPositions:t.map((e=>o.map((t=>({col:t,row:e,sheetId:s})))))}}paste(e,t,o){if(!t?.cellPositions)return;if(o?.pasteOption)return;if(!("zones"in e)||!e.zones.length)return;const s=e.zones,i=this.getters.getActiveSheetId();o?.isCutOperation?this.pasteFromCut(i,s,t):this.pasteFromCopy(i,s,t.cellPositions)}pasteFromCut(e,t,o){const s=t[0];this.pasteZone(e,s.left,s.top,o.cellPositions,{isCutOperation:!0})}pasteZone(e,t,o,s,i){for(const[n,r]of s.entries())for(const[s,a]of r.entries()){const r={col:t+s,row:o+n,sheetId:e};this.pasteDataValidation(a,r,i?.isCutOperation)}}pasteDataValidation(e,t,o){const s=this.getters.getValidationRuleForCell(e);if(!s){const e=this.getters.getValidationRuleForCell(t);return void(e&&this.adaptDataValidationRule(t.sheetId,e,[],[on(t)]))}const i=on(t);for(const n of s.ranges)if(Yi(e.col,e.row,n.zone)){const n=[];if(o&&n.push(on(e)),e.sheetId===t.sheetId)this.adaptDataValidationRule(e.sheetId,s,[i],n);else{this.adaptDataValidationRule(e.sheetId,s,[],n);const o=this.getDataValidationRuleToCopyTo(t.sheetId,s);this.adaptDataValidationRule(t.sheetId,o,[i],[])}}}getDataValidationRuleToCopyTo(e,t){const o=this.getters.getDataValidationRules(e).find((e=>Be(t.criterion,e.criterion)&&t.isBlocking===e.isBlocking));return o||{...t,id:this.uuidGenerator.uuidv4(),ranges:[]}}adaptDataValidationRule(e,t,o,s){const i=t.ranges.map((e=>e.zone)),n=Oi([...i,...o],s);0!==n.length?this.dispatch("ADD_DATA_VALIDATION_RULE",{rule:t,ranges:n.map((t=>this.getters.getRangeDataFromZone(e,t))),sheetId:e}):this.dispatch("REMOVE_DATA_VALIDATION_RULE",{sheetId:e,id:t.id})}}).add("cell",wr).add("sheet",class extends qn{isPasteAllowed(e,t,o,s){if(!("cells"in o))return"Success";const{xSplit:i,ySplit:n}=this.getters.getPaneDivisions(e);for(const e of Gn(t,o.cells))if(e.left<i&&e.right>=i||e.top<n&&e.bottom>=n)return"FrozenPaneOverlap";return"Success"}}).add("merge",class extends qn{isPasteAllowed(e,t,o){if(!("cells"in o))return"Success";const s=o.cells.length,i=o.cells[0].length;for(const n of Gn(t,o.cells))if(this.getters.doesIntersectMerge(e,n)&&(t.length>1||!this.getters.isSingleCellOrMerge(e,t[0])||s*i!=1))return"WillRemoveExistingMerge";return"Success"}paste(e,t,o){if(o?.isCutOperation||!("zones"in e)||!e.zones.length)return;const s=this.getters.getActiveSheetId();this.pasteFromCopy(s,e.zones,t.cells,o)}pasteZone(e,t,o,s){for(const[i,n]of s.entries())for(const[s,r]of n.entries()){if(!r.position)continue;const n={col:t+s,row:o+i,sheetId:e};this.pasteMergeIfExist(r.position,n)}}pasteMergeIfExist(e,t){let{sheetId:o,col:s,row:i}=e;const{col:n,row:r}=this.getters.getMainCellPosition(e);if(n===s&&r===i){const n=this.getters.getMerge(e);if(!n)return;({sheetId:o,col:s,row:i}=t),this.dispatch("ADD_MERGE",{sheetId:o,force:!0,target:[{left:s,top:i,right:s+n.right-n.left,bottom:i+n.bottom-n.top}]})}}}).add("border",class extends qn{copy(e){const t=this.getters.getActiveSheetId();if(0===e.zones.length)return;const{rowsIndexes:o,columnsIndexes:s}=e,i=[];for(const e of o){const o=[];for(const i of s){const s={col:i,row:e,sheetId:t};o.push(this.getters.getCellBorder(s))}i.push(o)}return{borders:i}}paste(e,t,o){if(!t)return;const s=this.getters.getActiveSheetId();if("asValue"===o?.pasteOption)return;if(!("borders"in t)||!("zones"in e)||!e.zones.length)return;const i=e.zones;if(o?.isCutOperation){const{left:e,top:o}=i[0];this.pasteZone(s,e,o,t.borders)}else this.pasteFromCopy(s,i,t.borders)}pasteZone(e,t,o,s){for(const[i,n]of s.entries())for(const[s,r]of n.entries()){const n={col:t+s,row:o+i,sheetId:e};this.pasteBorder(r,n)}}pasteBorder(e,t){const o={...this.getters.getCellBorder(t),...e};this.dispatch("SET_BORDER",{...t,border:o})}}).add("table",class extends qn{copy(e){const t=this.getters.getActiveSheetId(),{rowsIndexes:o,columnsIndexes:s,zones:i}=e;if(!i||!o.length||!s.length)return{tableCells:[[]],sheetId:t};const n=new Set,r=[];for(let e of o){let o=[];r.push(o);for(let r of s){const s={col:r,row:e,sheetId:t},a=this.getters.getTable(s);if(!a||n.has(a.id)){o.push({});continue}const l=this.getters.getCoreTable(s),c=l?.range.zone;if(l&&c&&i.some((e=>ji(c,e)))){n.add(l.id);const e=[];for(const o of ve(c.left,c.right+1))e.push(this.getters.getFilterHiddenValues({sheetId:t,col:o,row:c.top}));o.push({table:{range:l.range,config:l.config,type:l.type}})}else a&&o.push({style:this.getTableStyleToCopy(s)})}}return{tableCells:r,sheetId:this.getters.getActiveSheetId()}}getTableStyleToCopy(e){const t=this.getters.getCellTableStyle(e),o=this.getters.getCellStyle(e),s=this.getters.getCellTableBorder(e),i=this.getters.getCellBorder(e);return{style:{...t,...$e(o)},border:{...s,...$e(i)}}}paste(e,t,o){if(!t||!t.tableCells)return;const s=e.zones,i=this.getters.getActiveSheetId();o?.isCutOperation?this.pasteFromCut(i,s,t,o):this.pasteFromCopy(i,s,t.tableCells,o)}pasteFromCut(e,t,o,s){for(const e of o.tableCells)for(const t of e)t.table&&this.dispatch("REMOVE_TABLE",{sheetId:o.sheetId,target:[t.table.range.zone]});const i=t[0];this.pasteZone(e,i.left,i.top,o.tableCells,s)}pasteZone(e,t,o,s,i){for(let n=0;n<s.length;n++){const r=s[n];for(let s=0;s<r.length;s++){const a=r[s];if(!a)continue;const l={col:t+s,row:o+n,sheetId:e};this.pasteTableCell(e,a,l,i)}}if(1===s.length)for(let i=0;i<s[0].length;i++)this.dispatch("AUTOFILL_TABLE_COLUMN",{col:t+i,row:o,sheetId:e})}pasteTableCell(e,t,o,s){if(t.table&&!s?.pasteOption){const{range:s}=t.table,i=Xi(s.zone),n={left:o.col,top:o.row,right:o.col+i.numberOfCols-1,bottom:o.row+i.numberOfRows-1};this.dispatch("CREATE_TABLE",{sheetId:o.sheetId,ranges:[this.getters.getRangeDataFromZone(e,n)],config:t.table.config,tableType:t.table.type})}this.getters.getCoreTable(o)||(t.style?.style&&"asValue"!==s?.pasteOption&&this.dispatch("UPDATE_CELL",{...o,style:t.style.style}),t.style?.border&&this.dispatch("SET_BORDER",{...o,border:t.style.border}))}}).add("conditionalFormat",class extends qn{uuidGenerator=new Vn;copy(e){if(!e.zones.length)return;const{rowsIndexes:t,columnsIndexes:o}=e,s=this.getters.getActiveSheetId();return{cellPositions:t.map((e=>o.map((t=>({col:t,row:e,sheetId:s})))))}}paste(e,t,o){if(!t?.cellPositions||"asValue"===o?.pasteOption||!("zones"in e)||!e.zones.length)return;const s=e.zones,i=this.getters.getActiveSheetId();o?.isCutOperation?this.pasteFromCut(i,s,t):this.pasteFromCopy(i,s,t.cellPositions)}pasteFromCut(e,t,o){const s=t[0];this.pasteZone(e,s.left,s.top,o.cellPositions,{isCutOperation:!0})}pasteZone(e,t,o,s,i){for(const[n,r]of s.entries())for(const[s,a]of r.entries()){const r={col:t+s,row:o+n,sheetId:e};this.pasteCf(a,r,i?.isCutOperation)}}pasteCf(e,t,o){const s=on(t);for(const i of this.getters.getConditionalFormats(e.sheetId))for(const n of i.ranges)if(Yi(e.col,e.row,this.getters.getRangeFromSheetXC(e.sheetId,n).zone)){const n=[];if(o&&n.push(on(e)),e.sheetId===t.sheetId)this.adaptCFRules(e.sheetId,i,[s],n);else{this.adaptCFRules(e.sheetId,i,[],n);const o=this.getCFToCopyTo(t.sheetId,i);this.adaptCFRules(t.sheetId,o,[s],[])}}}adaptCFRules(e,t,o,s){const i=this.getters.getAdaptedCfRanges(e,t,o,s);i&&(0!==i.length?this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},ranges:i,sheetId:e}):this.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:t.id,sheetId:e}))}getCFToCopyTo(e,t){const o=this.getters.getConditionalFormats(e).find((e=>e.stopIfTrue===t.stopIfTrue&&Be(e.rule,t.rule)));return o||{...t,id:this.uuidGenerator.uuidv4(),ranges:[]}}});const Or=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,_r=["-","+"],Dr=["%"],Mr=["*","+","&"],Fr={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10};function Nr(e){const t=e.shift();if(!t)throw new ko;switch(t.type){case"DEBUGGER":const o=kr(e,1e3);return o.debug=!0,o;case"NUMBER":return{type:"NUMBER",value:ro(t.value,Ao)};case"STRING":return{type:"STRING",value:de(t.value)};case"INVALID_REFERENCE":throw new Vo;case"REFERENCE":if(":"===e[0]?.value&&"REFERENCE"===e[1]?.type){e.shift();const o=e.shift();return{type:"REFERENCE",value:`${t.value}:${o?.value}`}}return{type:"REFERENCE",value:t.value};case"SYMBOL":const s=t.value,i=e[0];if("LEFT_PAREN"===i?.type&&Or.test(t.value)){const t=function(e){Lr(e,"LEFT_PAREN",uo("Missing opening parenthesis"));const t=e[0];if("RIGHT_PAREN"===t?.type)return Lr(e,"RIGHT_PAREN"),[];const o=[];o.push(Pr(e));for(;"RIGHT_PAREN"!==e[0]?.type;)Lr(e,"ARG_SEPARATOR",uo("Wrong function call")),o.push(Pr(e));return Lr(e,"RIGHT_PAREN"),o}(e);return{type:"FUNCALL",value:s,args:t}}const n=s.toUpperCase();if("TRUE"===n||"FALSE"===n)return{type:"BOOLEAN",value:"TRUE"===n};throw new ko(uo("Invalid formula"));case"LEFT_PAREN":const r=kr(e);return Lr(e,"RIGHT_PAREN",uo("Missing closing parenthesis")),r;case"OPERATOR":const a=t.value;if(_r.includes(a))return{type:"UNARY_OPERATION",value:a,operand:kr(e,Fr[a])};throw new ko(uo("Unexpected token: %s",t.value));default:throw new ko(uo("Unexpected token: %s",t.value))}}function Pr(e){const t=e[0];return"ARG_SEPARATOR"===t?.type||"RIGHT_PAREN"===t?.type?{type:"EMPTY",value:""}:kr(e)}function Lr(e,t,o){const s=e.shift();if(!s||s.type!==t)throw new ko(o)}function kr(e,t=0){if(0===e.length)throw new ko;let o=Nr(e);for(;"OPERATOR"===e[0]?.type&&Fr[e[0].value]>t;){const t=e.shift().value;if(Dr.includes(t))o={type:"UNARY_OPERATION",value:t,operand:o,postfix:!0};else{o={type:"BIN_OPERATION",value:t,left:o,right:kr(e,Fr[t])}}}return o}function Vr(e){return Ur(jn(e))}function Ur(e){"="===(e=e.filter((e=>"SPACE"!==e.type)))[0].value&&e.splice(0,1);const t=kr(e);if(e.length)throw new ko;return t}function Br(e,t,o){return $r(e,(e=>e.type===t?o(e):e))}function Hr(e){return Array.from(zr(e))}function*zr(e){switch(yield e,e.type){case"FUNCALL":for(const t of e.args)yield*zr(t);break;case"UNARY_OPERATION":yield*zr(e.operand);break;case"BIN_OPERATION":yield*zr(e.left),yield*zr(e.right)}}function $r(e,t){switch((e=t(e)).type){case"FUNCALL":return{...e,args:e.args.map((e=>$r(e,t)))};case"UNARY_OPERATION":return{...e,operand:$r(e.operand,t)};case"BIN_OPERATION":return{...e,right:$r(e.right,t),left:$r(e.left,t)};default:return e}}function Gr(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>Gr(e)));return`${e.value}(${t.join(",")})`;case"NUMBER":return e.value.toString();case"REFERENCE":default:return e.value;case"STRING":return`"${e.value}"`;case"BOOLEAN":return e.value?"TRUE":"FALSE";case"UNARY_OPERATION":return e.postfix?Wr(e)+e.value:e.value+qr(e);case"BIN_OPERATION":return Wr(e)+e.value+qr(e)}}function Wr(e){const t=e.value,o="left"in e?e.left:e.operand,s=o.value;return"BIN_OPERATION"===o.type&&Fr[s]<Fr[t]?`(${Gr(o)})`:Gr(o)}function qr(e){const t=e.value,o="right"in e?e.right:e.operand,s=Fr[o.value],i=Fr[t];let n=!1;return"BIN_OPERATION"!==o.type?n=!1:s<i?n=!0:s!==i||Mr.includes(t)||(n=!0),n?`(${Gr(o)})`:Gr(o)}var Zr;!function(e){e[e.LeftRef=0]="LeftRef",e[e.RightRef=1]="RightRef",e[e.Separator=2]="Separator",e[e.FullColumnSeparator=3]="FullColumnSeparator",e[e.FullRowSeparator=4]="FullRowSeparator",e[e.RightColumnRef=5]="RightColumnRef",e[e.RightRowRef=6]="RightRowRef",e[e.Found=7]="Found"}(Zr||(Zr={}));const Yr=(e,t=(()=>!0))=>[{goTo:e,guard:t}],jr=(e,t=(()=>!0))=>({goTo:e,guard:t}),Xr={[Zr.LeftRef]:{REFERENCE:Yr(Zr.Separator),NUMBER:Yr(Zr.FullRowSeparator),SYMBOL:[jr(Zr.FullColumnSeparator,(e=>Ei(e.value))),jr(Zr.FullRowSeparator,(e=>xi(e.value)))]},[Zr.FullColumnSeparator]:{SPACE:Yr(Zr.FullColumnSeparator),OPERATOR:Yr(Zr.RightColumnRef,(e=>":"===e.value))},[Zr.FullRowSeparator]:{SPACE:Yr(Zr.FullRowSeparator),OPERATOR:Yr(Zr.RightRowRef,(e=>":"===e.value))},[Zr.Separator]:{SPACE:Yr(Zr.Separator),OPERATOR:Yr(Zr.RightRef,(e=>":"===e.value))},[Zr.RightRef]:{SPACE:Yr(Zr.RightRef),NUMBER:Yr(Zr.Found),REFERENCE:Yr(Zr.Found,(e=>Ri(e.value))),SYMBOL:Yr(Zr.Found,(e=>wi(e.value)||Ii(e.value)))},[Zr.RightColumnRef]:{SPACE:Yr(Zr.RightColumnRef),SYMBOL:Yr(Zr.Found,(e=>wi(e.value))),REFERENCE:Yr(Zr.Found,(e=>Ri(e.value)))},[Zr.RightRowRef]:{SPACE:Yr(Zr.RightRowRef),NUMBER:Yr(Zr.Found),REFERENCE:Yr(Zr.Found,(e=>Ri(e.value))),SYMBOL:Yr(Zr.Found,(e=>Ii(e.value)))},[Zr.Found]:{}};function Kr(e){let t=0,o=Xr[Zr.LeftRef],s="";for(;void 0!==o;){const i=e[t++];if(!i)return null;const n=o[i.type]?.find((e=>e.guard(i))),r=n?n.goTo:void 0;switch(r){case void 0:return null;case Zr.Found:return s+=i.value,e.splice(0,t),{type:"REFERENCE",value:s};default:o=Xr[r],s+=i.value}}return null}function Qr(e,t=Ao){const o=jn(e,t),s=[];for(;o.length;)s.push(Kr(o)||o.shift());return s}function Jr(e,t){return function(e){for(const t of e)if(t.functionContext){const{argsTokens:e,args:o}=t.functionContext;if(delete t.functionContext.argsTokens,o.length||!e)continue;"LEFT_PAREN"===e[0]?.[0]?.type&&(e[0]=e[0].slice(1));for(const t of e){let e=t;"ARG_SEPARATOR"===e.at(-1)?.type&&(e=e.slice(0,-1));try{o.push(Ur(e))}catch(e){o.push(void 0)}}}return e}(function(e){let t=[],o="";function s(e){if(0===t.length)return;const o=t.at(-1);if(o&&o.argsTokens){const{argsTokens:t,argPosition:s}=o;t[s]||(t[s]=[]),t[s].push({value:e.value,type:e.type})}}return e.map(((e,i)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(o=""),e.type){case"SYMBOL":s(e),o=e.value;break;case"LEFT_PAREN":t.push({parent:o,argPosition:0,argsTokens:[],args:[]}),s(e),o="";break;case"RIGHT_PAREN":const i=t.pop();i?.argsTokens?.flat().forEach(s),s(e);break;case"ARG_SEPARATOR":s(e),t.length&&t[t.length-1].argPosition++;break;default:s(e)}if(t.length){const o=t[t.length-1];o.parent&&(e.functionContext=Object.assign({},o))}return e}))}(function(e){let t=1;const o=[];return e.map((e=>("LEFT_PAREN"===e.type?(o.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=o.pop()),e)))}(function(e){let t=0;return e.map((e=>{const o=e.value.toString().length,s=Object.assign({},e,{start:t,end:t+o,length:o});return t=s.end,s}))}(Qr(e,t)))))}function ea(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}const ta=new zn;function oa(e,t){return{url:e=ea(e),label:t||e,isExternal:!0,isUrlEditable:!0}}ta.add("sheet_URL",{match:e=>Ae(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){const o=_e(e);return t.tryGetSheetName(o)||uo("Invalid sheet")},open(e,t){const o=_e(e);t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:o}).isCancelledBecause("SheetIsHidden")&&t.notifyUser({type:"warning",sticky:!1,text:uo("Cannot open the link because the linked sheet is hidden.")})},sequence:0});const sa={createLink:oa,match:e=>we(e),open:e=>window.open(e,"_blank"),urlRepresentation:e=>e,sequence:0};function ia(e){return ta.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((t=>t.match(e)))||sa}function na(e,t){return ia(e.url).urlRepresentation(e.url,t)}function ra(e,t){ia(e.url).open(e.url,t)}function aa(e){if("string"==typeof e){if(xe(e)){const{label:t,url:o}=Re(e);return ia(o).createLink(o,t)}return we(e)?oa(e):void 0}}function la(e="",t){return ha({value:t.format===Ro?e:ca(e,t.locale),format:t.format},t.locale)}function ca(e,t){if(e.startsWith("="))throw new Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);return""===e?null:io(e,Ao)?Zo(e,Ao):Ht(e,t)?Zo(e,t):function(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}(e)?"TRUE"===e.toUpperCase():e}function ha(e,t=Ao,o){const s=aa(e.value);if(!s)return da(e,t,o);return{...da({value:ca(s.label,t),format:e.format||ti(s.label,t)||oi(s.label)},t,o),link:s}}function da(e,t,o){let{value:s,format:i,message:n}=e;i=o?.format||i;const r=Hs(s,{format:i,locale:t});return Wo(s)?function(e,t){return{value:e,formattedValue:e,message:t,type:po.error,isAutoSummable:!1,defaultAlign:"center"}}(s,n):i===Ro?ua(ts(s),i,r):null===s?ga(i):"number"==typeof s?Ys(i||"")?function(e,t,o){return{value:e,format:t,formattedValue:o,type:po.number,isAutoSummable:!1,defaultAlign:"right"}}(s,i,r):function(e,t,o){return{value:e||0,format:t,formattedValue:o,type:po.number,isAutoSummable:!0,defaultAlign:"right"}}(s,i,r):"boolean"==typeof s?function(e,t,o){return{value:e,format:t,formattedValue:o,type:po.boolean,isAutoSummable:!1,defaultAlign:"center"}}(s,i,r):ua(s,i,r)}function ua(e,t,o){return{value:e,format:t,formattedValue:o,type:po.text,isAutoSummable:!0,defaultAlign:"left"}}const ga=Ye((function(e){return{value:null,format:e,formattedValue:"",type:po.empty,isAutoSummable:!0,defaultAlign:"left"}}));function pa(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:o}=Ti(e.value),[s,i]=t.split(":"),n=ma(s),r=i?`:${ma(i)}`:"";return{...e,value:Ai(o,n+r)}}function ma(e){switch(function(e){if(function(e){return e.startsWith("$")&&e.length>1&&e.slice(1).includes("$")}(e))return"colrow";if(function(e){return e.startsWith("$")}(e))return"col";if(function(e){return e.includes("$",1)}(e))return"row";return"none"}(e)){case"none":e=fa(e,"colrow");break;case"colrow":e=fa(e,"row");break;case"row":e=fa(e,"col");break;case"col":e=fa(e,"none")}return e}function fa(e,t){if(e.includes("!"))throw new Error("The given XC should not contain a sheet name");let o;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return o=e.search(/[0-9]/),e.slice(0,o)+"$"+e.slice(o);case"colrow":return o=e.search(/[0-9]/),-1===o||0===o?"$"+e:"$"+(e=e.slice(0,o)+"$"+e.slice(o));case"none":return e}}function ba(e,t,o){const s=(t.startsWith("=")?Jr(t,o):[]).filter((t=>t.start<=e.start&&t.end>=e.start||t.start>=e.start&&t.start<e.end)),i=s.filter((e=>"REFERENCE"===e.type));if(0===i.length)return;const n=s.map(pa).map((e=>e.value)).join(""),r=s[0].start,a=s[s.length-1].end,l=t.slice(0,r)+n+t.slice(a),c=l.length-t.length,h={start:i[0].start,end:i[i.length-1].end+c};return 1===i.length&&e.start===e.end&&(h.start=h.end),{content:l,selection:h}}const va=new zn,Sa={wrongPasteSelection:uo("This operation is not allowed with multiple selections."),willRemoveExistingMerge:uo("This operation is not possible due to a merge. Please remove the merges first than try again."),wrongFigurePasteOption:uo("Cannot do a special paste of a figure."),frozenPaneOverlap:uo("This operation is not allowed due to an overlapping frozen pane.")};function Ca(e,t){t.isSuccessful||(t.reasons.includes("WrongPasteSelection")?e.raiseError(Sa.wrongPasteSelection):t.reasons.includes("WillRemoveExistingMerge")?e.raiseError(Sa.willRemoveExistingMerge):t.reasons.includes("WrongFigurePasteOption")?e.raiseError(Sa.wrongFigurePasteOption):t.reasons.includes("FrozenPaneOverlap")&&e.raiseError(Sa.frozenPaneOverlap))}function ya(e,t,o){const s=e.model.dispatch("PASTE",{target:t,pasteOption:o});Ca(e,s)}function Ea(e,t,o,s){const i=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:o,pasteOption:s});Ca(e,i)}const xa={Errors:{InvalidRange:uo("The range is invalid"),FirstArgMissing:uo("The argument is missing. Please provide a value"),SecondArgMissing:uo("The second argument is missing. Please provide a value"),MinNaN:uo("The minpoint must be a number"),MidNaN:uo("The midpoint must be a number"),MaxNaN:uo("The maxpoint must be a number"),ValueUpperInflectionNaN:uo("The first value must be a number"),ValueLowerInflectionNaN:uo("The second value must be a number"),MinBiggerThanMax:uo("Minimum must be smaller then Maximum"),MinBiggerThanMid:uo("Minimum must be smaller then Midpoint"),MidBiggerThanMax:uo("Midpoint must be smaller then Maximum"),LowerBiggerThanUpper:uo("Lower inflection point must be smaller than upper inflection point"),MinInvalidFormula:uo("Invalid Minpoint formula"),MaxInvalidFormula:uo("Invalid Maxpoint formula"),MidInvalidFormula:uo("Invalid Midpoint formula"),ValueUpperInvalidFormula:uo("Invalid upper inflection point formula"),ValueLowerInvalidFormula:uo("Invalid lower inflection point formula"),EmptyRange:uo("A range needs to be defined"),Unexpected:uo("The rule is invalid for an unknown reason")},ColorScale:uo("Color scale"),IconSet:uo("Icon set")},wa={IsEmpty:uo("Is empty"),IsNotEmpty:uo("Is not empty"),ContainsText:uo("Contains"),NotContains:uo("Does not contain"),BeginsWith:uo("Starts with"),EndsWith:uo("Ends with"),Equal:uo("Is equal to"),NotEqual:uo("Is not equal to"),GreaterThan:uo("Is greater than"),GreaterThanOrEqual:uo("Is greater than or equal to"),LessThan:uo("Is less than"),LessThanOrEqual:uo("Is less than or equal to"),Between:uo("Is between"),NotBetween:uo("Is not between")},Ia={Series:uo("Series"),BackgroundColor:uo("Background color"),Errors:{Unexpected:uo("The chart definition is invalid for an unknown reason"),InvalidDataSet:uo("The dataset is invalid"),InvalidLabelRange:uo("Labels are invalid"),InvalidScorecardKeyValue:uo("The key value is invalid"),InvalidScorecardBaseline:uo("The baseline value is invalid"),InvalidGaugeDataRange:uo("The data range is invalid"),EmptyGaugeRangeMin:uo("A minimum range limit value is needed"),GaugeRangeMinNaN:uo("The minimum range limit value must be a number"),EmptyGaugeRangeMax:uo("A maximum range limit value is needed"),GaugeRangeMaxNaN:uo("The maximum range limit value must be a number"),GaugeRangeMinBiggerThanRangeMax:uo("Minimum range limit must be smaller than maximum range limit"),GaugeLowerInflectionPointNaN:uo("The lower inflection point value must be a number"),GaugeUpperInflectionPointNaN:uo("The upper inflection point value must be a number")}},Ra={Custom:uo("Custom")},Ta=uo("Merged cells are preventing this operation. Unmerge those cells and try again."),Aa={Errors:{Unexpected:uo("Cannot split the selection for an unknown reason"),NoSplitSeparatorInSelection:uo("There is no match for the selected separator in the selection"),MoreThanOneColumnSelected:uo("Only a selection from a single column can be split"),SplitWillOverwriteContent:uo("Splitting will overwrite existing content")}},Oa={Errors:{Unexpected:uo("Cannot remove duplicates for an unknown reason"),MoreThanOneRangeSelected:uo("Please select only one range of cells"),EmptyTarget:uo("Please select a range of cells containing values."),NoColumnsProvided:uo("Please select at latest one column to analyze."),WillRemoveExistingMerge:Sa.willRemoveExistingMerge}},_a={DateIs:{today:uo("today"),yesterday:uo("yesterday"),tomorrow:uo("tomorrow"),lastWeek:uo("in the past week"),lastMonth:uo("in the past month"),lastYear:uo("in the past year")},DateIsBefore:{today:uo("today"),yesterday:uo("yesterday"),tomorrow:uo("tomorrow"),lastWeek:uo("one week ago"),lastMonth:uo("one month ago"),lastYear:uo("one year ago")},CriterionError:{notEmptyValue:uo("The value must not be empty"),numberValue:uo("The value must be a number"),dateValue:uo("The value must be a date"),validRange:uo("The value must be a valid range")}},Da={Errors:{Unexpected:uo("The table zone is invalid for an unknown reason"),TableOverlap:uo("You cannot create overlapping tables."),NonContinuousTargets:uo("A table can only be created on a continuous selection."),InvalidRange:uo("The range is invalid"),TargetOutOfSheet:uo("The range is out of the sheet")},Checkboxes:{hasFilters:uo("Filter button"),headerRow:uo("Header row(s)"),bandedRows:uo("Banded rows"),firstColumn:uo("First column"),lastColumn:uo("Last column"),bandedColumns:uo("Banded columns"),automaticAutofill:uo("Automatically autofill formulas"),totalRow:uo("Total row"),isDynamic:uo("Auto-adjust to formula result")},Tooltips:{filterWithoutHeader:uo("Cannot have filters without a header row"),isDynamic:uo("For tables based on array formulas only")}},Ma=new zn;Ma.add("textContains",{type:"textContains",isValueValid:(e,t)=>String(e).toLowerCase().includes(t.values[0].toLowerCase()),getErrorString:e=>uo('The value must be a text that contains "%s"',e.values[0]),isCriterionValueValid:e=>!!e,criterionValueErrorString:_a.CriterionError.notEmptyValue,numberOfValues:()=>1,name:uo("Text contains"),getPreview:e=>uo('Text contains "%s"',e.values[0])}),Ma.add("textNotContains",{type:"textNotContains",isValueValid:(e,t)=>!String(e).toLowerCase().includes(t.values[0].toLowerCase()),getErrorString:e=>uo('The value must be a text that does not contain "%s"',e.values[0]),isCriterionValueValid:e=>!!e,criterionValueErrorString:_a.CriterionError.notEmptyValue,numberOfValues:()=>1,name:uo("Text does not contains"),getPreview:e=>uo('Text does not contain "%s"',e.values[0])}),Ma.add("textIs",{type:"textIs",isValueValid:(e,t)=>String(e).toLowerCase()===t.values[0].toLowerCase(),getErrorString:e=>uo('The value must be exactly "%s"',e.values[0]),isCriterionValueValid:e=>!!e,criterionValueErrorString:_a.CriterionError.notEmptyValue,numberOfValues:()=>1,name:uo("Text is exactly"),getPreview:e=>uo('Text is exactly "%s"',e.values[0])});const Fa=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$/;function Na(e,t){return e.values.map((e=>void 0!==e?ur(e,t):No.InvalidReference))}function Pa(e,t){return _s(e,Ao).map((e=>void 0!==e?Hs(e,{locale:t,format:t.dateFormat}):No.InvalidReference))}function La(e){return void 0!==Bt(e,Ao)}function ka(e){return void 0!==Yo(e,Ao)}function Va(e,t){const o=t.getLocale();return e.values.map((e=>{if(e.startsWith("="))return e;const t=ca(e,o);return"number"==typeof t?Hs(t,{format:o.dateFormat,locale:o}):""}))}Ma.add("textIsEmail",{type:"textIsEmail",isValueValid:e=>"string"==typeof e&&Fa.test(e),getErrorString:()=>uo("The value must be a valid email address"),isCriterionValueValid:()=>!0,criterionValueErrorString:"",numberOfValues:()=>0,name:uo("Text is valid email"),getPreview:()=>uo("Text is valid email")}),Ma.add("textIsLink",{type:"textIsLink",isValueValid:e=>void 0!==aa(e),getErrorString:()=>uo("The value must be a valid link"),isCriterionValueValid:()=>!0,criterionValueErrorString:"",numberOfValues:()=>0,name:uo("Text is valid link"),getPreview:()=>uo("Text is valid link")}),Ma.add("dateIs",{type:"dateIs",isValueValid:(e,t)=>{const o=_s(t,Ao)[0],s=Bt(e,Ao);if(void 0===s||void 0===o)return!1;if(["lastWeek","lastMonth","lastYear"].includes(t.dateValue)){return to(s,Wt(At.now()),o)}return i=s,n=o,Math.trunc(i)===Math.trunc(n);var i,n},getErrorString:(e,t)=>{const o=t.getLocale();return"exactDate"===e.dateValue?uo("The value must be the date %s",Pa(e,o)[0]):uo("The value must be %s",_a.DateIs[e.dateValue])},isCriterionValueValid:e=>La(e),criterionValueErrorString:_a.CriterionError.dateValue,numberOfValues:e=>"exactDate"===e.dateValue?1:0,name:uo("Date is"),getPreview:(e,t)=>"exactDate"===e.dateValue?uo("Date is %s",Va(e,t)[0]):uo("Date is %s",_a.DateIs[e.dateValue])}),Ma.add("dateIsBefore",{type:"dateIsBefore",isValueValid:(e,t)=>{const o=_s(t,Ao)[0],s=Bt(e,Ao);return void 0!==s&&void 0!==o&&function(e,t){return Math.trunc(e)<Math.trunc(t)}(s,o)},getErrorString:(e,t)=>{const o=t.getLocale();return"exactDate"===e.dateValue?uo("The value must be a date before %s",Pa(e,o)[0]):uo("The value must be a date before %s",_a.DateIsBefore[e.dateValue])},isCriterionValueValid:e=>La(e),criterionValueErrorString:_a.CriterionError.dateValue,numberOfValues:e=>"exactDate"===e.dateValue?1:0,name:uo("Date is before"),getPreview:(e,t)=>"exactDate"===e.dateValue?uo("Date is before %s",Va(e,t)[0]):uo("Date is before %s",_a.DateIsBefore[e.dateValue])}),Ma.add("dateIsOnOrBefore",{type:"dateIsOnOrBefore",isValueValid:(e,t)=>{const o=_s(t,Ao)[0],s=Bt(e,Ao);return void 0!==s&&void 0!==o&&function(e,t){return Math.trunc(e)<=Math.trunc(t)}(s,o)},getErrorString:(e,t)=>{const o=t.getLocale();return"exactDate"===e.dateValue?uo("The value must be a date on or before %s",Pa(e,o)[0]):uo("The value must be a date on or before %s",_a.DateIsBefore[e.dateValue])},isCriterionValueValid:e=>La(e),criterionValueErrorString:_a.CriterionError.dateValue,numberOfValues:e=>"exactDate"===e.dateValue?1:0,name:uo("Date is on or before"),getPreview:(e,t)=>"exactDate"===e.dateValue?uo("Date is on or before %s",Va(e,t)[0]):uo("Date is on or before %s",_a.DateIsBefore[e.dateValue])}),Ma.add("dateIsAfter",{type:"dateIsAfter",isValueValid:(e,t)=>{const o=_s(t,Ao)[0],s=Bt(e,Ao);return void 0!==s&&void 0!==o&&function(e,t){return Math.trunc(e)>Math.trunc(t)}(s,o)},getErrorString:(e,t)=>{const o=t.getLocale();return"exactDate"===e.dateValue?uo("The value must be a date after %s",Pa(e,o)[0]):uo("The value must be a date after %s",_a.DateIsBefore[e.dateValue])},isCriterionValueValid:e=>La(e),criterionValueErrorString:_a.CriterionError.dateValue,numberOfValues:e=>"exactDate"===e.dateValue?1:0,name:uo("Date is after"),getPreview:(e,t)=>"exactDate"===e.dateValue?uo("Date is after %s",Va(e,t)[0]):uo("Date is after %s",_a.DateIsBefore[e.dateValue])}),Ma.add("dateIsOnOrAfter",{type:"dateIsOnOrAfter",isValueValid:(e,t)=>{const o=_s(t,Ao)[0],s=Bt(e,Ao);return void 0!==s&&void 0!==o&&function(e,t){return Math.trunc(e)>=Math.trunc(t)}(s,o)},getErrorString:(e,t)=>{const o=t.getLocale();return"exactDate"===e.dateValue?uo("The value must be a date on or after %s",Pa(e,o)[0]):uo("The value must be a date on or after %s",_a.DateIsBefore[e.dateValue])},isCriterionValueValid:e=>La(e),criterionValueErrorString:_a.CriterionError.dateValue,numberOfValues:e=>"exactDate"===e.dateValue?1:0,name:uo("Date is on or after"),getPreview:(e,t)=>"exactDate"===e.dateValue?uo("Date is on or after %s",Va(e,t)[0]):uo("Date is on or after %s",_a.DateIsBefore[e.dateValue])}),Ma.add("dateIsBetween",{type:"dateIsBetween",isValueValid:(e,t)=>{const o=_s(t,Ao),s=Bt(e,Ao);return void 0!==s&&void 0!==o[0]&&void 0!==o[1]&&to(s,o[0],o[1])},getErrorString:(e,t)=>{const o=Pa(e,t.getLocale());return uo("The value must be a date between %s and %s",o[0],o[1])},isCriterionValueValid:e=>La(e),criterionValueErrorString:_a.CriterionError.dateValue,numberOfValues:()=>2,name:uo("Date is between"),getPreview:(e,t)=>{const o=Va(e,t);return uo("Date is between %s and %s",o[0],o[1])}}),Ma.add("dateIsNotBetween",{type:"dateIsNotBetween",isValueValid:(e,t)=>{const o=_s(t,Ao),s=Bt(e,Ao);return void 0!==s&&void 0!==o[0]&&void 0!==o[1]&&!to(s,o[0],o[1])},getErrorString:(e,t)=>{const o=Pa(e,t.getLocale());return uo("The value must be a date not between %s and %s",o[0],o[1])},isCriterionValueValid:e=>La(e),criterionValueErrorString:_a.CriterionError.dateValue,numberOfValues:()=>2,name:uo("Date is not between"),getPreview:(e,t)=>{const o=Va(e,t);return uo("Date is not between %s and %s",o[0],o[1])}}),Ma.add("dateIsValid",{type:"dateIsValid",isValueValid:e=>void 0!==Bt(e,Ao),getErrorString:()=>uo("The value must be a valid date"),isCriterionValueValid:e=>La(e),criterionValueErrorString:"",numberOfValues:()=>0,name:uo("Is valid date"),getPreview:()=>uo("Date is valid")}),Ma.add("isEqual",{type:"isEqual",isValueValid:(e,t)=>{if("number"!=typeof e)return!1;const o=Ds(t,Ao)[0];return void 0!==o&&e===o},getErrorString:(e,t)=>{const o=Na(e,t.getLocale());return uo("The value must be equal to %s",o[0])},isCriterionValueValid:e=>ka(e),criterionValueErrorString:_a.CriterionError.numberValue,numberOfValues:()=>1,name:uo("Is equal to"),getPreview:e=>uo("Value is equal to %s",e.values[0])}),Ma.add("isNotEqual",{type:"isNotEqual",isValueValid:(e,t)=>{if("number"!=typeof e)return!1;const o=Ds(t,Ao)[0];return void 0!==o&&e!==o},getErrorString:(e,t)=>{const o=Na(e,t.getLocale());return uo("The value must not be equal to %s",o[0])},isCriterionValueValid:e=>ka(e),criterionValueErrorString:_a.CriterionError.numberValue,numberOfValues:()=>1,name:uo("Is not equal to"),getPreview:e=>uo("Value is not equal to %s",e.values[0])}),Ma.add("isGreaterThan",{type:"isGreaterThan",isValueValid:(e,t)=>{if("number"!=typeof e)return!1;const o=Ds(t,Ao)[0];return void 0!==o&&e>o},getErrorString:(e,t)=>{const o=Na(e,t.getLocale());return uo("The value must be greater than %s",o[0])},isCriterionValueValid:e=>ka(e),criterionValueErrorString:_a.CriterionError.numberValue,numberOfValues:()=>1,name:uo("Is greater than"),getPreview:e=>uo("Value is greater than %s",e.values[0])}),Ma.add("isGreaterOrEqualTo",{type:"isGreaterOrEqualTo",isValueValid:(e,t)=>{if("number"!=typeof e)return!1;const o=Ds(t,Ao)[0];return void 0!==o&&e>=o},getErrorString:(e,t)=>{const o=Na(e,t.getLocale());return uo("The value must be greater or equal to %s",o[0])},isCriterionValueValid:e=>ka(e),criterionValueErrorString:_a.CriterionError.numberValue,numberOfValues:()=>1,name:uo("Is greater or equal to"),getPreview:e=>uo("Value is greater or equal to %s",e.values[0])}),Ma.add("isLessThan",{type:"isLessThan",isValueValid:(e,t)=>{if("number"!=typeof e)return!1;const o=Ds(t,Ao)[0];return void 0!==o&&e<o},getErrorString:(e,t)=>{const o=Na(e,t.getLocale());return uo("The value must be less than %s",o[0])},isCriterionValueValid:e=>ka(e),criterionValueErrorString:_a.CriterionError.numberValue,numberOfValues:()=>1,name:uo("Is less than"),getPreview:e=>uo("Value is less than %s",e.values[0])}),Ma.add("isLessOrEqualTo",{type:"isLessOrEqualTo",isValueValid:(e,t)=>{if("number"!=typeof e)return!1;const o=Ds(t,Ao)[0];return void 0!==o&&e<=o},getErrorString:(e,t)=>{const o=Na(e,t.getLocale());return uo("The value must be less or equal to %s",o[0])},isCriterionValueValid:e=>ka(e),criterionValueErrorString:_a.CriterionError.numberValue,numberOfValues:()=>1,name:uo("Is less or equal to"),getPreview:e=>uo("Value is less or equal to %s",e.values[0])}),Ma.add("isBetween",{type:"isBetween",isValueValid:(e,t)=>{if("number"!=typeof e)return!1;const o=Ds(t,Ao);return void 0!==o[0]&&void 0!==o[1]&&Ke(e,o[0],o[1])},getErrorString:(e,t)=>{const o=Na(e,t.getLocale());return uo("The value must be between %s and %s",o[0],o[1])},isCriterionValueValid:e=>ka(e),criterionValueErrorString:_a.CriterionError.numberValue,numberOfValues:()=>2,name:uo("Is between"),getPreview:e=>uo("Value is between %s and %s",e.values[0],e.values[1])}),Ma.add("isNotBetween",{type:"isNotBetween",isValueValid:(e,t)=>{if("number"!=typeof e)return!1;const o=Ds(t,Ao);return void 0!==o[0]&&void 0!==o[1]&&!Ke(e,o[0],o[1])},getErrorString:(e,t)=>{const o=Na(e,t.getLocale());return uo("The value must not be between %s and %s",o[0],o[1])},isCriterionValueValid:e=>ka(e),criterionValueErrorString:_a.CriterionError.numberValue,numberOfValues:()=>2,name:uo("Is not between"),getPreview:e=>uo("Value is not between %s and %s",e.values[0],e.values[1])}),Ma.add("isBoolean",{type:"isBoolean",isValueValid:e=>""===e||"boolean"==typeof e,getErrorString:()=>uo("The value must be a boolean"),isCriterionValueValid:()=>!0,criterionValueErrorString:"",numberOfValues:()=>0,name:uo("Checkbox"),getPreview:()=>uo("Checkbox")}),Ma.add("isValueInList",{type:"isValueInList",isValueValid:(e,t)=>null!==e&&t.values.map((e=>e.toLowerCase())).includes(e.toString().toLowerCase()),getErrorString:e=>uo("The value must be one of: %s",e.values.join(", ")),isCriterionValueValid:()=>!0,criterionValueErrorString:"",numberOfValues:()=>{},allowedValues:"onlyLiterals",name:uo("Value in list"),getPreview:e=>uo("Value one of: %s",e.values.join(", "))}),Ma.add("isValueInRange",{type:"isValueInList",isValueValid:(e,t,o,s)=>{if(!e)return!1;const i=o.getRangeFromSheetXC(s,t.values[0]);return o.getRangeValues(i).filter(Me).map((e=>e.toString().toLowerCase())).includes(e.toString().toLowerCase())},getErrorString:e=>uo("The value must be a value in the range %s",e.values[0]),isCriterionValueValid:e=>yi.test(e),criterionValueErrorString:_a.CriterionError.validRange,numberOfValues:()=>1,allowedValues:"onlyLiterals",name:uo("Value in range"),getPreview:e=>uo("Value in range %s",e.values[0])}),Ma.add("customFormula",{type:"customFormula",isValueValid:(e,t)=>{const o=ca(t.values[0],Ao);return("number"==typeof o||"boolean"==typeof o)&&!!o},getErrorString:()=>uo("The value does not match the custom formula data validation rule"),isCriterionValueValid:()=>!0,criterionValueErrorString:"",numberOfValues:()=>1,allowedValues:"onlyFormulas",name:uo("Custom formula"),getPreview:e=>uo("Custom formula %s",e.values[0])});class Ua{subscriptions={};on(e,t,o){if(!o)throw new Error("Missing callback");this.subscriptions[e]||(this.subscriptions[e]=[]),this.subscriptions[e].push({owner:t,callback:o})}trigger(e,t){const o=this.subscriptions[e]||[];for(let e=0,s=o.length;e<s;e++){const s=o[e];s.callback.call(s.owner,t)}}off(e,t){const o=this.subscriptions[e];o&&(this.subscriptions[e]=o.filter((e=>e.owner!==t)))}clear(){this.subscriptions={}}}class Ba extends Ua{dependencies=new Map;factory=new Ha(this.get.bind(this));inject(e,t){if(this.dependencies.has(e)&&this.dependencies.get(e)!==t)throw new Error(`Store ${e.name} already has an instance`);this.dependencies.set(e,t)}get(e){return this.dependencies.has(e)||this.dependencies.set(e,this.instantiate(e)),this.dependencies.get(e)}instantiate(e,...t){return this.factory.build(e,...t)}resetStores(){this.dependencies.clear()}}class Ha{get;pendingBuilds=new Set;constructor(e){this.get=e}build(e,...t){if(this.pendingBuilds.has(e))throw new Error(`Circular dependency detected: ${[...this.pendingBuilds,e].map((e=>e.name)).join(" -> ")}`);this.pendingBuilds.add(e);const o=new e(this.get,...t);return this.pendingBuilds.delete(e),o}}class za{get;disposeCallbacks=[];constructor(e){this.get=e}onDispose(e){this.disposeCallbacks.push(e)}dispose(){this.disposeCallbacks.forEach((e=>e()))}}function $a(){const e=t.useEnv();if(e.__spreadsheet_stores__ instanceof Ba)return e.__spreadsheet_stores__;const o=new Ba;return t.useSubEnv({__spreadsheet_stores__:o,getStore:e=>Za(o.get(e),(()=>o.trigger("store-updated")))}),o}function Ga(e){const o=Ya(t.useEnv()),s=o.get(e);return qa(o,s)}function Wa(e,...o){const s=Ya(t.useEnv()),i=s.instantiate(e,...o);return t.onWillUnmount((()=>i.dispose())),qa(s,i)}function qa(e,o){const s=t.useComponent();return Za(o,(()=>{"mounted"===t.status(s)&&e.trigger("store-updated")}))}function Za(e,t){return new Proxy(e,{get(o,s,i){const n=o,r=Reflect.get(o,s,n);if(e.mutators?.includes(s)){const e=new Proxy(r,{apply(e,o,s){Reflect.apply(e,n,s),t()}});return e}return r}})}function Ya(e){const t=e.__spreadsheet_stores__;if(!(t instanceof Ba))throw new Error("No store provider found. Did you forget to call useStoreProvider()?");return t}const ja=(Xa="Model",class{constructor(e){throw new Error(`This is a abstract store for ${Xa}, it cannot be instantiated.\nDid you forget to inject your store instance?\n\nconst stores = useStoreProvider();\nstores.inject(MyMetaStore, storeInstance);\n`)}});var Xa;class Ka{mutators=["register","unRegister"];renderers={};register(e){if(e.renderingLayers.length)for(const t of e.renderingLayers)this.renderers[t]||(this.renderers[t]=[]),this.renderers[t].push(e)}unRegister(e){for(const t of Object.keys(this.renderers))this.renderers[t]=this.renderers[t].filter((t=>t!==e))}drawLayer(e,t){const o=this.renderers[t];if(o)for(const s of o)e.ctx.save(),s.drawLayer(e,t),e.ctx.restore()}}class Qa extends za{model=this.get(ja);getters=this.model.getters;renderer=this.get(Ka);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){}}function Ja(e,t,o){const{x:i,y:n,width:r,height:a}=o;if(r<0||a<0)return;const l=t.color||s,{ctx:c}=e;t.noBorder||(t.dashed&&c.setLineDash([5,3]),c.strokeStyle=l,t.thinLine?(c.lineWidth=1,c.strokeRect(i,n,r,a)):(c.lineWidth=2,c.strokeRect(i+.5,n+.5,r,a))),t.noFill||(c.fillStyle=function(e,t){return 1===t?nt(e).slice(0,7):ht({...dt(e),a:t})}(nt(l),t.fillAlpha??.12),c.fillRect(i,n,r,a))}class el extends Qa{mutators=["register","unRegister"];providers=[];constructor(e){super(e),this.onDispose((()=>{this.providers=[]}))}get renderingLayers(){return["Highlights"]}get highlights(){const e=this.getters.getActiveSheetId();return this.providers.flatMap((e=>e.highlights)).filter((t=>t.sheetId===e)).map((e=>{const{numberOfRows:t,numberOfCols:o}=Xi(e.zone),s=t*o==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:s}}))}register(e){this.providers.push(e)}unRegister(e){this.providers=this.providers.filter((t=>t!==e))}drawLayer(e,t){if("Highlights"===t)for(const t of this.highlights){Ja(e,t,this.getters.getVisibleRect(t.zone))}}}class tl{mutators=["notifyUser","raiseError","askConfirmation","updateNotificationCallbacks"];notifyUser=e=>window.alert(e);askConfirmation=(e,t,o)=>{window.confirm(e)?t():o?.()};raiseError=(e,t)=>{window.alert(e),t?.()};updateNotificationCallbacks(e){this.notifyUser=e.notifyUser||this.notifyUser,this.raiseError=e.raiseError||this.raiseError,this.askConfirmation=e.askConfirmation||this.askConfirmation}}const ol=uo("The cell you are trying to edit has been deleted.");class sl extends Qa{mutators=["startEdition","setCurrentContent","stopEdition","stopComposerRangeSelection","cancelEdition","cycleReferences","changeComposerCursorSelection","replaceComposerCursorSelection"];col=0;row=0;editionMode="inactive";sheetId="";_currentContent="";currentTokens=[];selectionStart=0;selectionEnd=0;initialContent="";colorIndexByRange={};notificationStore=this.get(tl);highlightStore=this.get(el);constructor(e){super(e),this.highlightStore.register(this),this.onDispose((()=>{this.highlightStore.unRegister(this)}))}canStopEdition(){return"inactive"===this.editionMode||this.checkDataValidation()}handleEvent(e){const t=this.getters.getActiveSheetId();let o;if(o=e.options.unbounded?this.getters.getUnboundedZone(t,e.anchor.zone):e.anchor.zone,"newAnchor"===e.mode)"selecting"===this.editionMode&&this.insertSelectedRange(o);else"selecting"===this.editionMode?this.replaceSelectedRange(o):this.updateComposerRange(e.previousAnchor.zone,o)}changeComposerCursorSelection(e,t){this.isSelectionValid(this._currentContent.length,e,t)&&(this.selectionStart=e,this.selectionEnd=t)}stopComposerRangeSelection(){this.isSelectingRange&&(this.editionMode="editing")}startEdition(e,t){if(t){const o=e||this.getComposerContent(this.getters.getActivePosition());if(!this.isSelectionValid(o.length,t.start,t.end))return}const{col:o,row:s}=this.getters.getActivePosition();this.model.dispatch("SELECT_FIGURE",{id:null}),this.model.dispatch("SCROLL_TO_CELL",{col:o,row:s}),"inactive"!==this.editionMode&&e?this.setContent(e,t):this._startEdition(e,t),this.updateRangeColor()}stopEdition(){if(this.canStopEdition())return this._stopEdition(),void(this.colorIndexByRange={});const e=this.currentEditedCell,t=Tt(e.col,e.row),o=this.getters.getValidationRuleForCell(e);if(!o)return;const s=Ma.get(o.criterion.type).getErrorString(o.criterion,this.getters,e.sheetId);this.notificationStore.raiseError(uo("The data you entered in %s violates the data validation rule set on the cell:\n%s",t,s)),this.cancelEdition(),this.colorIndexByRange={}}cancelEdition(){this.cancelEditionAndActivateSheet(),this.resetContent(),this.colorIndexByRange={}}setCurrentContent(e,t){t&&!this.isSelectionValid(e.length,t.start,t.end)||(this.setContent(e,t,!0),this.updateRangeColor())}replaceComposerCursorSelection(e){this.replaceSelection(e)}handle(e){switch(e.type){case"SELECT_FIGURE":e.id&&(this.cancelEditionAndActivateSheet(),this.resetContent());break;case"SET_FORMATTING":this.cancelEdition();break;case"ADD_COLUMNS_ROWS":this.onAddElements(e);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case"START_CHANGE_HIGHLIGHT":const{left:t,top:o}=e.zone;this.isSelectingRange&&(this.editionMode="editing"),this.model.selection.resetAnchor(this,{cell:{col:t,row:o},zone:e.zone});break;case"ACTIVATE_SHEET":if(this._currentContent.startsWith("=")||(this._cancelEdition(),this.resetContent()),e.sheetIdFrom!==e.sheetIdTo){const t=this.getters.getActivePosition(),{col:o,row:s}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:t.col,row:t.row}),i=this.getters.expandZone(e.sheetIdTo,on({col:o,row:s}));this.model.selection.resetAnchor(this,{cell:{col:o,row:s},zone:i})}break;case"DELETE_SHEET":case"UNDO":case"REDO":!!this.getters.tryGetSheet(this.sheetId)||"inactive"===this.editionMode||(this.sheetId=this.getters.getActiveSheetId(),this.cancelEditionAndActivateSheet(),this.resetContent(),this.notificationStore.raiseError(ol))}}get currentContent(){return"inactive"===this.editionMode?this.getComposerContent(this.getters.getActivePosition()):this._currentContent}get composerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}get currentEditedCell(){return{sheetId:this.sheetId,col:this.col,row:this.row}}get isSelectingRange(){return"selecting"===this.editionMode}get showSelectionIndicator(){return this.isSelectingRange&&this.canStartComposerRangeSelection()}get tokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((o=>o.start<=e&&o.end>=t))}cycleReferences(){const e=this.getters.getLocale(),t=ba(this.composerSelection,this._currentContent,e);void 0!==t&&this.setCurrentContent(t.content,t.selection)}isSelectionValid(e,t,o){return t>=0&&t<=e&&o>=0&&o<=e}onColumnsRemoved(e){if(e.elements.includes(this.col)&&"inactive"!==this.editionMode)return this.cancelEdition(),void this.notificationStore.raiseError(ol);const{top:t,left:o}=zi({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=o,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.editionMode)return this.cancelEdition(),void this.notificationStore.raiseError(ol);const{top:t,left:o}=zi({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=o,this.row=t}onAddElements(e){const{top:t,left:o}=Hi({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=o,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=on({col:this.col,row:this.row});this.model.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.editionMode="selecting"}_startEdition(e,t){const o=this.getters.getActiveCell(),s=this.getters.getLocale();e&&o.format?.includes("%")&&io(e,s)&&(t=t||{start:e.length,end:e.length},e=`${e}%`);const{col:i,row:n,sheetId:r}=this.getters.getActivePosition();this.col=i,this.sheetId=r,this.row=n,this.initialContent=this.getComposerContent({sheetId:r,col:i,row:n}),this.editionMode="editing",this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const a=on({col:this.col,row:this.row});this.model.selection.capture(this,{cell:{col:this.col,row:this.row},zone:a},{handleEvent:this.handleEvent.bind(this),release:()=>{this._stopEdition()}})}_stopEdition(){if("inactive"!==this.editionMode){this.cancelEditionAndActivateSheet();const e=this.col,t=this.row;let o=this.getCurrentCanonicalContent();if(!(this.initialContent!==o))return;if(o){const s=this.getters.getActiveSheetId(),i=this.getters.getEvaluatedCell({sheetId:s,col:this.col,row:this.row});if(o.startsWith("=")){const e=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length-this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length;e>0&&(o+=Le(new Array(e).fill(")")))}else i.link&&(o=Ie(o,i.link.url));this.addHeadersForSpreadingFormula(o),this.model.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:e,row:t,content:o})}else this.model.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:e,row:t});this.model.dispatch("AUTOFILL_TABLE_COLUMN",{col:e,row:t,sheetId:this.sheetId}),this.setContent("")}}getCurrentCanonicalContent(){return hr(this._currentContent,this.getters.getLocale())}cancelEditionAndActivateSheet(){if("inactive"===this.editionMode)return;this._cancelEdition();this.getters.getActiveSheetId()!==this.sheetId&&this.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}getComposerContent(e){const t=this.getters.getLocale(),o=this.getters.getCell(e);if(o?.isFormula)return pr(o.content,t);const{format:s,value:i,type:n,formattedValue:r}=this.getters.getEvaluatedCell(e);switch(n){case po.empty:return"";case po.text:case po.error:return i;case po.boolean:return r;case po.number:if(s&&Ys(s)){if(null!==$t(r,t))return r;return Hs(i,{locale:t,format:Number.isInteger(i)?t.dateFormat:Er(t)})}return this.numberComposerContent(i,s,t)}}numberComposerContent(e,t,o){return t?.includes("%")?`${Zs(100*e,o.decimalSeparator)}%`:Zs(e,o.decimalSeparator)}_cancelEdition(){"inactive"!==this.editionMode&&(this.editionMode="inactive",this.model.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,o){const s=this._currentContent!==e;if(this._currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,s||"inactive"!==this.editionMode){const t=this.getters.getLocale();this.currentTokens=e.startsWith("=")?Jr(e,t):[],this.currentTokens.length>100&&o&&this.notificationStore.raiseError(uo("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells"))}this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=this.getZoneReference(e);this.canStartComposerRangeSelection()?this.insertText(o,t):this.insertText(","+o,t)}replaceSelectedRange(e){const t=this.getZoneReference(e),o=this.tokenAtCursor,s="REFERENCE"===o?.type?o.start:this.selectionStart;this.replaceText(t,s,this.selectionEnd)}updateComposerRange(e,t){const o=this.getters.getActiveSheetId(),s=this.tokenAtCursor,i=(s?[s,...this.currentTokens]:this.currentTokens).filter((e=>"REFERENCE"===e.type)).find((t=>{const{xc:s,sheetName:i}=Ti(t.value),n=i||this.getters.getSheetName(this.sheetId);if(this.getters.getSheetName(o)!==n)return!1;const r=this.getters.getRangeFromSheetXC(o,s);return qi(this.getters.expandZone(o,r.zone),e)}));if(!i)throw new Error("Previous range not found");const n=this.getters.getRangeFromSheetXC(o,i.value);this.selectionStart=i.start,this.selectionEnd=this.selectionStart+i.value.length;const r=this.getters.getRangeFromZone(o,t),a=this.getRangeReference(r,n.parts);this.replaceSelection(a)}getZoneReference(e){const t=this.currentEditedCell.sheetId,o=this.getters.getActiveSheetId(),s=this.getters.getRangeFromZone(o,e);return this.getters.getSelectionRangeString(s,t)}getRangeReference(e,t){let o=[...t];const s=e.clone({parts:o});return this.getters.getSelectionRangeString(s,this.currentEditedCell.sheetId)}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,o)}replaceText(e,t,o){this._currentContent=this._currentContent.slice(0,t)+this._currentContent.slice(o,this._currentContent.length),this.insertText(e,t)}insertText(e,t){const o=this._currentContent.slice(0,t)+e+this._currentContent.slice(t),s=t+e.length;this.setCurrentContent(o,{start:s,end:s})}updateRangeColor(){if(!this._currentContent.startsWith("=")||"inactive"===this.editionMode)return;const e=this.currentEditedCell.sheetId,t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),o={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(o[e]=this.colorIndexByRange[e]);const s=new Set(Object.values(o));let i=0;const n=()=>{for(;s.has(i);)i++;return s.add(i),i};for(const e of t){const t=e in o?o[e]:n();o[e]=t}this.colorIndexByRange=o}addHeadersForSpreadingFormula(e){if(!e.startsWith("="))return;const t=this.getters.evaluateFormula(this.sheetId,e);if(!_o(t))return;const o=this.getters.getNumberRows(this.sheetId),s=this.getters.getNumberCols(this.sheetId),i=this.row+t[0].length-o,n=this.col+t.length-s;n>0&&this.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:this.sheetId,dimension:"COL",base:s-1,position:"after",quantity:n+20}),i>0&&this.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:this.sheetId,dimension:"ROW",base:o-1,position:"after",quantity:i+50})}get highlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.editionMode)return[];const e=this.currentEditedCell.sheetId,t=e=>{const t=this.colorIndexByRange[e];return st[t%st.length]};return this.getReferencedRanges().map((o=>{const s=this.getters.getRangeString(o,e),{numberOfRows:i,numberOfCols:n}=Xi(o.zone);return{zone:i*n==1?this.getters.expandZone(o.sheetId,o.zone):o.zone,color:t(s),sheetId:o.sheetId,interactive:!0}}))}getReferencedRanges(){const e=this.currentEditedCell.sheetId;return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value))).filter((e=>!e.invalidSheetName&&!e.invalidXc))}get autocompleteProvider(){const e=this.currentContent,t=e.startsWith("=")?this.tokenAtCursor:{type:"STRING",value:e};if("inactive"===this.editionMode||!t)return;const o={composer:this,getters:this.getters},s=va.getAll().sort(((e,t)=>(e.sequence??1/0)-(t.sequence??1/0))).map((s=>({...s,getProposals:s.getProposals.bind(o,t,e),selectProposal:s.selectProposal.bind(o,t)})));for(const e of s){let o=e.getProposals();const s=o?.find((e=>e.text===t.value)),i=t.value.replace(/[ ,\(\)]/g,"");if(s&&this._currentContent!==this.initialContent)return;if(i&&o&&!["ARG_SEPARATOR","LEFT_PAREN"].includes(t.type)){const e=fn(i,o,(e=>e.fuzzySearchKey||e.text));(!s||e.length>1)&&(o=e)}if(e.maxDisplayedProposals&&(o=o?.slice(0,e.maxDisplayedProposals)),o?.length)return{proposals:o,selectProposal:e.selectProposal,autoSelectFirstProposal:e.autoSelectFirstProposal??!1}}}canStartComposerRangeSelection(){if(this._currentContent.startsWith("=")){const e=this.tokenAtCursor;if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let o=t,s=e;for(;!["ARG_SEPARATOR","LEFT_PAREN","OPERATOR"].includes(s.type)||Zn.includes(s.value);){if("SPACE"!==s.type||o<1)return!1;o--,s=this.currentTokens[o]}for(o=t+1,s=this.currentTokens[o];s&&!["ARG_SEPARATOR","RIGHT_PAREN","OPERATOR"].includes(s.type);){if("SPACE"!==s.type)return!1;o++,s=this.currentTokens[o]}return!0}return!1}checkDataValidation(){const e={sheetId:this.sheetId,col:this.col,row:this.row};try{const t=this.getCurrentCanonicalContent(),o=t.startsWith("=")?this.getters.evaluateFormula(this.sheetId,t):ca(t,this.getters.getLocale());if(_o(o))return!0;const s=this.getters.getValidationResultForCellValue(o,e);return!(!s.isValid&&s.rule.isBlocking)}catch(e){return!0}}}class il extends Qa{mutators=["focusTopBarComposer","focusGridComposerContent","focusGridComposerCell"];composerStore=this.get(sl);topBarFocus="inactive";gridFocusMode="inactive";get topBarComposerFocus(){return"inactive"===this.composerStore.editionMode?"inactive":this.topBarFocus}get gridComposerFocus(){return"inactive"===this.composerStore.editionMode?"inactive":this.gridFocusMode}focusTopBarComposer(e){this.getters.isReadonly()||(this.topBarFocus="contentFocus",this.gridFocusMode="inactive",this.setComposerContent({selection:e}||{}))}focusGridComposerContent(){this.getters.isReadonly()||(this.topBarFocus="inactive",this.gridFocusMode="contentFocus",this.setComposerContent({}))}focusGridComposerCell(e,t){this.getters.isReadonly()||(this.topBarFocus="inactive",this.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}))}setComposerContent({content:e,selection:t}){"inactive"===this.composerStore.editionMode?this.composerStore.startEdition(e,t):e&&this.composerStore.setCurrentContent(e,t)}}const nl={id:"waterfallLinesPlugin",beforeDraw(e,t,o){if(!o.showConnectorLines)return;const s=e._metasets?.[0]?.data;if(!s)return;const i=e.ctx;i.save(),i.setLineDash([3,2]);for(let e=0;e<s.length;e++){const t=s[e];if(0===t.height)continue;const o=al(s,e);if(!o)break;const n=rl(t),r=rl(o),a=t.$context.raw,l=a[1]-a[0],c=Math.round(l<0?n.bottom-1:n.top),h=Math.round(n.right),d=Math.round(r.left);i.strokeStyle="#999",i.beginPath(),i.moveTo(h+1,c+.5),i.lineTo(d,c+.5),i.stroke()}i.restore()}};function rl(e){const t=e.base<e.y;return{left:e.x-e.width/2,right:e.x+e.width/2,bottom:t?e.base+e.height:e.y+e.height,top:t?e.base:e.y}}function al(e,t){return e.find(((e,o)=>o>t&&0!==e.height))}window.Chart?.register(nl);class ll extends t.Component{static template="o-spreadsheet-ChartJsComponent";static props={figure:Object};canvas=t.useRef("graphContainer");chart;currentRuntime;get background(){return this.chartRuntime.background}get canvasStyle(){return`background-color: ${this.background}`}get chartRuntime(){const e=this.env.model.getters.getChartRuntime(this.props.figure.id);if(!("chartJsConfig"in e))throw new Error("Unsupported chart runtime");return e}setup(){t.onMounted((()=>{const e=this.chartRuntime;this.currentRuntime=e,this.createChart(ge(e.chartJsConfig))})),t.onWillUnmount((()=>this.chart?.destroy())),t.useEffect((()=>{const e=this.chartRuntime;Be(e,this.currentRuntime,"ignoreFunctions")||(this.currentRuntime=e,this.updateChartJs(ge(e)))}))}createChart(e){const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e)}updateChartJs(e){const t=e.chartJsConfig;t.data&&t.data.datasets?(this.chart.data=t.data,t.options?.plugins?.title&&(this.chart.config.options.plugins.title=t.options.plugins.title)):this.chart.data.datasets=[],this.chart.config.options=t.options,this.chart.update()}}class cl{sheetId;title;getters;constructor(e,t,o){this.title=e.title,this.sheetId=t,this.getters=o}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function hl(e,t,o,s){let i=!1;const n=[];for(let s in o){let r=o[s];if(r.labelCell){const e=gl(r.labelCell,t);r.labelCell!==e&&(i=!0,r={...r,labelCell:e})}const a=gl(r.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===No.InvalidReference?(i=!0,r=void 0):a!==r.dataRange&&(i=!0,r={...r,dataRange:a}),n[s]=r}let r=s;const a=gl(r,t);a!==r&&(i=!0,r=a);return{isStale:i,dataSets:n.filter(De),labelRange:r}}function dl(e,t,o){return o.map((o=>({dataRange:gn(e,t,o.dataRange),labelCell:o.labelCell?gn(e,t,o.labelCell):void 0})))}function ul(e,t,o){return o?gn(e,t,o):void 0}function gl(e,t){if(!e)return;const o=t(e);switch(o.changeType){case"NONE":return e;case"REMOVE":return;default:return o.range}}function pl(e,t,o,s){const i=[];for(const n of t){const t=e.getRangeFromSheetXC(o,n.dataRange),{unboundedZone:r,sheetId:a,invalidSheetName:l,invalidXc:c}=t;if(!l&&!c)if(r.left!==r.right&&r.top!==r.bottom){if(void 0===r.right)continue;for(let t=r.left;t<=r.right;t++){const o={...r,left:t,right:t};i.push({...ml(e,a,o,s?{top:o.top,bottom:o.top,left:o.left,right:o.left}:void 0),backgroundColor:n.backgroundColor,rightYAxis:"y1"===n.yAxisId,customLabel:n.label})}}else i.push({...ml(e,a,r,s?{top:r.top,bottom:r.top,left:r.left,right:r.left}:void 0),backgroundColor:n.backgroundColor,rightYAxis:"y1"===n.yAxisId,customLabel:n.label})}return i}function ml(e,t,o,s){if(o.left!==o.right&&o.top!==o.bottom)throw new Error(`Zone should be a single column or row: ${Ui(o)}`);if(s){const i=Ui(o),n=Ui(s);return{labelCell:e.getRangeFromSheetXC(t,n),dataRange:e.getRangeFromSheetXC(t,i)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,Ui(o))}}function fl(e,t){const o=t.labelCell?.zone;let s=t.dataRange.zone;if(o){const{numberOfRows:e,numberOfCols:t}=Xi(s);1===e?s={...s,left:s.left+1}:1===t&&(s={...s,top:s.top+1})}const i=t.dataRange.clone({zone:s});let n={};return t.customLabel?n={text:t.customLabel}:t.labelCell&&(n={reference:e.getRangeString(t.labelCell,"forceSheetReference",{useFixedReference:!0})}),{label:n,range:e.getRangeString(i,"forceSheetReference",{useFixedReference:!0}),backgroundColor:t.backgroundColor,rightYAxis:t.rightYAxis}}function bl(e,t,o){if(!t)return;let s={...t.zone};o&&t.zone.bottom>t.zone.top&&(s.top=s.top+1);const i=t.clone({zone:s});return e.getRangeString(i,"forceSheetReference",{useFixedReference:!0})}function vl(e,t){let o;if(e.labelRange){const s=Tr(Pi(e.labelRange),t);o=s?Ui(s):void 0}const s=e.dataSets.map((e=>Pi(e.dataRange))).map((e=>Tr(e,t))).filter(De).map((e=>({dataRange:Ui(e)})));return{...e,labelRange:o,dataSets:s}}function Sl(e){return e&&ct(e)<.3?"#FFFFFF":"#000000"}function Cl(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!yi.test(e.dataRange)));if(t)return"InvalidDataSet";if(e.dataSets.map((e=>Pi(e.dataRange))).some((e=>e.top!==e.bottom&&nn(e))))return"InvalidDataSet"}return"Success"}function yl(e){if(e.labelRange){if(!yi.test(e.labelRange||""))return"InvalidLabelRange"}return"Success"}function El(e,t,o){if(!o)return!1;if(!e)return!1;if(!t)return!0;const s=rn(t.dataRange.zone);return!(rn(e.zone)<s)}function xl(e){if(e?.title?.text){const{text:t,color:o,align:s,italic:i,bold:n}=e.title;return{display:!0,text:t,color:o,font:{style:i?"italic":"normal",weight:n?"bold":"normal"},align:"left"===s?"start":"right"===s?"end":"center"}}}function wl(e){let t=!1,o=!1;for(const s of e.dataSets||[])"y1"===s.yAxisId?o=!0:t=!0;return t||=!o,{useLeftAxis:t,useRightAxis:o}}function Il(e,t,o,s,i){if("text"===t||"progress"===t||e?.type!==po.number||o?.type!==po.number)return;const n=o.value-e.value;return n>0?s:n<0?i:void 0}function Rl(e,t,o){if("text"===o||e?.type!==po.number||t?.type!==po.number)return"neutral";const s=t.value-e.value;return s>0?"up":s<0?"down":"neutral"}function Tl(e){return e.keyValue&&!yi.test(e.keyValue)?"InvalidScorecardKeyValue":"Success"}function Al(e){return e.baseline&&!yi.test(e.baseline)?"InvalidScorecardBaseline":"Success"}const Ol=new window.Path2D("M8.6 4.8a.5.5 0 0 1 0 .75l-3.9 3.9a.5 .5 0 0 1 -.75 0l-3.8 -3.9a.5 .5 0 0 1 0 -.75l.4-.4a.5.5 0 0 1 .75 0l2.3 2.4v-5.7c0-.25.25-.5.5-.5h.6c.25 0 .5.25.5.5v5.8l2.3 -2.4a.5.5 0 0 1 .75 0z"),_l=new window.Path2D("M8.7 5.5a.5.5 0 0 0 0-.75l-3.8-4a.5.5 0 0 0-.75 0l-3.8 4a.5.5 0 0 0 0 .75l.4.4a.5.5 0 0 0 .75 0l2.3-2.4v5.8c0 .25.25.5.5.5h.6c.25 0 .5-.25.5-.5v-5.8l2.2 2.4a.5.5 0 0 0 .75 0z");let Dl=class e extends cl{keyValue;baseline;baselineMode;baselineDescr;progressBar=!1;background;baselineColorUp;baselineColorDown;fontColor;humanize;type="scorecard";constructor(e,t,o){super(e,t,o),this.keyValue=pn(o,t,e.keyValue),this.baseline=pn(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown,this.humanize=e.humanize??!1}static validateChartDefinition(e,t){return e.checkValidations(t,Tl,Al)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0].dataRange:void 0,title:e.title||{text:""},baselineMode:Q,baselineColorUp:J,baselineColorDown:ee,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,s;return e.baseline&&(o=Tr(Pi(e.baseline),t)),e.keyValue&&(s=Tr(Pi(e.keyValue),t)),{...e,baseline:o?Ui(o):void 0,keyValue:s?Ui(s):void 0}}copyForSheetId(t){const o=ul(this.sheetId,t,this.baseline),s=ul(this.sheetId,t,this.keyValue),i=this.getDefinitionWithSpecificRanges(o,s,t);return new e(i,t,this.getters)}copyInSheetId(t){const o=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,t);return new e(o,t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{...this,range:this.keyValue?[{dataRange:this.getters.getRangeString(this.keyValue,this.sheetId)}]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,o){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,o||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,o||this.sheetId):void 0,humanize:this.humanize}}getDefinitionForExcel(){}updateRanges(t){const o=gl(this.baseline,t),s=gl(this.keyValue,t);if(this.baseline===o&&this.keyValue===s)return this;const i=this.getDefinitionWithSpecificRanges(o,s);return new e(i,this.sheetId,this.getters)}};function Ml(e,t){const o=t.getContext("2d");if(t.width=e.canvas.width,t.height=e.canvas.height,o.fillStyle=e.canvas.backgroundColor,o.fillRect(0,0,e.canvas.width,e.canvas.height),e.title){o.font=e.title.style.font,o.fillStyle=e.title.style.color;const s=o.textBaseline;o.textBaseline="middle",o.fillText(Pn(o,e.title.text,t.width-e.title.position.x),e.title.position.x,e.title.position.y),o.textBaseline=s}if(e.baseline&&(o.font=e.baseline.style.font,o.fillStyle=e.baseline.style.color,kn(o,e.baseline.text,e.baseline.position,e.baseline.style.underline,e.baseline.style.strikethrough)),e.baselineArrow&&e.baselineArrow.style.size>0){o.save(),o.fillStyle=e.baselineArrow.style.color,o.translate(e.baselineArrow.position.x,e.baselineArrow.position.y);const t=e.baselineArrow.style.size/10;switch(o.scale(t,t),e.baselineArrow.direction){case"down":o.fill(Ol);break;case"up":o.fill(_l)}o.restore()}if(e.baselineDescr){const s=e.baselineDescr[0];o.font=s.style.font,o.fillStyle=s.style.color;for(const s of e.baselineDescr)o.fillText(Pn(o,s.text,t.width-s.position.x),s.position.x,s.position.y)}if(e.key&&(o.font=e.key.style.font,o.fillStyle=e.key.style.color,kn(o,e.key.text,e.key.position,e.key.style.underline,e.key.style.strikethrough)),e.progressBar){if(o.fillStyle=e.progressBar.style.backgroundColor,o.beginPath(),o.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width,e.progressBar.dimension.height,e.progressBar.dimension.height/2),o.fill(),o.fillStyle=e.progressBar.style.color,o.beginPath(),e.progressBar.value>0)o.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width*Math.max(0,Math.min(1,e.progressBar.value)),e.progressBar.dimension.height,e.progressBar.dimension.height/2);else{const t=e.progressBar.dimension.width*Math.max(0,Math.min(1,-e.progressBar.value));o.roundRect(e.progressBar.position.x+e.progressBar.dimension.width-t,e.progressBar.position.y,t,e.progressBar.dimension.height,e.progressBar.dimension.height/2)}o.fill()}}const Fl=R,Nl=.05;function Pl({width:e,height:t},o){return new Ll({width:e,height:t},o).computeDesign()}class Ll{runtime;context;width;height;constructor({width:e,height:t},o){this.runtime=o;const s=document.createElement("canvas");this.width=s.width=e,this.height=s.height=t,this.context=s.getContext("2d")}computeDesign(){const e={canvas:{width:this.width,height:this.height,backgroundColor:this.backgroundColor}},t=this.getTextStyles();let o=0;if(this.title){let s,i;switch(({height:o,width:i}=this.getFullTextDimensions(this.title,t.title.font)),this.runtime.title.align){case"center":s=(this.width-i)/2;break;case"right":s=this.width-i-Fl;break;default:s=Fl}e.title={text:this.title,style:t.title,position:{x:s,y:Fl+o/2}}}const s=t.baselineArrow?.size??0;let{height:i,width:n}=this.getTextDimensions(this.baseline,t.baselineValue.font);this.baseline||(i=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).height);const r=t.baselineDescr.isSplit?Math.max(...Ln(this.baselineDescr).map((e=>this.getTextDimensions(e,t.baselineDescr.font).width))):this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).width;if(e.baseline={text:this.baseline,style:t.baselineValue,position:{x:(this.width-n-r+s)/2,y:this.keyValue?this.height*(1-Nl*(this.runtime.progressBar?1:2)):this.height-(this.height-o-i)/2-Fl}},t.baselineArrow&&!this.runtime.progressBar&&(e.baselineArrow={direction:this.baselineArrow,style:t.baselineArrow,position:{x:e.baseline.position.x-s,y:e.baseline.position.y-(i+s)/2}}),this.baselineDescr){const o={x:e.baseline.position.x+n,y:e.baseline.position.y};if(t.baselineDescr.isSplit){const s=Ln(this.baselineDescr),i=this.context.measureText(s[1]),n=i.fontBoundingBoxAscent+i.fontBoundingBoxDescent;e.baselineDescr=[{text:s[0],style:t.baselineDescr,position:{x:o.x,y:o.y-n}},{text:s[1],style:t.baselineDescr,position:o}]}else e.baselineDescr=[{text:this.baselineDescr,style:t.baselineDescr,position:o}]}let a=0;this.runtime.progressBar&&(a=.05*this.height,e.progressBar={position:{x:2*Fl,y:.9*this.height-i-a},dimension:{height:a,width:this.width-4*Fl},value:this.runtime.progressBar.value,style:{color:this.runtime.progressBar.color,backgroundColor:this.secondaryFontColor}});const{width:l,height:c}=this.getFullTextDimensions(this.keyValue,t.keyValue.font);return this.keyValue&&(e.key={text:this.keyValue,style:t.keyValue,position:{x:(this.width-l)/2,y:.4*this.height+(o+c/(this.baseline||this.baselineDescr?2:1.2))/2}}),e}get title(){return this.runtime.title.text??""}get keyValue(){return this.runtime.keyValue}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){return function(e,t){const o=e||"";return t&&o?" "+o:o}(this.runtime.baselineDescr,this.baseline)}get baselineArrow(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get secondaryFontColor(){return ct(this.backgroundColor)>.3?"#525252":"#C8C8C8"}getTextDimensions(e,t){this.context.font=t;const o=this.context.measureText(e);return{width:o.width,height:o.actualBoundingBoxAscent+o.actualBoundingBoxDescent}}getFullTextDimensions(e,t){this.context.font=t;const o=this.context.measureText(e);return{width:o.width,height:o.fontBoundingBoxAscent+o.fontBoundingBoxDescent}}getTextStyles(){const e=this.width-2*Fl,t=this.getDrawableHeight(),o=new Vl(this.runtime.keyValueStyle),s=o.getElementMaxFontSize(t,this),i=Mn(e,600,(e=>o.getElementWidth(e,this.context,this))),n=Math.min(s,i);let r=Math.floor(.5*n);this.context.font=yn(r,this.runtime.baselineStyle?.bold,this.runtime.baselineStyle?.italic);const a="neutral"!==this.baselineArrow?"A "+this.baseline:this.baseline,l=e-wn(this.context,a);let c=Mn(l,r,(e=>xn(this.context,this.baselineDescr,{fontSize:e}))),h=!1;if(c<r/2.5){h=!0,c=Math.floor(r/2.5);for(const e of Ln(this.baselineDescr)){const t=Mn(l,r,(t=>(this.context.font=yn(t),this.context.measureText(e).width)));c=Math.min(c,t)}}return this.runtime.progressBar&&(r/=1.5),{title:{font:yn(T,this.runtime.title.bold,this.runtime.title.italic),color:this.runtime.title.color??this.secondaryFontColor},keyValue:{color:this.runtime.keyValueStyle?.textColor||this.runtime.fontColor,font:yn(n,this.runtime.keyValueStyle?.bold,this.runtime.keyValueStyle?.italic),strikethrough:this.runtime.keyValueStyle?.strikethrough,underline:this.runtime.keyValueStyle?.underline},baselineValue:{font:yn(r,this.runtime.baselineStyle?.bold,this.runtime.baselineStyle?.italic),strikethrough:this.runtime.baselineStyle?.strikethrough,underline:this.runtime.baselineStyle?.underline,color:this.runtime.baselineStyle?.textColor||this.runtime.baselineColor||this.secondaryFontColor},baselineDescr:{font:yn(c),isSplit:h,color:this.secondaryFontColor},baselineArrow:"neutral"===this.baselineArrow||this.runtime.progressBar?void 0:{size:this.keyValue?.8*r:0,color:this.runtime.baselineColor||this.secondaryFontColor}}}getDrawableHeight(){const e=Fl+this.height*Nl;let t=this.height-2*e;return t-=this.title?1.2*T:0,t}}class kl{style;constructor(e={}){this.style=e}measureTextWidth(e,t,o){return e.font=yn(o,this.style.bold,this.style.italic),wn(e,t)}}class Vl extends kl{getElementWidth(e,t,o){if(!o.runtime)return 0;const s=o.keyValue||"";return this.measureTextWidth(t,s,e)}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.8*e:e)/1.2}}class Ul extends t.Component{static template="o-spreadsheet-ScorecardChart";static props={figure:Object};canvas=t.useRef("chartContainer");get runtime(){return this.env.model.getters.getChartRuntime(this.props.figure.id)}setup(){t.useEffect(this.createChart.bind(this),(()=>{const e=this.canvas.el.getBoundingClientRect();return[e.width,e.height,this.runtime,this.canvas.el]}))}createChart(){const e=this.canvas.el;Ml(Pl(e.getBoundingClientRect(),this.runtime),e)}}function Bl(e,t,o,s){const i=[];e=e.toLowerCase();for(const n of e){const e=t.toLocaleLowerCase().indexOf(n);-1!==e&&(i.push({value:t.slice(0,e),color:""},{value:t[e],color:o,class:s}),t=t.slice(e+1))}i.push({value:t});return i.filter((e=>e.value))}va.add("dataValidation",{getProposals(e,t){if(t.startsWith("="))return[];const o=this.composer.currentEditedCell,s=this.getters.getValidationRuleForCell(o);if(!s||"isValueInList"!==s.criterion.type&&"isValueInRange"!==s.criterion.type)return[];let i;if("isValueInList"===s.criterion.type)i=s.criterion.values;else{const e=this.getters.getRangeFromSheetXC(o.sheetId,s.criterion.values[0]);i=Array.from(new Set(this.getters.getRangeValues(e).filter(Me).map((e=>e.toString())).filter((e=>""!==e))))}return i.map((e=>({text:e})))},selectProposal(e,t){this.composer.setCurrentContent(t),this.composer.stopEdition()}});const Hl=/(.*?)\((.*?)\)(.*)/,zl=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function $l(e,t=""){return function(e,t){let o=e.match(Hl),s=o[1].trim();if(!s)throw new Error(`Function argument definition is missing a name: '${e}'.`);let i,n=[],r=!1,a=!1;for(let e of o[2].split(",")){const t=e.trim().toUpperCase();let o=zl.find((e=>t===e));o?n.push(o):"RANGE<ANY>"===t?n.push("RANGE"):"OPTIONAL"===t?r=!0:"REPEATING"===t?a=!0:t.startsWith("DEFAULT=")&&(i=e.trim().slice(8))}const l={name:s,description:t,type:n};r&&(l.optional=!0);a&&(l.repeating=!0);void 0!==i&&(l.default=!0,l.defaultValue=i);n.some((e=>e.startsWith("RANGE")))&&(l.acceptMatrix=!0);return l}(e,t)}function Gl(e){let t=0,o=0,s=0;for(let i of e.args)t++,i.optional||i.repeating||i.default||o++,i.repeating&&s++;const i=e;return i.minArgRequired=o,i.maxArgPossible=s?1/0:t,i.nbrArgRepeating=s,i.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const o=e-t;return e=>{if(e<=o)return e;return o+((e-o)%t||t)}}(t,s),i.hidden=e.hidden||!1,i}function Wl(e,t){$o((()=>1===t.length||1===t[0].length),e)}function ql(e,...t){if(t.every(_o)){const o=t[0].length,s=t[0][0].length;for(const i of t)$o((()=>i.length===o&&i[0].length===s),e)}else if(t.some((e=>Array.isArray(e)&&(1!==e.length||1!==e[0].length))))throw new Lo(e)}function Zl(e,t){$o((()=>t>0),e)}function Yl(e,t){$o((()=>t.length===t[0].length),e)}function jl(e){const t=Array(e);for(let o=0;o<e;o++)t[o]=Array(e).fill(0),t[o][o]=1;return t}function Xl(e){if(e.length!==e[0].length)throw new Lo(uo("Function [[FUNCTION_NAME]] invert matrix error, only square matrices are invertible"));let t=1;const o=e.length,s=jl(o),i=e.map((e=>e.slice()));for(let e=0;e<o;e++){let n=i[e][e];if(0===n){for(let n=e+1;n<o;n++)if(0!=i[e][n]){Kl(i,e,n),Kl(s,e,n),t*=-1;break}if(n=i[e][e],0===n)return{determinant:0}}for(let t=0;t<o;t++)i[t][e]=i[t][e]/n,s[t][e]=s[t][e]/n;t*=n;for(let t=0;t<o;t++){if(t===e)continue;const n=i[e][t];for(let r=0;r<o;r++)i[r][t]-=n*i[r][e],s[r][t]-=n*s[r][e]}}return{inverted:s,determinant:t}}function Kl(e,t,o){for(let s=0;s<e.length;s++){const i=e[s][t];e[s][t]=e[s][o],e[s][o]=i}}function Ql(e,t){if(e.length!==t[0].length)throw new Lo(uo("Cannot multiply matrices : incompatible matrices size."));const o=e[0].length,s=t.length,i=e.length,n=Array(s);for(let r=0;r<s;r++){n[r]=Array(o);for(let s=0;s<o;s++){let o=0;for(let n=0;n<i;n++)o+=e[n][s]*t[r][n];n[r][s]=o}}return n}function Jl(e){if(!_o(e))return e;if(1!==e.length||1!==e[0].length)throw new Lo(uo("The value should be a scalar or a 1x1 matrix"));return e[0][0]}const ec={description:uo("Returns a result array constrained to a specific width and height."),args:[$l("input_range (any, range<any>)",uo("The range to constrain.")),$l("rows (number)",uo("The number of rows in the constrained array.")),$l("columns (number)",uo("The number of columns in the constrained array."))],returns:["RANGE<ANY>"],compute:function(e,t,o){const s=Rs(e),i=Ko(t?.value,this.locale),n=Ko(o?.value,this.locale);Zl(uo("The rows argument (%s) must be strictly positive.",i.toString()),i),Zl(uo("The columns argument (%s) must be strictly positive.",i.toString()),n);const r=Math.min(i,s[0].length);return ps(Math.min(n,s.length),r,((e,t)=>s[e][t]))},isExported:!1},tc={description:uo("Creates a new array from the selected columns in the existing range."),args:[$l("array (any, range<any>)",uo("The array that contains the columns to be returned.")),$l("col_num (number, range<number>)",uo("The first column index of the columns to be returned.")),$l("col_num2 (number, range<number>, repeating)",uo("The columns indexes of the columns to be returned."))],returns:["RANGE<ANY>"],compute:function(e,...t){const o=Rs(e),s=Ts(t,(e=>Ko(e?.value,this.locale)));$o((()=>s.every((e=>e>0&&e<=o.length))),uo("The columns arguments must be between 1 and %s (got %s).",o.length.toString(),(s.find((e=>e<=0||e>o.length))||0).toString()));const i=Array(s.length);for(let e=0;e<s.length;e++){const t=s[e]-1;i[e]=o[t]}return i},isExported:!0},oc={description:uo("Creates a new array from the selected rows in the existing range."),args:[$l("array (any, range<any>)",uo("The array that contains the rows to be returned.")),$l("row_num (number, range<number>)",uo("The first row index of the rows to be returned.")),$l("row_num2 (number, range<number>, repeating)",uo("The rows indexes of the rows to be returned."))],returns:["RANGE<ANY>"],compute:function(e,...t){const o=Rs(e),s=Ts(t,(e=>Ko(e?.value,this.locale))),i=o.length;return $o((()=>s.every((e=>e>0&&e<=o[0].length))),uo("The rows arguments must be between 1 and %s (got %s).",o[0].length.toString(),(s.find((e=>e<=0||e>o[0].length))||0).toString())),ps(i,s.length,((e,t)=>o[e][s[t]-1]))},isExported:!0},sc={description:uo("Expands or pads an array to specified row and column dimensions."),args:[$l("array (any, range<any>)",uo("The array to expand.")),$l("rows (number)",uo("The number of rows in the expanded array. If missing, rows will not be expanded.")),$l("columns (number, optional)",uo("The number of columns in the expanded array. If missing, columns will not be expanded.")),$l("pad_with (any, default=0)",uo("The value with which to pad."))],returns:["RANGE<ANY>"],compute:function(e,t,o,s={value:0}){const i=Rs(e),n=Ko(t?.value,this.locale),r=void 0!==o?Ko(o.value,this.locale):i.length;return $o((()=>n>=i[0].length),uo("The rows arguments (%s) must be greater or equal than the number of rows of the array.",n.toString())),$o((()=>r>=i.length),uo("The columns arguments (%s) must be greater or equal than the number of columns of the array.",r.toString())),ps(r,n,((e,t)=>e>=i.length||t>=i[e].length?s:i[e][t]))},isExported:!0},ic={description:uo("Flattens all the values from one or more ranges into a single column."),args:[$l("range (any, range<any>)",uo("The first range to flatten.")),$l("range2 (any, range<any>, repeating)",uo("Additional ranges to flatten."))],returns:["RANGE<ANY>"],compute:function(...e){return[Ts(e,(e=>void 0===e?{value:""}:e))]},isExported:!1},nc={description:uo("Calculates the frequency distribution of a range."),args:[$l("data (range<number>)",uo("The array of ranges containing the values to be counted.")),$l("classes (number, range<number>)",uo("The range containing the set of classes."))],returns:["RANGE<NUMBER>"],compute:function(e,t){const o=Ts([e],(e=>e.value)).filter((e=>"number"==typeof e)),s=Ts([t],(e=>e.value)).filter((e=>"number"==typeof e)),i=s.map(((e,t)=>({initialIndex:t,value:e,count:0}))).sort(((e,t)=>e.value-t.value));i.push({initialIndex:i.length,value:1/0,count:0});const n=o.sort(((e,t)=>e-t));let r=0;for(const e of n){for(;e>i[r].value&&r<i.length-1;)r++;i[r].count++}return[i.sort(((e,t)=>e.initialIndex-t.initialIndex)).map((e=>e.count))]},isExported:!0},rc={description:uo("Appends ranges horizontally and in sequence to return a larger array."),args:[$l("range1 (any, range<any>)",uo("The first range to be appended.")),$l("range2 (any, range<any>, repeating)",uo("Additional ranges to add to range1."))],returns:["RANGE<ANY>"],compute:function(...e){const t=Math.max(...e.map((e=>e?.[0]?.length??0))),o=[];for(const s of e){const e=Rs(s);for(let s=0;s<e.length;s++){const i=Array(t).fill({value:null});for(let t=0;t<e[s].length;t++)i[t]=e[s][t];o.push(i)}}return o},isExported:!0},ac={description:uo("Returns the matrix determinant of a square matrix."),args:[$l("square_matrix (number, range<number>)",uo("An range with an equal number of rows and columns representing a matrix whose determinant will be calculated."))],returns:["NUMBER"],compute:function(e){const t=jo(e,"square_matrix");return Yl(uo("The argument square_matrix must have the same number of columns and rows."),t),Xl(t).determinant},isExported:!0},lc={description:uo("Returns the multiplicative inverse of a square matrix."),args:[$l("square_matrix (number, range<number>)",uo("An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated."))],returns:["RANGE<NUMBER>"],compute:function(e){const t=jo(e,"square_matrix");Yl(uo("The argument square_matrix must have the same number of columns and rows."),t);const{inverted:o}=Xl(t);if(!o)throw new Lo(uo("The matrix is not invertible."));return o},isExported:!0},cc={description:uo("Calculates the matrix product of two matrices."),args:[$l("matrix1 (number, range<number>)",uo("The first matrix in the matrix multiplication operation.")),$l("matrix2 (number, range<number>)",uo("The second matrix in the matrix multiplication operation."))],returns:["RANGE<NUMBER>"],compute:function(e,t){const o=jo(e,"matrix1"),s=jo(t,"matrix2");return $o((()=>o.length===s[0].length),uo("In [[FUNCTION_NAME]], the number of columns of the first matrix (%s) must be equal to the number of rows of the second matrix (%s).",o.length.toString(),s[0].length.toString())),Ql(o,s)},isExported:!0},hc={description:uo("Calculates the sum of the products of corresponding entries in equal-sized ranges."),args:[$l("range1 (number, range<number>)",uo("The first range whose entries will be multiplied with corresponding entries in the other ranges.")),$l("range2 (number, range<number>, repeating)",uo("The other range whose entries will be multiplied with corresponding entries in the other ranges."))],returns:["NUMBER"],compute:function(...e){ql(uo("All the ranges must have the same dimensions."),...e);const t=e.map(Rs);let o=0;for(let e=0;e<t[0].length;e++)for(let s=0;s<t[0][e].length;s++){if(!t.every((t=>"number"==typeof t[e][s].value)))continue;let i=1;for(const o of t)i*=Zo(o[e][s],this.locale);o+=i}return o},isExported:!0};function dc(e,t,o){ql("The arguments array_x and array_y must have the same dimensions.",e,t);const s=Rs(e),i=Rs(t);let n=!1,r=0;for(const e in s)for(const t in s[e]){const a=s[e][t].value,l=i[e][t].value;"number"==typeof a&&"number"==typeof l&&(n=!0,r+=o(a,l))}if(!n)throw new Lo(uo("The arguments array_x and array_y must contain at least one pair of numbers."));return r}const uc={description:uo("Calculates the sum of the difference of the squares of the values in two array."),args:[$l("array_x (number, range<number>)",uo("The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.")),$l("array_y (number, range<number>)",uo("The array or range of values whose squares will be subtracted from the squares of corresponding entries in array_x and added together."))],returns:["NUMBER"],compute:function(e,t){return dc(e,t,((e,t)=>e**2-t**2))},isExported:!0},gc={description:uo("Calculates the sum of the sum of the squares of the values in two array."),args:[$l("array_x (number, range<number>)",uo("The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.")),$l("array_y (number, range<number>)",uo("The array or range of values whose squares will be added to the squares of corresponding entries in array_x and added together."))],returns:["NUMBER"],compute:function(e,t){return dc(e,t,((e,t)=>e**2+t**2))},isExported:!0},pc={description:uo("Calculates the sum of squares of the differences of values in two array."),args:[$l("array_x (number, range<number>)",uo("The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.")),$l("array_y (number, range<number>)",uo("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."))],returns:["NUMBER"],compute:function(e,t){return dc(e,t,((e,t)=>(e-t)**2))},isExported:!0},mc=!1,fc=[$l("array (any, range<any>)",uo("The array which will be transformed.")),$l("ignore (number, default=0)",uo("The control to ignore blanks and errors. 0 (default) is to keep all values, 1 is to ignore blanks, 2 is to ignore errors, and 3 is to ignore blanks and errors.")),$l("scan_by_column (number, default=false)",uo("Whether the array should be scanned by column. True scans the array by column and false (default) scans the array by row."))];function bc(e){const t=Math.trunc(e);if(0===t)return()=>!0;if(1===t)return e=>null!==e.value;if(2===t)return e=>!Wo(e.value);if(3===t)return e=>null!==e.value&&!Wo(e.value);throw new Lo(uo("Argument ignore must be between 0 and 3"))}const vc={description:uo("Transforms a range of cells into a single column."),args:fc,returns:["RANGE<ANY>"],compute:function(e,t={value:0},o={value:mc}){const s=Rs(e),i=Zo(t.value,this.locale),n=(is(o.value)?s:fs(s)).flat().filter(bc(i));if(0===n.length)throw new Uo(uo("No results for the given arguments of TOCOL."));return[n]},isExported:!0},Sc={description:uo("Transforms a range of cells into a single row."),args:fc,returns:["RANGE<ANY>"],compute:function(e,t={value:0},o={value:mc}){const s=Rs(e),i=Zo(t.value,this.locale),n=(is(o.value)?s:fs(s)).flat().filter(bc(i)).map((e=>[e]));if(0===n.length||0===n[0].length)throw new Uo(uo("No results for the given arguments of TOROW."));return n},isExported:!0},Cc={description:uo("Transposes the rows and columns of a range."),args:[$l("range (any, range<any>)",uo("The range to be transposed."))],returns:["RANGE"],compute:function(e){const t=Rs(e);return ps(t[0].length,t.length,((e,o)=>t[o][e]))},isExported:!0},yc={description:uo("Appends ranges vertically and in sequence to return a larger array."),args:[$l("range1 (any, range<any>)",uo("The first range to be appended.")),$l("range2 (any, range<any>, repeating)",uo("Additional ranges to add to range1."))],returns:["RANGE<ANY>"],compute:function(...e){const t=Math.max(...e.map((e=>Rs(e).length))),o=e.reduce(((e,t)=>e+Rs(t)[0].length),0),s=Array(t).fill([]).map((()=>Array(o).fill({value:0})));let i=0;for(const t of e){const e=Rs(t);for(let t=0;t<e.length;t++)for(let o=0;o<e[t].length;o++)s[t][i+o]=e[t][o];i+=e[0].length}return s},isExported:!0},Ec={description:uo("Wraps the provided row or column of cells by columns after a specified number of elements to form a new array."),args:[$l("range (any, range<any>)",uo("The range to wrap.")),$l("wrap_count (number)",uo("The maximum number of cells for each column, rounded down to the nearest whole number.")),$l("pad_with (any, default=0)",uo("The value with which to fill the extra cells in the range."))],returns:["RANGE<ANY>"],compute:function(e,t,o={value:0}){const s=Rs(e),i=Ko(t?.value,this.locale);Wl(uo("Argument range must be a single row or column."),s);const n=s.flat();return ps(Math.ceil(n.length/i),i,((e,t)=>{const s=e*i+t;return s<n.length?n[s]:o}))},isExported:!0},xc={description:uo("Wraps the provided row or column of cells by rows after a specified number of elements to form a new array."),args:[$l("range (any, range<any>)",uo("The range to wrap.")),$l("wrap_count (number)",uo("The maximum number of cells for each row, rounded down to the nearest whole number.")),$l("pad_with (any, default=0)",uo("The value with which to fill the extra cells in the range."))],returns:["RANGE<ANY>"],compute:function(e,t,o={value:0}){const s=Rs(e),i=Ko(t?.value,this.locale);Wl(uo("Argument range must be a single row or column."),s);const n=s.flat(),r=Math.ceil(n.length/i);return ps(i,r,((e,t)=>{const s=t*i+e;return s<n.length?n[s]:o}))},isExported:!0};var wc=Object.freeze({__proto__:null,ARRAY_CONSTRAIN:ec,CHOOSECOLS:tc,CHOOSEROWS:oc,EXPAND:sc,FLATTEN:ic,FREQUENCY:nc,HSTACK:rc,MDETERM:ac,MINVERSE:lc,MMULT:cc,SUMPRODUCT:hc,SUMX2MY2:uc,SUMX2PY2:gc,SUMXMY2:pc,TOCOL:vc,TOROW:Sc,TRANSPOSE:Cc,VSTACK:yc,WRAPCOLS:Ec,WRAPROWS:xc});const Ic={description:uo("Apply a large number format"),args:[$l("value (number)",uo("The number.")),$l("unit (string, optional)",uo("The formatting unit. Use 'k', 'm', or 'b' to force the unit"))],returns:["NUMBER"],compute:function(e,t){return{value:Zo(e,this.locale),format:ri(e,t,this.locale)}}};var Rc=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:Ic});function Tc(e,t){return us(e,((e,t)=>e+t),0,t)}function Ac(e){return ds(e,((e,t)=>As(t)?e.add(t?.value):e),new Set).size}const Oc=/^-?[a-z0-9]+$/i,_c={description:uo("Absolute value of a number."),args:[$l("value (number)",uo("The number of which to return the absolute value."))],returns:["NUMBER"],compute:function(e){return Math.abs(Zo(e,this.locale))},isExported:!0},Dc={description:uo("Inverse cosine of a value, in radians."),args:[$l("value (number)",uo("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return $o((()=>Math.abs(t)<=1),uo("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},Mc={description:uo("Inverse hyperbolic cosine of a number."),args:[$l("value (number)",uo("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return $o((()=>t>=1),uo("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},Fc={description:uo("Inverse cotangent of a value."),args:[$l("value (number)",uo("The value for which to calculate the inverse cotangent."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},Nc={description:uo("Inverse hyperbolic cotangent of a value."),args:[$l("value (number)",uo("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return $o((()=>Math.abs(t)>1),uo("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},Pc={description:uo("Inverse sine of a value, in radians."),args:[$l("value (number)",uo("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return $o((()=>Math.abs(t)<=1),uo("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Lc={description:uo("Inverse hyperbolic sine of a number."),args:[$l("value (number)",uo("The value for which to calculate the inverse hyperbolic sine."))],returns:["NUMBER"],compute:function(e){return Math.asinh(Zo(e,this.locale))},isExported:!0},kc={description:uo("Inverse tangent of a value, in radians."),args:[$l("value (number)",uo("The value for which to calculate the inverse tangent."))],returns:["NUMBER"],compute:function(e){return Math.atan(Zo(e,this.locale))},isExported:!0},Vc={description:uo("Angle from the X axis to a point (x,y), in radians."),args:[$l("x (number)",uo("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),$l("y (number)",uo("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis."))],returns:["NUMBER"],compute:function(e,t){const o=Zo(e,this.locale),s=Zo(t,this.locale);return $o((()=>0!==o||0!==s),uo("Function [[FUNCTION_NAME]] caused a divide by zero error."),No.DivisionByZero),Math.atan2(s,o)},isExported:!0},Uc={description:uo("Inverse hyperbolic tangent of a number."),args:[$l("value (number)",uo("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return $o((()=>Math.abs(t)<1),uo("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},Bc={description:uo("Rounds number up to nearest multiple of factor."),args:[$l("value (number)",uo("The value to round up to the nearest integer multiple of factor.")),$l("factor (number, default=1)",uo("The number to whose multiples value will be rounded."))],returns:["NUMBER"],compute:function(e,t={value:1}){const o=Zo(e,this.locale),s=Zo(t,this.locale);return $o((()=>s>=0||o<=0),uo("The factor (%s) must be positive when the value (%s) is positive.",s.toString(),o.toString())),{value:s?Math.ceil(o/s)*s:0,format:e?.format}},isExported:!0};function Hc(e,t,o=0){return 0===t?0:(t=Math.abs(t),e>=0?Math.ceil(e/t)*t:0===o?-Math.floor(Math.abs(e)/t)*t:-Math.ceil(Math.abs(e)/t)*t)}const zc={description:uo("Rounds number up to nearest multiple of factor."),args:[$l("number (number)",uo("The value to round up to the nearest integer multiple of significance.")),$l("significance (number, default=1)",uo("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),$l("mode (number, default=0)",uo("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero."))],returns:["NUMBER"],compute:function(e,t={value:1},o={value:0}){const s=Zo(t,this.locale);return{value:Hc(Zo(e,this.locale),s,Zo(o,this.locale)),format:e?.format}},isExported:!0},$c={description:uo("Rounds number up to nearest multiple of factor."),args:[$l("number (number)",uo("The value to round up to the nearest integer multiple of significance.")),$l("significance (number, default=1)",uo("The number to whose multiples number will be rounded."))],returns:["NUMBER"],compute:function(e,t={value:1}){const o=Zo(t,this.locale);return{value:Hc(Zo(e,this.locale),o),format:e?.format}},isExported:!0},Gc={description:uo("Cosine of an angle provided in radians."),args:[$l("angle (number)",uo("The angle to find the cosine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.cos(Zo(e,this.locale))},isExported:!0},Wc={description:uo("Hyperbolic cosine of any real number."),args:[$l("value (number)",uo("Any real value to calculate the hyperbolic cosine of."))],returns:["NUMBER"],compute:function(e){return Math.cosh(Zo(e,this.locale))},isExported:!0},qc={description:uo("Cotangent of an angle provided in radians."),args:[$l("angle (number)",uo("The angle to find the cotangent of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return es(t),1/Math.tan(t)},isExported:!0},Zc={description:uo("Hyperbolic cotangent of any real number."),args:[$l("value (number)",uo("Any real value to calculate the hyperbolic cotangent of."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return es(t),1/Math.tanh(t)},isExported:!0},Yc={description:uo("Number of empty values."),args:[$l("value1 (any, range)",uo("The first value or range in which to count the number of blanks.")),$l("value2 (any, range, repeating)",uo("Additional values or ranges in which to count the number of blanks."))],returns:["NUMBER"],compute:function(...e){return ds(e,((e,t)=>void 0===t||null===t.value||""===t.value?e+1:e),0)},isExported:!0},jc={description:uo("A conditional count across a range."),args:[$l("range (range)",uo("The range that is tested against criterion.")),$l("criterion (string)",uo("The pattern or test to apply to range."))],returns:["NUMBER"],compute:function(...e){let t=0;return ys(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0},Xc={description:uo("Count values depending on multiple criteria."),args:[$l("criteria_range1 (range)",uo("The range to check against criterion1.")),$l("criterion1 (string)",uo("The pattern or test to apply to criteria_range1.")),$l("criteria_range2 (any, range, repeating)",uo("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),$l("criterion2 (string, repeating)",uo("Additional criteria to check."))],returns:["NUMBER"],compute:function(...e){let t=0;return ys(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0},Kc={description:uo("Counts number of unique values in a range."),args:[$l("value1 (any, range)",uo("The first value or range to consider for uniqueness.")),$l("value2 (any, range, repeating)",uo("Additional values or ranges to consider for uniqueness."))],returns:["NUMBER"],compute:function(...e){return Ac(e)}},Qc={description:uo("Counts number of unique values in a range, filtered by a set of criteria."),args:[$l("range (range)",uo("The range of cells from which the number of unique values will be counted.")),$l("criteria_range1 (range)",uo("The range of cells over which to evaluate criterion1.")),$l("criterion1 (string)",uo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),$l("criteria_range2 (any, range, repeating)",uo("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),$l("criterion2 (string, repeating)",uo("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=new Set;return ys(t,((t,s)=>{const i=e[t]?.[s];As(i)&&o.add(i.value)}),this.locale),o.size}},Jc={description:uo("Cosecant of an angle provided in radians."),args:[$l("angle (number)",uo("The angle to find the cosecant of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return es(t),1/Math.sin(t)},isExported:!0},eh={description:uo("Hyperbolic cosecant of any real number."),args:[$l("value (number)",uo("Any real value to calculate the hyperbolic cosecant of."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return es(t),1/Math.sinh(t)},isExported:!0},th={description:uo("Converts from another base to decimal."),args:[$l("value (string)",uo("The number to convert.")),$l("base (number)",uo("The base to convert the value from."))],returns:["NUMBER"],compute:function(e,t){let o=Zo(t,this.locale);o=Math.floor(o),$o((()=>2<=o&&o<=36),uo("The base (%s) must be between 2 and 36 inclusive.",o.toString()));const s=ts(e);if(""===s)return 0;$o((()=>!!Oc.test(s)),uo("The value (%s) must be a valid base %s representation.",s,o.toString()));const i=parseInt(s,o);return $o((()=>!isNaN(i)),uo("The value (%s) must be a valid base %s representation.",s,o.toString())),i},isExported:!0},oh={description:uo("Converts an angle value in radians to degrees."),args:[$l("angle (number)",uo("The angle to convert from radians to degrees."))],returns:["NUMBER"],compute:function(e){return 180*Zo(e,this.locale)/Math.PI},isExported:!0},sh={description:uo("Euler's number, e (~2.718) raised to a power."),args:[$l("value (number)",uo("The exponent to raise e."))],returns:["NUMBER"],compute:function(e){return Math.exp(Zo(e,this.locale))},isExported:!0},ih={description:uo("Rounds number down to nearest multiple of factor."),args:[$l("value (number)",uo("The value to round down to the nearest integer multiple of factor.")),$l("factor (number, default=1)",uo("The number to whose multiples value will be rounded."))],returns:["NUMBER"],compute:function(e,t={value:1}){const o=Zo(e,this.locale),s=Zo(t,this.locale);return $o((()=>s>=0||o<=0),uo("The factor (%s) must be positive when the value (%s) is positive.",s.toString(),o.toString())),{value:s?Math.floor(o/s)*s:0,format:e?.format}},isExported:!0};function nh(e,t,o=0){return 0===t?0:(t=Math.abs(t),e>=0?Math.floor(e/t)*t:0===o?-Math.ceil(Math.abs(e)/t)*t:-Math.floor(Math.abs(e)/t)*t)}const rh={description:uo("Rounds number down to nearest multiple of factor."),args:[$l("number (number)",uo("The value to round down to the nearest integer multiple of significance.")),$l("significance (number, default=1)",uo("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),$l("mode (number, default=0)",uo("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero."))],returns:["NUMBER"],compute:function(e,t={value:1},o={value:0}){const s=Zo(t,this.locale);return{value:nh(Zo(e,this.locale),s,Zo(o,this.locale)),format:e?.format}},isExported:!0},ah={description:uo("Rounds number down to nearest multiple of factor."),args:[$l("number (number)",uo("The value to round down to the nearest integer multiple of significance.")),$l("significance (number, default=1)",uo("The number to whose multiples number will be rounded."))],returns:["NUMBER"],compute:function(e,t={value:1}){const o=Zo(t,this.locale);return{value:nh(Zo(e,this.locale),o),format:e?.format}},isExported:!0},lh={description:uo("Whether the provided value is even."),args:[$l("value (number)",uo("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Xo(e,this.locale);return!(1&Math.floor(Math.abs(t)))},isExported:!0},ch={description:uo("Rounds number up to nearest multiple of factor."),args:[$l("number (number)",uo("The value to round up to the nearest integer multiple of significance.")),$l("significance (number, default=1)",uo("The number to whose multiples number will be rounded."))],returns:["NUMBER"],compute:function(e,t={value:1}){return{value:Hc(Zo(e,this.locale),Zo(t,this.locale)),format:e?.format}},isExported:!0},hh={description:uo("Whether the provided value is even."),args:[$l("value (number)",uo("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Xo(e,this.locale);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},dh={description:uo("The logarithm of a number, base e (euler's number)."),args:[$l("value (number)",uo("The value for which to calculate the logarithm, base e."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return $o((()=>t>0),uo("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0};function uh(e,t){$o((()=>0!==t),uo("The divisor must be different from 0."),No.DivisionByZero);const o=e%t;return o>0&&t<0||o<0&&t>0?o+t:o}const gh={description:uo("Modulo (remainder) operator."),args:[$l("dividend (number)",uo("The number to be divided to find the remainder.")),$l("divisor (number)",uo("The number to divide by."))],returns:["NUMBER"],compute:function(e,t){const o=Zo(t,this.locale);return{value:uh(Zo(e,this.locale),o),format:e?.format}},isExported:!0},ph={description:uo("Returns a n x n unit matrix, where n is the input dimension."),args:[$l("dimension (number)",uo("An integer specifying the dimension size of the unit matrix. It must be positive."))],returns:["RANGE<NUMBER>"],compute:function(e){const t=Ko(e,this.locale);return Zl(uo("The argument dimension must be positive"),t),jl(t)},isExported:!0},mh={description:uo("Rounds a number up to the nearest odd integer."),args:[$l("value (number)",uo("The value to round to the next greatest odd number."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);let o=Math.ceil(Math.abs(t));return o=1&o?o:o+1,{value:t<0?-o:o,format:e?.format}},isExported:!0},fh={description:uo("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},bh={description:uo("A number raised to a power."),args:[$l("base (number)",uo("The number to raise to the exponent power.")),$l("exponent (number)",uo("The exponent to raise base to."))],returns:["NUMBER"],compute:function(e,t){const o=Zo(e,this.locale),s=Zo(t,this.locale);return $o((()=>o>=0||Number.isInteger(s)),uo("The exponent (%s) must be an integer when the base is negative.",s.toString())),{value:Math.pow(o,s),format:e?.format}},isExported:!0},vh={description:uo("Result of multiplying a series of numbers together."),args:[$l("factor1 (number, range<number>)",uo("The first number or range to calculate for the product.")),$l("factor2 (number, range<number>, repeating)",uo("More numbers or ranges to calculate for the product."))],returns:["NUMBER"],compute:function(...e){let t=0,o=1;for(let s of e)if(_o(s))for(let e of s)for(let s of e){const e=s.value;if("number"==typeof e&&(o*=e,t+=1),Wo(e))throw s}else void 0!==s&&null!==s.value&&(o*=Xo(s,this.locale),t+=1);return{value:0===t?0:o,format:Go(e[0])}},isExported:!0},Sh={description:uo("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},Ch={description:uo("Returns a grid of random numbers between 0 inclusive and 1 exclusive."),args:[$l("rows (number, default=1)",uo("The number of rows to be returned.")),$l("columns (number, default=1)",uo("The number of columns to be returned.")),$l("min (number, default=0)",uo("The minimum number you would like returned.")),$l("max (number, default=1)",uo("The maximum number you would like returned.")),$l("whole_number (number, default=FALSE)",uo("Return a whole number or a decimal value."))],returns:["RANGE<NUMBER>"],compute:function(e={value:1},t={value:1},o={value:0},s={value:1},i={value:!1}){const n=Ko(t,this.locale),r=Ko(e,this.locale),a=Zo(o,this.locale),l=Zo(s,this.locale),c=is(i);Zl(uo("The number columns (%s) must be positive.",n.toString()),n),Zl(uo("The number rows (%s) must be positive.",r.toString()),r),$o((()=>a<=l),uo("The maximum (%s) must be greater than or equal to the minimum (%s).",l.toString(),a.toString())),c&&$o((()=>Number.isInteger(a)&&Number.isInteger(l)),uo("The maximum (%s) and minimum (%s) must be integers when whole_number is TRUE.",l.toString(),a.toString()));const h=Array(n);for(let e=0;e<n;e++){h[e]=Array(r);for(let t=0;t<r;t++)h[e][t]=c?Math.floor(Math.random()*(l-a+1)+a):a+Math.random()*(l-a)}return h},isExported:!0},yh={description:uo("Random integer between two values, inclusive."),args:[$l("low (number)",uo("The low end of the random range.")),$l("high (number)",uo("The high end of the random range."))],returns:["NUMBER"],compute:function(e,t){let o=Zo(e,this.locale);Number.isInteger(o)||(o=Math.ceil(o));let s=Zo(t,this.locale);return Number.isInteger(s)||(s=Math.floor(s)),$o((()=>o<=s),uo("The high (%s) must be greater than or equal to the low (%s).",s.toString(),o.toString())),{value:o+Math.ceil((s-o+1)*Math.random())-1,format:e?.format}},isExported:!0},Eh={description:uo("Rounds a number according to standard rules."),args:[$l("value (number)",uo("The value to round to places number of places.")),$l("places (number, default=0)",uo("The number of decimal places to which to round."))],returns:["NUMBER"],compute:function(e,t={value:0}){const o=Zo(e,this.locale);let s=Zo(t,this.locale);const i=Math.abs(o);let n;return 0===s?n=Math.round(i):(Number.isInteger(s)||(s=Math.trunc(s)),n=Math.round(i*Math.pow(10,s))/Math.pow(10,s)),{value:o>=0?n:-n,format:e?.format}},isExported:!0},xh={description:uo("Rounds down a number."),args:[$l("value (number)",uo("The value to round to places number of places, always rounding down.")),$l("places (number, default=0)",uo("The number of decimal places to which to round."))],returns:["NUMBER"],compute:function(e,t={value:0}){const o=Zo(e,this.locale);let s=Zo(t,this.locale);const i=Math.abs(o);let n;return 0===s?n=Math.floor(i):(Number.isInteger(s)||(s=Math.trunc(s)),n=Math.floor(i*Math.pow(10,s))/Math.pow(10,s)),{value:o>=0?n:-n,format:e?.format}},isExported:!0},wh={description:uo("Rounds up a number."),args:[$l("value (number)",uo("The value to round to places number of places, always rounding up.")),$l("places (number, default=0)",uo("The number of decimal places to which to round."))],returns:["NUMBER"],compute:function(e,t={value:0}){const o=Zo(e,this.locale);let s=Zo(t,this.locale);const i=Math.abs(o);let n;return 0===s?n=Math.ceil(i):(Number.isInteger(s)||(s=Math.trunc(s)),n=Math.ceil(i*Math.pow(10,s))/Math.pow(10,s)),{value:o>=0?n:-n,format:e?.format}},isExported:!0},Ih={description:uo("Secant of an angle provided in radians."),args:[$l("angle (number)",uo("The angle to find the secant of, in radians."))],returns:["NUMBER"],compute:function(e){return 1/Math.cos(Zo(e,this.locale))},isExported:!0},Rh={description:uo("Hyperbolic secant of any real number."),args:[$l("value (number)",uo("Any real value to calculate the hyperbolic secant of."))],returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Zo(e,this.locale))},isExported:!0},Th={description:uo("Sine of an angle provided in radians."),args:[$l("angle (number)",uo("The angle to find the sine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.sin(Zo(e,this.locale))},isExported:!0},Ah={description:uo("Hyperbolic sine of any real number."),args:[$l("value (number)",uo("Any real value to calculate the hyperbolic sine of."))],returns:["NUMBER"],compute:function(e){return Math.sinh(Zo(e,this.locale))},isExported:!0},Oh={description:uo("Positive square root of a positive number."),args:[$l("value (number)",uo("The number for which to calculate the positive square root."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return $o((()=>t>=0),uo("The value (%s) must be positive or null.",t.toString())),{value:Math.sqrt(t),format:e?.format}},isExported:!0},_h={description:uo("Sum of a series of numbers and/or cells."),args:[$l("value1 (number, range<number>)",uo("The first number or range to add together.")),$l("value2 (number, range<number>, repeating)",uo("Additional numbers or ranges to add to value1."))],returns:["NUMBER"],compute:function(...e){const t=e[0];return{value:Tc(e,this.locale),format:Go(t)}},isExported:!0},Dh={description:uo("A conditional sum across a range."),args:[$l("criteria_range (range)",uo("The range which is tested against criterion.")),$l("criterion (string)",uo("The pattern or test to apply to range.")),$l("sum_range (range, default=criteria_range)",uo("The range to be summed, if different from range."))],returns:["NUMBER"],compute:function(e,t,o){void 0===o&&(o=e);let s=0;return ys([e,t],((e,t)=>{const i=o[e]?.[t]?.value;"number"==typeof i&&(s+=i)}),this.locale),s},isExported:!0},Mh={description:uo("Sums a range depending on multiple criteria."),args:[$l("sum_range (range)",uo("The range to sum.")),$l("criteria_range1 (range)",uo("The range to check against criterion1.")),$l("criterion1 (string)",uo("The pattern or test to apply to criteria_range1.")),$l("criteria_range2 (any, range, repeating)",uo("Additional ranges to check.")),$l("criterion2 (string, repeating)",uo("Additional criteria to check."))],returns:["NUMBER"],compute:function(e,...t){let o=0;return ys(t,((t,s)=>{const i=e[t]?.[s]?.value;"number"==typeof i&&(o+=i)}),this.locale),o},isExported:!0},Fh={description:uo("Tangent of an angle provided in radians."),args:[$l("angle (number)",uo("The angle to find the tangent of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.tan(Zo(e,this.locale))},isExported:!0},Nh={description:uo("Hyperbolic tangent of any real number."),args:[$l("value (number)",uo("Any real value to calculate the hyperbolic tangent of."))],returns:["NUMBER"],compute:function(e){return Math.tanh(Zo(e,this.locale))},isExported:!0};function Ph(e,t){return 0===t?Math.trunc(e):(Number.isInteger(t)||(t=Math.trunc(t)),Math.trunc(e*Math.pow(10,t))/Math.pow(10,t))}const Lh={description:uo("Truncates a number."),args:[$l("value (number)",uo("The value to be truncated.")),$l("places (number, default=0)",uo("The number of significant digits to the right of the decimal point to retain."))],returns:["NUMBER"],compute:function(e,t={value:0}){return{value:Ph(Zo(e,this.locale),Zo(t,this.locale)),format:e?.format}},isExported:!0},kh={description:uo("Rounds a number down to the nearest integer that is less than or equal to it."),args:[$l("value (number)",uo("The number to round down to the nearest integer."))],returns:["NUMBER"],compute:function(e){return Math.floor(Zo(e,this.locale))},isExported:!0};var Vh=Object.freeze({__proto__:null,ABS:_c,ACOS:Dc,ACOSH:Mc,ACOT:Fc,ACOTH:Nc,ASIN:Pc,ASINH:Lc,ATAN:kc,ATAN2:Vc,ATANH:Uc,CEILING:Bc,CEILING_MATH:zc,CEILING_PRECISE:$c,COS:Gc,COSH:Wc,COT:qc,COTH:Zc,COUNTBLANK:Yc,COUNTIF:jc,COUNTIFS:Xc,COUNTUNIQUE:Kc,COUNTUNIQUEIFS:Qc,CSC:Jc,CSCH:eh,DECIMAL:th,DEGREES:oh,EXP:sh,FLOOR:ih,FLOOR_MATH:rh,FLOOR_PRECISE:ah,INT:kh,ISEVEN:lh,ISODD:hh,ISO_CEILING:ch,LN:dh,MOD:gh,MUNIT:ph,ODD:mh,PI:fh,POWER:bh,PRODUCT:vh,RAND:Sh,RANDARRAY:Ch,RANDBETWEEN:yh,ROUND:Eh,ROUNDDOWN:xh,ROUNDUP:wh,SEC:Ih,SECH:Rh,SIN:Th,SINH:Ah,SQRT:Oh,SUM:_h,SUMIF:Dh,SUMIFS:Mh,TAN:Fh,TANH:Nh,TRUNC:Lh});function Uh(...e){const t=e[0].length;e.forEach(((e,o)=>$o((()=>e.length===t),uo("[[FUNCTION_NAME]] has mismatched dimensions for argument %s (%s vs %s).",o.toString(),t.toString(),e.length.toString()))))}function Bh(e,t){let o=0;const s=us(e,((e,t)=>(o+=1,e+t)),0,t);return es(o),s/o}function Hh(e,t){let o=0;for(let s of e)if(_o(s))for(let e of s)for(let t of e)"number"==typeof t.value&&(o+=1);else{const e=s?.value;Wo(e)||"string"==typeof e&&!io(e,t)&&!$t(e,t)||(o+=1)}return o}function zh(e){return ds(e,((e,t)=>void 0!==t&&null!==t.value?e+1:e),0)}function $h(e,t){const o=us(e,((e,t)=>e<t?t:e),-1/0,t);return o===-1/0?0:o}function Gh(e,t){const o=us(e,((e,t)=>t<e?t:e),1/0,t);return o===1/0?0:o}function Wh(e,t){const o=[],s=[];let i=0,n=0;ls([e],(e=>{o.push(e),i+=1})),ls([t],(e=>{s.push(e),n+=1})),$o((()=>i===n),uo("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",i,n));const r=[],a=[];for(let e=0;e<i;e++){const t=o[e]?.value,i=s[e]?.value;"number"==typeof t&&"number"==typeof i&&(a.push(t),r.push(i))}return{flatDataX:r,flatDataY:a}}function qh(e,t,o){const{flatDataX:s,flatDataY:i}=Wh(e,t),n=i.length;$o((()=>0!==n&&(!o||1!==n)),uo("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."),No.DivisionByZero);let r=0,a=0;for(let e=0;e<n;e++)r+=i[e],a+=s[e];const l=r/n,c=a/n;let h=0;for(let e=0;e<n;e++)h+=(i[e]-l)*(s[e]-c);return h/(n-(o?1:0))}function Zh(e,t,o,s){let i=0,n=0;const r=o?gs:us;n=r(e,((e,t)=>(i+=1,e+t)),0,s),$o((()=>0!==i&&(!t||1!==i)),uo("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."),No.DivisionByZero);const a=n/i;return r(e,((e,t)=>e+Math.pow(t-a,2)),0,s)/(i-(t?1:0))}function Yh(e,t,o,s){const i=Zo(t,s);$o((()=>o?0<=i&&i<=1:0<i&&i<1),uo("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let n,r=[],a=0;return ls(e,(e=>{const t=e?.value;"number"==typeof t&&(n=Es(r,e,"nextSmaller","asc",r.length,((e,t)=>e[t])),r.splice(n+1,0,t),a++)})),$o((()=>0!==a),uo("[[FUNCTION_NAME]] has no valid input data.")),o||$o((()=>1/(a+1)<=i&&i<=a/(a+1)),uo("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),ao(r,i,o)}function jh(e,t,o){const s=e[0].length?e:[ve(1,t.flat().length+1)],i=s.length;let n=o[0].length?o:s;return n=n.length===i?fs(n):n,{_X:s,_newX:n}}function Xh(e,t,o=!0,s=!1){const i=t.flat(),n=i.length;let{_X:r}=jh(e,t,[[]]);r=r.length===n?fs(r):r.slice(),Uh(r[0],i);const a=r.length,l=n-a-(o?1:0),c=[i],h=fs(r.reverse());let d=[];for(let e=0;e<a;e++)if(d.push(0),o){for(const t of r[e])d[e]+=t;d[e]/=n}let u=0;if(o){for(const e of i)u+=e;u/=n}const g=h.map((e=>e.map(((e,t)=>e-d[t]))));o&&h.forEach((e=>e.push(1)));const p=Qh(h,c);if(o||p.push([0]),!s)return p;const m=Ql(g,fs(g)),{inverted:f}=Xl(m);if(void 0===f)throw new Lo(uo("Matrix is not invertible"));let b=0,v=0;for(let e=0;e<n;e++){const t=i[e]-u;let o=0;for(let t=0;t<a;t++){o+=g[e][t]*p[t][0]}const s=t-o;b+=s*s,v+=o*o}const S=Math.sqrt(b/l),C=v/(v+b),y=v/a/(b/l),E=[];for(let e=0;e<a;e++)E.push(S*Math.sqrt(f[e][e]));if(o){const e=Ql(f,[d]),t=Ql(fs([d]),e);E.push(S*Math.sqrt(t[0][0]+1/i.length))}const x=[[p[0][0],E[0],C,y,v],[p[1][0],E[1],S,l,b]];for(let e=2;e<a;e++)x.push([p[e][0],E[e],"","",""]);return o?x.push([p[a][0],E[a],"","",""]):x.push([0,"","","",""]),x}function Kh(e,t,o,s){Uh(t,e),$o((()=>o>=1),uo("Function [[FUNCTION_NAME]] A regression of order less than 1 cannot be possible."));const i=[e],n=t.map((e=>ve(0,o).map((t=>Math.pow(e,o-t)))));s&&n.forEach((e=>e.push(1)));const r=Qh(n,i);return s||r.push([0]),r}function Qh(e,t){const o=Ql(e,fs(e)),{inverted:s}=Xl(o);if(void 0===s)throw new Lo(uo("Matrix is not invertible"));const i=Ql(e,t);return fs(Ql(s,i))}function Jh(e){return e.map((e=>e.map((e=>Math.log(e)))))}function ed(e,t,o,s){const{_X:i,_newX:n}=jh(t,e,o),r=Xh(i,e,s,!1),a=r.length-1,l=n.map((e=>{let t=0;for(let o=0;o<a;o++)t+=r[o][0]*e[a-o-1];return t+=r[a][0],[t]}));return l.length===o.length?l:fs(l)}const td={description:uo("Average magnitude of deviations from mean."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the sample.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){let t=0;const o=us(e,((e,o)=>(t+=1,e+o)),0,this.locale);es(t);const s=o/t;return us(e,((e,t)=>e+Math.abs(s-t)),0,this.locale)/t},isExported:!0},od={description:uo("Numerical average value in a dataset, ignoring text."),args:[$l("value1 (number, range<number>)",uo("The first value or range to consider when calculating the average value.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],compute:function(...e){return{value:Bh(e,this.locale),format:Go(e[0])}},isExported:!0},sd=uo("[[FUNCTION_NAME]] has mismatched range sizes."),id=uo("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),nd={description:uo("Weighted average."),args:[$l("values (number, range<number>)",uo("Values to average.")),$l("weights (number, range<number>)",uo("Weights for each corresponding value.")),$l("additional_values (number, range<number>, repeating)",uo("Additional values to average.")),$l("additional_weights (number, range<number>, repeating)",uo("Additional weights."))],returns:["NUMBER"],compute:function(...e){let t=0,o=0;for(let s=0;s<e.length-1;s+=2){const i=e[s],n=e[s+1];if(ql(sd,i,n),_o(i))for(let e=0;e<i.length;e++)for(let s=0;s<i[0].length;s++){const r=i[e][s].value,a=_o(n)?n?.[e][s].value:Zo(n,this.locale),l="number"==typeof r,c="number"==typeof a;l&&c?($o((()=>a>=0),id),t+=r*a,o+=a):$o((()=>l===c),uo("[[FUNCTION_NAME]] expects number values."))}else{const e=Zo(i,this.locale),s=_o(n)?n?.[0][0].value:Zo(n,this.locale);"number"==typeof s&&($o((()=>s>=0),id),t+=e*s,o+=s)}}return es(o),{value:t/o,format:Go(e[0])}}},rd={description:uo("Numerical average value in a dataset."),args:[$l("value1 (number, range<number>)",uo("The first value or range to consider when calculating the average value.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],compute:function(...e){let t=0;const o=gs(e,((e,o)=>(t+=1,e+o)),0,this.locale);return es(t),{value:o/t,format:Go(e[0])}},isExported:!0},ad={description:uo("Average of values depending on criteria."),args:[$l("criteria_range (number, range<number>)",uo("The range to check against criterion.")),$l("criterion (string)",uo("The pattern or test to apply to criteria_range.")),$l("average_range (number, range<number>, default=criteria_range)",uo("The range to average. If not included, criteria_range is used for the average instead."))],returns:["NUMBER"],compute:function(e,t,o){const s=Rs(void 0===o?e:o);let i=0,n=0;return ys([e,t],((e,t)=>{const o=s[e]?.[t]?.value;"number"==typeof o&&(i+=1,n+=o)}),this.locale),es(i),n/i},isExported:!0},ld={description:uo("Average of values depending on multiple criteria."),args:[$l("average_range (range)",uo("The range to average.")),$l("criteria_range1 (range)",uo("The range to check against criterion1.")),$l("criterion1 (string)",uo("The pattern or test to apply to criteria_range1.")),$l("criteria_range2 (any, range, repeating)",uo("Additional criteria_range and criterion to check.")),$l("criterion2 (string, repeating)",uo("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){const o=Rs(e);let s=0,i=0;return ys(t,((e,t)=>{const n=o[e]?.[t]?.value;"number"==typeof n&&(s+=1,i+=n)}),this.locale),es(s),i/s},isExported:!0},cd={description:uo("The number of numeric values in dataset."),args:[$l("value1 (number, range<number>)",uo("The first value or range to consider when counting.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){return Hh(e,this.locale)},isExported:!0},hd={description:uo("The number of values in a dataset."),args:[$l("value1 (any, range)",uo("The first value or range to consider when counting.")),$l("value2 (any, range, repeating)",uo("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){return zh(e)},isExported:!0},dd={description:uo("The covariance of a dataset."),args:[$l("data_y (any, range)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (any, range)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return qh(e,t,!1)},isExported:!0},ud={description:uo("The covariance of a dataset."),args:[$l("data_y (any, range)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (any, range)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return qh(e,t,!1)},isExported:!0},gd={description:uo("The sample covariance of a dataset."),args:[$l("data_y (any, range)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (any, range)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return qh(e,t,!0)},isExported:!0},pd={description:uo("Calculates the expected y-value for a specified x based on a linear regression of a dataset."),args:[$l("x (number, range<number>)",uo("The value(s) on the x-axis to forecast.")),$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t,o){const{flatDataX:s,flatDataY:i}=Wh(t,o);return ed([i],[s],ms(Rs(e),(e=>Zo(e,this.locale))),!0)},isExported:!0},md={description:uo("Fits points to exponential growth trend."),args:[$l("known_data_y (range<number>)",uo("The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.")),$l("known_data_x (range<number>, default={1;2;3;...})",uo("The values of the independent variable(s) corresponding with known_data_y.")),$l("new_data_x (any, range, default=known_data_x)",uo("The data points to return the y values for on the ideal curve fit.")),$l("b (boolean, default=TRUE)",uo("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."))],returns:["NUMBER"],compute:function(e,t=[[]],o=[[]],s={value:!0}){return ed(Jh(jo(e,"the first argument (known_data_y)")),jo(t,"the second argument (known_data_x)"),jo(o,"the third argument (new_data_y)"),is(s)).map((e=>e.map((e=>Math.exp(e)))))}},fd={description:uo("Compute the intercept of the linear regression."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Wh(e,t),[[],[i]]=Xh([o],[s]);return i},isExported:!0},bd={description:uo("Nth largest element from a data set."),args:[$l("data (any, range)",uo("Array or range containing the dataset to consider.")),$l("n (number)",uo("The rank from largest to smallest of the element to return."))],returns:["NUMBER"],compute:function(e,t){const o=Math.trunc(Zo(t?.value,this.locale));let s,i=[],n=0;ls([e],(e=>{"number"==typeof e?.value&&(s=Es(i,e,"nextSmaller","asc",i.length,((e,t)=>e[t].value)),i.splice(s+1,0,e),n++,n>o&&(i.shift(),n--))}));const r=i.shift();return $o((()=>void 0!==r),uo("[[FUNCTION_NAME]] has no valid input data.")),$o((()=>n>=o),uo("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o)),r},isExported:!0},vd={description:uo("Compute the intercept of the linear regression."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>, default={1;2;3;...})",uo("The range representing the array or matrix of independent data.")),$l("calculate_b (boolean, default=TRUE)",uo("A flag specifying wheter to compute the slope or not")),$l("verbose (boolean, default=FALSE)",uo("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept"))],returns:["NUMBER"],compute:function(e,t=[[]],o={value:!0},s={value:!1}){return Xh(jo(t,"the first argument (data_y)"),jo(e,"the second argument (data_x)"),is(o),is(s))},isExported:!0},Sd={description:uo("Compute the intercept of the linear regression."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>, optional, default={1;2;3;...})",uo("The range representing the array or matrix of independent data.")),$l("calculate_b (boolean, default=TRUE)",uo("A flag specifying wheter to compute the slope or not")),$l("verbose (boolean, default=FALSE)",uo("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept"))],returns:["NUMBER"],compute:function(e,t=[[]],o={value:!0},s={value:!1}){const i=Xh(jo(t,"the second argument (data_x)"),Jh(jo(e,"the first argument (data_y)")),is(o),is(s));for(let e=0;e<i.length;e++)i[e][0]=Math.exp(i[e][0]);return i},isExported:!0},Cd={description:uo("Compute the Matthews correlation coefficient of a dataset."),args:[$l("data_x (range)",uo("The range representing the array or matrix of observed data.")),$l("data_y (range)",uo("The range representing the array or matrix of predicted data."))],returns:["NUMBER"],compute:function(e,t){const o=e.flat(),s=t.flat();if(Uh(o,s),0===o.length)throw new Lo(uo("[[FUNCTION_NAME]] expects non-empty ranges for both parameters."));const i=o.length;let n=0,r=0,a=0,l=0;for(let e=0;e<i;++e){const t=is(o[e]);t===is(s[e])?t?r++:n++:t?l++:a++}return(r*n-a*l)/Math.sqrt((r+a)*(r+l)*(n+a)*(n+l))},isExported:!1},yd={description:uo("Maximum value in a numeric dataset."),args:[$l("value1 (number, range<number>)",uo("The first value or range to consider when calculating the maximum value.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],compute:function(...e){return{value:$h(e,this.locale),format:Go(e[0])}},isExported:!0},Ed={description:uo("Maximum numeric value in a dataset."),args:[$l("value1 (any, range)",uo("The first value or range to consider when calculating the maximum value.")),$l("value2 (any, range, repeating)",uo("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],compute:function(...e){const t=gs(e,((e,t)=>Math.max(t,e)),-1/0,this.locale);return{value:t===-1/0?0:t,format:Go(e[0])}},isExported:!0},xd={description:uo("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:[$l("range (range)",uo("The range of cells from which the maximum will be determined.")),$l("criteria_range1 (range)",uo("The range of cells over which to evaluate criterion1.")),$l("criterion1 (string)",uo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),$l("criteria_range2 (any, range, repeating)",uo("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),$l("criterion2 (string, repeating)",uo("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=-1/0;return ys(t,((t,s)=>{const i=e[t]?.[s]?.value;"number"==typeof i&&(o=o<i?i:o)}),this.locale),o===-1/0?0:o},isExported:!0},wd={description:uo("Median value in a numeric dataset."),args:[$l("value1 (any, range)",uo("The first value or range to consider when calculating the median value.")),$l("value2 (any, range, repeating)",uo("Additional values or ranges to consider when calculating the median value."))],returns:["NUMBER"],compute:function(...e){let t=[];return cs(e,(e=>{t.push({value:e})}),this.locale),{value:Yh(t,{value:.5},!0,this.locale),format:Go(e[0])}},isExported:!0},Id={description:uo("Minimum value in a numeric dataset."),args:[$l("value1 (number, range<number>)",uo("The first value or range to consider when calculating the minimum value.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],compute:function(...e){return{value:Gh(e,this.locale),format:Go(e[0])}},isExported:!0},Rd={description:uo("Minimum numeric value in a dataset."),args:[$l("value1 (number, range<number>)",uo("The first value or range to consider when calculating the minimum value.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],compute:function(...e){const t=gs(e,((e,t)=>Math.min(t,e)),1/0,this.locale);return{value:t===1/0?0:t,format:Go(e[0])}},isExported:!0},Td={description:uo("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:[$l("range (range)",uo("The range of cells from which the minimum will be determined.")),$l("criteria_range1 (range)",uo("The range of cells over which to evaluate criterion1.")),$l("criterion1 (string)",uo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),$l("criteria_range2 (any, range, repeating)",uo("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),$l("criterion2 (string, repeating)",uo("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=1/0;return ys(t,((t,s)=>{const i=e[t]?.[s]?.value;"number"==typeof i&&(o=o>i?i:o)}),this.locale),o===1/0?0:o},isExported:!0};function Ad(e,t){const{flatDataX:o,flatDataY:s}=Wh(e,t);if(0===o.length)throw new Lo(uo("[[FUNCTION_NAME]] expects non-empty ranges for both parameters."));if(o.length<2)throw new Lo(uo("[[FUNCTION_NAME]] needs at least two values for both parameters."));const i=o.length;let n=0,r=0,a=0,l=0,c=0;for(let e=0;e<i;e++){const t=o[e],i=s[e];n+=t,r+=i,a+=t*i,l+=t*t,c+=i*i}return(i*a-n*r)/Math.sqrt((i*l-n*n)*(i*c-r*r))}const Od={description:uo("Compute the Pearson product-moment correlation coefficient of a dataset."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return Ad(e,t)},isExported:!0},_d=Od,Dd={description:uo("Value at a given percentile of a dataset."),args:[$l("data (any, range)",uo("The array or range containing the dataset to consider.")),$l("percentile (number)",uo("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],compute:function(e,t){return Fd.compute.bind(this)(e,t)},isExported:!0},Md={description:uo("Value at a given percentile of a dataset exclusive of 0 and 1."),args:[$l("data (any, range)",uo("The array or range containing the dataset to consider.")),$l("percentile (number)",uo("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned."))],returns:["NUMBER"],compute:function(e,t){return{value:Yh([e],t,!1,this.locale),format:Go(e)}},isExported:!0},Fd={description:uo("Value at a given percentile of a dataset."),args:[$l("data (any, range)",uo("The array or range containing the dataset to consider.")),$l("percentile (number)",uo("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],compute:function(e,t){return{value:Yh([e],t,!0,this.locale),format:Go(e)}},isExported:!0},Nd={description:uo("Compute the coefficients of polynomial regression of the dataset."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data.")),$l("order (number)",uo("The order of the polynomial to fit the data, between 1 and 6.")),$l("intercept (boolean, default=TRUE)",uo("A flag specifying whether to compute the intercept or not."))],returns:["RANGE<NUMBER>"],compute:function(e,t,o,s={value:!0}){const{flatDataX:i,flatDataY:n}=Wh(e,t);return Kh(n,i,Zo(o,this.locale),is(s))},isExported:!1},Pd={description:uo("Predict value by computing a polynomial regression of the dataset."),args:[$l("x (number, range<number>)",uo("The value(s) on the x-axis to forecast.")),$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data.")),$l("order (number)",uo("The order of the polynomial to fit the data, between 1 and 6.")),$l("intercept (boolean, default=TRUE)",uo("A flag specifying whether to compute the intercept or not."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:!0}){const n=Zo(s,this.locale),{flatDataX:r,flatDataY:a}=Wh(t,o),l=Kh(a,r,n,is(i)).flat();return ms(Rs(e),(e=>function(e,t,o){return e.reduce(((e,s,i)=>e+s*Math.pow(t,o-i)),0)}(l,Zo(e,this.locale),n)))},isExported:!1},Ld={description:uo("Value nearest to a specific quartile of a dataset."),args:[$l("data (any, range)",uo("The array or range containing the dataset to consider.")),$l("quartile_number (number)",uo("Which quartile value to return."))],returns:["NUMBER"],compute:function(e,t){return Vd.compute.bind(this)(e,t)},isExported:!0},kd={description:uo("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:[$l("data (any, range)",uo("The array or range containing the dataset to consider.")),$l("quartile_number (number)",uo("Which quartile value, exclusive of 0 and 4, to return."))],returns:["NUMBER"],compute:function(e,t){return{value:Yh([e],{value:.25*Math.trunc(Zo(t,this.locale))},!1,this.locale),format:Go(e)}},isExported:!0},Vd={description:uo("Value nearest to a specific quartile of a dataset."),args:[$l("data (any, range)",uo("The array or range containing the dataset to consider.")),$l("quartile_number (number)",uo("Which quartile value to return."))],returns:["NUMBER"],compute:function(e,t){return{value:Yh([e],{value:.25*Math.trunc(Zo(t,this.locale))},!0,this.locale),format:Go(e)}},isExported:!0},Ud={description:uo("Returns the rank of a specified value in a dataset."),args:[$l("value (number)",uo("The value whose rank will be determined.")),$l("data (range)",uo("The range containing the dataset to consider.")),$l("is_ascending (boolean, default=FALSE)",uo("Whether to consider the values in data in descending or ascending order."))],returns:["ANY"],compute:function(e,t,o={value:!1}){const s=is(o),i=Zo(e,this.locale);let n=1,r=!1;for(const e of t)for(const t of e){if("number"!=typeof t.value)continue;const e=Zo(t,this.locale);e===i?r=!0:e>i!==s&&n++}if(!r)throw new Uo(uo("Value not found in the given data."));return n},isExported:!0},Bd={description:uo("Compute the square of r, the Pearson product-moment correlation coefficient of a dataset."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return Math.pow(Ad(t,e),2)},isExported:!0},Hd={description:uo("Compute the slope of the linear regression."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Wh(e,t),[[i]]=Xh([o],[s]);return i},isExported:!0},zd={description:uo("Nth smallest element in a data set."),args:[$l("data (any, range)",uo("The array or range containing the dataset to consider.")),$l("n (number)",uo("The rank from smallest to largest of the element to return."))],returns:["NUMBER"],compute:function(e,t){const o=Math.trunc(Zo(t?.value,this.locale));let s,i=[],n=0;ls([e],(e=>{"number"==typeof e?.value&&(s=Es(i,e,"nextSmaller","asc",i.length,((e,t)=>e[t].value)),i.splice(s+1,0,e),n++,n>o&&(i.pop(),n--))}));const r=i.pop();return $o((()=>void 0!==r),uo("[[FUNCTION_NAME]] has no valid input data.")),$o((()=>n>=o),uo("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o)),r},isExported:!0},$d={description:uo("Compute the Spearman rank correlation coefficient of a dataset."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Wh(t,e),i=o.length,n=o.map(((e,t)=>[e,s[t]]));n.sort(((e,t)=>e[0]-t[0]));for(let e=0;e<i;++e)n[e][0]=e;n.sort(((e,t)=>e[1]-t[1]));let r=0;for(let e=0;e<i;++e)r+=(n[e][0]-e)**2;return 1-6*r/(i**3-i)},isExported:!1},Gd={description:uo("Standard deviation."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the sample.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Qd.compute.bind(this)(...e))},isExported:!0},Wd={description:uo("Standard deviation of entire population."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the population.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Jd.compute.bind(this)(...e))},isExported:!0},qd={description:uo("Standard deviation."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the sample.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(eu.compute.bind(this)(...e))},isExported:!0},Zd={description:uo("Standard deviation of sample (text as 0)."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the sample.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(tu.compute.bind(this)(...e))},isExported:!0},Yd={description:uo("Standard deviation of entire population."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the population.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(ou.compute.bind(this)(...e))},isExported:!0},jd={description:uo("Standard deviation of entire population (text as 0)."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the population.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(su.compute.bind(this)(...e))},isExported:!0},Xd={description:uo("Calculates the standard error of the predicted y-value for each x in the regression of a dataset."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Wh(e,t);return Xh([o],[s],!0,!0)[1][2]},isExported:!0},Kd={description:uo("Fits points to linear trend derived via least-squares."),args:[$l("known_data_y (number, range<number>)",uo("The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.")),$l("known_data_x (number, range<number>, optional, default={1;2;3;...})",uo("The values of the independent variable(s) corresponding with known_data_y.")),$l("new_data_x (number, range<number>, optional, default=known_data_x)",uo("The data points to return the y values for on the ideal curve fit.")),$l("b (boolean, optional, default=TRUE)",uo("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."))],returns:["NUMBER"],compute:function(e,t=[[]],o=[[]],s={value:!0}){return ed(jo(e,"the first argument (known_data_y)"),jo(t,"the second argument (known_data_x)"),jo(o,"the third argument (new_data_y)"),is(s))}},Qd={description:uo("Variance."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the sample.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Zh(e,!0,!1,this.locale)},isExported:!0},Jd={description:uo("Variance of entire population."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the population.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Zh(e,!1,!1,this.locale)},isExported:!0},eu={description:uo("Variance."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the sample.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Zh(e,!0,!1,this.locale)},isExported:!0},tu={description:uo("Variance of sample (text as 0)."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the sample.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Zh(e,!0,!0,this.locale)},isExported:!0},ou={description:uo("Variance of entire population."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the population.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Zh(e,!1,!1,this.locale)},isExported:!0},su={description:uo("Variance of entire population (text as 0)."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the population.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Zh(e,!1,!0,this.locale)},isExported:!0};var iu=Object.freeze({__proto__:null,AVEDEV:td,AVERAGE:od,AVERAGEA:rd,AVERAGEIF:ad,AVERAGEIFS:ld,AVERAGE_WEIGHTED:nd,CORREL:_d,COUNT:cd,COUNTA:hd,COVAR:dd,COVARIANCE_P:ud,COVARIANCE_S:gd,FORECAST:pd,GROWTH:md,INTERCEPT:fd,LARGE:bd,LINEST:vd,LOGEST:Sd,MATTHEWS:Cd,MAX:yd,MAXA:Ed,MAXIFS:xd,MEDIAN:wd,MIN:Id,MINA:Rd,MINIFS:Td,PEARSON:Od,PERCENTILE:Dd,PERCENTILE_EXC:Md,PERCENTILE_INC:Fd,POLYFIT_COEFFS:Nd,POLYFIT_FORECAST:Pd,QUARTILE:Ld,QUARTILE_EXC:kd,QUARTILE_INC:Vd,RANK:Ud,RSQ:Bd,SLOPE:Hd,SMALL:zd,SPEARMAN:$d,STDEV:Gd,STDEVA:Zd,STDEVP:Yd,STDEVPA:jd,STDEV_P:Wd,STDEV_S:qd,STEYX:Xd,TREND:Kd,VAR:Qd,VARA:tu,VARP:ou,VARPA:su,VAR_P:Jd,VAR_S:eu});function nu(e,t,o,s){const i=new Map,n=e.length;for(let t=n-1;t>=0;t--)i.set(ts(e[t][0]).toUpperCase(),t);const r=t?.value;if("number"!=typeof r&&"string"!=typeof r)throw new Lo(uo("The field must be a number or a string"));let a;if("number"==typeof r){if(a=Math.trunc(r)-1,a<0||n-1<a)throw new Lo(uo("The field (%(fieldValue)s) must be one of %(dimRowDB)s or must be a number between 1 and %s inclusive.",{fieldValue:r.toString(),dimRowDB:n.toString()}))}else{const e=ts(t).toUpperCase();if(a=i.get(e)??-1,-1===a)throw new Lo(uo("The field (%s) must be one of %s.",ts(t),[...i.keys()].toString()))}const l=o[0].length;if(l<2)throw new Lo(uo("The criteria range contains %s row, it must be at least 2 rows.",l.toString()));let c=new Set;const h=e[0].length;for(let t=1;t<l;t++){let n=[],r=!0;for(let s=0;s<o.length;s++){const a=ts(o[s][0]).toUpperCase(),l=i.get(a),c=o[s][t];if(null!==c.value){if(void 0===l){r=!1;break}n.push([e[l].slice(1,h)]),n.push(c)}}if(r){if(!(n.length>0)){c=new Set(Array(h-1).keys());break}ys(n,((e,t)=>{c.add(t)}),s,!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const ru=[$l("database (range)",uo("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.")),$l("field (any)",uo("Indicates which column in database contains the values to be extracted and operated on.")),$l("criteria (range)",uo("An array or range containing zero or more criteria to filter the database values by before operating."))],au={description:uo("Average of a set of values from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return od.compute.bind(this)([s])},isExported:!0},lu={description:uo("Counts values from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return cd.compute.bind(this)([s])},isExported:!0},cu={description:uo("Counts values and text from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return hd.compute.bind(this)([s])},isExported:!0},hu={description:uo("Single value from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return $o((()=>1===s.length),uo("More than one match found in DGET evaluation.")),s[0]},isExported:!0},du={description:uo("Maximum of values from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return yd.compute.bind(this)([s])},isExported:!0},uu={description:uo("Minimum of values from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return Id.compute.bind(this)([s])},isExported:!0},gu={description:uo("Product of values from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return vh.compute.bind(this)([s])},isExported:!0},pu={description:uo("Standard deviation of population sample from table."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return Gd.compute.bind(this)([s])},isExported:!0},mu={description:uo("Standard deviation of entire population from table."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return Yd.compute.bind(this)([s])},isExported:!0},fu={description:uo("Sum of values from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return _h.compute.bind(this)([s])},isExported:!0},bu={description:uo("Variance of population sample from table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return Qd.compute.bind(this)([s])},isExported:!0},vu={description:uo("Variance of a population from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return ou.compute.bind(this)([s])},isExported:!0};var Su=Object.freeze({__proto__:null,DAVERAGE:au,DCOUNT:lu,DCOUNTA:cu,DGET:hu,DMAX:du,DMIN:uu,DPRODUCT:gu,DSTDEV:pu,DSTDEVP:mu,DSUM:fu,DVAR:bu,DVARP:vu});var Cu;!function(e){e.WHOLE_YEARS="Y",e.WHOLE_MONTHS="M",e.WHOLE_DAYS="D",e.DAYS_WITHOUT_WHOLE_MONTHS="MD",e.MONTH_WITHOUT_WHOLE_YEARS="YM",e.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR="YD"}(Cu||(Cu={}));const yu={description:uo("Converts year/month/day into a date."),args:[$l("year (number)",uo("The year component of the date.")),$l("month (number)",uo("The month component of the date.")),$l("day (number)",uo("The day component of the date."))],returns:["DATE"],compute:function(e,t,o){let s=Math.trunc(Zo(e,this.locale));const i=Math.trunc(Zo(t,this.locale)),n=Math.trunc(Zo(o,this.locale));$o((()=>0<=s&&s<=9999),uo("The year (%s) must be between 0 and 9999 inclusive.",s.toString())),s<1900&&(s+=1900);const r=Wt(new At(s,i-1,n));return $o((()=>r>=0),uo("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),{value:r,format:this.locale.dateFormat}},isExported:!0},Eu={description:uo("Calculates the number of days, months, or years between two dates."),args:[$l("start_date (date)",uo("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.")),$l("end_date (date)",uo("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.")),$l("unit (string)",uo('A text abbreviation for unit of time. Accepted values are "Y" (the number of whole years between start_date and end_date), "M" (the number of whole months between start_date and end_date), "D" (the number of days between start_date and end_date), "MD" (the number of days between start_date and end_date after subtracting whole months), "YM" (the number of whole months between start_date and end_date after subtracting whole years), "YD" (the number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart).'))],returns:["NUMBER"],compute:function(e,t,o){const s=ts(o).toUpperCase();$o((()=>Object.values(Cu).includes(s)),((e,t)=>{const o=e.map((e=>`'${e}'`)).join(", ");return uo("The function [[FUNCTION_NAME]] has an argument with value '%s'. It should be one of: %s.",t,o)})(Object.values(Cu),ts(o)));const i=Math.trunc(Zo(e,this.locale)),n=Math.trunc(Zo(t,this.locale)),r=Gt(i),a=Gt(n);switch($o((()=>n>=i),uo("start_date (%s) should be on or before end_date (%s).",r.toLocaleDateString(),a.toLocaleDateString())),s){case Cu.WHOLE_YEARS:return eo(r,a);case Cu.WHOLE_MONTHS:return Qt(r,a);case Cu.WHOLE_DAYS:return Jt(r,a);case Cu.MONTH_WITHOUT_WHOLE_YEARS:return Qt(r,a)-12*eo(r,a);case Cu.DAYS_WITHOUT_WHOLE_MONTHS:let e=a.getDate()-r.getDate();if(e<0){e=Zt(new At(a.getFullYear(),a.getMonth()-1,1))-Math.abs(e)}return e;case Cu.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR:{if(function(e,t){return Kt(e,t,1)<1}(i,n))return Jt(r,a);const e=new At(r.getFullYear(),a.getMonth(),a.getDate());let t=Jt(r,e);return t<0&&(e.setFullYear(r.getFullYear()+1),t=Jt(r,e)),t}}},isExported:!0},xu={description:uo("Converts a date string to a date value."),args:[$l("date_string (string)",uo("The string representing the date."))],returns:["NUMBER"],compute:function(e){const t=ts(e),o=$t(t,this.locale);return $o((()=>null!==o),uo("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(o.value)},isExported:!0},wu={description:uo("Day of the month that a specific date falls on."),args:[$l("date (string)",uo("The date from which to extract the day."))],returns:["NUMBER"],compute:function(e){return ns(e,this.locale).getDate()},isExported:!0},Iu={description:uo("Number of days between two dates."),args:[$l("end_date (date)",uo("The end of the date range.")),$l("start_date (date)",uo("The start of the date range."))],returns:["NUMBER"],compute:function(e,t){const o=ns(e,this.locale),s=ns(t,this.locale),i=o.getTime()-s.getTime();return Math.round(i/_t)},isExported:!0},Ru={description:uo("Number of days between two dates on a 360-day year (months of 30 days)."),args:[$l("start_date (date)",uo("The start date to consider in the calculation.")),$l("end_date (date)",uo("The end date to consider in the calculation.")),$l("method (number, default=0)",uo("An indicator of what day count method to use. (0) US NASD method (1) European method"))],returns:["NUMBER"],compute:function(e,t,o={value:0}){const s=Math.trunc(Zo(e,this.locale)),i=Math.trunc(Zo(t,this.locale)),n=Kt(s,i,is(o)?4:0);return Math.sign(i-s)*Math.round(360*n)},isExported:!0},Tu={description:uo("Date a number of months before/after another date."),args:[$l("start_date (date)",uo("The date from which to calculate the result.")),$l("months (number)",uo("The number of months before (negative) or after (positive) 'start_date' to calculate."))],returns:["DATE"],compute:function(e,t){return{value:Wt(jt(ns(e,this.locale),Math.trunc(Zo(t,this.locale)),!1)),format:this.locale.dateFormat}},isExported:!0},Au={description:uo("Last day of a month before or after a date."),args:[$l("start_date (date)",uo("The date from which to calculate the result.")),$l("months (number)",uo("The number of months before (negative) or after (positive) 'start_date' to consider."))],returns:["DATE"],compute:function(e,t){const o=ns(e,this.locale),s=Math.trunc(Zo(t,this.locale)),i=o.getFullYear(),n=o.getMonth();return{value:Wt(new At(i,n+s+1,0)),format:this.locale.dateFormat}},isExported:!0},Ou={description:uo("Hour component of a specific time."),args:[$l("time (date)",uo("The time from which to calculate the hour component."))],returns:["NUMBER"],compute:function(e){return ns(e,this.locale).getHours()},isExported:!0},_u={description:uo("ISO week number of the year."),args:[$l("date (date)",uo("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."))],returns:["NUMBER"],compute:function(e){const t=ns(e,this.locale),o=t.getFullYear();let s=1;for(;4!==new At(o,0,s).getDay();)s+=1;const i=new At(o,0,s-3);let n=31;for(;4!==new At(o,11,n).getDay();)n-=1;const r=new At(o,11,n+3);let a,l;switch(a=i.getTime()<=t.getTime()?t.getTime()<=r.getTime()?0:1:-1,a){case 0:l=i;break;case 1:l=new At(o,11,n+3+1);break;case-1:let e=1;for(;4!==new At(o-1,0,e).getDay();)e+=1;l=new At(o-1,0,e-3)}const c=(t.getTime()-l.getTime())/_t;return Math.floor(c/7)+1},isExported:!0},Du={description:uo("Minute component of a specific time."),args:[$l("time (date)",uo("The time from which to calculate the minute component."))],returns:["NUMBER"],compute:function(e){return ns(e,this.locale).getMinutes()},isExported:!0},Mu={description:uo("Month of the year a specific date falls in"),args:[$l("date (date)",uo("The date from which to extract the month."))],returns:["NUMBER"],compute:function(e){return ns(e,this.locale).getMonth()+1},isExported:!0},Fu={description:uo("Net working days between two provided days."),args:[$l("start_date (date)",uo("The start date of the period from which to calculate the number of net working days.")),$l("end_date (date)",uo("The end date of the period from which to calculate the number of net working days.")),$l("holidays (date, range<date>, optional)",uo("A range or array constant containing the date serial numbers to consider holidays."))],returns:["NUMBER"],compute:function(e,t,o){return Pu.compute.bind(this)(e,t,{value:1},o)},isExported:!0};function Nu(e){const t=e?.value;if("string"==typeof t){$o((()=>{if(7!==t.length)return!1;for(let e of t)if("0"!==e&&"1"!==e)return!1;return!0}),uo('When weekend is a string (%s) it must be composed of "0" or "1".',t));let e=[];for(let o=0;o<7;o++)"1"===t[o]&&e.push((o+1)%7);return e}if("number"==typeof t)return $o((()=>1<=t&&t<=7||11<=t&&t<=17),uo("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 Lo(uo("The weekend must be a number or a string."))}const Pu={description:uo("Net working days between two dates (specifying weekends)."),args:[$l("start_date (date)",uo("The start date of the period from which to calculate the number of net working days.")),$l("end_date (date)",uo("The end date of the period from which to calculate the number of net working days.")),$l("weekend (any, default=1)",uo("A number or string representing which days of the week are considered weekends.")),$l("holidays (date, range<date>, optional)",uo("A range or array constant containing the dates to consider as holidays."))],returns:["NUMBER"],compute:function(e,t,o={value:1},s){const i=ns(e,this.locale),n=ns(t,this.locale),r=Nu(o);let a=new Set;void 0!==s&&ls([s],(e=>{const t=ns(e,this.locale);a.add(t.getTime())}));const l=i.getTime()>n.getTime(),c=At.fromTimestamp((l?i:n).getTime());let h=At.fromTimestamp((l?n:i).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)r.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},Lu={description:uo("Current date and time as a date value."),args:[],returns:["DATE"],compute:function(){const e=At.now(),t=e.getTime()-Ot.getTime(),o=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return{value:Math.floor(t/_t)+o,format:Er(this.locale)}},isExported:!0},ku={description:uo("Minute component of a specific time."),args:[$l("time (date)",uo("The time from which to calculate the second component."))],returns:["NUMBER"],compute:function(e){return ns(e,this.locale).getSeconds()},isExported:!0},Vu={description:uo("Converts hour/minute/second into a time."),args:[$l("hour (number)",uo("The hour component of the time.")),$l("minute (number)",uo("The minute component of the time.")),$l("second (number)",uo("The second component of the time."))],returns:["DATE"],compute:function(e,t,o){let s=Math.trunc(Zo(e,this.locale)),i=Math.trunc(Zo(t,this.locale)),n=Math.trunc(Zo(o,this.locale));return i+=Math.floor(n/60),n=n%60+(n<0?60:0),s+=Math.floor(i/60),i=i%60+(i<0?60:0),s%=24,$o((()=>s>=0),uo("The function [[FUNCTION_NAME]] result cannot be negative")),{value:s/24+i/1440+n/86400,format:this.locale.timeFormat}},isExported:!0},Uu={description:uo("Converts a time string into its serial number representation."),args:[$l("time_string (string)",uo("The string that holds the time representation."))],returns:["NUMBER"],compute:function(e){const t=ts(e),o=$t(t,this.locale);$o((()=>null!==o),uo("The time_string (%s) cannot be parsed to date/time.",t));const s=o.value-Math.trunc(o.value);return s<0?1+s:s},isExported:!0},Bu={description:uo("Current date as a date value."),args:[],returns:["DATE"],compute:function(){const e=At.now();return{value:Wt(new At(e.getFullYear(),e.getMonth(),e.getDate())),format:this.locale.dateFormat}},isExported:!0},Hu={description:uo("Day of the week of the date provided (as number)."),args:[$l("date (date)",uo("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.")),$l("type (number, default=1)",uo("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1."))],returns:["NUMBER"],compute:function(e,t={value:1}){const o=ns(e,this.locale),s=Math.round(Zo(t,this.locale)),i=o.getDay();return $o((()=>[1,2,3].includes(s)),uo("The type (%s) must be 1, 2 or 3.",s.toString())),1===s?i+1:2===s?0===i?7:i:0===i?6:i-1},isExported:!0},zu={description:uo("Week number of the year."),args:[$l("date (date)",uo("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.")),$l("type (number, default=1)",uo("A number representing the day that a week starts on. Sunday = 1."))],returns:["NUMBER"],compute:function(e,t={value:1}){const o=ns(e,this.locale),s=Math.round(Zo(t,this.locale));if($o((()=>1===s||2===s||11<=s&&s<=17||21===s),uo("The type (%s) is out of range.",s.toString())),21===s)return _u.compute.bind(this)(e);let i;i=1===s||2===s?s-1:s-10==7?0:s-10;const n=o.getFullYear();let r=1,a=new At(n,0,r);for(;a.getDay()!==i;)r+=1,a=new At(n,0,r);const l=(o.getTime()-a.getTime())/_t;return l<0?1:Math.floor(l/7)+(1===r?1:2)},isExported:!0},$u={description:uo("Date after a number of workdays."),args:[$l("start_date (date)",uo("The date from which to begin counting.")),$l("num_days (number)",uo("The number of working days to advance from start_date. If negative, counts backwards.")),$l("holidays (date, range<date>, optional)",uo("A range or array constant containing the dates to consider holidays."))],returns:["NUMBER"],compute:function(e,t,o={value:null}){return Gu.compute.bind(this)(e,t,{value:1},o)},isExported:!0},Gu={description:uo("Date after a number of workdays (specifying weekends)."),args:[$l("start_date (date)",uo("The date from which to begin counting.")),$l("num_days (number)",uo("The number of working days to advance from start_date. If negative, counts backwards.")),$l("weekend (any, default=1)",uo("A number or string representing which days of the week are considered weekends.")),$l("holidays (date, range<date>, optional)",uo("A range or array constant containing the dates to consider holidays."))],returns:["DATE"],compute:function(e,t,o={value:1},s){let i=ns(e,this.locale),n=Math.trunc(Zo(t,this.locale));"string"==typeof o.value&&$o((()=>"1111111"!==o.value),uo("The weekend must be different from '1111111'."));const r=Nu(o);let a=new Set;void 0!==s&&ls([s],(e=>{const t=ns(e,this.locale);a.add(t.getTime())}));let l=At.fromTimestamp(i.getTime()),c=l.getTime();const h=Math.sign(n);let d=Math.abs(n);for(;d>0;)l.setDate(l.getDate()+h),c=l.getTime(),r.includes(l.getDay())||a.has(c)||(d-=1);const u=c-Ot.getTime();return{value:Math.round(u/_t),format:this.locale.dateFormat}},isExported:!0},Wu={description:uo("Year specified by a given date."),args:[$l("date (date)",uo("The date from which to extract the year."))],returns:["NUMBER"],compute:function(e){return ns(e,this.locale).getFullYear()},isExported:!0},qu={description:uo("Exact number of years between two dates."),args:[$l("start_date (date)",uo("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.")),$l("end_date (date)",uo("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.")),$l("day_count_convention (number, default=0)",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o={value:0}){let s=Math.trunc(Zo(e,this.locale)),i=Math.trunc(Zo(t,this.locale));const n=Math.trunc(Zo(o,this.locale));return $o((()=>s>=0),uo("The start_date (%s) must be positive or null.",s.toString())),$o((()=>i>=0),uo("The end_date (%s) must be positive or null.",i.toString())),$o((()=>0<=n&&n<=4),uo("The day_count_convention (%s) must be between 0 and 4 inclusive.",n.toString())),Kt(s,i,n)}},Zu={description:uo("First day of the month preceding a date."),args:[$l("date (date)",uo("The date from which to calculate the result."))],returns:["DATE"],compute:function(e){const t=ns(e,this.locale),o=t.getFullYear(),s=t.getMonth();return{value:Wt(new At(o,s,1)),format:this.locale.dateFormat}}},Yu={description:uo("Last day of the month following a date."),args:[$l("date (date)",uo("The date from which to calculate the result."))],returns:["DATE"],compute:function(e){return Au.compute.bind(this)(e,{value:0})}},ju={description:uo("Quarter of the year a specific date falls in"),args:[$l("date (date)",uo("The date from which to extract the quarter."))],returns:["NUMBER"],compute:function(e){return Math.ceil((ns(e,this.locale).getMonth()+1)/3)}},Xu={description:uo("First day of the quarter of the year a specific date falls in."),args:[$l("date (date)",uo("The date from which to calculate the start of quarter."))],returns:["DATE"],compute:function(e){const t=ju.compute.bind(this)(e),o=Wu.compute.bind(this)(e);return{value:Wt(new At(o,3*(t-1),1)),format:this.locale.dateFormat}}},Ku={description:uo("Last day of the quarter of the year a specific date falls in."),args:[$l("date (date)",uo("The date from which to calculate the end of quarter."))],returns:["DATE"],compute:function(e){const t=ju.compute.bind(this)(e),o=Wu.compute.bind(this)(e);return{value:Wt(new At(o,3*t,0)),format:this.locale.dateFormat}}},Qu={description:uo("First day of the year a specific date falls in."),args:[$l("date (date)",uo("The date from which to calculate the start of the year."))],returns:["DATE"],compute:function(e){const t=Wu.compute.bind(this)(e);return{value:Wt(new At(t,0,1)),format:this.locale.dateFormat}}},Ju={description:uo("Last day of the year a specific date falls in."),args:[$l("date (date)",uo("The date from which to calculate the end of the year."))],returns:["DATE"],compute:function(e){const t=Wu.compute.bind(this)(e);return{value:Wt(new At(t+1,0,0)),format:this.locale.dateFormat}}};var eg=Object.freeze({__proto__:null,DATE:yu,DATEDIF:Eu,DATEVALUE:xu,DAY:wu,DAYS:Iu,DAYS360:Ru,EDATE:Tu,EOMONTH:Au,HOUR:Ou,ISOWEEKNUM:_u,MINUTE:Du,MONTH:Mu,MONTH_END:Yu,MONTH_START:Zu,NETWORKDAYS:Fu,NETWORKDAYS_INTL:Pu,NOW:Lu,QUARTER:ju,QUARTER_END:Ku,QUARTER_START:Xu,SECOND:ku,TIME:Vu,TIMEVALUE:Uu,TODAY:Bu,WEEKDAY:Hu,WEEKNUM:zu,WORKDAY:$u,WORKDAY_INTL:Gu,YEAR:Wu,YEARFRAC:qu,YEAR_END:Ju,YEAR_START:Qu});const tg={description:uo("Compare two numeric values, returning 1 if they're equal."),args:[$l("number1 (number)",uo("The first number to compare.")),$l("number2 (number, default=0)",uo("The second number to compare."))],returns:["NUMBER"],compute:function(e,t={value:0}){return Zo(e,this.locale)===Zo(t,this.locale)?1:0},isExported:!0};var og=Object.freeze({__proto__:null,DELTA:tg});const sg=[po.number,po.error,po.text,po.boolean];function ig(e){const t="ascending"===e?1:-1;return(e,o)=>{if(e.type===po.empty)return o.type===po.empty?0:1;if(o.type===po.empty)return-1;let s=sg.indexOf(e.type)-sg.indexOf(o.type);return 0===s&&(s=e.type===po.text||e.type===po.error?e.value.localeCompare(o.value):e.value-o.value),t*s}}function ng(e,t,o,s,i){let n=xo.Success,r=s.right>s.left;if(e.model.getters.doesIntersectMerge(t,s)){let o;r=!1;for(let i=s.top;i<=s.bottom;i++){o=[];for(let n=s.left;n<=s.right;n++){let s=e.model.getters.getMerge({sheetId:t,col:n,row:i});s&&!o.includes(s.id.toString())&&o.push(s.id.toString())}if(o.length>=2){r=!0;break}}}const{col:a,row:l}=o;if(r)n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:a,row:l,zone:s,sortDirection:i});else{const o=e.model.getters.getContiguousZone(t,s);qi(o,s)?n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:a,row:l,zone:s,sortDirection:i}):e.askConfirmation(uo("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>{s=o,n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:a,row:l,zone:s,sortDirection:i})}),(()=>{n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:a,row:l,zone:s,sortDirection:i})}))}if(n.isCancelledBecause("InvalidSortZone")){const{col:t,row:i}=o;e.model.selection.selectZone({cell:{col:t,row:i},zone:s}),e.raiseError(uo("Cannot sort. To sort, select only cells or only merges that have the same size."))}}function rg(e,t,...o){for(const[e,t]of o.entries())$o((()=>void 0!==t),uo("Value for parameter %d is missing, while the function [[FUNCTION_NAME]] expect a number or a range.",e+1));const s=[],i=[],n=e.length;for(let r=0;r<o.length;r+=2){s.push(is(Jl(o[r+1])?.value)?"ascending":"descending");const a=o[r];if(_o(a)&&(a.length>1||a[0].length>1))$o((()=>1===a.length&&a[0].length===n),uo("Wrong size for %s. Expected a range of size 1x%s. Got %sx%s.",`sort_column${r+1}`,n,a.length,a[0].length)),i.push(a.flat().map((e=>e.value)));else{const o=Zo(Jl(a)?.value,t);if(o<1||o>e[0].length)return e;i.push(e.map((e=>e[o-1].value)))}}if(0===i.length)for(let t=0;t<e[0].length;t++)i.push(e.map((e=>e[t].value))),s.push("ascending");const r={descending:ig("descending"),ascending:ig("ascending")},a=ve(0,e.length);return a.sort(((e,t)=>{for(const[o,n]of i.entries()){const i=n[e],a=n[t],l={value:i,type:null===i?po.empty:"string"==typeof i?po.text:typeof i},c={value:a,type:null===a?po.empty:"string"==typeof a?po.text:typeof a},h=r[s[o]](l,c);if(0!==h)return h}return 0})),a.map((t=>e[t]))}const ag={description:uo("Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions."),args:[$l("range (any, range<any>)",uo("The data to be filtered.")),$l("condition1 (boolean, range<boolean>)",uo("A column or row containing true or false values corresponding to the first column or row of range.")),$l("condition2 (boolean, range<boolean>, repeating)",uo("Additional column or row containing true or false values."))],returns:["RANGE<ANY>"],compute:function(e,...t){let o=Rs(e);const s=t.map((e=>ms(Rs(e),(e=>e.value))));s.map((e=>Wl(uo("The arguments condition must be a single column or row."),e))),ql(uo("The arguments conditions must have the same dimensions."),...t);const i=s.map((e=>e.flat())),n=1===s[0].length?"row":"col";o="row"===n?fs(o):o,$o((()=>i.every((e=>e.length===o.length))),uo("FILTER has mismatched sizes on the range and conditions."));const r=[];for(let e=0;e<o.length;e++){const t=o[e];i.every((t=>t[e]))&&r.push(t)}if(!r.length)throw new Uo(uo("No match found in FILTER evaluation"));return"row"===n?fs(r):r},isExported:!0},lg={description:uo("Sorts the rows of a given array or range by the values in one or more columns."),args:[$l("range (range)",uo("The data to be sorted.")),$l("sort_column (any, range<number>, repeating)",uo("The index of the column in range or a range outside of range containing the values by which to sort.")),$l("is_ascending (boolean, repeating)",uo("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order."))],returns:["RANGE"],compute:function(e,...t){const o=fs(e);return fs(rg(o,this.locale,...t))},isExported:!0},cg={description:uo("Returns the first n items in a data set after performing a sort."),args:[$l("range (range)",uo("The data to be sorted.")),$l("n (number, default=1)",uo("The number of items to return.")),$l("display_ties_mode (number, default=0)",uo("A number representing the way to display ties.")),$l("sort_column (number, range<number>, repeating)",uo("The index of the column in range or a range outside of range containing the values by which to sort.")),$l("is_ascending (boolean, repeating)",uo("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order."))],returns:["RANGE"],compute:function(e,t,o,...s){const i=Zo(t?.value??1,this.locale);$o((()=>i>=0),uo("Wrong value of 'n'. Expected a positive number. Got %s.",i));const n=Zo(o?.value??0,this.locale);$o((()=>n>=0&&n<=3),uo("Wrong value of 'display_ties_mode'. Expected a positive number between 0 and 3. Got %s.",n));const r=rg(fs(e),this.locale,...s),a=(e,t)=>JSON.stringify(r[e].map((e=>e.value)))===JSON.stringify(r[t].map((e=>e.value)));switch(n){case 0:return fs(r.slice(0,i));case 1:for(let e=i;e<r.length;e++)if(!a(e,i-1))return fs(r.slice(0,e));return fs(r);case 2:{const e=[r[0]];for(let t=1;t<r.length;t++)for(let o=0;o<t&&!a(t,o);o++)o===t-1&&e.push(r[t]);return fs(e.slice(0,i))}case 3:{const e=[r[0]];let t=1;for(let o=1;o<r.length&&(a(o,o-1)||t++,!(t>i));o++)e.push(r[o]);return fs(e)}}},isExported:!0},hg={description:uo("Unique rows in the provided source range."),args:[$l("range (any, range<any>)",uo("The data to filter by unique entries.")),$l("by_column (boolean, default=FALSE)",uo("Whether to filter the data by columns or by rows.")),$l("exactly_once (boolean, default=FALSE)",uo("Whether to return only entries with no duplicates."))],returns:["RANGE<NUMBER>"],compute:function(e={value:""},t,o){if(!_o(e))return[[e]];const s=is(t?.value)||!1,i=is(o?.value)||!1;s||(e=fs(e));const n=new Map;for(const t of e){const e=JSON.stringify(t.map((e=>e.value))),o=n.get(e);o?o.count++:n.set(e,{data:t,count:1})}const r=[];for(const e of n.values())i&&e.count>1||r.push(e.data);if(!r.length)throw new Lo(uo("No unique values found"));return s?r:fs(r)},isExported:!0};var dg=Object.freeze({__proto__:null,FILTER:ag,SORT:lg,SORTN:cg,UNIQUE:hg});function ug(e,t){$o((()=>e<t),uo("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function gg(e,t){$o((()=>t<e),uo("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function pg(e){$o((()=>[1,2,4].includes(e)),uo("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function mg(e){$o((()=>0<=e&&e<=4),uo("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function fg(e){$o((()=>e>0),uo("The redemption (%s) must be strictly positive.",e.toString()))}function bg(e){$o((()=>e>0),uo("The price (%s) must be strictly positive.",e.toString()))}function vg(e){$o((()=>e>0),uo("The number_of_periods (%s) must be greater than 0.",e.toString()))}function Sg(e){$o((()=>e>0),uo("The rate (%s) must be strictly positive.",e.toString()))}function Cg(e){$o((()=>e>0),uo("The life (%s) must be strictly positive.",e.toString()))}function yg(e){$o((()=>e>=0),uo("The cost (%s) must be positive or null.",e.toString()))}function Eg(e){$o((()=>e>0),uo("The period (%s) must be strictly positive.",e.toString()))}function xg(e){$o((()=>e>=0),uo("The salvage (%s) must be positive or null.",e.toString()))}function wg(e){$o((()=>e>0),uo("The present value (%s) must be strictly positive.",e.toString()))}function Ig(e,t){$o((()=>e<=t),uo("The period (%s) must be less than or equal life (%s).",e.toString(),t.toString()))}function Rg(e){$o((()=>e>0),uo("The investment (%s) must be strictly positive.",e.toString()))}function Tg(e){$o((()=>e>0),uo("The discount (%s) must be strictly positive.",e.toString()))}function Ag(e){$o((()=>e<1),uo("The discount (%s) must be smaller than 1.",e.toString()))}function Og(e){$o((()=>e>0),uo("The depreciation factor (%s) must be strictly positive.",e.toString()))}function _g(e,t,o){const s=ns(e,o),i=ns(t,o),n=ns(e,o);n.setFullYear(s.getFullYear()+1),$o((()=>i.getTime()<=n.getTime()),uo("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function Dg(e,t,o){vg(o),$o((()=>e>0),uo("The first_period (%s) must be strictly positive.",e.toString())),$o((()=>t>0),uo("The last_period (%s) must be strictly positive.",t.toString())),$o((()=>e<=t),uo("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),$o((()=>t<=o),uo("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),o.toString()))}function Mg(e){$o((()=>e>-1),uo("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function Fg(e,t){$o((()=>e.length===t.length&&e[0].length===t[0].length),uo("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function Ng(e){$o((()=>e.every((t=>t>=e[0]))),uo("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const Pg=[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("frequency (number)",uo("The number of interest or coupon payments per year (1, 2, or 4).")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))];function Lg(e,t,o,s,i=1e-10,n){let r,a,l,c,h=o,d=!1,u=0;do{l=e(h),isNaN(l)?($o((()=>u<s&&void 0!==n),uo("Function [[FUNCTION_NAME]] didn't find any result.")),u++,h=n(c),c=h):(r=h-l/t(h),a=Math.abs(r-h),h=r,d=a<i||Math.abs(l)<i,$o((()=>u<s),uo("Function [[FUNCTION_NAME]] didn't find any result.")),u++)}while(!d);return h}const kg={description:uo("Accrued interest of security paying at maturity."),args:[$l("issue (date)",uo("The date the security was initially issued.")),$l("maturity (date)",uo("The maturity date of the security.")),$l("rate (number)",uo("The annualized rate of interest.")),$l("redemption (number)",uo("The redemption amount per 100 face value, or par.")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:0}){const n=Math.trunc(Zo(e,this.locale)),r=Math.trunc(Zo(t,this.locale)),a=Zo(s,this.locale),l=Zo(o,this.locale),c=Math.trunc(Zo(i,this.locale));!function(e){$o((()=>e>=0),uo("The issue (%s) must be positive or null.",e.toString()))}(n),gg(r,n),mg(c),fg(a),Sg(l);return a*l*Kt(n,r,c)},isExported:!0},Vg={description:uo("Depreciation for an accounting period."),args:[$l("cost (number)",uo("The initial cost of the asset.")),$l("purchase_date (date)",uo("The date the asset was purchased.")),$l("first_period_end (date)",uo("The date the first period ended.")),$l("salvage (number)",uo("The value of the asset at the end of depreciation.")),$l("period (number)",uo("The single period within life for which to calculate depreciation.")),$l("rate (number)",uo("The deprecation rate.")),$l("day_count_convention (number, optional)",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=Zo(e,this.locale),l=Math.trunc(Zo(t,this.locale)),c=Math.trunc(Zo(o,this.locale)),h=Zo(s,this.locale),d=Zo(i,this.locale),u=Zo(n,this.locale),g=Math.trunc(Zo(r,this.locale));!function(e){$o((()=>e>0),uo("The cost (%s) must be strictly positive.",e.toString()))}(a),function(e){$o((()=>e>=0),uo("The purchase_date (%s) must be positive or null.",e.toString()))}(l),xg(h),function(e,t){$o((()=>e<=t),uo("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(h,a),function(e){$o((()=>e>=0),uo("The period (%s) must be positive or null.",e.toString()))}(d),Sg(u),mg(g),$o((()=>l<=c),uo("The purchase_date (%s) must be before the first_period_end (%s).",l.toString(),c.toString()));const p=d<1&&d>0?1:Math.trunc(d),m=a*u,f=Kt(l,c,g),b=l===c?m:m*f,v=a-b-m*p;return v>=h?0===p?b:m:h-v<m?m-(h-v):0},isExported:!0},Ug={description:uo("Days in coupon period containing settlement date."),args:Pg,returns:["NUMBER"],compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Zo(e,this.locale)),n=Math.trunc(Zo(t,this.locale)),r=Math.trunc(Zo(o,this.locale)),a=Math.trunc(Zo(s,this.locale));if(ug(i,n),pg(r),mg(a),1===a){const i=Gg.compute.bind(this)(e,t,o,s).value;return zg.compute.bind(this)(e,t,o,s).value-i}return(3===a?365:360)/r},isExported:!0},Bg={description:uo("Days from settlement until next coupon."),args:Pg,returns:["NUMBER"],compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Zo(e,this.locale)),n=Math.trunc(Zo(t,this.locale)),r=Math.trunc(Zo(o,this.locale)),a=Math.trunc(Zo(s,this.locale));ug(i,n),pg(r),mg(a);const l=Gg.compute.bind(this)(e,t,o,s).value;if([1,2,3].includes(a))return i-l;if(4===a){const e=Kt(l,i,a);return Math.round(360*e)}const c=ns(i,this.locale),h=ns(l,this.locale),d=h.getFullYear(),u=c.getFullYear(),g=h.getMonth()+1,p=c.getMonth()+1;let m=h.getDate(),f=c.getDate();return 2===g&&2===p&&Yt(h)&&Yt(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&Yt(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Hg={description:uo("Days from settlement until next coupon."),args:Pg,returns:["NUMBER"],compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Zo(e,this.locale)),n=Math.trunc(Zo(t,this.locale)),r=Math.trunc(Zo(o,this.locale)),a=Math.trunc(Zo(s,this.locale));ug(i,n),pg(r),mg(a);const l=zg.compute.bind(this)(e,t,o,s).value;if([1,2,3].includes(a))return l-i;if(4===a){const e=Kt(i,l,a);return Math.round(360*e)}const c=Bg.compute.bind(this)(e,t,o,s);return Ug.compute.bind(this)(e,t,o,s)-c},isExported:!0},zg={description:uo("Next coupon date after the settlement date."),args:Pg,returns:["NUMBER"],compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Zo(e,this.locale)),n=Math.trunc(Zo(t,this.locale)),r=Math.trunc(Zo(o,this.locale)),a=Math.trunc(Zo(s,this.locale));ug(i,n),pg(r),mg(a);const l=12/r,c=$g.compute.bind(this)(e,t,o,s);return{value:Wt(jt(ns(n,this.locale),-(c-1)*l,!0)),format:this.locale.dateFormat}},isExported:!0},$g={description:uo("Number of coupons between settlement and maturity."),args:Pg,returns:["NUMBER"],compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Zo(e,this.locale)),n=Math.trunc(Zo(t,this.locale)),r=Math.trunc(Zo(o,this.locale)),a=Math.trunc(Zo(s,this.locale));ug(i,n),pg(r),mg(a);let l=1,c=n;const h=12/r;for(;c>i;)c=Wt(jt(ns(c,this.locale),-h,!1)),l++;return l-1},isExported:!0},Gg={description:uo("Last coupon date prior to or on the settlement date."),args:Pg,returns:["NUMBER"],compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Zo(e,this.locale)),n=Math.trunc(Zo(t,this.locale)),r=Math.trunc(Zo(o,this.locale)),a=Math.trunc(Zo(s,this.locale));ug(i,n),pg(r),mg(a);const l=12/r,c=$g.compute.bind(this)(e,t,o,s);return{value:Wt(jt(ns(n,this.locale),-c*l,!0)),format:this.locale.dateFormat}},isExported:!0},Wg={description:uo("Cumulative interest paid over a set of periods."),args:[$l("rate (number)",uo("The interest rate.")),$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("present_value (number)",uo("The current value of the annuity.")),$l("first_period (number)",uo("The number of the payment period to begin the cumulative calculation.")),$l("last_period (number)",uo("The number of the payment period to end the cumulative calculation.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n={value:0}){const r=Zo(s,this.locale),a=Zo(i,this.locale),l=Zo(e,this.locale),c=Zo(o,this.locale),h=Zo(t,this.locale),d=is(n)?1:0;Dg(r,a,h),Sg(l),wg(c);let u=0;for(let e=r;e<=a;e++)u+=np(l,e,h,c,0,d);return u},isExported:!0},qg={description:uo("Cumulative principal paid over a set of periods."),args:[$l("rate (number)",uo("The interest rate.")),$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("present_value (number)",uo("The current value of the annuity.")),$l("first_period (number)",uo("The number of the payment period to begin the cumulative calculation.")),$l("last_period (number)",uo("The number of the payment period to end the cumulative calculation.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n={value:0}){const r=Zo(s,this.locale),a=Zo(i,this.locale),l=Zo(e,this.locale),c=Zo(o,this.locale),h=Zo(t,this.locale),d=is(n)?1:0;Dg(r,a,h),Sg(l),wg(c);let u=0;for(let e=r;e<=a;e++)u+=vp(l,e,h,c,0,d);return u},isExported:!0},Zg={description:uo("Depreciation via declining balance method."),args:[$l("cost (number)",uo("The initial cost of the asset.")),$l("salvage (number)",uo("The value of the asset at the end of depreciation.")),$l("life (number)",uo("The number of periods over which the asset is depreciated.")),$l("period (number)",uo("The single period within life for which to calculate depreciation.")),$l("month (number, optional)",uo("The number of months in the first year of depreciation."))],returns:["NUMBER"],compute:function(e,t,o,s,...i){const n=Zo(e,this.locale),r=Zo(t,this.locale),a=Zo(o,this.locale),l=Math.trunc(Zo(s,this.locale)),c=i.length?Math.trunc(Zo(i[0],this.locale)):12,h=a+(12===c?0:1);yg(n),xg(r),Eg(l),Cg(a),$o((()=>1<=c&&c<=12),uo("The month (%s) must be between 1 and 12 inclusive.",c.toString())),$o((()=>l<=h),uo("The period (%s) must be less than or equal to %s.",l.toString(),h.toString()));const d=c/12;let u=1-Math.pow(r/n,1/a);u=Math.round(1e3*u)/1e3;let g=n,p=n*(1-u*d);for(let e=1;e<l;e++)g=p,p=g*(1-u),e===a&&(p=g*(1-u*(1-d)));return{value:g-p,format:"#,##0.00"}},isExported:!0};function Yg(e,t,o,s,i){if(yg(e),xg(t),Eg(s),Cg(o),Ig(s,o),Og(i),0===e||t>=e)return 0;const n=i/o;if(n>1)return 1===s?e-t:0;if(s<=1)return e*n;const r=e*Math.pow(1-n,s-1),a=e*Math.pow(1-n,s),l=a<t?r-t:r-a;return Math.max(l,0)}const jg={description:uo("Depreciation via double-declining balance method."),args:[$l("cost (number)",uo("The initial cost of the asset.")),$l("salvage (number)",uo("The value of the asset at the end of depreciation.")),$l("life (number)",uo("The number of periods over which the asset is depreciated.")),$l("period (number)",uo("The single period within life for which to calculate depreciation.")),$l("factor (number, default=2)",uo("The factor by which depreciation decreases."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:2}){return{value:Yg(Zo(e,this.locale),Zo(t,this.locale),Zo(o,this.locale),Zo(s,this.locale),Zo(i,this.locale)),format:"#,##0.00"}},isExported:!0},Xg={description:uo("Discount rate of a security based on price."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("price (number)",uo("The price at which the security is bought per 100 face value.")),$l("redemption (number)",uo("The redemption amount per 100 face value, or par.")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(Zo(e,this.locale)),r=Math.trunc(Zo(t,this.locale)),a=Zo(o,this.locale),l=Zo(s,this.locale),c=Math.trunc(Zo(i,this.locale));ug(n,r),mg(c),bg(a),fg(l);return(l-a)/l/Kt(n,r,c)},isExported:!0},Kg={description:uo("Convert a decimal fraction to decimal value."),args:[$l("fractional_price (number)",uo("The price quotation given using fractional decimal conventions.")),$l("unit (number)",uo("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const o=Zo(e,this.locale),s=Math.trunc(Zo(t,this.locale));$o((()=>s>0),uo("The unit (%s) must be strictly positive.",s.toString()));const i=Math.trunc(o);return i+(o-i)*(10**Math.ceil(Math.log10(s))/s)},isExported:!0},Qg={description:uo("Convert a decimal value to decimal fraction."),args:[$l("decimal_price (number)",uo("The price quotation given as a decimal value.")),$l("unit (number)",uo("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const o=Zo(e,this.locale),s=Math.trunc(Zo(t,this.locale));$o((()=>s>0),uo("The unit (%s) must be strictly positive.",s.toString()));const i=Math.trunc(o);return i+(o-i)*(s/10**Math.ceil(Math.log10(s)))},isExported:!0},Jg={description:uo("Number of periods for an investment to reach a value."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("rate (number)",uo("The annualized rate of interest.")),$l("yield (number)",uo("The expected annual yield of the security.")),$l("frequency (number)",uo("The number of interest or coupon payments per year (1, 2, or 4).")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n={value:0}){const r=Math.trunc(Zo(e,this.locale)),a=Math.trunc(Zo(t,this.locale)),l=Zo(o,this.locale),c=Zo(s,this.locale),h=Math.trunc(Zo(i,this.locale)),d=Math.trunc(Zo(n,this.locale));ug(r,a),pg(h),mg(d),$o((()=>l>=0),uo("The rate (%s) must be positive or null.",l.toString())),$o((()=>c>=0),uo("The yield (%s) must be positive or null.",c.toString()));const u=Kt(r,a,d),g=u-Math.trunc(u)||1/h,p=Math.ceil(u*h),m=l/h,f=c/h;let b=0,v=0;for(let e=1;e<=p;e++){const t=(m+(e===p?1:0))/(1+f)**e;v+=(g+(e-1)/h)*t,b+=t}return 0===b?0:v/b},isExported:!0},ep={description:uo("Annual effective interest rate."),args:[$l("nominal_rate (number)",uo("The nominal interest rate per year.")),$l("periods_per_year (number)",uo("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const o=Zo(e,this.locale),s=Math.trunc(Zo(t,this.locale));return $o((()=>o>0),uo("The nominal rate (%s) must be strictly greater than 0.",o.toString())),$o((()=>s>0),uo("The number of periods by year (%s) must strictly greater than 0.",s.toString())),Math.pow(1+o/s,s)-1},isExported:!0};function tp(e,t,o,s,i){return 0===e?-(s+o*t):-s*(1+e)**t-o*(1+e*i)*((1+e)**t-1)/e}const op={description:uo("Future value of an annuity investment."),args:[$l("rate (number)",uo("The interest rate.")),$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("payment_amount (number)",uo("The amount per period to be paid.")),$l("present_value (number, default=0)",uo("The current value of the annuity.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;return{value:tp(Zo(e,this.locale),Zo(t,this.locale),Zo(o,this.locale),Zo(s,this.locale),is(i)?1:0),format:"#,##0.00"}},isExported:!0},sp={description:uo("Future value of principal from series of rates."),args:[$l("principal (number)",uo("The amount of initial capital or value to compound against.")),$l("rate_schedule (number, range<number>)",uo("A series of interest rates to compound against the principal."))],returns:["NUMBER"],compute:function(e,t){return ds([t],((e,t)=>e*(1+Zo(t,this.locale))),Zo(e,this.locale))},isExported:!0},ip={description:uo("Calculates effective interest rate."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("investment (number)",uo("The amount invested in the security.")),$l("redemption (number)",uo("The amount to be received at maturity.")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:0}){const n=Math.trunc(Zo(e,this.locale)),r=Math.trunc(Zo(t,this.locale)),a=Zo(s,this.locale),l=Zo(o,this.locale),c=Math.trunc(Zo(i,this.locale));ug(n,r),Rg(l),fg(a),mg(c);return(a-l)/l/Kt(n,r,c)},isExported:!0};function np(e,t,o,s,i,n){return fp(e,o,s,i,n)-vp(e,t,o,s,i,n)}const rp={description:uo("Payment on the principal of an investment."),args:[$l("rate (number)",uo("The annualized rate of interest.")),$l("period (number)",uo("The amortization period, in terms of number of periods.")),$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("present_value (number)",uo("The current value of the annuity.")),$l("future_value (number, default=0)",uo("The future value remaining after the final payment has been made.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:0},n={value:0}){return{value:np(Zo(e,this.locale),Zo(t,this.locale),Zo(o,this.locale),Zo(s,this.locale),Zo(i,this.locale),is(n)?1:0),format:"#,##0.00"}},isExported:!0},ap={description:uo("Internal rate of return given periodic cashflows."),args:[$l("cashflow_amounts (number, range<number>)",uo("An array or range containing the income or payments associated with the investment.")),$l("rate_guess (number, default=0.1)",uo("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],compute:function(e,t={value:.1}){const o=Zo(t,this.locale);Mg(o);let s=!1,i=!1,n=[];cs([e],(e=>{e>0&&(s=!0),e<0&&(i=!0),n.push(e)}),this.locale),$o((()=>s&&i),uo("The cashflow_amounts must include negative and positive values."));const r=n.shift();return{value:Lg((function(e){return function(e,t,o){const s=o.length;let i=0;return o.reduce(((t,o)=>(i++,t+o*e**(s-i))),t*e**s)}(e,r,n)}),(function(e){return function(e,t,o){const s=o.length;let i=0;return o.reduce(((t,o)=>(i++,t+o*(s-i)*e**(s-i-1))),t*s*e**(s-1))}(e,r,n)}),o+1,20,1e-5)-1,format:"0%"}},isExported:!0},lp={description:uo("Returns the interest paid at a particular period of an investment."),args:[$l("rate (number)",uo("The interest rate.")),$l("period (number)",uo("The period for which you want to view the interest payment.")),$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("present_value (number)",uo("The current value of the annuity."))],returns:["NUMBER"],compute:function(e,t,o,s){const i=Zo(e,this.locale),n=Zo(t,this.locale),r=Zo(o,this.locale),a=Zo(s,this.locale);$o((()=>0!==r),uo("The number of periods must be different than 0.",r.toString()));return-1*(a-a*(n/r))*i},isExported:!0},cp={description:uo("Modified Macaulay duration."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("rate (number)",uo("The annualized rate of interest.")),$l("yield (number)",uo("The expected annual yield of the security.")),$l("frequency (number)",uo("The number of interest or coupon payments per year (1, 2, or 4).")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n={value:0}){return Jg.compute.bind(this)(e,t,o,s,i,n)/(1+Zo(s,this.locale)/Math.trunc(Zo(i,this.locale)))},isExported:!0},hp={description:uo("Modified internal rate of return."),args:[$l("cashflow_amounts (range<number>)",uo("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")),$l("financing_rate (number)",uo("The interest rate paid on funds invested.")),$l("reinvestment_return_rate (number)",uo("The return (as a percentage) earned on reinvestment of income received from the investment."))],returns:["NUMBER"],compute:function(e,t,o){const s=Zo(t,this.locale),i=Zo(o,this.locale),n=fs(e).flat().filter((e=>null!==e.value)).map((e=>Zo(e,this.locale))),r=n.length;let a=0,l=0;for(const e of ve(0,r)){const t=n[e];t>=0?a+=t*(i+1)**(r-e-1):l+=t/(s+1)**e}$o((()=>0!==l&&0!==a),uo("There must be both positive and negative values in cashflow_amounts."));return(-a/l)**(1/(r-1))-1},isExported:!0},dp={description:uo("Annual nominal interest rate."),args:[$l("effective_rate (number)",uo("The effective interest rate per year.")),$l("periods_per_year (number)",uo("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const o=Zo(e,this.locale),s=Math.trunc(Zo(t,this.locale));return $o((()=>o>0),uo("The effective rate (%s) must must strictly greater than 0.",o.toString())),$o((()=>s>0),uo("The number of periods by year (%s) must strictly greater than 0.",s.toString())),(Math.pow(o+1,1/s)-1)*s},isExported:!0},up={description:uo("Number of payment periods for an investment."),args:[$l("rate (number)",uo("The interest rate.")),$l("payment_amount (number)",uo("The amount of each payment made.")),$l("present_value (number)",uo("The current value of the annuity.")),$l("future_value (number, default=0)",uo("The future value remaining after the final payment has been made.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;const n=Zo(e,this.locale),r=Zo(t,this.locale),a=Zo(o,this.locale),l=Zo(s,this.locale),c=is(i)?1:0;if(0===n)return-(l+a)/r;const h=r*(1+n*c)/n;return Math.log((h-l)/(a+h))/Math.log(1+n)},isExported:!0};function gp(e,t,o,s){let i=0;return us(o,((t,o)=>(i++,t+o/(1+e)**i)),t,s)}const pp={description:uo("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:[$l("discount (number)",uo("The discount rate of the investment over one period.")),$l("cashflow1 (number, range<number>)",uo("The first future cash flow.")),$l("cashflow2 (number, range<number>, repeating)",uo("Additional future cash flows."))],returns:["NUMBER"],compute:function(e,...t){const o=Zo(e,this.locale);return $o((()=>-1!==o),uo("The discount (%s) must be different from -1.",o.toString())),{value:gp(o,0,t,this.locale),format:"#,##0.00"}},isExported:!0},mp={description:uo("Computes the number of periods needed for an investment to reach a value."),args:[$l("rate (number)",uo("The rate at which the investment grows each period.")),$l("present_value (number)",uo("The investment's current value.")),$l("future_value (number)",uo("The investment's desired future value."))],returns:["NUMBER"],compute:function(e,t,o){const s=Zo(e,this.locale),i=Zo(t,this.locale),n=Zo(o,this.locale);return Sg(s),$o((()=>i>0),uo("The present_value (%s) must be strictly positive.",i.toString())),$o((()=>n>0),uo("The future_value (%s) must be strictly positive.",n.toString())),(Math.log(n)-Math.log(i))/Math.log(1+s)},isExported:!0};function fp(e,t,o,s,i){if(vg(t),0===e)return-(s+o)/t;let n=-(o*(1+e)**t+s);return n=n*e/((1+e*i)*((1+e)**t-1)),n}const bp={description:uo("Periodic payment for an annuity investment."),args:[$l("rate (number)",uo("The annualized rate of interest.")),$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("present_value (number)",uo("The current value of the annuity.")),$l("future_value (number, default=0)",uo("The future value remaining after the final payment has been made.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s={value:0},i={value:0}){const n=Zo(t,this.locale),r=Zo(e,this.locale),a=is(i)?1:0,l=Zo(s,this.locale);return{value:fp(r,n,Zo(o,this.locale),l,a),format:"#,##0.00"}},isExported:!0};function vp(e,t,o,s,i,n){vg(o),$o((()=>t>0&&t<=o),uo("The period must be between 1 and number_of_periods (%s)",o));const r=fp(e,o,s,i,n);if(1===n&&1===t)return r;return r+-tp(e,0===n?t-1:t-2,r,s+r*n,0)*e}const Sp={description:uo("Payment on the principal of an investment."),args:[$l("rate (number)",uo("The annualized rate of interest.")),$l("period (number)",uo("The amortization period, in terms of number of periods.")),$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("present_value (number)",uo("The current value of the annuity.")),$l("future_value (number, default=0)",uo("The future value remaining after the final payment has been made.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:0},n={value:0}){const r=Zo(o,this.locale),a=Zo(e,this.locale),l=Zo(t,this.locale),c=is(n)?1:0,h=Zo(i,this.locale);return{value:vp(a,l,r,Zo(s,this.locale),h,c),format:"#,##0.00"}},isExported:!0},Cp={description:uo("Present value of an annuity investment."),args:[$l("rate (number)",uo("The interest rate.")),$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("payment_amount (number)",uo("The amount per period to be paid.")),$l("future_value (number, default=0)",uo("The future value remaining after the final payment has been made.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;const n=Zo(e,this.locale),r=Zo(t,this.locale),a=Zo(o,this.locale),l=Zo(s,this.locale),c=is(i)?1:0;return{value:n?-(a*(1+n*c)*((1+n)**r-1)/n+l)/(1+n)**r:-(l+a*r),format:"#,##0.00"}},isExported:!0},yp={description:uo("Price of a security paying periodic interest."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("rate (number)",uo("The annualized rate of interest.")),$l("yield (number)",uo("The expected annual yield of the security.")),$l("redemption (number)",uo("The redemption amount per 100 face value, or par.")),$l("frequency (number)",uo("The number of interest or coupon payments per year (1, 2, or 4).")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=Math.trunc(Zo(e,this.locale)),l=Math.trunc(Zo(t,this.locale)),c=Zo(o,this.locale),h=Zo(s,this.locale),d=Zo(i,this.locale),u=Math.trunc(Zo(n,this.locale)),g=Math.trunc(Zo(r,this.locale));ug(a,l),pg(u),mg(g),$o((()=>c>=0),uo("The rate (%s) must be positive or null.",c.toString())),$o((()=>h>=0),uo("The yield (%s) must be positive or null.",h.toString())),fg(d);const p=Kt(a,l,g)*u,m=Math.ceil(p),f=p-Math.floor(p)||1,b=1+h/u,v=100*c/u;if(1===m)return(v+d)/(f*h/u+1)-v*(1-f);let S=0;for(let e=1;e<=m;e++)S+=v/b**(e-1+f);return d/b**(m-1+f)+S-v*(1-f)},isExported:!0},Ep={description:uo("Price of a discount security."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("discount (number)",uo("The discount rate of the security at time of purchase.")),$l("redemption (number)",uo("The redemption amount per 100 face value, or par.")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(Zo(e,this.locale)),r=Math.trunc(Zo(t,this.locale)),a=Zo(o,this.locale),l=Zo(s,this.locale),c=Math.trunc(Zo(i,this.locale));ug(n,r),mg(c),Tg(a),fg(l);return l-a*l*Kt(n,r,c)},isExported:!0},xp={description:uo("Calculates the price of a security paying interest at maturity, based on expected yield."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("issue (date)",uo("The date the security was initially issued.")),$l("rate (number)",uo("The annualized rate of interest.")),$l("yield (number)",uo("The expected annual yield of the security.")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n={value:0}){n=n||0;const r=Math.trunc(Zo(e,this.locale)),a=Math.trunc(Zo(t,this.locale)),l=Math.trunc(Zo(o,this.locale)),c=Zo(s,this.locale),h=Zo(i,this.locale),d=Math.trunc(Zo(n,this.locale));gg(r,l),ug(r,a),mg(d),$o((()=>c>=0),uo("The rate (%s) must be positive or null.",c.toString())),$o((()=>h>=0),uo("The yield (%s) must be positive or null.",h.toString()));const u=Kt(r,a,d),g=Kt(r,l,d);return(100+Kt(l,a,d)*c*100)/(1+u*h)-g*c*100},isExported:!0},wp=.1,Ip={description:uo("Interest rate of an annuity investment."),args:[$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("payment_per_period (number)",uo("The amount per period to be paid.")),$l("present_value (number)",uo("The current value of the annuity.")),$l("future_value (number, default=0)",uo("The future value remaining after the final payment has been made.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period.")),$l("rate_guess (number, default=0.1)",uo("An estimate for what the interest rate will be."))],returns:["NUMBER"],compute:function(e,t,o,s={value:0},i={value:0},n={value:wp}){const r=Zo(e,this.locale),a=Zo(t,this.locale),l=is(i)?1:0,c=Zo(n,this.locale)||wp;let h=Zo(s,this.locale),d=Zo(o,this.locale);vg(r),$o((()=>[a,d,h].some((e=>e>0))&&[a,d,h].some((e=>e<0))),uo("There must be both positive and negative values in [payment_amount, present_value, future_value].",r.toString())),Mg(c),h-=a*l,d+=a*l;return{value:Lg((e=>{const t=Math.pow(1+e,r);return h+d*t+a*((t-1)/e)}),(e=>{const t=Math.pow(1+e,r-1),o=Math.pow(1+e,r);return d*r*t+a*(r*t/e-(o-1)/e/e)}),c,40,1e-5),format:"0%"}},isExported:!0},Rp={description:uo("Amount received at maturity for a security."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("investment (number)",uo("The amount invested (irrespective of face value of each security).")),$l("discount (number)",uo("The discount rate of the security invested in.")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(Zo(e,this.locale)),r=Math.trunc(Zo(t,this.locale)),a=Zo(o,this.locale),l=Zo(s,this.locale),c=Math.trunc(Zo(i,this.locale));ug(n,r),mg(c),Rg(a),Tg(l);return a/(1-l*Kt(n,r,c))},isExported:!0},Tp={description:uo("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:[$l("number_of_periods (number)",uo("The number of periods.")),$l("present_value (number)",uo("The present value of the investment.")),$l("future_value (number)",uo("The future value of the investment."))],returns:["NUMBER"],compute:function(e,t,o){const s=Zo(e,this.locale),i=Zo(t,this.locale),n=Zo(o,this.locale);return vg(s),(n/i)**(1/s)-1},isExported:!0},Ap={description:uo("Depreciation of an asset using the straight-line method."),args:[$l("cost (number)",uo("The initial cost of the asset.")),$l("salvage (number)",uo("The value of the asset at the end of depreciation.")),$l("life (number)",uo("The number of periods over which the asset is depreciated."))],returns:["NUMBER"],compute:function(e,t,o){return{value:(Zo(e,this.locale)-Zo(t,this.locale))/Zo(o,this.locale),format:"#,##0.00"}},isExported:!0},Op={description:uo("Depreciation via sum of years digit method."),args:[$l("cost (number)",uo("The initial cost of the asset.")),$l("salvage (number)",uo("The value of the asset at the end of depreciation.")),$l("life (number)",uo("The number of periods over which the asset is depreciated.")),$l("period (number)",uo("The single period within life for which to calculate depreciation."))],returns:["NUMBER"],compute:function(e,t,o,s){const i=Zo(e,this.locale),n=Zo(t,this.locale),r=Zo(o,this.locale),a=Zo(s,this.locale);Eg(a),Cg(r),Ig(a,r);return{value:(r-a+1)/(r*(r+1)/2)*(i-n),format:"#,##0.00"}},isExported:!0};function _p(e,t,o){return 100*(1-o*Kt(e,t,2))}const Dp={description:uo("Price of a US Treasury bill."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("discount (number)",uo("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,o){const s=Math.trunc(Zo(e,this.locale)),i=Math.trunc(Zo(t,this.locale)),n=Zo(o,this.locale);return ug(s,i),_g(s,i,this.locale),Tg(n),Ag(n),_p(s,i,n)},isExported:!0},Mp={description:uo("Equivalent rate of return for a US Treasury bill."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("discount (number)",uo("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,o){const s=Math.trunc(Zo(e,this.locale)),i=Math.trunc(Zo(t,this.locale)),n=Zo(o,this.locale);ug(s,i),_g(s,i,this.locale),Tg(n),Ag(n);const r=Iu.compute.bind(this)({value:i},{value:s});if(r<=182)return 365*n/(360-n*r);const a=_p(s,i,n)/100,l=r/(366===r?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},Fp={description:uo("The yield of a US Treasury bill based on price."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("price (number)",uo("The price at which the security is bought per 100 face value."))],returns:["NUMBER"],compute:function(e,t,o){const s=Math.trunc(Zo(e,this.locale)),i=Math.trunc(Zo(t,this.locale)),n=Zo(o,this.locale);ug(s,i),_g(s,i,this.locale),bg(n);return(100-n)/n*(1/Kt(s,i,2))},isExported:!0},Np={description:uo("Variable declining balance. WARNING : does not handle decimal periods."),args:[$l("cost (number)",uo("The initial cost of the asset.")),$l("salvage (number)",uo("The value of the asset at the end of depreciation.")),$l("life (number)",uo("The number of periods over which the asset is depreciated.")),$l("start (number)",uo("Starting period to calculate depreciation.")),$l("end (number)",uo("Ending period to calculate depreciation.")),$l("factor (number, default=2)",uo("The number of months in the first year of depreciation.")),$l("no_switch (number, default=false)",uo("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n={value:2},r={value:false}){n=n||0;const a=Zo(e,this.locale),l=Zo(t,this.locale),c=Zo(o,this.locale),h=Math.trunc(Zo(s,this.locale)),d=Math.trunc(Zo(i,this.locale)),u=Zo(n,this.locale),g=is(r);if(yg(a),xg(l),function(e,t,o){Cg(o),$o((()=>e>=0),uo("The start_period (%s) must be greater or equal than 0.",e.toString())),$o((()=>t>=0),uo("The end_period (%s) must be greater or equal than 0.",t.toString())),$o((()=>e<=t),uo("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),$o((()=>t<=o),uo("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),o.toString()))}(h,d,c),Og(u),0===a)return 0;if(l>=a)return h<1?a-l:0;const p=u/c;if(p>=1)return h<1?a-l:0;let m=a,f=0,b=0,v=!1;for(let e=0;e<d;e++){if(!v||g){const t=m*p,o=(m-l)/(c-e);!g&&o>t?(v=!0,f=o):f=t}const t=Math.max(m-f,l);e>=h&&(b+=m-t),m=t}return b},isExported:!0},Pp={description:uo("Internal rate of return given non-periodic cash flows."),args:[$l("cashflow_amounts (range<number>)",uo("An range containing the income or payments associated with the investment.")),$l("cashflow_dates (range<number>)",uo("An range with dates corresponding to the cash flows in cashflow_amounts.")),$l("rate_guess (number, default=0.1)",uo("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],compute:function(e,t,o={value:wp}){const s=Zo(o,this.locale),i=e.flat().map((e=>Zo(e,this.locale))),n=t.flat().map((e=>Zo(e,this.locale)));var r;Fg(e,t),r=i,$o((()=>r.some((e=>e>0))&&r.some((e=>e<0))),uo("There must be both positive and negative values in cashflow_amounts.")),Ng(n),Mg(s);const a=new Map;for(const e of ve(0,n.length)){const t=n[e];a.has(t)?a.set(t,a.get(t)+i[e]):a.set(t,i[e])}const l=Array.from(a.keys()),c=l.map((e=>a.get(e)));return Lg((e=>{let t=c[0];for(const o of ve(1,c.length)){const s=(l[0]-l[o])/365;t+=c[o]*(1+e)**s}return t}),(e=>{let t=0;for(const o of ve(1,c.length)){const s=(l[0]-l[o])/365;t+=s*c[o]*(1+e)**(s-1)}return t}),s,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},Lp={description:uo("Net present value given to non-periodic cash flows.."),args:[$l("discount (number)",uo("The discount rate of the investment over one period.")),$l("cashflow_amounts (number, range<number>)",uo("An range containing the income or payments associated with the investment.")),$l("cashflow_dates (number, range<number>)",uo("An range with dates corresponding to the cash flows in cashflow_amounts."))],returns:["NUMBER"],compute:function(e,t,o){const s=Zo(e,this.locale),i=_o(t)?t.flat().map((e=>Xo(e,this.locale))):[Xo(t,this.locale)],n=_o(o)?o.flat().map((e=>Xo(e,this.locale))):[Xo(o,this.locale)];if(_o(o)&&_o(t)?Fg(t,o):$o((()=>i.length===n.length),uo("There must be the same number of values in cashflow_amounts and cashflow_dates.")),Ng(n),Sg(s),1===i.length)return i[0];const r=new Map;for(const e of ve(0,n.length)){const t=n[e];r.has(t)?r.set(t,r.get(t)+i[e]):r.set(t,i[e])}const a=Array.from(r.keys()),l=a.map((e=>r.get(e)));let c=l[0];for(const e of ve(1,l.length)){const t=(a[0]-a[e])/365;c+=l[e]*(1+s)**t}return c},isExported:!0},kp={description:uo("Annual yield of a security paying periodic interest."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("rate (number)",uo("The annualized rate of interest.")),$l("price (number)",uo("The price at which the security is bought per 100 face value.")),$l("redemption (number)",uo("The redemption amount per 100 face value, or par.")),$l("frequency (number)",uo("The number of interest or coupon payments per year (1, 2, or 4).")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=Math.trunc(Zo(e,this.locale)),l=Math.trunc(Zo(t,this.locale)),c=Zo(o,this.locale),h=Zo(s,this.locale),d=Zo(i,this.locale),u=Math.trunc(Zo(n,this.locale)),g=Math.trunc(Zo(r,this.locale));ug(a,l),pg(u),mg(g),$o((()=>c>=0),uo("The rate (%s) must be positive or null.",c.toString())),bg(h),fg(d);const p=Kt(a,l,g)*u,m=Math.ceil(p),f=p-Math.floor(p)||1,b=100*c/u;if(1===m){const e=h+b*(1-f);return(d+b-e)*u*(1/f)/e}const v=Lg((function(e){return function(e,t,o,s,i,n){let r=n-(e+i*(1-t))*s**(o-1+t);for(let e=1;e<=o;e++)r+=i*s**(e-1);return r}(h,f,m,e,b,d)}),(function(e){return function(e,t,o,s,i){let n=-(e+i*(1-t))*(o-1+t)*s**(o-2+t);for(let e=1;e<=o;e++)n+=i*(e-1)*s**(e-2);return n}(h,f,m,e,b)}),1+(c+1)/u,100,1e-5);return(v-1)*u},isExported:!0},Vp={description:uo("Annual yield of a discount security."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("price (number)",uo("The price at which the security is bought per 100 face value.")),$l("redemption (number)",uo("The redemption amount per 100 face value, or par.")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(Zo(e,this.locale)),r=Math.trunc(Zo(t,this.locale)),a=Zo(o,this.locale),l=Zo(s,this.locale),c=Math.trunc(Zo(i,this.locale));ug(n,r),mg(c),bg(a),fg(l);return(l/a-1)/Kt(n,r,c)},isExported:!0},Up={description:uo("Annual yield of a security paying interest at maturity."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("issue (date)",uo("The date the security was initially issued.")),$l("rate (number)",uo("The annualized rate of interest.")),$l("price (number)",uo("The price at which the security is bought.")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n={value:0}){n=n||0;const r=Math.trunc(Zo(e,this.locale)),a=Math.trunc(Zo(t,this.locale)),l=Math.trunc(Zo(o,this.locale)),c=Zo(s,this.locale),h=Zo(i,this.locale),d=Math.trunc(Zo(n,this.locale));ug(r,a),mg(d),$o((()=>r>=l),uo("The settlement (%s) must be greater than or equal to the issue (%s).",r.toString(),l.toString())),$o((()=>c>=0),uo("The rate (%s) must be positive or null.",c.toString())),bg(h);const u=Kt(l,a,d),g=Kt(l,r,d),p=Kt(r,a,d);return(100*(1+c*u)/(h+100*c*g)-1)/p},isExported:!0};var Bp=Object.freeze({__proto__:null,ACCRINTM:kg,AMORLINC:Vg,COUPDAYBS:Bg,COUPDAYS:Ug,COUPDAYSNC:Hg,COUPNCD:zg,COUPNUM:$g,COUPPCD:Gg,CUMIPMT:Wg,CUMPRINC:qg,DB:Zg,DDB:jg,DISC:Xg,DOLLARDE:Kg,DOLLARFR:Qg,DURATION:Jg,EFFECT:ep,FV:op,FVSCHEDULE:sp,INTRATE:ip,IPMT:rp,IRR:ap,ISPMT:lp,MDURATION:cp,MIRR:hp,NOMINAL:dp,NPER:up,NPV:pp,PDURATION:mp,PMT:bp,PPMT:Sp,PRICE:yp,PRICEDISC:Ep,PRICEMAT:xp,PV:Cp,RATE:Ip,RECEIVED:Rp,RRI:Tp,SLN:Ap,SYD:Op,TBILLEQ:Mp,TBILLPRICE:Dp,TBILLYIELD:Fp,VDB:Np,XIRR:Pp,XNPV:Lp,YIELD:kp,YIELDDISC:Vp,YIELDMAT:Up});const Hp=["address","col","contents","format","row","type"],zp={description:uo("Gets information about a cell."),args:[$l("info_type (string)",uo("The type of information requested. Can be one of %s",Hp.join(", "))),$l("reference (meta)",uo("The reference to the cell."))],returns:["ANY"],compute:function(e,t){const o=ts(e).toLowerCase();$o((()=>Hp.includes(o)),uo("The info_type should be one of %s.",Hp.join(", ")));const s=this.__originSheetId,i=ts(t),n=i.includes(":")?i.split(":")[0]:i;let{sheetName:r,xc:a}=Ti(n);r=r===this.getters.getSheetName(s)?void 0:r;const l=Ai(r,fa(a,"colrow")),c=this.getters.getRangeFromSheetXC(s,l);switch(o){case"address":return this.getters.getRangeString(c,s);case"col":return c.zone.left+1;case"contents":{const e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top};return this.getters.getEvaluatedCell(e).value}case"format":{const e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top};return this.getters.getEvaluatedCell(e).format||""}case"row":return c.zone.top+1;case"type":{const e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top},t=this.getters.getEvaluatedCell(e).type;return t===po.empty?"b":t===po.text?"l":"v"}}return""},isExported:!0},$p={description:uo("Whether a value is an error other than #N/A."),args:[$l("value (any)",uo("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){const t=e?.value;return Wo(t)&&t!==No.NotAvailable},isExported:!0},Gp={description:uo("Whether a value is an error."),args:[$l("value (any)",uo("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){const t=e?.value;return Wo(t)},isExported:!0},Wp={description:uo("Whether a value is `true` or `false`."),args:[$l("value (any)",uo("The value to be verified as a logical TRUE or FALSE."))],returns:["BOOLEAN"],compute:function(e){return"boolean"==typeof e?.value},isExported:!0},qp={description:uo("Whether a value is the error #N/A."),args:[$l("value (any)",uo("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){return e?.value===No.NotAvailable},isExported:!0},Zp={description:uo("Whether a value is non-textual."),args:[$l("value (any)",uo("The value to be checked."))],returns:["BOOLEAN"],compute:function(e){return!jp.compute.bind(this)(e)},isExported:!0},Yp={description:uo("Whether a value is a number."),args:[$l("value (any)",uo("The value to be verified as a number."))],returns:["BOOLEAN"],compute:function(e){return"number"==typeof e?.value},isExported:!0},jp={description:uo("Whether a value is text."),args:[$l("value (any)",uo("The value to be verified as text."))],returns:["BOOLEAN"],compute:function(e){return"string"==typeof e?.value&&!1===Wo(e?.value)},isExported:!0},Xp={description:uo("Whether the referenced cell is empty"),args:[$l("value (any)",uo("Reference to the cell that will be checked for emptiness."))],returns:["BOOLEAN"],compute:function(e){return null===e?.value},isExported:!0},Kp={description:uo("Returns the error value #N/A."),args:[],returns:["BOOLEAN"],compute:function(){return{value:No.NotAvailable}},isExported:!0};var Qp=Object.freeze({__proto__:null,CELL:zp,ISBLANK:Xp,ISERR:$p,ISERROR:Gp,ISLOGICAL:Wp,ISNA:qp,ISNONTEXT:Zp,ISNUMBER:Yp,ISTEXT:jp,NA:Kp});function Jp(e){let t=!1,o=!0;return bs(e,(e=>(t=!0,o=o&&e,o))),{foundBoolean:t,result:o}}function em(e){let t=!1,o=!1;return bs(e,(e=>(t=!0,o=o||e,!o))),{foundBoolean:t,result:o}}const tm={description:uo("Logical `and` operator."),args:[$l("logical_expression1 (boolean, range<boolean>)",uo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),$l("logical_expression2 (boolean, range<boolean>, repeating)",uo("More expressions that represent logical values."))],returns:["BOOLEAN"],compute:function(...e){const{result:t,foundBoolean:o}=Jp(e);return $o((()=>o),uo("[[FUNCTION_NAME]] has no valid input data.")),t},isExported:!0},om={description:uo("Logical value `false`."),args:[],returns:["BOOLEAN"],compute:function(){return!1},isExported:!0},sm={description:uo("Returns value depending on logical expression."),args:[$l("logical_expression (boolean)",uo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")),$l("value_if_true (any)",uo("The value the function returns if logical_expression is TRUE.")),$l("value_if_false (any, default=FALSE)",uo("The value the function returns if logical_expression is FALSE."))],returns:["ANY"],compute:function(e,t,o){const s=is(e?.value)?t:o;return void 0===s?{value:""}:(null===s.value&&(s.value=""),s)},isExported:!0},im={description:uo("Value if it is not an error, otherwise 2nd argument."),args:[$l("value (any)",uo("The value to return if value itself is not an error.")),$l('value_if_error (any, default="empty")',uo("The value the function returns if value is an error."))],returns:["ANY"],compute:function(e,t={value:""}){const o=Wo(e?.value)?t:e;return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)},isExported:!0},nm={description:uo("Value if it is not an #N/A error, otherwise 2nd argument."),args:[$l("value (any)",uo("The value to return if value itself is not #N/A an error.")),$l('value_if_error (any, default="empty")',uo("The value the function returns if value is an #N/A error."))],returns:["ANY"],compute:function(e,t={value:""}){const o=e?.value===No.NotAvailable?t:e;return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)},isExported:!0},rm={description:uo("Returns a value depending on multiple logical expressions."),args:[$l("condition1 (boolean)",uo("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")),$l("value1 (any)",uo("The returned value if condition1 is TRUE.")),$l("condition2 (boolean, repeating)",uo("Additional conditions to be evaluated if the previous ones are FALSE.")),$l("value2 (any, repeating)",uo("Additional values to be returned if their corresponding conditions are TRUE."))],returns:["ANY"],compute:function(...e){$o((()=>e.length%2==0),uo("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(is(e[t]?.value)){const o=e[t+1];return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)}throw new Lo(uo("No match."))},isExported:!0},am={description:uo("Returns opposite of provided logical value."),args:[$l("logical_expression (boolean)",uo("An expression or reference to a cell holding an expression that represents some logical value."))],returns:["BOOLEAN"],compute:function(e){return!is(e)},isExported:!0},lm={description:uo("Logical `or` operator."),args:[$l("logical_expression1 (boolean, range<boolean>)",uo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),$l("logical_expression2 (boolean, range<boolean>, repeating)",uo("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){const{result:t,foundBoolean:o}=em(e);return $o((()=>o),uo("[[FUNCTION_NAME]] has no valid input data.")),t},isExported:!0},cm={description:uo("Logical value `true`."),args:[],returns:["BOOLEAN"],compute:function(){return!0},isExported:!0},hm={description:uo("Logical `xor` operator."),args:[$l("logical_expression1 (boolean, range<boolean>)",uo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),$l("logical_expression2 (boolean, range<boolean>, repeating)",uo("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return bs(e,(e=>(t=!0,o=o?!e:e,!0))),$o((()=>t),uo("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0};var dm=Object.freeze({__proto__:null,AND:tm,FALSE:om,IF:sm,IFERROR:im,IFNA:nm,IFS:rm,NOT:am,OR:lm,TRUE:cm,XOR:hm});const um=new zn;function gm(e,t){const o=t.getPivotId(e);if(!o)throw new Lo(uo('There is no pivot with id "%s"',e));return o}function pm(e){if(e.length%2!=0)throw new Lo(uo("Function PIVOT takes an even number of arguments."))}function mm(e,t){if("SPREADSHEET"!==t.type||!t.dataSet)return;const{sheetId:o,zone:s}=t.dataSet;let i;const n=e.__originSheetId,r=e.__originCellXC?.();if(r){const t=Li(r);i={sheetId:n,col:t.left,row:t.top},e.updateDependencies?.(i)}const a=Ui(s),l=e.getters.getRangeFromSheetXC(o,a);if(void 0===l||l.invalidXc||l.invalidSheetName)throw new Vo;i&&e.addDependencies?.(i,[l])}um.add("SPREADSHEET",!1);const fm=!0;function bm(e){return{value:No.NotAvailable,message:uo("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ts(e))}}const vm={description:uo("Returns a cell reference as a string. "),args:[$l("row (number)",uo("The row number of the cell reference. ")),$l("column (number)",uo("The column number (not name) of the cell reference. A is column number 1. ")),$l("absolute_relative_mode (number, default=1)",uo("An indicator of whether the reference is row/column absolute. 1 is row and column absolute (e.g. $A$1), 2 is row absolute and column relative (e.g. A$1), 3 is row relative and column absolute (e.g. $A1), and 4 is row and column relative (e.g. A1).")),$l("use_a1_notation (boolean, default=TRUE)",uo("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).")),$l("sheet (string, optional)",uo("A string indicating the name of the sheet into which the address points."))],returns:["STRING"],compute:function(e,t,o={value:1},s={value:!0},i){const n=Qo(e,this.locale),r=Qo(t,this.locale);Jo(n),Jo(r);const a=Qo(o,this.locale);var l,c;$o((()=>[1,2,3,4].includes(a)),(l=4,c=a,uo("The function [[FUNCTION_NAME]] expects a number value between %s and %s inclusive, but receives %s.",1..toString(),l.toString(),c.toString())));let h;if(is(s)){h=Tt(r-1,n-1,{rowFixed:!![1,2].includes(a),colFixed:!![1,3].includes(a)})}else{h=([1,2].includes(a)?`R${n}`:`R[${n}]`)+([1,3].includes(a)?`C${r}`:`C[${r}]`)}return void 0!==i?Ai(ts(i),h):h},isExported:!0},Sm={description:uo("Column number of a specified cell."),args:[$l("cell_reference (meta, default='this cell')",uo("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."))],returns:["NUMBER"],compute:function(e){if(Wo(e?.value))throw e;const t=void 0===e?this.__originCellXC?.():e.value;$o((()=>!!t),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Li(t).left+1},isExported:!0},Cm={description:uo("Number of columns in a specified array or range."),args:[$l("range (meta)",uo("The range whose column count will be returned."))],returns:["NUMBER"],compute:function(e){if(Wo(e?.value))throw e;const t=Li(e.value);return t.right-t.left+1},isExported:!0},ym={description:uo("Horizontal lookup"),args:[$l("search_key (any)",uo("The value to search for. For example, 42, 'Cats', or I24.")),$l("range (range)",uo("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")),$l("index (number)",uo("The row index of the value to be returned, where the first row in range is numbered 1.")),$l("is_sorted (boolean, default=true)",uo("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."))],returns:["ANY"],compute:function(e,t,o,s={value:fm}){const i=Math.trunc(Zo(o?.value,this.locale));if($o((()=>1<=i&&i<=t[0].length),uo("[[FUNCTION_NAME]] evaluates to an out of bounds range.")),e&&Wo(e.value))return e;const n=(e,t)=>e[t][0].value,r=is(s.value)?Es(t,e,"nextSmaller","asc",t.length,n):xs(t,e,"wildcard",t.length,n),a=t[r];return void 0===a?bm(e):a[i-1]},isExported:!0},Em={description:uo("Returns the content of a cell, specified by row and column offset."),args:[$l("reference (any, range)",uo("The range of cells from which the values are returned.")),$l("row (number, default=0)",uo("The index of the row to be returned from within the reference range of cells.")),$l("column (number, default=0)",uo("The index of the column to be returned from within the reference range of cells."))],returns:["ANY"],compute:function(e,t={value:0},o={value:0}){const s=Rs(e),i=Zo(t.value,this.locale),n=Zo(o.value,this.locale);return $o((()=>n>=0&&n-1<s.length&&i>=0&&i-1<s[0].length),uo("Index out of range.")),0===i&&0===n?s:0===i?[s[n-1]]:0===n?s.map((e=>[e[i-1]])):s[n-1][i-1]},isExported:!0},xm={description:uo("Returns the content of a cell, specified by a string."),args:[$l("reference (string)",uo("The range of cells from which the values are returned.")),$l("use_a1_notation (boolean, default=TRUE)",uo("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE)."))],returns:["ANY"],compute:function(e,t={value:!0}){let o=e?.value?.toString();if(!o)throw new Vo(uo("Reference should be defined."));if(!is(t))throw new Lo(uo("R1C1 notation is not supported."));const s=this.__originSheetId;let i;const n=this.__originCellXC?.();if(n){const e=Li(n);i={sheetId:s,col:e.left,row:e.top},this.updateDependencies?.(i)}const r=this.getters.getRangeFromSheetXC(s,o);if(void 0===r||r.invalidXc||r.invalidSheetName)throw new Vo;i&&this.addDependencies?.(i,[r]);const a=[];for(let e=r.zone.left;e<=r.zone.right;e++){const t=[];for(let o=r.zone.top;o<=r.zone.bottom;o++){const s={sheetId:r.sheetId,col:e,row:o};t.push(this.getters.getEvaluatedCell(s))}a.push(t)}return 1===a.length&&1===a[0].length?a[0][0]:a},isExported:!0},wm={description:uo("Look up a value."),args:[$l("search_key (any)",uo("The value to search for. For example, 42, 'Cats', or I24.")),$l("search_array (range)",uo("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.")),$l("result_range (range, optional)",uo("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."))],returns:["ANY"],compute:function(e,t,o){let s=t.length,i=t[0].length;const n=i>=s,r=n?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,a=Es(t,e,"nextSmaller","asc",n?i:s,r);return-1===a||n&&void 0===t[0][a]||!n&&void 0===t[a][i-1]?bm(e):void 0===o?n?t[s-1][a]:t[a][i-1]:(s=o.length,i=o[0].length,$o((()=>1===s||1===i),uo("The result_range must be a single row or a single column.")),s>1?($o((()=>a<=s-1),uo("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(a+1).toString())),o[a][0]):($o((()=>a<=i-1),uo("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(a+1).toString())),o[0][a]))},isExported:!0},Im={description:uo("Position of item in range that matches value."),args:[$l("search_key (any)",uo("The value to search for. For example, 42, 'Cats', or I24.")),$l("range (any, range)",uo("The one-dimensional array to be searched.")),$l("search_type (number, default=1)",uo("The search method. 1 (default) finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order."))],returns:["NUMBER"],compute:function(e,t,o={value:1}){let s=Zo(o,this.locale);const i=t.length,n=t[0].length;$o((()=>1===i||1===n),uo("The range must be a single row or a single column."));let r=-1;const a=1===i?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,l=1===i?t[0].length:t.length;switch(s=Math.sign(s),s){case 1:r=Es(t,e,"nextSmaller","asc",l,a);break;case 0:r=xs(t,e,"wildcard",l,a);break;case-1:r=Es(t,e,"nextGreater","desc",l,a)}return 1===i&&void 0===t[0][r]||1!==i&&void 0===t[r]?bm(e):r+1},isExported:!0},Rm={description:uo("Row number of a specified cell."),args:[$l("cell_reference (meta, default='this cell')",uo("The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered."))],returns:["NUMBER"],compute:function(e){if(Wo(e?.value))throw e;const t=void 0===e?this.__originCellXC?.():e.value;$o((()=>!!t),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Li(t).top+1},isExported:!0},Tm={description:uo("Number of rows in a specified array or range."),args:[$l("range (meta)",uo("The range whose row count will be returned."))],returns:["NUMBER"],compute:function(e){if(Wo(e?.value))throw e;const t=Li(e.value);return t.bottom-t.top+1},isExported:!0},Am={description:uo("Vertical lookup."),args:[$l("search_key (any)",uo("The value to search for. For example, 42, 'Cats', or I24.")),$l("range (any, range)",uo("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")),$l("index (number)",uo("The column index of the value to be returned, where the first column in range is numbered 1.")),$l("is_sorted (boolean, default=true)",uo("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."))],returns:["ANY"],compute:function(e,t,o,s={value:fm}){const i=Math.trunc(Zo(o?.value,this.locale));if($o((()=>1<=i&&i<=t.length),uo("[[FUNCTION_NAME]] evaluates to an out of bounds range.")),e&&Wo(e.value))return e;const n=(e,t)=>e[0][t].value,r=is(s.value)?Es(t,e,"nextSmaller","asc",t[0].length,n):xs(t,e,"wildcard",t[0].length,n),a=t[i-1][r];return void 0===a?bm(e):a},isExported:!0},Om={0:"strict",1:"nextGreater","-1":"nextSmaller",2:"wildcard"},_m={description:uo("Search a range for a match and return the corresponding item from a second range."),args:[$l("search_key (any)",uo("The value to search for.")),$l("lookup_range (any, range)",uo("The range to consider for the search. Should be a single column or a single row.")),$l("return_range (any, range)",uo("The range containing the return value. Should have the same dimensions as lookup_range.")),$l("if_not_found (any, optional)",uo("If a valid match is not found, return this value.")),$l("match_mode (any, default=0)",uo("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match. (2) Wildcard match.")),$l("search_mode (any, default=1)",uo("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. "))],returns:["ANY"],compute:function(e,t,o,s,i={value:0},n={value:1}){const r=Math.trunc(Zo(i.value,this.locale)),a=Math.trunc(Zo(n.value,this.locale));$o((()=>1===t.length||1===t[0].length),uo("lookup_range should be either a single row or single column.")),$o((()=>[-1,1,-2,2].includes(a)),uo("search_mode should be a value in [-1, 1, -2, 2].")),$o((()=>[-1,0,1,2].includes(r)),uo("match_mode should be a value in [-1, 0, 1, 2]."));const l=1===t.length?"col":"row";if($o((()=>!(2===r&&[-2,2].includes(a))),uo("the search and match mode combination is not supported for XLOOKUP evaluation.")),$o((()=>"col"===l?o[0].length===t[0].length:o.length===t.length),uo("return_range should have the same dimensions as lookup_range.")),e&&Wo(e.value))return[[e]];const c="col"===l?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,h="col"===l?t[0].length:t.length,d=Om[r],u=-1===a,g=2===a||-2===a?Es(t,e,d,2===a?"asc":"desc",h,c):xs(t,e,d,h,c,u);return-1!==g?"col"===l?o.map((e=>[e[g]])):[o[g]]:void 0===s?bm(e):[[s]]},isExported:!0},Dm={description:uo("Get the value from a pivot."),args:[$l("pivot_id (string)",uo("ID of the pivot.")),$l("measure_name (string)",uo("Name of the measure.")),$l("domain_field_name (string,optional,repeating)",uo("Field name.")),$l("domain_value (string,optional,repeating)",uo("Value."))],compute:function(e,t,...o){const s=ts(e),i=ts(t),n=o.map(ts),r=gm(s,this.getters);!function(e,t,o){const{measures:s}=o.getPivotCoreDefinition(e);if(!s.find((e=>e.name===t))){const e=`(${s.map((e=>e.name)).join(", ")})`;throw new Lo(uo("The argument %s is not a valid measure. Here are the measures: %s",t,e))}}(r,i,this.getters),pm(n);const a=this.getters.getPivot(r),l=this.getters.getPivotCoreDefinition(r);if(!um.get(l.type))return{value:No.GenericError,message:uo("This pivot does not support PIVOT.VALUE formula")};mm(this,l);const c=a.assertIsValid({throwOnError:!1});if(c)return c;const{value:h,format:d}=a.getPivotCellValueAndFormat(i,n);return h||this.getters.areDomainArgsFieldsValid(r,n)?{value:h,format:d}:{value:No.GenericError,message:uo("Dimensions don't match the pivot definition")}},returns:["NUMBER","STRING"]},Mm={description:uo("Get the header of a pivot."),args:[$l("pivot_id (string)",uo("ID of the pivot.")),$l("domain_field_name (string,optional,repeating)",uo("Field name.")),$l("domain_value (string,optional,repeating)",uo("Value."))],compute:function(e,...t){const o=ts(e),s=t.map(ts),i=gm(o,this.getters);pm(s);const n=this.getters.getPivot(i),r=this.getters.getPivotCoreDefinition(i);if(!um.get(r.type))return{value:No.GenericError,message:uo("This pivot does not support PIVOT.VALUE formula")};mm(this,r);const a=n.assertIsValid({throwOnError:!1});if(a)return a;const l=s.at(-2),c=s.at(-1);if(!this.getters.areDomainArgsFieldsValid(i,"measure"===l?s.slice(0,-2):s))return{value:No.GenericError,message:uo("Dimensions don't match the pivot definition")};const{value:h,format:d}=n.getPivotHeaderValueAndFormat(s);return{value:h,format:l&&"measure"!==l&&"false"!==c?d:void 0}},returns:["NUMBER","STRING"]},Fm={description:uo("Get a pivot table."),args:[$l("pivot_id (string)",uo("ID of the pivot.")),$l("row_count (number, optional, default=10000)",uo("number of rows")),$l("include_total (boolean, default=TRUE)",uo("Whether to include total/sub-totals or not.")),$l("include_column_titles (boolean, default=TRUE)",uo("Whether to include the column titles or not."))],compute:function(e,t={value:1e4},o={value:!0},s={value:!0}){const i=gm(ts(e),this.getters),n=this.getters.getPivot(i);mm(this,this.getters.getPivotCoreDefinition(i)),n.init({reload:n.needsReevaluation});const r=n.assertIsValid({throwOnError:!1});if(r)return r;const a=n.getTableStructure(),l=is(s),c=a.getPivotCells(is(o),l),h=l?a.columns.length:0,d=this.getters.getPivotDisplayName(i),u=Zo(t,this.locale);if(u<0)throw new Lo(uo("The number of rows must be positive."));const g=Math.min(h+u,c[0].length);if(0===g)return[[{value:d}]];const p=c.length,m=ve(0,g),f=[];for(const e of ve(0,p)){f[e]=[];for(const t of m){const o=c[e][t];if(o.domain)if(o.isHeader)f[e].push(n.getPivotHeaderValueAndFormat(o.domain));else{if(!o.measure)throw new Error("Measure is missing");f[e].push(n.getPivotCellValueAndFormat(o.measure,o.domain))}else f[e].push({value:"",format:void 0})}}return l&&(f[0][0]={value:d}),f},returns:["RANGE<ANY>"]};var Nm=Object.freeze({__proto__:null,ADDRESS:vm,COLUMN:Sm,COLUMNS:Cm,HLOOKUP:ym,INDEX:Em,INDIRECT:xm,LOOKUP:wm,MATCH:Im,PIVOT:Fm,PIVOT_HEADER:Mm,PIVOT_VALUE:Dm,ROW:Rm,ROWS:Tm,VLOOKUP:Am,XLOOKUP:_m});const Pm={description:uo("Sum of two numbers."),args:[$l("value1 (number)",uo("The first addend.")),$l("value2 (number)",uo("The second addend."))],returns:["NUMBER"],compute:function(e,t){return{value:Zo(e,this.locale)+Zo(t,this.locale),format:e?.format||t?.format}}},Lm={description:uo("Concatenation of two values."),args:[$l("value1 (string)",uo("The value to which value2 will be appended.")),$l("value2 (string)",uo("The value to append to value1."))],returns:["STRING"],compute:function(e,t){return ts(e)+ts(t)},isExported:!0},km={description:uo("One number divided by another."),args:[$l("dividend (number)",uo("The number to be divided.")),$l("divisor (number)",uo("The number to divide by."))],returns:["NUMBER"],compute:function(e,t){const o=Zo(t,this.locale);return $o((()=>0!==o),uo("The divisor must be different from zero."),No.DivisionByZero),{value:Zo(e,this.locale)/o,format:e?.format||t?.format}}};function Vm(e){return void 0===e||null===e.value}const Um={number:0,string:"",boolean:!1},Bm={description:uo("Equal."),args:[$l("value1 (any)",uo("The first value.")),$l("value2 (any)",uo("The value to test against value1 for equality."))],returns:["BOOLEAN"],compute:function(e,t){let o=Vm(e)?Um[typeof t?.value]:e?.value,s=Vm(t)?Um[typeof e?.value]:t?.value;if("string"==typeof o&&(o=o.toUpperCase()),"string"==typeof s&&(s=s.toUpperCase()),Wo(o))throw e;if(Wo(s))throw t;return o===s}};function Hm(e,t,o){let s=Vm(e)?Um[typeof t?.value]:e?.value,i=Vm(t)?Um[typeof e?.value]:t?.value;if(Wo(s))throw e;if(Wo(i))throw t;"number"!=typeof s&&(s=ts(s).toUpperCase()),"number"!=typeof i&&(i=ts(i).toUpperCase());const n=typeof s,r=typeof i;return"string"===n&&"number"===r||("string"!==r||"number"!==n)&&o(s,i)}const zm={description:uo("Strictly greater than."),args:[$l("value1 (any)",uo("The value to test as being greater than value2.")),$l("value2 (any)",uo("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return Hm(e,t,((e,t)=>e>t))}},$m={description:uo("Greater than or equal to."),args:[$l("value1 (any)",uo("The value to test as being greater than or equal to value2.")),$l("value2 (any)",uo("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return Hm(e,t,((e,t)=>e>=t))}},Gm={description:uo("Less than."),args:[$l("value1 (any)",uo("The value to test as being less than value2.")),$l("value2 (any)",uo("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!$m.compute.bind(this)(e,t)}},Wm={description:uo("Less than or equal to."),args:[$l("value1 (any)",uo("The value to test as being less than or equal to value2.")),$l("value2 (any)",uo("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!zm.compute.bind(this)(e,t)}},qm={description:uo("Difference of two numbers."),args:[$l("value1 (number)",uo("The minuend, or number to be subtracted from.")),$l("value2 (number)",uo("The subtrahend, or number to subtract from value1."))],returns:["NUMBER"],compute:function(e,t){return{value:Zo(e,this.locale)-Zo(t,this.locale),format:e?.format||t?.format}}},Zm={description:uo("Product of two numbers"),args:[$l("factor1 (number)",uo("The first multiplicand.")),$l("factor2 (number)",uo("The second multiplicand."))],returns:["NUMBER"],compute:function(e,t){return{value:Zo(e,this.locale)*Zo(t,this.locale),format:e?.format||t?.format}}},Ym={description:uo("Not equal."),args:[$l("value1 (any)",uo("The first value.")),$l("value2 (any)",uo("The value to test against value1 for inequality."))],returns:["BOOLEAN"],compute:function(e,t){return!Bm.compute.bind(this)(e,t)}},jm={description:uo("A number raised to a power."),args:[$l("base (number)",uo("The number to raise to the exponent power.")),$l("exponent (number)",uo("The exponent to raise base to."))],returns:["NUMBER"],compute:function(e,t){return bh.compute.bind(this)(e,t)}},Xm={description:uo("A number with the sign reversed."),args:[$l("value (number)",uo("The number to have its sign reversed. Equivalently, the number to multiply by -1."))],returns:["NUMBER"],compute:function(e){return{value:-Zo(e,this.locale),format:e?.format}}},Km={description:uo("Value interpreted as a percentage."),args:[$l("percentage (number)",uo("The value to interpret as a percentage."))],returns:["NUMBER"],compute:function(e){return Zo(e,this.locale)/100}},Qm={description:uo("A specified number, unchanged."),args:[$l("value (any)",uo("The number to return."))],returns:["ANY"],compute:function(e={value:null}){return e}};var Jm=Object.freeze({__proto__:null,ADD:Pm,CONCAT:Lm,DIVIDE:km,EQ:Bm,GT:zm,GTE:$m,LT:Gm,LTE:Wm,MINUS:qm,MULTIPLY:Zm,NE:Ym,POW:jm,UMINUS:Xm,UNARY_PERCENT:Km,UPLUS:Qm});const ef=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,tf={description:uo("Gets character associated with number."),args:[$l("table_number (number)",uo("The number of the character to look up from the current Unicode table in decimal format."))],returns:["STRING"],compute:function(e){const t=Math.trunc(Zo(e,this.locale));return $o((()=>t>=1),uo("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},of={description:uo("Remove non-printable characters from a piece of text."),args:[$l("text (string)",uo("The text whose non-printable characters are to be removed."))],returns:["STRING"],compute:function(e){const t=ts(e);let o="";for(const e of t)e&&e.charCodeAt(0)>31&&(o+=e);return o},isExported:!0},sf={description:uo("Appends strings to one another."),args:[$l("string1 (string, range<string>)",uo("The initial string.")),$l("string2 (string, range<string>, repeating)",uo("More strings to append in sequence."))],returns:["STRING"],compute:function(...e){return ds(e,((e,t)=>e+ts(t)),"")},isExported:!0},nf={description:uo("Tests whether two strings are identical."),args:[$l("string1 (string)",uo("The first string to compare.")),$l("string2 (string)",uo("The second string to compare."))],returns:["BOOLEAN"],compute:function(e,t){return ts(e)===ts(t)},isExported:!0},rf={description:uo("First position of string found in text, case-sensitive."),args:[$l("search_for (string)",uo("The string to look for within text_to_search.")),$l("text_to_search (string)",uo("The text to search for the first occurrence of search_for.")),$l("starting_at (number, default=1)",uo("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,o={value:1}){const s=ts(e),i=ts(t),n=Zo(o,this.locale);$o((()=>""!==i),uo("The text_to_search must be non-empty.")),$o((()=>n>=1),uo("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const r=i.indexOf(s,n-1);return $o((()=>r>=0),uo("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",s.toString(),i)),r+1},isExported:!0},af={description:uo("Concatenates elements of arrays with delimiter."),args:[$l("delimiter (string)",uo("The character or string to place between each concatenated value.")),$l("value_or_array1 (string, range<string>)",uo("The value or values to be appended using delimiter.")),$l("value_or_array2 (string, range<string>, repeating)",uo("More values to be appended using delimiter."))],returns:["STRING"],compute:function(e,...t){const o=ts(e);return ds(t,((e,t)=>(e?e+o:"")+ts(t)),"")}},lf={description:uo("Substring from beginning of specified string."),args:[$l("text (string)",uo("The string from which the left portion will be returned.")),$l("number_of_characters (number, optional)",uo("The number of characters to return from the left side of string."))],returns:["STRING"],compute:function(e,...t){const o=t.length?Zo(t[0],this.locale):1;return $o((()=>o>=0),uo("The number_of_characters (%s) must be positive or null.",o.toString())),ts(e).substring(0,o)},isExported:!0},cf={description:uo("Length of a string."),args:[$l("text (string)",uo("The string whose length will be returned."))],returns:["NUMBER"],compute:function(e){return ts(e).length},isExported:!0},hf={description:uo("Converts a specified string to lowercase."),args:[$l("text (string)",uo("The string to convert to lowercase."))],returns:["STRING"],compute:function(e){return ts(e).toLowerCase()},isExported:!0},df={description:uo("A segment of a string."),args:[$l("text (string)",uo("The string to extract a segment from.")),$l("starting_at (number)",uo("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),$l("extract_length (number)",uo("The length of the segment to extract."))],returns:["STRING"],compute:function(e,t,o){const s=ts(e),i=Zo(t,this.locale),n=Zo(o,this.locale);return $o((()=>i>=1),uo("The starting_at argument (%s) must be positive greater than one.",i.toString())),$o((()=>n>=0),uo("The extract_length argument (%s) must be positive or null.",n.toString())),s.slice(i-1,i+n-1)},isExported:!0},uf={description:uo("Capitalizes each word in a specified string."),args:[$l("text_to_capitalize (string)",uo("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase."))],returns:["STRING"],compute:function(e){return ts(e).replace(ef,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},gf={description:uo("Replaces part of a text string with different text."),args:[$l("text (string)",uo("The text, a part of which will be replaced.")),$l("position (number)",uo("The position where the replacement will begin (starting from 1).")),$l("length (number)",uo("The number of characters in the text to be replaced.")),$l("new_text (string)",uo("The text which will be inserted into the original text."))],returns:["STRING"],compute:function(e,t,o,s){const i=Zo(t,this.locale);$o((()=>i>=1),uo("The position (%s) must be greater than or equal to 1.",i.toString()));const n=ts(e),r=Zo(o,this.locale),a=ts(s);return n.substring(0,i-1)+a+n.substring(i-1+r)},isExported:!0},pf={description:uo("A substring from the end of a specified string."),args:[$l("text (string)",uo("The string from which the right portion will be returned.")),$l("number_of_characters (number, optional)",uo("The number of characters to return from the right side of string."))],returns:["STRING"],compute:function(e,...t){const o=t.length?Zo(t[0],this.locale):1;$o((()=>o>=0),uo("The number_of_characters (%s) must be positive or null.",o.toString()));const s=ts(e),i=s.length;return s.substring(i-o,i)},isExported:!0},mf={description:uo("First position of string found in text, ignoring case."),args:[$l("search_for (string)",uo("The string to look for within text_to_search.")),$l("text_to_search (string)",uo("The text to search for the first occurrence of search_for.")),$l("starting_at (number, default=1)",uo("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,o={value:1}){const s=ts(e).toLowerCase(),i=ts(t).toLowerCase(),n=Zo(o,this.locale);$o((()=>""!==i),uo("The text_to_search must be non-empty.")),$o((()=>n>=1),uo("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const r=i.indexOf(s,n-1);return $o((()=>r>=0),uo("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",s,i)),r+1},isExported:!0},ff={description:uo("Split text by specific character delimiter(s)."),args:[$l("text (string)",uo("The text to divide.")),$l("delimiter (string)",uo("The character or characters to use to split text.")),$l("split_by_each (boolean, default=true})",uo("Whether or not to divide text around each character contained in delimiter.")),$l("remove_empty_text (boolean, default=true)",uo("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."))],returns:["RANGE<STRING>"],compute:function(e,t,o={value:true},s={value:true}){const i=ts(e),n=ue(ts(t)),r=is(o),a=is(s);$o((()=>n.length>0),uo("The _delimiter (%s) must be not be empty.",n));const l=r?new RegExp(`[${n}]`,"g"):new RegExp(n,"g");let c=i.split(l);return a&&(c=c.filter((e=>""!==e))),fs([c])},isExported:!0},bf={description:uo("Replaces existing text with new text in a string."),args:[$l("text_to_search (string)",uo("The text within which to search and replace.")),$l("search_for (string)",uo("The string to search for within text_to_search.")),$l("replace_with (string)",uo("The string that will replace search_for.")),$l("occurrence_number (number, optional)",uo("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."))],returns:["NUMBER"],compute:function(e,t,o,s){const i=Zo(s,this.locale);$o((()=>i>=0),uo("The occurrenceNumber (%s) must be positive or null.",i.toString()));const n=ts(e),r=ts(t);if(""===r)return n;const a=ts(o),l=new RegExp(ue(r),"g");if(0===i)return n.replace(l,a);let c=0;return n.replace(l,(e=>++c===i?a:e))},isExported:!0},vf={description:uo("Combines text from multiple strings and/or arrays."),args:[$l("delimiter (string)",uo(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")),$l("ignore_empty (boolean)",uo("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")),$l("text1 (string, range<string>)",uo("Any text item. This could be a string, or an array of strings in a range.")),$l("text2 (string, range<string>, repeating)",uo("Additional text item(s)."))],returns:["STRING"],compute:function(e,t,...o){const s=ts(e),i=is(t);let n=0;return ds(o,((e,t)=>i&&""===ts(t)?e:(n++?e+s:"")+ts(t)),"")},isExported:!0},Sf={description:uo("Removes space characters."),args:[$l("text (string)",uo("The text or reference to a cell containing text to be trimmed."))],returns:["STRING"],compute:function(e){return Xe(ts(e))},isExported:!0},Cf={description:uo("Converts a specified string to uppercase."),args:[$l("text (string)",uo("The string to convert to uppercase."))],returns:["STRING"],compute:function(e){return ts(e).toUpperCase()},isExported:!0},yf={description:uo("Converts a number to text according to a specified format."),args:[$l("number (number)",uo("The number, date or time to format.")),$l("format (string)",uo("The pattern by which to format the number, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){return Hs(Zo(e,this.locale),{format:ts(t),locale:this.locale})},isExported:!0};var Ef=Object.freeze({__proto__:null,CHAR:tf,CLEAN:of,CONCATENATE:sf,EXACT:nf,FIND:rf,JOIN:af,LEFT:lf,LEN:cf,LOWER:hf,MID:df,PROPER:uf,REPLACE:gf,RIGHT:pf,SEARCH:mf,SPLIT:ff,SUBSTITUTE:bf,TEXT:yf,TEXTJOIN:vf,TRIM:Sf,UPPER:Cf});const xf={description:uo("Creates a hyperlink in a cell."),args:[$l("url (string)",uo("The full URL of the link enclosed in quotation marks.")),$l("link_label (string, optional)",uo("The text to display in the cell, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){const o=ts(e).trim(),s=ts(t)||o;return""===o?s:Ie(s,o)},isExported:!0};var wf=Object.freeze({__proto__:null,HYPERLINK:xf});const If=[{name:uo("Array"),functions:wc},{name:uo("Database"),functions:Su},{name:uo("Date"),functions:eg},{name:uo("Filter"),functions:dg},{name:uo("Financial"),functions:Bp},{name:uo("Info"),functions:Qp},{name:uo("Lookup"),functions:Nm},{name:uo("Logical"),functions:dm},{name:uo("Math"),functions:Vh},{name:uo("Misc"),functions:Rc},{name:uo("Operator"),functions:Jm},{name:uo("Statistical"),functions:iu},{name:uo("Text"),functions:Ef},{name:uo("Engineering"),functions:og},{name:uo("Web"),functions:wf}],Rf=/^[A-Z0-9\_\.]+$/;const Tf=uo("An unexpected error occurred. Submit a support ticket at odoo.com/help.");function Af(e){return void 0!==e?.message&&"string"==typeof e.message}function Of(e,t){e.message?.includes("[[FUNCTION_NAME]]")&&(e.message=e.message.replace("[[FUNCTION_NAME]]",t))}const _f=new class extends zn{mapping={};add(e,t){if(e=e.toUpperCase(),!Rf.test(e))throw new Error(uo("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const o=Gl(t);var s,i;return function(e){let t=!1,o=!1,s=!1;for(let i of e){if(i.type.includes("META")&&i.type.length>1)throw new Error(uo("Function ${name} has an argument that has been declared with more than one type whose type 'META'. The 'META' type can only be declared alone."));if(t&&!i.repeating)throw new Error(uo("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=o||t||s,n=!(i.optional||i.repeating||i.default);if(e&&n)throw new Error(uo("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=i.repeating,o=i.optional,s=i.default}}(o.args),this.mapping[e]=function(e,t){return function(...o){try{return e.apply(this,o)}catch(e){return function(e,t){if(o=e,void 0!==o?.value&&"string"==typeof o.value&&Wo(e.value))return Af(e)&&Of(e,t),e;var o;return console.error(e),new Lo(Tf+(Af(e)?" "+e.message:""))}(e,t)}}}((s=function(e){function t(...t){for(let o=0;o<t.length;o++){const s=e.args[e.getArgToFocus(o+1)-1],i=t[o];if(_o(i)&&!s.acceptMatrix){if(1!==i.length||1!==i[0].length)throw new Lo(uo("Function [[FUNCTION_NAME]] expects the parameter '%s' to be a single value or a single cell reference, not a range.",s.name));t[o]=i[0][0]}}return e.compute.apply(this,t)}return t}(o),i=e,function(...e){const t=s.apply(this,e);return _o(t)?"object"==typeof t[0][0]&&null!==t[0][0]&&"value"in t[0][0]?(function(e,t){const o=e.length,s=e[0]?.length??0;for(let i=0;i<o;i++)for(let o=0;o<s;o++)t(e[i][o])}(t,(e=>Of(e,i))),t):ms(t,(e=>({value:e}))):"object"==typeof t&&null!==t&&"value"in t?(Of(t,i),t):{value:t}}),e),super.add(e,o),this}};for(let e of If){const t=e.functions;for(let o in t){const s=t[o];s.category=s.category||e.name,o=o.replace(/_/g,"."),_f.add(o,{isExported:!1,...s})}}va.add("functions",{sequence:100,autoSelectFirstProposal:!0,maxDisplayedProposals:10,getProposals(e){if("SYMBOL"!==e.type)return[];const t=e.value,o=t.toUpperCase();if(!this.composer.currentContent.startsWith("=")||"TRUE"===o||"FALSE"===o)return[];const s=Object.entries(_f.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:o}])=>({text:e,description:o,htmlContent:Bl(t,e,E,"o-semi-bold")}))).sort(((e,t)=>e.text.length-t.text.length||e.text.localeCompare(t.text)));return s},selectProposal(e,t){let o=e.end,s=e.end;["SYMBOL","FUNCTION"].includes(e.type)&&(o=e.start);const i=this.composer.currentTokens;t+="(";const n=i.map((e=>e.start)).indexOf(e.start);if(n+1<i.length){const e=i[n+1];"LEFT_PAREN"===e?.type&&s++}this.composer.changeComposerCursorSelection(o,s),this.composer.replaceComposerCursorSelection(t)}});class Df{mutators=["setFocusableElement","focus"];focusableElement=void 0;setFocusableElement(e){this.focusableElement=e}focus(){this.focusableElement?.focus()}}const Mf={};let Ff=0;function Nf(e,...t){const o="__sheet__"+Ff++;return function(e,t){const o=document.createElement("style");o.textContent=function(e){const t=e.split(/(\{|\}|;)/).map((e=>e.trim())),o=[],s=[];let i=[];function n(e,t){const s=[];for(const i of o[e]){let r=t&&t+" "+i||i;r.includes("&")&&(r=i.replace(/&/g,t||"")),e<o.length-1&&(r=n(e+1,r)),s.push(r)}return s.join(", ")}function r(){i.length&&(s.push(n(0)+" {"),s.push(...i),s.push("}"),i=[])}for(;t.length;){let e=t.shift();"}"===e?(r(),o.pop()):("{"===t[0]&&(r(),o.push(e.split(/\s*,\s*/)),t.shift()),";"===t[0]&&i.push(" "+e+";"))}return s.join("\n")}(t),Mf[e]=o}(o,String.raw(e,...t)),function(e){const t=Mf[e];t.setAttribute("component",e),document.head.appendChild(t)}(o),o}function Pf({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function Lf(e){const t=function(e){const t={};if(!e)return t;e.bold&&(t["font-weight"]="bold");e.italic&&(t["font-style"]="italic");if(e.strikethrough||e.underline){let o=e.strikethrough?"line-through":"";o=e.underline?o+" underline":o,t["text-decoration"]=o}e.textColor&&(t.color=e.textColor);return t}(e);return e?(e.fillColor&&(t.background=e.fillColor),t):t}function kf(e){let t="";for(const o in e)e[o]&&(t+=`${o}:${e[o]}; `);return t}const Vf=/Mac/i,Uf=["Shift","Control","Alt","Meta"];function Bf(e,t){return!!t.target&&e.contains(t.target)}function Hf(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:o}=e?.getBoundingClientRect();return{top:t,left:o}}throw new Error("Can't find spreadsheet position")}function zf(e){const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}function*$f(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*$f(t)}const Gf=/^[a-zA-Z]$/;function Wf(e,t="key"){let o="";Uf.includes(e.key)||(Zf(e)&&(o+="Ctrl+"),e.altKey&&(o+="Alt+"),e.shiftKey&&(o+="Shift+"));const s="key"===t?e.key:e.code;return o+=Gf.test(s)?s.toUpperCase():s,o}function qf(){return Boolean(Vf.test(navigator.userAgent))}function Zf(e){return qf()?e.metaKey:e.ctrlKey}const Yf={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"};function jf(e,t){const o=Yf[e.key];e.shiftKey?t.resizeAnchorZone(o,Zf(e)?"end":1):t.moveAnchorCell(o,Zf(e)?"end":1)}Nf`
|
|
1
|
+
!function(e,t){"use strict";const o=.5,s="#37A850",i="#f5f5f5",n="#F8F9FA",r="#E8EAED",a="#595959",l="#666666",c="#c9ccd2",h="#3266ca",d="#FFFFFF",u="#EBEBEB",g="#CACACA",p=11982760,m="#017E84",f="#188038",b="#E0E2E4",v="#4A4F59",S="#999",C="#E2E3E3",y="#BCBCBC",E="#9B359B",x="#006FBE",w="#E40000",I="#AAAAAA",R=20,T=22,A=["#000000","#434343","#666666","#999999","#B7B7B7","#CCCCCC","#D9D9D9","#EFEFEF","#F3F3F3","#FFFFFF","#980000","#FF0000","#FF9900","#FFFF00","#00FF00","#00FFFF","#4A86E8","#0000FF","#9900FF","#FF00FF","#E6B8AF","#F4CCCC","#FCE5CD","#FFF2CC","#D9EAD3","#D0E0E3","#C9DAF8","#CFE2F3","#D9D2E9","#EAD1DC","#DD7E6B","#EA9999","#F9CB9C","#FFE599","#B6D7A8","#A2C4C9","#A4C2F4","#9FC5E8","#B4A7D6","#D5A6BD","#CC4125","#E06666","#F6B26B","#FFD966","#93C47D","#76A5AF","#6D9EEB","#6FA8DC","#8E7CC3","#C27BA0","#A61C00","#CC0000","#E69138","#F1C232","#6AA84F","#45818E","#3C78D8","#3D85C6","#674EA7","#A64D79","#85200C","#990000","#B45F06","#BF9000","#38761D","#134F5C","#1155CC","#0B5394","#351C75","#741B47","#5B0F00","#660000","#783F04","#7F6000","#274E13","#0C343D","#1C4587","#073763","#20124D","#4C1130"],O=26,_=48,D=96,M=23,F=15,N=4,P=N,L=21,k=17,V=2*M,U=250,B={align:"left",verticalAlign:"bottom",wrapping:"overflow",bold:!1,italic:!1,strikethrough:!1,underline:!1,fontSize:10,fillColor:"",textColor:"#000000"},H=B.verticalAlign,z=B.wrapping,$="400",G=B.fontSize,W="'Roboto', arial",q="thin",Z="#000000",Y="START_REVISION",j=1,X=20,K="??",Q="difference",J="#6AA84F",ee="#E06666",te=.4,oe=["'","*","?","/","\\","[","]"],se=/'|\*|\?|\/|\\|\[|\]/,ie="|";var ne;!function(e){e[e.Grid=0]="Grid",e[e.Highlight=5]="Highlight",e[e.HeaderGroupingButton=6]="HeaderGroupingButton",e[e.Figure=10]="Figure",e[e.ScrollBar=15]="ScrollBar",e[e.GridPopover=19]="GridPopover",e[e.GridComposer=20]="GridComposer",e[e.Dropdown=21]="Dropdown",e[e.IconPicker=25]="IconPicker",e[e.TopBarComposer=30]="TopBarComposer",e[e.Popover=35]="Popover",e[e.FigureAnchor=1e3]="FigureAnchor",e[e.FigureSnapLine=1001]="FigureSnapLine"}(ne||(ne={}));let re=0;function ae(){return re}const le="\n",ce=[6,7,8,9,10,11,12,14,18,24,36],he={hasFilters:!1,totalRow:!1,firstColumn:!0,lastColumn:!1,numberOfHeaders:1,bandedRows:!0,bandedColumns:!1,styleId:"TableStyleMedium5"};function de(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function ue(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ge(e){const t=Array.isArray(e)?[]:{};switch(typeof e){case"object":if(null===e)return e;if(function(e){return"clone"in e&&e.clone instanceof Function}(e))return e.clone();if(!(function(e){return"object"==typeof e&&e?.constructor===Object}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");for(const o in e)t[o]=ge(e[o]);return t;case"number":case"string":case"boolean":case"function":case"undefined":return e;default:throw new Error("Unsupported type: "+typeof e)}}function pe(e){return me(e,"'")}function me(e,t='"'){return e.startsWith(t)&&(e=e.slice(1)),e.endsWith(t)&&(e=e.slice(0,-1)),e}function fe(e){return e.match(/\w/g)?.length!==e.length&&(e=`'${e}'`),e}function be(e,t,o){return e<t?t:e>o?o:e}function ve(e,t,o=1){if(t<=e&&o>0)return[];if(0===o)throw new Error("range() step must not be zero");const s=Math.ceil(Math.abs((t-e)/o)),i=Array(s);for(let t=0;t<s;t++)i[t]=e+t*o;return i}function Se(e){return e.reduce(((e,t,o,s)=>{if(1===Math.abs(t-s[o-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*Ce(e,t){t.next();for(const o of e){const e=t.next();yield{...o,next:e.done?void 0:e.value}}}const ye=/^\[(.+)\]\((.+)\)$/,Ee=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function xe(e){return ye.test(e)}function we(e){return Ee.test(e)}function Ie(e,t){return`[${e}](${t})`}function Re(e){const t=e.match(ye)||[],o=t[1],s=t[2];if(!o||!s)throw new Error(`Could not parse markdown link ${e}.`);return{label:o,url:s}}const Te="o-spreadsheet://";function Ae(e){return e.startsWith(Te)}function Oe(e){return`${Te}${e}`}function _e(e){if(e.startsWith(Te))return e.substr(Te.length);throw new Error(`${e} is not a valid sheet link`)}function De(e){return void 0!==e}function Me(e){return null!==e}function Fe(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?Fe(e):!e))}function Ne(e,t){for(const o in t)if(Be(t[o],e))return parseInt(o,10);const o=Object.keys(t),s=0===o.length?0:Je(o.map((e=>parseInt(e,10))));return t[s+1]=e,s+1}function Pe(e,t,o){let s;const i=function(){const i=this,n=Array.from(arguments);const r=o&&!s;clearTimeout(s),s=setTimeout((function(){s=void 0,o||e.apply(i,n)}),t),r&&e.apply(i,n)};return i.isDebouncePending=()=>void 0!==s,i.stopDebounce=()=>{clearTimeout(s)},i}function Le(e){let t="";for(let o=0,s=e.length;o<s;o++)t+=e[o];return t}function ke(e){let t,o=!1;const s=()=>(o||(t=e instanceof Function?e():e,o=!0),t);return s.map=e=>ke((()=>e(s()))),s}function Ve(e,t){let o=e.slice(t).find((e=>e));return o||(o=e.slice(0,t).reverse().find((e=>e))),o||""}function Ue(e,t){return"after"===e?t+1:t}function Be(e,t,o){if(e===t)return!0;if(e&&!t||t&&!e)return!1;if(typeof e!=typeof t)return!1;if("object"!=typeof e)return!1;for(const o in t)if(!(o in e)&&void 0!==t[o])return!1;for(const s in e){const i=typeof e[s];if(i!==typeof t[s])return!1;if("object"===i){if(!Be(e[s],t[s],o))return!1}else{if(o&&"function"===i)continue;if(e[s]!==t[s])return!1}}return!0}function He(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(!Be(e[o],t[o]))return!1;return!0}function ze(e,t){return t.every((t=>e.includes(t)))}function $e(e){if(!e)return e;const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}const Ge=["\t","\f","\v",String.fromCharCode(parseInt("00a0",16)),String.fromCharCode(parseInt("1680",16)),String.fromCharCode(parseInt("2000",16)),String.fromCharCode(parseInt("200a",16)),String.fromCharCode(parseInt("2028",16)),String.fromCharCode(parseInt("2029",16)),String.fromCharCode(parseInt("202f",16)),String.fromCharCode(parseInt("205f",16)),String.fromCharCode(parseInt("3000",16)),String.fromCharCode(parseInt("feff",16))],We=new RegExp(Ge.join("|")+"|(\r\n|\r|\n)","g");function qe(e){return e?We.test(e)?e.replace(We,((e,t)=>t?le:" ")):e:""}function Ze(e){const t=Array.from(e).sort(((e,t)=>e-t));for(let e=1;e<t.length;e++)if(t[e]-t[e-1]!=1)return!1;return!0}function Ye(e){const t=new Map,o=e.name?e.name+" (memoized)":"memoized";return{[o]:(...o)=>(t.has(o[0])||t.set(o[0],e(...o)),t.get(o[0]))}[o]}function je(e,t){return e.filter(((e,o)=>!t.includes(o)))}function Xe(e){return e.split("\n").map((e=>e.replace(/\s+/g," ").trim())).join("\n")}function Ke(e,t,o){return t>o?Ke(e,o,t):e>=t&&e<=o}function Qe(e,t){let o=ue(e);const s=t.matchCase?"":"i";return t.exactMatch&&(o=`^${o}$`),RegExp(o,s)}function Je(e){let t=e.length;if(t<1e5)return Math.max(...e);let o=-1/0;for(;t--;)o=e[t]>o?e[t]:o;return o}function et(e){let t=e.length;if(t<1e5)return Math.min(...e);let o=1/0;for(;t--;)o=e[t]<o?e[t]:o;return o}const tt=/rgba?\(|\s+|\)/gi,ot=/^#([A-F\d]{2}){3,4}$/,st=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function it(e){return nt(e.toString(16).padStart(6,"0"))}function nt(e){let t=e;if(e.startsWith("rgb")?t=function(e){const t=e.replace(tt,"").split(",");let o=255;if(3!==t.length&&4!==t.length)throw new Error("invalid color");if(4===t.length){const e=parseFloat(t.pop()||"1");o=Math.round(255*(e||1))}const s=t.map((e=>parseInt(e,10)));255!==o&&s.push(o);return"#"+Le(s.map((e=>e.toString(16).padStart(2,"0")))).toUpperCase()}(e):(t=e.replace("#","").toUpperCase(),3!==t.length&&4!==t.length||(t=t.split("").reduce(((e,t)=>e+t+t),"")),t=`#${t}`),!ot.test(t))throw new Error(`invalid color input: ${e}`);return t}function rt(e){try{return nt(e),!0}catch(e){return!1}}const at=e=>e>=0&&e<=255;function lt(e,t,o,s=1){if(!at(e)||!at(t)||!at(o)||s<0||s>1)throw new Error(`Invalid RGBA values ${[e,t,o,s]}`);return{a:s,b:o,g:t,r:e}}function ct(e){let{r:t,g:o,b:s}=dt(e);t/=255,o/=255,s/=255;const i=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*i(t)+.7152*i(o)+.0722*i(s)}function ht(e){let t=e.r.toString(16),o=e.g.toString(16),s=e.b.toString(16),i=Math.round(255*e.a).toString(16);return 1===t.length&&(t="0"+t),1===o.length&&(o="0"+o),1===s.length&&(s="0"+s),1===i.length&&(i="0"+i),"ff"===i&&(i=""),("#"+t+o+s+i).toUpperCase()}function dt(e){let t,o,s,i;if(7===(e=nt(e)).length)t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),s=parseInt(e[5]+e[6],16),i=255;else{if(9!==e.length)throw new Error("Invalid color");t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),s=parseInt(e[5]+e[6],16),i=parseInt(e[7]+e[8],16)}return i=+(i/255).toFixed(3),{a:i,r:t,g:o,b:s}}function ut(e){(e={...e}).s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,o=t*(1-Math.abs(e.h/60%2-1)),s=e.l-t/2,i=0,n=0,r=0;return 0<=e.h&&e.h<60?(i=t,n=o,r=0):60<=e.h&&e.h<120?(i=o,n=t,r=0):120<=e.h&&e.h<180?(i=0,n=t,r=o):180<=e.h&&e.h<240?(i=0,n=o,r=t):240<=e.h&&e.h<300?(i=o,n=0,r=t):300<=e.h&&e.h<360&&(i=t,n=0,r=o),i=Math.round(255*(i+s)),n=Math.round(255*(n+s)),r=Math.round(255*(r+s)),{a:e.a,r:i,g:n,b:r}}function gt(e){const t=e.r/255,o=e.g/255,s=e.b/255;let i=Math.min(t,o,s),n=Math.max(t,o,s),r=n-i,a=0,l=0,c=0;return a=0===r?0:n===t?(o-s)/r%6:n===o?(s-t)/r+2:(t-o)/r+4,a=Math.round(60*a),a<0&&(a+=360),c=(n+i)/2,l=0===r?0:r/(1-Math.abs(2*c-1)),l=+(100*l).toFixed(1),c=+(100*c).toFixed(1),{a:e.a,h:a,s:l,l:c}}function pt(e){return ht(ut(e))}function mt(e){return gt(dt(e))}function ft(e,t){const o=mt(e);return 1===t?"#fff":(o.l=t*(100-o.l)+o.l,pt(o))}function bt(e,t){const o=mt(e);return 1===t?"#000":(o.l=o.l-t*o.l,pt(o))}const vt=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];function St(e){return vt[e%vt.length]}class Ct{currentColorIndex=0;colors;constructor(e=[]){this.colors=e}next(){return this.colors?.[this.currentColorIndex]?this.colors[this.currentColorIndex++]:St(this.currentColorIndex++)}}function yt(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):yt(Math.floor(e/26)-1)+yt(e%26)}const Et={};for(const e of"ABCDEFGHIJKLMNOPQRSTUVWXYZ"){const t=e.charCodeAt(0)-64;Et[e]=t,Et[e.toLowerCase()]=t}function xt(e){let t=-1;let o=1;for(let s=e.length-1;s>=0;s--){t+=Et[e[s]]*o,o*=26}return t}function wt(e){return e>="A"&&e<="Z"||e>="a"&&e<="z"}function It(e){return e>="0"&&e<="9"}function Rt(e){let t;e=e.trim();for(let o=0;o<e.length;o++){const s=e[o];if(!t){if("$"===s&&0===o||wt(s))continue;t=o}if(!It(s)){if("$"===s&&o===t)continue;throw new Error(`Invalid cell description: ${e}`)}}if(!t||t===e.length)throw new Error(`Invalid cell description: ${e}`);const o="$"===e[0]?e.slice(1,t):e.slice(0,t),s="$"===e[t]?e.slice(t+1):e.slice(t);if(o.length<1||o.length>3||s.length<1||s.length>7)throw new Error(`Invalid cell description: ${e}`);const i=xt(o),n=Number(s)-1;if(isNaN(n))throw new Error(`Invalid cell description: ${e}`);return{col:i,row:n}}function Tt(e,t,o={colFixed:!1,rowFixed:!1}){return(o.colFixed?"$":"")+yt(e)+(o.rowFixed?"$":"")+String(t+1)}class At{jsDate;constructor(e,t,o,s=0,i=0,n=0){this.jsDate=new Date(Date.UTC(e,t,o,s,i,n,0))}static fromTimestamp(e){const t=new Date(e);return new At(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds())}static now(){const e=new Date;return new At(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.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(){const e=new Date(this.jsDate.getTime()),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);const o=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-o.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)}}const Ot=new At(1899,11,30),_t=864e5,Dt=2e3,Mt=At.now().getFullYear(),Ft=At.now().getMonth(),Nt=At.fromTimestamp(0).getTime()-Ot.getTime(),Pt=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,Lt=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,kt=/\/|-|\s/,Vt=/^(\d{1,4})[\/-\s](\d{1,4})([\/-\s](\d{1,4}))?$/,Ut=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function Bt(e,t){switch(typeof e){case"number":return e;case"string":return Ht(e,t)?$t(e,t)?.value:!e||isNaN(Number(e))?void 0:Number(e);default:return}}function Ht(e,t){return null!==$t(e,t)}const zt=new Map;function $t(e,t){return zt.has(t)||zt.set(t,new Map),zt.get(t).has(e)||zt.get(t).set(e,function(e,t){e=e.trim();let o=null;const s=e.match(Ut);if(s){if(o=function(e){if(e=e.trim(),Ut.test(e)){const t=/AM/i.test(e),o=/PM/i.test(e),s=(t||o?e.substring(0,e.length-2).trim():e).split(/:/),i=s.length>=2,n=3===s.length;let r=Number(s[0]),a=i?Number(s[1]):0,l=n?Number(s[2]):0,c=n?"hh:mm:ss":"hh:mm";if(t||o)c+=" a";else if(!i)return null;r>=12&&t?r-=12:r<12&&o&&(r+=12),a+=Math.floor(l/60),l%=60,r+=Math.floor(a/60),a%=60,r>=24&&(c="hhhh:mm:ss");return{value:r/24+a/1440+l/86400,format:c,jsDate:new At(1899,11,30,r,a,l)}}return null}(s[0]),null===o)return null;e=e.replace(s[0],"").trim()}let i=null;const n=function(e,t){const o=e.match(Vt);if(!o)return null;const[,s,i,,n]=o;if(s.length>2&&n&&n.length>2)return null;if(s.length>2)return{year:s,month:i,day:n,dateString:e,type:"ymd"};const r=function(e){switch(e.dateFormat[0]){case"d":return"dmy";case"m":return"mdy";case"y":return"ymd"}throw new Error("Invalid date format in locale")}(t);if(!n)return i.length>2?{month:s,year:i,day:void 0,dateString:e,type:r}:"dmy"===r?{day:s,month:i,year:n,dateString:e,type:"dmy"}:{month:s,day:i,year:n,dateString:e,type:"mdy"};if(n.length>2)return"mdy"===r?{month:s,day:i,year:n,dateString:e,type:"mdy"}:{day:s,month:i,year:n,dateString:e,type:"dmy"};if("mdy"===r)return{month:s,day:i,year:n,dateString:e,type:"mdy"};if("ymd"===r)return{year:s,month:i,day:n,dateString:e,type:"ymd"};if("dmy"===r)return{day:s,month:i,year:n,dateString:e,type:"dmy"};return null}(e,t);if(n){const t=n.dateString.match(kt)[0];if(i=function(e,t){let{year:o,month:s,day:i}=e;const n=function(e){if(!e)return Ft;const t=Number(e);if(t>=1&&t<=12)return t-1;return null}(s),r=function(e){if(!e)return 1;const t=Number(e);if(t>=0&&t<=31)return t;return null}(i),a=function(e){if(!e)return Mt;const t=Number(e);switch(e.length){case 1:return Dt+t;case 2:return Dt+(Dt+t>Mt+10?-100:0)+t;case 3:case 4:return t}return null}(o);if(null===a||null===n||null===r)return null;const l=2===s?.length&&n+1<10||2===i?.length&&r<10,c=2!==o?.length,h=new At(a,n,r);if(h.getMonth()!==n||h.getDate()!==r)return null;const d=h.getTime()-Ot.getTime(),u=function(e,t,o,s){const i=e.year?s?"yyyy":"yy":void 0,n=e.month?o?"mm":"m":void 0,r=e.day?o?"dd":"d":void 0;switch(e.type){case"mdy":return[n,r,i].filter(De).join(t);case"ymd":return[i,n,r].filter(De).join(t);case"dmy":return[r,n,i].filter(De).join(t)}}(e,t,l,c);return{value:Math.round(d/_t),format:u,jsDate:h}}(n,t),null===i)return null;e=e.replace(n.dateString,"").trim()}if(""!==e||!i&&!o)return null;if(i&&i.jsDate&&o&&o.jsDate)return{value:i.value+o.value,format:i.format+" "+("hhhh:mm:ss"===o.format?"hh:mm:ss":o.format),jsDate:new At(i.jsDate.getFullYear()+o.jsDate.getFullYear()-1899,i.jsDate.getMonth()+o.jsDate.getMonth()-11,i.jsDate.getDate()+o.jsDate.getDate()-30,i.jsDate.getHours()+o.jsDate.getHours(),i.jsDate.getMinutes()+o.jsDate.getMinutes(),i.jsDate.getSeconds()+o.jsDate.getSeconds())};return i||o}(e,t)),zt.get(t).get(e)}function Gt(e){const t=Math.trunc(e);let o=At.fromTimestamp(t*_t-Nt),s=e-t;s=s<0?1+s:s;const i=Math.round(24*s),n=Math.round(24*(s-i/24)*60),r=Math.round(24*(s-i/24-n/24/60)*60*60);return o.setHours(i),o.setMinutes(n),o.setSeconds(r),o}function Wt(e){return Math.round(qt(e))}function qt(e){return(e.getTime()-Ot.getTime())/_t}function Zt(e){return new At(e.getFullYear(),e.getMonth()+1,0).getDate()}function Yt(e){return Zt(e)===e.getDate()}function jt(e,t,o){const s=e.getFullYear(),i=e.getMonth(),n=e.getDate(),r=new At(s,i+t,1);return o&&n===Zt(e)||n>Zt(r)?r.setDate(Zt(r)):r.setDate(n),r}function Xt(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function Kt(e,t,o){if(e===t)return 0;if(e>t){const o=t;t=e,e=o}const s=Gt(e),i=Gt(t);let n=s.getDate(),r=i.getDate();const a=s.getMonth(),l=i.getMonth(),c=s.getFullYear(),h=i.getFullYear();let d=0,u=0;switch(o){case 0:31===n&&(n=30),30===n&&31===r&&(r=30),1===a&&n===(Xt(c)?29:28)&&(n=30,1===l&&r===(Xt(h)?29:28)&&(r=30)),d=c+(30*a+n)/360,u=h+(30*l+r)/360;break;case 1:let o=365;const s=c===h;if(!s&&!(c+1===h)||!s&&a<l||!s&&a===l&&n<r){let e=0,t=0;for(let o=c;o<=h;o++)e++,t+=Xt(o)?366:365;o=t/e}else s?Xt(c)&&(o=366):(Xt(c)&&a<2&&(o=366),Xt(h)&&(l>1||1===l&&29===r)&&(o=366));d=e/o,u=t/o;break;case 2:d=e/360,u=t/360;break;case 3:d=e/365,u=t/365;break;case 4:31===n&&(n=30),31===r&&(r=30),d=c+(30*a+n)/360,u=h+(30*l+r)/360}return u-d}function Qt(e,t){const o=12*(t.getFullYear()-e.getFullYear())+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?o-1:o}function Jt(e,t){const o=e.getTime(),s=t.getTime();return Math.floor((s-o)/_t)}function eo(e,t){const o=t.getFullYear()-e.getFullYear(),s=e.getMonth(),i=t.getMonth(),n=e.getDate(),r=t.getDate();return i>s||i===s&&r>=n?o:o-1}function to(e,t,o){return t>o?to(e,o,t):(e=Math.trunc(e),t=Math.trunc(t),o=Math.trunc(o),e>=t&&e<=o)}const oo=Ye((function(e){return e=ue(e),new RegExp(`(^-?\\d+(${e}?\\d*(e\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)})),so=Ye((function(e){const t=ue(e.decimalSeparator),o="(\\s*"+`(\\d+(${ue(e.thousandsSeparator)}\\d{3,})*(${t}\\d*)?)`+"|"+`(${t}\\d+)`+")(e(\\+|-)?\\d+)?(\\s*%)?",s="(\\s*-)?",i="(\\s*[\\$€])?",n="^(("+[s+i+o,s+o+i,i+s+o].join(")|(")+"))$";return new RegExp(n,"i")}));function io(e,t){return!!e&&so(t).test(e.trim())}const no=Ye((function(e){return new RegExp(`[$€${ue(e.thousandsSeparator)}]`,"g")}));function ro(e,t){"."!==t.decimalSeparator&&(e=e.replace(t.decimalSeparator,".")),e=e.replace(no(t),"");let o=Number(e);return isNaN(o)&&e.includes("%")&&(o=Number(e.split("%")[0]),!isNaN(o))?o/100:o}function ao(e,t,o){const s=[...e].sort(((e,t)=>e-t));let i=(s.length+(o?-1:1))*t;if(o||i--,Number.isInteger(i))return s[i];const n=Math.ceil(i),r=Math.floor(i);return s[n]*(i-r)+s[r]*(n-i)}let lo=e=>e,co=()=>!1;function ho(e,...t){if(1!==t.length||"object"!=typeof t[0]||t[0]instanceof String)t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));else{const o=t[0];e=e.replace(/\%\(([^\)]+)\)s/g,((e,t)=>o[t]))}return e}const uo=function(e,...t){return co()?ho(lo(e),...t):new go(e,t)};class go extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return co()?ho(lo(e),...this.values):ho(e,...this.values)}toString(){return this.valueOf()}}var po,mo;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(po||(po={})),function(e){e.PlainText="text/plain",e.Html="text/html"}(mo||(mo={}));const fo=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"]),bo=new Set(["MOVE_RANGES"]),vo=new Set(["DUPLICATE_SHEET","EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","CHANGE_CONDITIONAL_FORMAT_PRIORITY"]),So=new Set(["AUTOFILL_CELL","SET_BORDER","SET_ZONE_BORDERS"]),Co=new Set(["START","ACTIVATE_SHEET","COPY","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","EVALUATE_CELLS","SET_FORMULA_VISIBILITY","UPDATE_FILTER"]),yo=new Set(["UPDATE_CELL","UPDATE_CELL_POSITION","CLEAR_CELL","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","HIDE_SHEET","SHOW_SHEET","MOVE_RANGES","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","CHANGE_CONDITIONAL_FORMAT_PRIORITY","CREATE_FIGURE","DELETE_FIGURE","UPDATE_FIGURE","SET_FORMATTING","CLEAR_FORMATTING","SET_BORDER","SET_ZONE_BORDERS","CREATE_CHART","UPDATE_CHART","CREATE_TABLE","REMOVE_TABLE","UPDATE_TABLE","CREATE_TABLE_STYLE","REMOVE_TABLE_STYLE","CREATE_IMAGE","GROUP_HEADERS","UNGROUP_HEADERS","UNFOLD_HEADER_GROUP","FOLD_HEADER_GROUP","FOLD_ALL_HEADER_GROUPS","UNFOLD_ALL_HEADER_GROUPS","UNFOLD_HEADER_GROUPS_IN_ZONE","FOLD_HEADER_GROUPS_IN_ZONE","ADD_DATA_VALIDATION_RULE","REMOVE_DATA_VALIDATION_RULE","UPDATE_LOCALE","ADD_PIVOT","UPDATE_PIVOT","INSERT_PIVOT","RENAME_PIVOT","REMOVE_PIVOT","DUPLICATE_PIVOT"]);function Eo(e){return yo.has(e.type)}class xo{reasons;constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>"Success"!==e))}static get Success(){return wo}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}const wo=new xo;var Io;e.CommandResult=void 0,(Io=e.CommandResult||(e.CommandResult={})).Success="Success",Io.CancelledForUnknownReason="CancelledForUnknownReason",Io.WillRemoveExistingMerge="WillRemoveExistingMerge",Io.MergeIsDestructive="MergeIsDestructive",Io.CellIsMerged="CellIsMerged",Io.InvalidTarget="InvalidTarget",Io.EmptyUndoStack="EmptyUndoStack",Io.EmptyRedoStack="EmptyRedoStack",Io.NotEnoughElements="NotEnoughElements",Io.NotEnoughSheets="NotEnoughSheets",Io.MissingSheetName="MissingSheetName",Io.UnchangedSheetName="UnchangedSheetName",Io.DuplicatedSheetName="DuplicatedSheetName",Io.DuplicatedSheetId="DuplicatedSheetId",Io.ForbiddenCharactersInSheetName="ForbiddenCharactersInSheetName",Io.WrongSheetMove="WrongSheetMove",Io.WrongSheetPosition="WrongSheetPosition",Io.InvalidAnchorZone="InvalidAnchorZone",Io.SelectionOutOfBound="SelectionOutOfBound",Io.TargetOutOfSheet="TargetOutOfSheet",Io.WrongCutSelection="WrongCutSelection",Io.WrongPasteSelection="WrongPasteSelection",Io.WrongPasteOption="WrongPasteOption",Io.WrongFigurePasteOption="WrongFigurePasteOption",Io.EmptyClipboard="EmptyClipboard",Io.EmptyRange="EmptyRange",Io.InvalidRange="InvalidRange",Io.InvalidZones="InvalidZones",Io.InvalidSheetId="InvalidSheetId",Io.InvalidFigureId="InvalidFigureId",Io.InputAlreadyFocused="InputAlreadyFocused",Io.MaximumRangesReached="MaximumRangesReached",Io.MinimumRangesReached="MinimumRangesReached",Io.InvalidChartDefinition="InvalidChartDefinition",Io.InvalidDataSet="InvalidDataSet",Io.InvalidLabelRange="InvalidLabelRange",Io.InvalidScorecardKeyValue="InvalidScorecardKeyValue",Io.InvalidScorecardBaseline="InvalidScorecardBaseline",Io.InvalidGaugeDataRange="InvalidGaugeDataRange",Io.EmptyGaugeRangeMin="EmptyGaugeRangeMin",Io.GaugeRangeMinNaN="GaugeRangeMinNaN",Io.EmptyGaugeRangeMax="EmptyGaugeRangeMax",Io.GaugeRangeMaxNaN="GaugeRangeMaxNaN",Io.GaugeRangeMinBiggerThanRangeMax="GaugeRangeMinBiggerThanRangeMax",Io.GaugeLowerInflectionPointNaN="GaugeLowerInflectionPointNaN",Io.GaugeUpperInflectionPointNaN="GaugeUpperInflectionPointNaN",Io.GaugeLowerBiggerThanUpper="GaugeLowerBiggerThanUpper",Io.InvalidAutofillSelection="InvalidAutofillSelection",Io.MinBiggerThanMax="MinBiggerThanMax",Io.LowerBiggerThanUpper="LowerBiggerThanUpper",Io.MidBiggerThanMax="MidBiggerThanMax",Io.MinBiggerThanMid="MinBiggerThanMid",Io.FirstArgMissing="FirstArgMissing",Io.SecondArgMissing="SecondArgMissing",Io.MinNaN="MinNaN",Io.MidNaN="MidNaN",Io.MaxNaN="MaxNaN",Io.ValueUpperInflectionNaN="ValueUpperInflectionNaN",Io.ValueLowerInflectionNaN="ValueLowerInflectionNaN",Io.MinInvalidFormula="MinInvalidFormula",Io.MidInvalidFormula="MidInvalidFormula",Io.MaxInvalidFormula="MaxInvalidFormula",Io.ValueUpperInvalidFormula="ValueUpperInvalidFormula",Io.ValueLowerInvalidFormula="ValueLowerInvalidFormula",Io.InvalidSortZone="InvalidSortZone",Io.WaitingSessionConfirmation="WaitingSessionConfirmation",Io.MergeOverlap="MergeOverlap",Io.TooManyHiddenElements="TooManyHiddenElements",Io.Readonly="Readonly",Io.InvalidViewportSize="InvalidViewportSize",Io.InvalidScrollingDirection="InvalidScrollingDirection",Io.ViewportScrollLimitsReached="ViewportScrollLimitsReached",Io.FigureDoesNotExist="FigureDoesNotExist",Io.InvalidConditionalFormatId="InvalidConditionalFormatId",Io.InvalidCellPopover="InvalidCellPopover",Io.EmptyTarget="EmptyTarget",Io.InvalidFreezeQuantity="InvalidFreezeQuantity",Io.FrozenPaneOverlap="FrozenPaneOverlap",Io.ValuesNotChanged="ValuesNotChanged",Io.InvalidFilterZone="InvalidFilterZone",Io.TableNotFound="TableNotFound",Io.TableOverlap="TableOverlap",Io.InvalidTableConfig="InvalidTableConfig",Io.InvalidTableStyle="InvalidTableStyle",Io.FilterNotFound="FilterNotFound",Io.MergeInTable="MergeInTable",Io.NonContinuousTargets="NonContinuousTargets",Io.DuplicatedFigureId="DuplicatedFigureId",Io.InvalidSelectionStep="InvalidSelectionStep",Io.DuplicatedChartId="DuplicatedChartId",Io.ChartDoesNotExist="ChartDoesNotExist",Io.InvalidHeaderIndex="InvalidHeaderIndex",Io.InvalidQuantity="InvalidQuantity",Io.MoreThanOneColumnSelected="MoreThanOneColumnSelected",Io.EmptySplitSeparator="EmptySplitSeparator",Io.SplitWillOverwriteContent="SplitWillOverwriteContent",Io.NoSplitSeparatorInSelection="NoSplitSeparatorInSelection",Io.NoActiveSheet="NoActiveSheet",Io.InvalidLocale="InvalidLocale",Io.AlreadyInPaintingFormatMode="AlreadyInPaintingFormatMode",Io.MoreThanOneRangeSelected="MoreThanOneRangeSelected",Io.NoColumnsProvided="NoColumnsProvided",Io.ColumnsNotIncludedInZone="ColumnsNotIncludedInZone",Io.DuplicatesColumnsSelected="DuplicatesColumnsSelected",Io.InvalidHeaderGroupStartEnd="InvalidHeaderGroupStartEnd",Io.HeaderGroupAlreadyExists="HeaderGroupAlreadyExists",Io.UnknownHeaderGroup="UnknownHeaderGroup",Io.UnknownDataValidationRule="UnknownDataValidationRule",Io.UnknownDataValidationCriterionType="UnknownDataValidationCriterionType",Io.InvalidDataValidationCriterionValue="InvalidDataValidationCriterionValue",Io.InvalidNumberOfCriterionValues="InvalidNumberOfCriterionValues",Io.InvalidCopyPasteSelection="InvalidCopyPasteSelection",Io.NoChanges="NoChanges",Io.InvalidInputId="InvalidInputId",Io.SheetIsHidden="SheetIsHidden",Io.InvalidTableResize="InvalidTableResize",Io.PivotIdNotFound="PivotIdNotFound",Io.EmptyName="EmptyName";const Ro="@",To=[{name:"English (US)",code:"en_US",thousandsSeparator:",",decimalSeparator:".",dateFormat:"m/d/yyyy",timeFormat:"hh:mm:ss a",formulaArgSeparator:","},{name:"French",code:"fr_FR",thousandsSeparator:" ",decimalSeparator:",",dateFormat:"dd/mm/yyyy",timeFormat:"hh:mm:ss",formulaArgSeparator:";"}],Ao=To[0],Oo=["thin","medium","thick","dashed","dotted"];function _o(e){return Array.isArray(e)&&Array.isArray(e[0])}var Do;!function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(Do||(Do={}));const Mo={Background:0,Highlights:1,Clipboard:2,Chart:4,Autofill:5,Selection:6,Headers:100},Fo=Ye((()=>Object.keys(Mo).sort(((e,t)=>Mo[e]-Mo[t]))));const No={NotAvailable:"#N/A",InvalidReference:"#REF",BadExpression:"#BAD_EXPR",CircularDependency:"#CYCLE",UnknownFunction:"#NAME?",DivisionByZero:"#DIV/0!",SpilledBlocked:"#SPILL!",GenericError:"#ERROR"},Po=new Set(Object.values(No));class Lo extends Error{value;constructor(e=uo("Error"),t=No.GenericError){super(e),this.value=t}}class ko extends Lo{constructor(e=uo("Invalid expression")){super(e,No.BadExpression)}}class Vo extends Lo{constructor(e=uo("Invalid reference")){super(e,No.InvalidReference)}}class Uo extends Lo{constructor(e=uo("Data not available")){super(e,No.NotAvailable)}}class Bo extends Lo{constructor(e=uo("Unknown function")){super(e,No.UnknownFunction)}}class Ho extends Lo{constructor(e=uo("Spill range is not empty")){super(e,No.SpilledBlocked)}}const zo=["number","string","boolean","undefined"];function $o(e,t,o){if(!e())throw new Lo(t,o)}function Go(e){if(void 0!==e)return _o(e)?e[0][0]?.format:e.format}function Wo(e){return"string"==typeof e&&Po.has(e)}const qo=e=>uo("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Zo(e,t){const o=rs(e);switch(typeof o){case"number":return o;case"boolean":return o?1:0;case"string":if(io(o,t)||""===o)return ro(o,t);const e=$t(o,t);if(e)return e.value;throw new Lo(qo(o));default:return 0}}function Yo(e,t){try{return Zo(e,t)}catch(e){return}}function jo(e,t){return Rs(e).map((e=>e.map((e=>{if("number"!=typeof e.value)throw new Lo(uo("Function [[FUNCTION_NAME]] expects number values for %s, but got a %s.",t,typeof e.value));return e.value}))))}function Xo(e,t){const o=rs(e);if(""===o)throw new Lo(qo(o));return Zo(o,t)}function Ko(e,t){return Math.trunc(Zo(e,t))}function Qo(e,t){return Math.trunc(Xo(e,t))}function Jo(e){$o((()=>e>=1),uo("The function [[FUNCTION_NAME]] expects a number value to be greater than or equal to 1, but receives %s.",e.toString()))}function es(e){$o((()=>0!==e),uo("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."),No.DivisionByZero)}function ts(e){const t=rs(e);switch(typeof t){case"string":return t;case"number":return t.toString();case"boolean":return t?"TRUE":"FALSE";default:return""}}const os=Ye((function(e){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")})),ss=e=>uo("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a boolean.",e);function is(e){const t=rs(e);switch(typeof t){case"boolean":return t;case"string":if(t){let e=t.toUpperCase();if("TRUE"===e)return!0;if("FALSE"===e)return!1;throw new Lo(ss(t))}return!1;case"number":return!!t;default:return!1}}function ns(e,t){return Gt(Zo(rs(e),t))}function rs(e){if("object"==typeof e&&null!==e&&"value"in e){if(Wo(e.value))throw e;return e.value}if(Wo(e))throw new Lo("",e);return e}function as(e,t,o){for(let s of e)if(_o(s)){const e=s.length,o=s[0].length;for(let i=0;i<o;i++)for(let o=0;o<e;o++)t(s[o][i])}else o(s)}function ls(e,t){as(e,(e=>{if(Wo(e.value))throw e;t(e)}),(e=>{if(Wo(e?.value))throw e;t(e)}))}function cs(e,t,o){as(e,(e=>{const o=e?.value;if("number"==typeof o&&t(o),Wo(o))throw e}),(e=>{t(Xo(e,o))}))}function hs(e,t,o,s,i="rowFirst"){let n=s;for(let s of e)if(_o(s)){const e=s.length,o=s[0].length;if("rowFirst"===i)for(let i=0;i<o;i++)for(let o=0;o<e;o++)n=t(n,s[o][i]);else for(let i=0;i<e;i++)for(let e=0;e<o;e++)n=t(n,s[i][e])}else n=o(n,s);return n}function ds(e,t,o,s="rowFirst"){return hs(e,t,t,o,s)}function us(e,t,o,s){return hs(e,((e,o)=>{const s=o?.value;if("number"==typeof s)return t(e,s);if(Wo(s))throw o;return e}),((e,o)=>t(e,Xo(o,s))),o)}function gs(e,t,o,s){return hs(e,((e,o)=>{const i=o?.value;if(null!=i){if("number"==typeof i)return t(e,i);if("boolean"==typeof i)return t(e,Zo(i,s));if(Wo(i))throw o;return t(e,0)}return e}),((e,o)=>t(e,Zo(o,s))),o)}function ps(e,t,o){const s=Array(e);for(let i=0;i<e;i++){s[i]=Array(t);for(let e=0;e<t;e++)s[i][e]=o(i,e)}return s}function ms(e,t){return 0===e.length?[]:ps(e.length,e[0].length,((o,s)=>t(e[o][s])))}function fs(e){return e.length?ps(e[0].length,e.length,((t,o)=>e[o][t])):[]}function bs(e,t){return function(e,t,o){for(let s of e)if(_o(s)){const e=s.length,o=s[0].length;for(let i=0;i<o;i++)for(let o=0;o<e;o++)if(!t(s[o][i]??void 0))return}else if(!o(s))return}(e,(e=>{const o=e?.value;if("boolean"==typeof o)return t(o);if("number"==typeof o)return t(!!o);if(Wo(o))throw e;return!0}),(e=>void 0===e||null===e.value||t(function(e){const t=rs(e);if(""===t)throw new Lo(ss(t));return is(t)}(e))))}function vs(e,t){let o,s,i=e.substring(0,2);return"<="===i||">="===i||"<>"===i?(o=i,s=e.substring(2)):(i=e.substring(0,1),"<"===i||">"===i||"="===i?(o=i,s=e.substring(1)):(o="=",s=e)),io(s,t)?s=Zo(s,t):"TRUE"!==s&&"FALSE"!==s||(s=is(s)),{operator:o,operand:s}}const Ss=Ye((function(e){let t="",o="";for(let s of e)"?"===s&&"~"!==o?t+=".":"*"===s&&"~"!==o?t+=".*":("*"!==s&&"?"!==s||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(s)&&(t+="\\"),t+=s),o=s;return new RegExp("^"+t+"$","i")}));function Cs(e,t){const{operator:o,operand:s}=t;if(void 0===e||void 0===s||null===e||null===s)return!1;if("number"==typeof s&&"="===o)return ts(e)===ts(s);if("<>"===o||"="===o){let t;return t=typeof e==typeof s&&("string"==typeof e&&"string"==typeof s?Ss(s).test(e):e===s),"="===o?t:!t}if(typeof e==typeof s)switch(o){case"<":return e<s;case">":return e>s;case"<=":return e<=s;case">=":return e>=s}return!1}function ys(e,t,o,s=!1){const i=e.length;if(i%2==1)throw new Lo(uo("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const n=e[0].length,r=e[0][0].length;let a=[];for(let t=0;t<i-1;t+=2){const i=e[t];if(!_o(i)||i.length!==n||i[0].length!==r)throw new Lo(uo("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const l=vs(ts(e[t+1]),o);s&&"string"==typeof l.operand&&(l.operand+="*"),a.push(l)}for(let o=0;o<n;o++)for(let s=0;s<r;s++){let n=!0;for(let t=0;t<i-1;t+=2){if(n=Cs(e[t][o][s].value??void 0,a[t/2]),!n)break}n&&t(o,s)}}function Es(e,t,o,s,i,n){if(void 0===t||null===t.value)return-1;if(Wo(t.value))throw t;const r=ws(t.value),a=typeof r;let l,c,h,d,u,g,p=0,m=i-1;for(;m-p>=0;){for(h=Math.floor((p+m)/2),d=h,u=ws(n(e,d)),g=typeof u;p<d&&a!==g;)d--,u=ws(n(e,d)),g=typeof u;g===a&&null!=u?("strict"===o&&u===r?(l=u,c=d):"nextSmaller"===o&&u<=r?(null==l||l<u||l===u&&"asc"===s&&c<d||l===u&&"desc"===s&&c>d)&&(l=u,c=d):"nextGreater"===o&&u>=r&&(void 0===l||l>u||l===u&&"asc"===s&&c<d||l===u&&"desc"===s&&c>d)&&(l=u,c=d),"asc"===s&&u>r||"desc"===s&&u<=r?m=d-1:p=h+1):p=h+1}return void 0!==c?c:-1}function xs(e,t,o,s,i,n=!1){if(void 0===t||null===t.value)return-1;if(Wo(t.value))throw t;const r=ws(t.value),a=n?(e,t)=>i(e,s-t-1):i;let l,c=t=>ws(a(e,t))===r;if("wildcard"===o&&"string"==typeof r&&(r.includes("*")||r.includes("?"))){const t=Ss(r);c=o=>{const s=ws(a(e,o));return"string"==typeof s&&t.test(s)}}let h=-1;"nextSmaller"===o&&(c=t=>{const o=ws(a(e,t));return(!l&&Is(r,o)>=0||Is(r,o)>=0&&Is(o,l)>0)&&(l=o,h=t),o===r}),"nextGreater"===o&&(c=t=>{const o=ws(a(e,t));return(!l&&Is(r,o)<=0||Is(r,o)<=0&&Is(o,l)<0)&&(l=o,h=t),o===r});for(let e=0;e<s;e++)if(c(e))return n?s-e-1:e;return n?s-h-1:h}function ws(e){return"string"==typeof e?os(e):e}function Is(e,t){let o=zo.indexOf(typeof e)-zo.indexOf(typeof t);return 0===o&&("string"==typeof e&&"string"==typeof t?o=e.localeCompare(t):"number"==typeof e&&"number"==typeof t?o=e-t:"boolean"==typeof e&&"boolean"==typeof t&&(o=Number(e)-Number(t))),o}function Rs(e){return void 0===e?[[]]:_o(e)?e:[[e]]}function Ts(e,t){return ds(e,((e,o)=>(e.push(t(o)),e)),[],"rowFirst")}function As(e){if(void 0===e)return!1;const{value:t}=e;return null!==t&&""!==t}function Os(e){const t=At.now();switch(e){case"today":return qt(t);case"yesterday":return qt(At.fromTimestamp(t.setDate(t.getDate()-1)));case"tomorrow":return qt(At.fromTimestamp(t.setDate(t.getDate()+1)));case"lastWeek":return qt(At.fromTimestamp(t.setDate(t.getDate()-7)));case"lastMonth":return qt(At.fromTimestamp(t.setMonth(t.getMonth()-1)));case"lastYear":return qt(At.fromTimestamp(t.setFullYear(t.getFullYear()-1)))}}function _s(e,t){return"dateValue"in e&&"exactDate"!==e.dateValue?[Os(e.dateValue)]:e.values.map((e=>Bt(e,t)))}function Ds(e,t){return e.values.map((e=>Yo(e,t)))}function Ms(e){return 20+120*Math.exp(-.035*(e-1))}const Fs=20,Ns=11,Ps=/(\d+?)(?=(\d{3})+(?!\d)|$)/g,Ls=/0/g,ks={0:uo("January"),1:uo("February"),2:uo("March"),3:uo("April"),4:uo("May"),5:uo("June"),6:uo("July"),7:uo("August"),8:uo("September"),9:uo("October"),10:uo("November"),11:uo("December")},Vs={0:uo("Sunday"),1:uo("Monday"),2:uo("Tuesday"),3:uo("Wednesday"),4:uo("Thursday"),5:uo("Friday"),6:uo("Saturday")},Us={};function Bs(e){let t=Us[e];return void 0===t&&(t=function(e){if(""===e)throw new Error("A format cannot be empty");let t=0,o=[];for(;t<e.length;){let s;if("["===e.charAt(t)){if("$"!==e.charAt(t+1))throw new Error(`Currency formats have to be prefixed by a $: ${e}`);if(s=e.substring(t+1).indexOf("]")+t+2,0===s)throw new Error(`Invalid currency brackets format: ${e}`);const i=e.substring(t+2,s-1);if(i.includes("["))throw new Error(`Invalid currency format: ${e}`);o.push({type:"STRING",format:i})}else{const i=e.substring(t).indexOf("[");s=i>-1?i+t:e.length;const n=e.substring(t,s);Ys(n)?o.push({type:"DATE",format:n}):o.push({type:"NUMBER",format:ui(n)})}t=s}return o}(e),Us[e]=t),t}function Hs(e,{format:t,locale:o}){if(t===Ro)return ts(e)||"";switch(typeof e){case"string":return e.includes('\\"')?e.replace(/\\"/g,'"'):e;case"boolean":return e?"TRUE":"FALSE";case"number":t||(t=ei(e));return function(e,t,o){if("DATE"===t[0].type)return Xs(e,t[0].format);let s=e<0?"-":"";for(let i of t)switch(i.type){case"NUMBER":s+=zs(Math.abs(e),i.format,o);break;case"STRING":s+=i.format}return s}(e,Bs(t),o);case"object":return""}}function zs(e,t,o){if(e===1/0)return"∞"+(t.isPercent?"%":"");t.isPercent&&(e*=100),e/=t.magnitude;let s=0;void 0!==t.decimalPart&&(s=t.decimalPart.length);const{integerDigits:i,decimalDigits:n}=Gs(e,s);let r=function(e,t,o){const s="0"===e?"":e;let i=s;const n=t.length-s.length;if(n>0){const e=(t.substring(0,n).match(Ls)||[]).length;i="0".repeat(e)+i}o&&(i=i.match(Ps)?.join(o)||i);return i}(i,t.integerPart,t.thousandsSeparator?o.thousandsSeparator:void 0);return void 0!==t.decimalPart&&(r+=o.decimalSeparator+function(e,t){let o=e;if(t.length-e.length>0){const s=(t.substring(e.length,t.length+1).match(Ls)||[]).length;o+="0".repeat(s)}return o}(n||"",t.decimalPart)),t.isPercent&&(r+="%"),r}const $s=[];function Gs(e,t=Fs){const o=e.toString();if(o.includes("e"))return function(e,t=Fs){let o=$s[t];o||(o=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),$s[t]=o);const[s,i]=o.format(e).split(".");return{integerDigits:s,decimalDigits:i}}(e,t);if(Number.isInteger(e))return{integerDigits:o,decimalDigits:void 0};const s=o.indexOf(".");let i=o.substring(0,s),n=o.substring(s+1);if(0===t)return Number(n[0])>=5&&(i=(Number(i)+1).toString()),{integerDigits:i,decimalDigits:void 0};if(n.length>t){const{integerDigits:e,decimalDigits:o}=function(e,t){let o="0",s=e,i=e.slice(0,t);const n=t;if(Number(e[n])<5)return{integerDigits:o,decimalDigits:i};const r=i.match(qs)?.[0]||"",a=(Number(i)+1).toString(),l=i.slice(r.length),c=a.length>l.length;c&&!r?(o="1",s=void 0):s=c?r.slice(0,-1)+a:r+a;return{integerDigits:o,decimalDigits:s}}(n,t);n=o,"0"!==e&&(i=(Number(i)+Number(e)).toString())}return{integerDigits:i,decimalDigits:Ws(n||"")}}function Ws(e){let t=e.length-1;for(;t>=0&&"0"===e[t];)t--;return e.slice(0,t+1)||void 0}const qs=/^0+/;function Zs(e,t){const{integerDigits:o,decimalDigits:s}=Gs(e,20);return s?o+t+s:o}function Ys(e){if(!js.has(e[0]))return!1;try{return Xs(1,e),!0}catch(e){return!1}}const js=new Set(["h","m","y","d","q"]);function Xs(e,t){const o=Gt(e),s=t.indexOf("h");let i="",n="";return s>0?(i=Ks(o,t.substring(0,s-1)),n=Qs(o,t.substring(s))):0===s?n=Qs(o,t):s<0&&(i=Ks(o,t)),i+(i&&n?" ":"")+n}function Ks(e,t){const o=t.match(/\/|-|\s/)?.[0];return(o?t.split(o):[t]).map((o=>{switch(o){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"ddd":return Vs[e.getDay()].slice(0,3);case"dddd":return Vs[e.getDay()];case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"mmm":return ks[e.getMonth()].slice(0,3);case"mmmm":return ks[e.getMonth()];case"mmmmm":return ks[e.getMonth()].slice(0,1);case"qq":return uo("Q%(quarter)s",{quarter:e.getQuarter()});case"qqqq":return uo("Quarter %(quarter)s",{quarter:e.getQuarter()});case"yy":const o=String(e.getFullYear()).replace("-","").padStart(2,"0");return o.slice(o.length-2);case"yyyy":return e.getFullYear();default:throw new Error(`invalid format: ${t}`)}})).join(o)}function Qs(e,t){let o=t.split(/:|\s/);const s=e.getHours(),i="a"===o[o.length-1];let n=s,r="";return i&&(n=0===n?12:n>12?n-12:n,r=s>=12?" PM":" AM",o.pop()),o.map((o=>{switch(o){case"hhhh":return Math.floor((e.getTime()-Ot.getTime())/36e5).toString();case"hh":return n.toString().padStart(2,"0");case"mm":return e.getMinutes().toString().padStart(2,"0");case"ss":return e.getSeconds().toString().padStart(2,"0");default:throw new Error(`invalid format: ${t}`)}})).join(":")+r}const Js=Ye((function(e){return new RegExp(`[0-9]+${ue(e.decimalSeparator)}[0-9]`)}));function ei(e){let{integerDigits:t,decimalDigits:o}=Gs(e);if(!o)return"0";const s=t.replace("-","").length;if(s+2>Ns)return"0";const i=Ns-s-1;return({decimalDigits:o}=Gs(e,Math.min(i,o.length))),o?"0."+"0".repeat(o.length):"0"}function ti(e,t){if(!Ht(e,t))return;return $t(e,t).format}function oi(e){if(!io(e,Ao))return;const t=e.includes(".")?"0.00":"0",o=e.match(/[\$€]/);if(o){const s=e.match(/[\d]/),i="[$"+o.values().next().value+"]";return s.index<o.index?"#,##"+t+i:i+"#,##"+t}return e.includes("%")?t+"%":void 0}function si(e){const t=e.decimalPlaces??2,o=e.position??"before",s=e.code??"",i=e.symbol??"",n="#,##0"+(t?"."+"0".repeat(t):"");let r=`${s} ${i}`.trim();return"after"===o&&s&&(r=" "+r),function(e,t,o){const s=`[$${e}]`;return"before"===t?s+o:o+s}(r,o,n)}function ii(e){return pi(Bs(e).map((e=>"NUMBER"===e.type?{type:e.type,format:{...e.format,decimalPart:void 0}}:e)))}function ni({value:e,format:t},o){return Hs(e,{format:ri({value:e,format:t},void 0,o),locale:o})}function ri(e,t,o){let s=0;try{s=Math.abs(Zo(e?.value,o))}catch(e){return""}const i=e?.format;if(void 0!==t){const e=t?.value;switch(e){case"k":return ai(i,1e3,"k");case"m":return ai(i,1e6,"m");case"b":return ai(i,1e9,"b");default:throw new Lo(uo("The formatting unit should be 'k', 'm' or 'b'."))}}return s<1e5?ai(i,0,""):s<1e8?ai(i,1e3,"k"):s<1e11?ai(i,1e6,"m"):ai(i,1e9,"b")}function ai(e,t,o,s){const i=Bs(e||"#,##0"),n=[];for(let e=0;e<i.length;e++){const s=i[e];if("NUMBER"!==s.type){n.push(s);continue}n.push({...s,format:{...s.format,magnitude:t,decimalPart:void 0}}),n.push({type:"STRING",format:o});const r=i[e+1];"STRING"===r?.type&&["k","m","b"].includes(r.format)&&e++}return pi(n)}function li(e,t,o){const s=Bs(e).map((e=>"NUMBER"===e.type?{...e,format:hi(e.format,t)}:e)),i=pi(s);return Us[i]=s,i}function ci(e){const t=Bs(e);for(let e of t)if("DATE"===e.type&&e.format.includes("q"))return!1;return!0}function hi(e,t){const o={...e},s=Math.sign(t),i=o.decimalPart?.length||0,n=Math.min(Math.max(0,i+s),Fs);return o.decimalPart="0".repeat(n),""===o.decimalPart&&delete o.decimalPart,o}const di=/,*?$/;function ui(e){if(function(e){return Boolean(e.replace(gi,""))}(e=e.trim()))throw new Error(`Invalid number format: ${e}`);const t=e.includes("%"),o=e.match(di)?.[0]||"",s=o?1e3**o.length:1;let i=e.slice(0,e.length-(o.length||0));const n=i.includes(",");if(/\..*,/.test(i))throw new Error("A format can't contain ',' symbol in the decimal part");i=i.replace("%","").replace(",","");const r=i.match(/[\%|,]/);if(r)throw new Error(`A format can only contain a single '${r[0]}' symbol`);const[a,l]=i.split(".");if(l&&l.length>20)throw new Error("A format can't contain more than 20 decimal places");return void 0!==l?{integerPart:a,isPercent:t,thousandsSeparator:n,decimalPart:l,magnitude:s}:{integerPart:a,isPercent:t,thousandsSeparator:n,magnitude:s}}const gi=/[,#0.%@]/g;function pi(e){let t="";for(let o of e){let e;switch(o.type){case"NUMBER":const t=o.format;e=t.integerPart,t.thousandsSeparator&&(e=e.slice(0,-3)+","+e.slice(-3)),void 0!==t.decimalPart&&(e+="."+t.decimalPart),t.isPercent&&(e+="%"),t.magnitude&&(e+=",".repeat(Math.log10(t.magnitude)/3));break;case"STRING":e=`[$${o.format}]`;break;case"DATE":e=o.format}t+=e}return t}const mi=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),fi=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),bi=new RegExp(/^\$?([A-Z]{1,3})+$/,"i"),vi=new RegExp(/^\$?([0-9]{1,7})+$/,"i"),Si=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),Ci=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),yi=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[mi.source,/(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*:\s*(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*/i.source,/\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*:\s*\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*/i.source].join("|")+")"+/$/.source,"i");function Ei(e){return Si.test(e)}function xi(e){return Ci.test(e)}function wi(e){return bi.test(e)}function Ii(e){return vi.test(e)}function Ri(e){return fi.test(e)}function Ti(e){if(!e.includes("!"))return{xc:e};const t=e.split("!"),o=t.pop();return{sheetName:pe(t.join("!"))||void 0,xc:o}}function Ai(e,t){return void 0!==e?`${fe(e)}!${t}`:t}function Oi(e,t=[]){if(e.length<=1&&0===t.length)return e;const o=[0],s=new Map([[0,[]]]);return _i(o,s,e,!1),_i(o,s,t,!0),function(e,t){const o=[];let s=[];for(let i=0;i<e.length;i++){const n=e[i],r=t.get(n);if(!r||0===r.length){o.push(...s),s=[];continue}let a=e[i+1];void 0!==a&&a--;const l=[];for(let e=0;e<r.length;e+=2){const t=r[e];let o=r[e+1];void 0!==o&&o--;const i={top:t,left:n,bottom:o,right:a,hasHeader:void 0===o&&0!==t||void 0===a&&0!==n};let c=!1;for(let e=s.length-1;e>=0;e--){const t=s[e];if(t.top===i.top&&t.bottom===i.bottom){t.right=i.right,s.splice(e,1),l.push(t),c=!0;break}}c||l.push(i)}o.push(...s),s=l}return o.push(...s),o}(o,s)}function _i(e,t,o,s=!1){for(const i of o){const o=i.left,n=void 0===i.right?void 0:i.right+1,r=Di(e,t,o,!0,0),a=Di(e,t,n,!1,r);for(let o=r;o<=a;o++){Mi(t.get(e[o]),i,s)}Fi(e,t,r,a)}}function Di(e,t,o,s,i){if(void 0===o)return e.length-1;const n=Ni(e,o,i);return o!=e[n]?(e.splice(n+1,0,o),t.set(o,[...t.get(e[n])]),s?n+1:n):s?n:n-1}function Mi(e,t,o=!1){const s=t.top,i=void 0===t.bottom?void 0:t.bottom+1,n=[],r=Ni(e,s,0,!1);if((r%2!=0&&!o||r%2==0&&o)&&n.push(s),void 0===i)return e.splice(r+1),void e.push(...n);const a=function(e,t,o=0,s=!0){let i=e.length-1,n=e.length;for(;o<=i;){const r=Math.floor((o+i)/2);if(e[r]===t&&s)return r;e[r]>t?(n=r,i=r-1):o=r+1}return n}(e,i,0,!1);(a%2==0&&!o||a%2!=0&&o)&&n.push(i),e.splice(r+1,a-r-1,...n)}function Fi(e,t,o,s){const i=o-1==-1?0:o-1;for(let o=s===e.length-1?s:s+1;o>i;o--)He(t.get(e[o]),t.get(e[o-1]))&&(t.delete(e[o]),e.splice(o,1))}function Ni(e,t,o=0,s=!0){let i=e.length-1,n=-1;for(;o<=i;){const r=Math.floor((o+i)/2);if(e[r]===t&&s)return r;e[r]<t?(n=r,o=r+1):i=r-1}return n}function Pi(e){const t=function(e){e.includes("!")&&(e=e.split("!").at(-1)),e.includes("$")&&(e=e.replaceAll("$",""));let t,o,s,i,n,r="";e.includes(":")?([r,t]=e.split(":"),r=r.trim(),t=t.trim()):r=e.trim();let a=!1,l=!1,c=!1;if(Ei(r))i=n=xt(r),o=s=0,a=!0;else if(xi(r))o=s=parseInt(r,10)-1,i=n=0,l=!0;else{const e=Rt(r);i=n=e.col,o=s=e.row,c=!0}if(t)if(Ei(t))n=xt(t),a=!0;else if(xi(t))s=parseInt(t,10)-1,l=!0;else{const e=Rt(t);n=e.col,s=e.row,o=a?s:o,i=l?n:i,c=!0}if(a&&l)throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");const h={top:o,left:i,bottom:a?void 0:s,right:l?void 0:n};return c=c&&(l||a),c&&(h.hasHeader=c),h}(e);if(void 0!==t.right&&t.right<t.left){const e=t.left;t.left=t.right,t.right=e}if(void 0!==t.bottom&&t.bottom<t.top){const e=t.top;t.top=t.bottom,t.bottom=e}return t}function Li(e){const t=Pi(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function ki(e){const{bottom:t,top:o,left:s,right:i}=e;return!(void 0!==t&&isNaN(t)||isNaN(o)||isNaN(s)||void 0!==i&&isNaN(i))&&(Vi(e)&&e.top>=0&&e.left>=0)}function Vi(e){return(void 0===e.bottom||e.bottom>=e.top&&e.bottom>=0)&&(void 0===e.right||e.right>=e.left&&e.right>=0)}function Ui(e){const{top:t,bottom:o,left:s,right:i}=e,n="hasHeader"in e&&e.hasHeader,r=t===o&&s===i;if(void 0===o&&void 0!==i)return 0!==t||n?`${Tt(s,t)}:${yt(i)}`:`${yt(s)}:${yt(i)}`;if(void 0===i&&void 0!==o)return 0!==s||n?`${Tt(s,t)}:${o+1}`:`${t+1}:${o+1}`;if(void 0!==o&&void 0!==i)return r?Tt(s,t):`${Tt(s,t)}:${Tt(i,o)}`;throw new Error(uo("Bad zone format"))}function Bi(e,t,o,s,i){const n="left"===t?"columns":"rows",r="before"===s?o-1:o,a=e["left"===t?"right":"bottom"];return e[t]<=r&&a&&a>r?en(e,n,"RESIZE",i):r<e[t]?en(e,n,"MOVE",i):{...e}}function Hi(e,t,o,s,i){const n="left"===t?"columns":"rows",r="before"===s?o-1:o,a="left"===t?"right":"bottom";return e[t]<=r&&e[a]>r?en(e,n,"RESIZE",i):r<e[t]?en(e,n,"MOVE",i):{...e}}function zi(e,t,o){const s="left"===t?"right":"bottom";let i=e[t],n=e[s];for(let r of o.sort(((e,t)=>t-e)))e[t]>r&&(i--,n--),e[t]<r&&e[s]>=r&&n--;return{...e,[t]:i,[s]:n}}function $i(e,t,o){const s="left"===t?"right":"bottom";let i=e[t],n=e[s];const r=e[s];for(let s of o.sort(((e,t)=>t-e)))e[t]>s&&(i--,void 0!==n&&n--),void 0!==r&&void 0!==n&&e[t]<=s&&r>=s&&n--;if(!(void 0!==n&&i>n))return{...e,[t]:i,[s]:n}}function Gi(...e){return{top:Math.min(...e.map((e=>e.top))),left:Math.min(...e.map((e=>e.left))),bottom:Math.max(...e.map((e=>e.bottom))),right:Math.max(...e.map((e=>e.right)))}}function Wi(e,t){if(Zi(e,t))return{top:Math.max(e.top,t.top),left:Math.max(e.left,t.left),bottom:Math.min(e.bottom,t.bottom),right:Math.min(e.right,t.right)}}function qi(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function Zi(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function Yi(e,t,o){const{left:s,right:i,top:n,bottom:r}=o;return e>=s&&e<=i&&t>=n&&t<=r}function ji(e,t){return qi(Gi(t,e),t)}function Xi(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function Ki(e){const{numberOfCols:t,numberOfRows:o}=Xi(e);return 1===t||1===o}function Qi(e){const t=[],{left:o,right:s,top:i,bottom:n}=Ji(e);for(const e of ve(o,s+1))for(const o of ve(i,n+1))t.push({col:e,row:o});return t}function Ji(e){return e.left>e.right&&(e={left:e.right,right:e.left,top:e.top,bottom:e.bottom}),e.top>e.bottom&&(e={left:e.left,right:e.right,top:e.bottom,bottom:e.top}),e}function en(e,t,o,s){const i="both"===t?s[0]:"columns"===t?s:0,n="both"===t?s[1]:"rows"===t?s:0,r="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||r?!(nn(e)&&!r)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===o&&(l.left+=i,l.top+=n),void 0!==l.right&&(l.right+=i),void 0!==l.bottom&&(l.bottom+=n),l}function tn(e,t){let o,s;const{left:i,right:n,top:r,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return o=l!=i?l:c!=n?c:l,s=h!=r?h:d!=a?d:h,{col:o,row:s}}function on(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function sn(e){return{...e,right:e.left,bottom:e.top}}function nn(e){return void 0===e.right}function rn(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function an(e){return e.length<2||1===Oi(e).length}function ln(e,t){const o=Gi(e,t);return e.right+1===t.left||e.left===t.right+1?cn(o)<=cn(e)+cn(t):(e.bottom+1===t.top||e.top===t.bottom+1)&&hn(o)<=hn(e)+hn(t)}function cn(e){return e.bottom-e.top+1}function hn(e){return e.right-e.left+1}function dn(e){const t=[...e];let o=!0;for(;o;){o=!1;for(let e=0;e<t.length;e++){const s=t[e],i=t.findIndex(((t,o)=>e!==o&&(ln(t,s)||Zi(t,s))));if(-1!==i){t[e]=Gi(t[i],s),t.splice(i,1),o=!0;break}}}return t}class un{getSheetSize;_zone;parts;invalidXc;prefixSheet=!1;sheetId;invalidSheetName;constructor(e,t){this.getSheetSize=t,this._zone=e.zone,this.prefixSheet=e.prefixSheet,this.invalidXc=e.invalidXc,this.sheetId=e.sheetId,this.invalidSheetName=e.invalidSheetName;let o=[...e.parts];1===e.parts.length&&rn(this.zone)>1?o.push({...e.parts[0]}):2===e.parts.length&&1===rn(this.zone)&&o.pop(),this.parts=o}static fromRange(e,t){return e instanceof un?e:new un(e,t.getSheetSize)}get unboundedZone(){return this._zone}get zone(){const{left:e,top:t,bottom:o,right:s}=this._zone;if(void 0!==s&&void 0!==o)return this._zone;if(void 0===o&&void 0!==s)return{right:s,top:t,left:e,bottom:this.getSheetSize(this.sheetId).numberOfRows-1};if(void 0===s&&void 0!==o)return{bottom:o,left:e,top:t,right:this.getSheetSize(this.sheetId).numberOfCols-1};throw new Error(uo("Bad zone format"))}static getRangeParts(e,t){const o=e.split(":").map((e=>{const t=xi(e);return{colFixed:!t&&e.startsWith("$"),rowFixed:t?e.startsWith("$"):e.includes("$",1)}})),s=void 0===t.bottom,i=void 0===t.right;return s&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed),i&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed),o}get isFullCol(){return void 0===this._zone.bottom}get isFullRow(){return void 0===this._zone.right}get rangeData(){return{_zone:this._zone,_sheetId:this.sheetId}}orderZone(){if(Vi(this._zone))return this;const e={...this._zone};let t=this.parts;if(void 0!==e.right&&e.right<e.left){let o=e.right;e.right=e.left,e.left=o,t=[{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1},{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1}]}if(void 0!==e.bottom&&e.bottom<e.top){let o=e.bottom;e.bottom=e.top,e.top=o,t=[{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1},{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1}]}return this.clone({zone:e,parts:t})}clone(e){return new un({zone:e?.zone?e.zone:{...this._zone},sheetId:e?.sheetId?e.sheetId:this.sheetId,invalidSheetName:e&&"invalidSheetName"in e?e.invalidSheetName:this.invalidSheetName,invalidXc:e&&"invalidXc"in e?e.invalidXc:this.invalidXc,parts:e?.parts?e.parts:this.parts.map((e=>({rowFixed:e.rowFixed,colFixed:e.colFixed}))),prefixSheet:void 0!==e?.prefixSheet?e.prefixSheet:this.prefixSheet},this.getSheetSize)}}function gn(e,t,o){const s=o.sheetId===e?t:o.sheetId;return o.clone({sheetId:s})}function pn(e,t,o){if(!o)return;const s=e.getRangeFromSheetXC(t,o);return s.invalidSheetName||s.invalidXc?void 0:s}function mn(e){const t=[];for(const o of e)for(const e of Qi(o.zone))t.push({...e,sheetId:o.sheetId});return t}function fn(e,t,o){const s=[];return t.forEach((t=>{const i=function(e,t){e=e.toLocaleLowerCase();let o=0,s=0,i=(t=t.toLocaleLowerCase()).length,n=0;for(let r=0;r<i;r++)t[r]===e[n]?(n++,s+=100+s-r/200):s=0,o+=s;return n===e.length?o:0}(e,o(t));i>0&&s.push({score:i,elem:t})})),s.sort(((e,t)=>t.score-e.score)),s.map((e=>e.elem))}function bn(e){const t=[];for(let o=0;o<e;o++){const e={cells:{}};t.push(e)}return t}function vn(e,t,o){return o.map((o=>o>=e?o+t:o))}function Sn(e,t){return e=[...e].sort(((e,t)=>t-e)),t.map((t=>{for(const o of e)if(t>o)t--;else if(t===o)return;return t})).filter(De)}function Cn(e,t=1){return t*(e+N)-N}function yn(e,t=!1,o=!1){return`${o?"italic":""} ${t?"bold":""} ${e}px ${W}`}const En={};function xn(e,t,o,s="pt"){const i=An(o,s);e.save(),e.font=i;const n=wn(e,t);return e.restore(),n}function wn(e,t){const o=e.font;if(En[o]||(En[o]={}),void 0===En[o][t]){const s=e.measureText(t).width;En[o][t]=s}return En[o][t]}const In={};function Rn(e,t,o,s="pt"){const i=An(o,s);e.save(),e.font=i;const n=function(e,t){const o=e.font;In[o]||(In[o]={});if(void 0===In[o][t]){const s=e.measureText(t),i=s.width,n=s.fontBoundingBoxAscent+s.fontBoundingBoxDescent;In[o][t]={width:i,height:n}}return In[o][t]}(e,t);return e.restore(),n}function Tn(e){return Math.round(96*e/72)}function An(e,t="pt"){return`${e.italic?"italic ":""}${e.bold?"bold":$} ${("pt"===t?On(e):e.fontSize)??G}px ${W}`}function On(e){return Tn(e?.fontSize||G)}function _n(e,t,o,s){if(xn(e,t,s)<=o)return[t];const i=[];let n="";for(let r of t){xn(e,n+r,s)>o?(i.push(n),n=r):n+=r}return i.push(n),i}function Dn(e,t,o,s){o||(o={});const i=[],n=t.includes(le)?t.split(le):[t];for(const t of n){const n=t.includes(" ")?t.split(" "):[t];if(!s){i.push(t);continue}let r="",a=s;for(let t of n){const n=_n(e,t,s,o),l=n.pop(),c=xn(e,l,o);if(n.length)""!==r&&(i.push(r),r="",a=s),n.forEach((e=>{i.push(e)})),r=l,a=s-c;else{const t=""===r?l:" "+l,n=xn(e,t,o);n<=a?(r+=t,a-=n):(i.push(r),r=l,a=s-c)}}""!==r&&i.push(r)}return i}function Mn(e,t,o,s=.25){let i=1;if(o(i)>e)return i;if(o(t)<e)return t;let n=(i+t)/2,r=o(n),a=0;for(;Math.abs(r-e)>s&&a<20;)r>=e?t=(i+t)/2:i=(i+t)/2,n=(i+t)/2,r=o(n),a++;return n}function Fn(e){return e?e.toLowerCase():""}const Nn=/([0-9\.]*)px/;function Pn(e,t,o){let s=wn(e,t);if(s<=o)return t;const i=wn(e,t);if(s<=i)return t;let n=t.length;for(;s>=o-i&&n-- >0;)s=wn(e,t=t.substring(0,n));return t+"…"}function Ln(e){let t="";for(;" "===e[0];)t+=" ",e=e.slice(1);const o=e.length,s=Math.floor(o/2),i=e.substring(0,s).lastIndexOf(" "),n=e.substring(s).indexOf(" ")+s;return-1===i&&n===s-1?[t+e,""]:i>o-n||n===s-1?[t+e.slice(0,i),t+e.slice(i+1)]:[t+e.slice(0,n),t+e.slice(n+1)]}function kn(e,t,o,s=!1,i=!1,n=function(e){return Number(e.match(Nn)?.[1])}(e.font)/10){if(e.fillText(t,o.x,o.y),!s&&!i)return;const r=e.measureText(t),a=r.width,l=r.actualBoundingBoxAscent+r.actualBoundingBoxDescent,c=r.fontBoundingBoxAscent+r.fontBoundingBoxDescent;let{x:h,y:d}=o,u=d,g=d;switch(e.textAlign){case"center":h-=a/2;break;case"right":h-=a}switch(e.textBaseline){case"top":g+=c-2*n,u+=c/2-n;break;case"middle":g+=c/2-n;break;case"alphabetic":g+=2*n,u-=3*n;break;case"bottom":g=d,u-=l/2-n/2}s&&(e.lineWidth=n,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(h,g),e.lineTo(h+a,g),e.stroke()),i&&(e.lineWidth=n,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(h,u),e.lineTo(h+a,u),e.stroke())}class Vn{isFastIdStrategy=!1;fastIdStart=0;setIsFastStrategy(e){this.isFastIdStrategy=e}uuidv4(){return this.isFastIdStrategy?(this.fastIdStart++,String(this.fastIdStart)):window.crypto&&window.crypto.getRandomValues?([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))):"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}}function Un(e){return e.map(Hn).sort(((e,t)=>e.sequence-t.sequence))}const Bn=new Vn;function Hn(e){const t=e.name,o=e.children,s=e.description,i=e.icon,n=e.secondaryIcon;return{id:e.id||Bn.uuidv4(),name:"function"==typeof t?t:()=>t,isVisible:e.isVisible?e.isVisible:()=>!0,isEnabled:e.isEnabled?e.isEnabled:()=>!0,isActive:e.isActive,execute:e.execute,children:o?e=>o.map((t=>"function"==typeof t?t(e):t)).flat().map(Hn):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:"function"==typeof i?i:()=>i||"",secondaryIcon:"function"==typeof n?n:()=>n||"",description:"function"==typeof s?s:()=>s||"",textColor:e.textColor,sequence:e.sequence||0,onStartHover:e.onStartHover,onStopHover:e.onStopHover}}class zn{content={};add(e,t){return this.content[e]=t,this}get(e){const t=this.content[e];if(!t&&!(e in this.content))throw new 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 $n(e){const t=new Set(e.map((e=>e.left))),o=new Set(e.map((e=>e.right))),s=new Set(e.map((e=>e.top))),i=new Set(e.map((e=>e.bottom))),n=1===s.size&&1===i.size||1===t.size&&1===o.size?function(e){return e.reduce(((e,t)=>{const o=e.length;for(let s=0;s<o;s++)if(Zi(e[s],t))return e[s]=Gi(e[s],t),e;return e[o]=t,e}),[])}(e):[e[e.length-1]],r=n.map((e=>Qi(e))).flat();return{zones:e,clippedZones:n,columnsIndexes:[...new Set(r.map((e=>e.col)))].sort(((e,t)=>e-t)),rowsIndexes:[...new Set(r.map((e=>e.row)))].sort(((e,t)=>e-t))}}function Gn(e,t){if(!t.length||!t[0].length)return e;const o=t[0].length,s=t.length;return e.map((e=>function(e,t,o){const s=Math.max(e.right-t+1,e.left),i=Math.max(e.bottom-o+1,e.top),n=[];for(let r=e.left;r<=s;r+=t)for(let s=e.top;s<=i;s+=o)n.push({left:r,top:s,bottom:s+o-1,right:r+t-1});return n}(e,o,s))).flat()}class Wn{getters;dispatch;constructor(e,t){this.getters=e,this.dispatch=t}copy(e){}paste(e,t,o){}isPasteAllowed(e,t,o,s){return"Success"}isCutAllowed(e){return"Success"}getPasteTarget(e,t,o){return{zones:[]}}convertOSClipboardData(e){}}class qn extends Wn{copy(e){}pasteFromCopy(e,t,o,s){if(1===t.length)for(const i of Gn(t,o))this.pasteZone(e,i.left,i.top,o,s);else for(const i of Oi(t))for(let t=i.left;t<=i.right;t++)for(let n=i.top;n<=i.bottom;n++)this.pasteZone(e,t,n,o,s)}pasteZone(e,t,o,s,i){}}const Zn=["%"],Yn="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(Zn);function jn(e,t=Ao){e=qe(e);const o=new lr(e),s=[];for(;!o.isOver();){let e=rr(o)||Jn(o,t)||Qn(o)||er(o)||sr(o)||Xn(o)||ar(o)||or(o,t)||nr(o);e||(e={type:"UNKNOWN",value:o.shift()}),s.push(e)}return s}function Xn(e){return"?"===e.current?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const Kn={"(":{type:"LEFT_PAREN",value:"("},")":{type:"RIGHT_PAREN",value:")"}};function Qn(e){if("("===e.current||")"===e.current){const t=e.shift();return Kn[t]}return null}function Jn(e,t){if(e.current===t.formulaArgSeparator){return{type:"ARG_SEPARATOR",value:e.shift()}}return null}function er(e){for(let t of Yn)if(e.currentStartsWith(t))return e.advanceBy(t.length),{type:"OPERATOR",value:t};return null}const tr=new Set("0123456789");function or(e,t){if(!tr.has(e.current)&&e.current!==t.decimalSeparator)return null;const o=e.remaining().match(oo(t.decimalSeparator));return o?(e.advanceBy(o[0].length),{type:"NUMBER",value:o[0]}):null}function sr(e){if('"'===e.current){const t=e.shift();let o=t;for(;e.current&&(e.current!==t||"\\"===o[o.length-1]);)o+=e.shift();return'"'===e.current&&(o+=e.shift()),{type:"STRING",value:o}}return null}const ir=new Set("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.!$");function nr(e){let t="";if("'"===e.current){let o=e.shift();for(t+=o;e.current;)if(o=e.shift(),t+=o,"'"===o){if(!e.current||"'"!==e.current)break;o=e.shift(),t+=o}if("'"!==o)return{type:"UNKNOWN",value:t}}for(;e.current&&ir.has(e.current);)t+=e.shift();if(t.length){const e=t;return yi.test(e)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}function rr(e){let t=0;for(;e.current===le;)t++,e.shift();if(t)return{type:"SPACE",value:le.repeat(t)};for(;" "===e.current;)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function ar(e){return e.currentStartsWith(No.InvalidReference)?(e.advanceBy(No.InvalidReference.length),{type:"INVALID_REFERENCE",value:No.InvalidReference}):null}class lr{text;currentIndex=0;current;constructor(e){this.text=e,this.current=e[0]}shift(){const e=this.current,t=this.text[++this.currentIndex];return this.current=t,e}advanceBy(e){this.currentIndex+=e,this.current=this.text[this.currentIndex]}isOver(){return this.currentIndex>=this.text.length}remaining(){return this.text.substring(this.currentIndex)}currentStartsWith(e){if(this.current!==e[0])return!1;for(let t=1;t<e.length;t++)if(this.text[this.currentIndex+t]!==e[t])return!1;return!0}}function cr(e){if(!e||"object"!=typeof e||"string"!=typeof e.name||"string"!=typeof e.code||"string"!=typeof e.thousandsSeparator||"string"!=typeof e.decimalSeparator||"string"!=typeof e.dateFormat||"string"!=typeof e.timeFormat||"string"!=typeof e.formulaArgSeparator)return!1;if(!Object.values(e).every((e=>e)))return!1;if(e.formulaArgSeparator===e.decimalSeparator)return!1;if(e.thousandsSeparator===e.decimalSeparator)return!1;try{Hs(1,{locale:e,format:"#,##0.00"}),Hs(1,{locale:e,format:e.dateFormat}),Hs(1,{locale:e,format:e.timeFormat})}catch{return!1}return!0}function hr(e,t){return e.startsWith("=")?gr(e,t):fr(e,t)}function dr(e,t){return e.startsWith("=")?gr(e,t):function(e,t){if(Ht(e,t)){const o=Zo(e,t);let s=Ao.dateFormat;return Number.isInteger(o)||(s+=" "+Ao.timeFormat),Hs(o,{locale:Ao,format:s})}return fr(e,t)}(e,t)}function ur(e,t){return e.startsWith("=")?pr(e,t):function(e,t){if(Ht(e,Ao)){const o=Zo(e,Ao);let s=t.dateFormat;return Number.isInteger(o)||(s+=" "+t.timeFormat),Hs(o,{locale:t,format:s})}return function(e,t){if("."===t.decimalSeparator||!io(e,Ao))return e;const o=Js(Ao),s=e.replace(o,(e=>e.replace(".",t.decimalSeparator)));return s}(e,t)}(e,t)}function gr(e,t){return mr(e,t,Ao)}function pr(e,t){return mr(e,Ao,t)}function mr(e,t,o){if(t.formulaArgSeparator===o.formulaArgSeparator&&t.decimalSeparator===o.decimalSeparator)return e;const s=jn(e,t);let i="";for(const e of s)"NUMBER"===e.type?i+=e.value.replace(t.decimalSeparator,o.decimalSeparator):"ARG_SEPARATOR"===e.type?i+=o.formulaArgSeparator:i+=e.value;return i}function fr(e,t){return"."!==t.decimalSeparator&&io(e,t)?e.replace(t.thousandsSeparator,"").replace(t.decimalSeparator,"."):e}function br(e,t){return Cr(e,(e=>dr(e,t)))}function vr(e,t){return Cr(e,(e=>ur(e,t)))}function Sr(e,t){const o=ge(e);return o.criterion.values=o.criterion.values.map((e=>ur(e,t))),o}function Cr(e,t){switch((e=ge(e)).type){case"CellIsRule":switch(e.operator){case"Between":case"NotBetween":case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return e.values=e.values.map((e=>t(e))),e;case"BeginsWith":case"ContainsText":case"EndsWith":case"NotContains":case"IsEmpty":case"IsNotEmpty":return e}break;case"ColorScaleRule":return e.minimum=yr(e.minimum,t),e.maximum=yr(e.maximum,t),e.midpoint&&(e.midpoint=yr(e.midpoint,t)),e;case"IconSetRule":return e.lowerInflectionPoint.value=t(e.lowerInflectionPoint.value),e.upperInflectionPoint.value=t(e.upperInflectionPoint.value),e}}function yr(e,t){if(!e?.value)return e;const o=t("formula"===e.type?"="+e.value:e.value),s="formula"===e.type?o.slice(1):o;return{...e,value:s}}function Er(e){return e.dateFormat+" "+e.timeFormat}function xr(e,t){return e.startsWith("=")?function(e,t){return function(e,t,o){if(t.formulaArgSeparator===o.formulaArgSeparator&&t.decimalSeparator===o.decimalSeparator)return e;const s=jn(e,t);let i="";for(const e of s)"NUMBER"===e.type?i+=e.value.replace(t.decimalSeparator,o.decimalSeparator):"ARG_SEPARATOR"===e.type?i+=o.formulaArgSeparator:i+=e.value;return i}(e,t,Ao)}(e,t):fr(e,t)}class wr extends qn{isCutAllowed(e){return 1!==e.zones.length?"WrongCutSelection":"Success"}copy(e){if(!("zones"in e)||!e.zones.length)return;const t=this.getters.getActiveSheetId();if(!e.zones.length)return{cells:[[]],zones:[],sheetId:t};const{clippedZones:o,rowsIndexes:s,columnsIndexes:i}=e,n=[];for(let e of s){let o=[];for(let n of i){const r={col:n,row:e,sheetId:t},a=this.getters.getArrayFormulaSpreadingOn(r);let l=this.getters.getCell(r);const c=this.getters.getEvaluatedCell(r);if(a&&!Be(a,r)){const e=s.includes(a.row)&&i.includes(a.col)?"":Hs(c.value,{locale:this.getters.getLocale()});l={id:l?.id||"",style:l?.style,format:c.format,content:e,isFormula:!1}}o.push({cell:l,border:this.getters.getCellBorder(r)||void 0,evaluatedCell:c,position:r})}n.push(o)}return{cells:n,zones:o,sheetId:this.getters.getActiveSheetId()}}isPasteAllowed(e,t,o,s){return"cells"in o?s?.isCutOperation&&void 0!==s?.pasteOption?"WrongPasteOption":t.length>1&&(o.cells.length>1||o.cells[0].length>1)?"WrongPasteSelection":"Success":"Success"}paste(e,t,o){if(!("cells"in t)||!("zones"in e)||!e.zones.length)return;const s=e.zones,i=this.getters.getActiveSheetId();o?.isCutOperation?this.pasteFromCut(i,s,t,o):this.pasteFromCopy(i,s,t.cells,o)}getPasteTarget(e,t,o){const s=t.cells[0].length,i=t.cells.length;return o?.isCutOperation?{zones:[{left:e[0].left,top:e[0].top,right:e[0].left+s-1,bottom:e[0].top+i-1}]}:1===s&&1===i?{zones:[]}:{zones:Gn(e,t.cells)}}pasteFromCut(e,t,o,s){this.clearClippedZones(o);const i=t[0];this.pasteZone(e,i.left,i.top,o.cells,s),this.dispatch("MOVE_RANGES",{target:o.zones,sheetId:o.sheetId,targetSheetId:e,col:i.left,row:i.top})}clearClippedZones(e){for(const t of e.cells)for(const e of t)e.cell&&this.dispatch("CLEAR_CELL",e.position);this.dispatch("CLEAR_FORMATTING",{sheetId:e.sheetId,target:e.zones})}pasteZone(e,t,o,s,i){for(const[n,r]of s.entries())for(const[s,a]of r.entries()){if(!a)continue;const r={col:t+s,row:o+n,sheetId:e};this.pasteCell(a,r,i)}}pasteCell(e,t,o){const{sheetId:s,col:i,row:n}=t,r=this.getters.getEvaluatedCell(t),a=e.cell?.format??e.evaluatedCell.format;if("asValue"===o?.pasteOption){const o=this.getters.getLocale(),s=Hs(e.evaluatedCell.value,{locale:o});return void this.dispatch("UPDATE_CELL",{...t,content:s,format:a})}if("onlyFormat"===o?.pasteOption)return void this.dispatch("UPDATE_CELL",{...t,style:e.cell?.style??null,format:a??r.format});let l=e.cell?.content;e.cell?.isFormula&&!o?.isCutOperation?l=this.getters.getTranslatedCellFormula(s,i-e.position.col,n-e.position.row,e.cell.compiledFormula):e.cell?.isFormula&&(l=this.getters.getFormulaMovedInSheet(s,e.cell.compiledFormula)),""!==l||e.cell?.format||e.cell?.style?this.dispatch("UPDATE_CELL",{...t,content:l,style:e.cell?.style||null,format:e.cell?.format}):r&&this.dispatch("CLEAR_CELL",t)}convertOSClipboardData(e){const t=this.getters.getLocale(),o={cells:[]},s=[];let i=0;for(const[t,o]of e.replace(/\r/g,"").split("\n").entries())s.push(o.split("\t")),s[t].length>i&&(i=s[t].length);for(const e of s){const s=[];for(let o=0;o<i;o++){const i=xr(e[o]||"",t);s.push({cell:{isFormula:!1,content:i},evaluatedCell:{formattedValue:i}})}o.cells.push(s)}return o}}class Ir extends Wn{copy(e){}}const Rr={figureHandlers:new zn,cellHandlers:new zn};function Tr(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?$i(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?Bi(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function Ar(e,t){const o="DELETE_SHEET"===t.type&&t.sheetId;if("sheetId"in t&&e._sheetId!==t.sheetId)return e;{const s=Tr(e._zone,t);if(s&&o!==e._sheetId)return{...e,_zone:s}}}Rr.figureHandlers.add("chart",class extends Ir{copy(e){const t=this.getters.getActiveSheetId(),o=this.getters.getFigure(t,e.figureId);if(!o)throw new Error(`No figure for the given id: ${e.figureId}`);if("chart"!==o.tag)return;const s={...o},i=this.getters.getChart(e.figureId);if(!i)throw new Error(`No chart for the given id: ${e.figureId}`);const n=i.copyInSheetId(t);return{figureId:e.figureId,copiedFigure:s,copiedChart:n}}getPasteTarget(e,t,o){if(!t?.copiedFigure||!t?.copiedChart)return{zones:[]};return{zones:[],figureId:(new Vn).uuidv4()}}paste(e,t,o){if(!t?.copiedFigure||!t?.copiedChart||!e.figureId)return;const{zones:s,figureId:i}=e,n=this.getters.getActiveSheetId(),r=this.getters.getNumberCols(n),a=this.getters.getNumberRows(n),l=this.getters.getColDimensions(n,s[0].left).start,c=this.getters.getRowDimensions(n,s[0].top).start,h=this.getters.getColDimensions(n,r-1).end,d=this.getters.getRowDimensions(n,a-1).end,{width:u,height:g}=t.copiedFigure,p={x:h<u?0:Math.min(l,h-u),y:d<g?0:Math.min(c,d-g)},m=t.copiedChart.copyInSheetId(n);this.dispatch("CREATE_CHART",{id:i,sheetId:n,position:p,size:{height:g,width:u},definition:m.getDefinition()}),o?.isCutOperation&&this.dispatch("DELETE_FIGURE",{sheetId:t.copiedChart.sheetId,id:t.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:i})}isPasteAllowed(e,t,o,s){return 0===t.length?"EmptyTarget":void 0!==s?.pasteOption?"WrongFigurePasteOption":"Success"}}).add("image",class extends Ir{copy(e){const t=this.getters.getActiveSheetId(),o=this.getters.getFigure(t,e.figureId);if(!o)throw new Error(`No figure for the given id: ${e.figureId}`);const s={...o};if("image"!==o.tag)return;const i=ge(this.getters.getImage(e.figureId));return{figureId:e.figureId,copiedFigure:s,copiedImage:i,sheetId:t}}getPasteTarget(e,t,o){if(!t?.copiedFigure||!t?.copiedImage)return{zones:[]};return{zones:[],figureId:(new Vn).uuidv4()}}paste(e,t,o){if(!t?.copiedFigure||!t?.copiedImage||!e.figureId)return;const{zones:s,figureId:i}=e,n=this.getters.getActiveSheetId(),r=this.getters.getNumberCols(n),a=this.getters.getNumberRows(n),l=this.getters.getColDimensions(n,s[0].left).start,c=this.getters.getRowDimensions(n,s[0].top).start,h=this.getters.getColDimensions(n,r-1).end,d=this.getters.getRowDimensions(n,a-1).end,{width:u,height:g}=t.copiedFigure,p={x:h<u?0:Math.min(l,h-u),y:d<g?0:Math.min(c,d-g)},m=ge(t.copiedImage);this.dispatch("CREATE_IMAGE",{figureId:i,sheetId:n,position:p,size:{height:g,width:u},definition:m}),o?.isCutOperation&&this.dispatch("DELETE_FIGURE",{sheetId:t.sheetId,id:t.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:i})}isPasteAllowed(e,t,o,s){return 0===t.length?"EmptyTarget":void 0!==s?.pasteOption?"WrongFigurePasteOption":"Success"}}),Rr.cellHandlers.add("dataValidation",class extends qn{uuidGenerator=new Vn;copy(e){if(!e.zones.length)return;const{rowsIndexes:t,columnsIndexes:o}=e,s=this.getters.getActiveSheetId();return{cellPositions:t.map((e=>o.map((t=>({col:t,row:e,sheetId:s})))))}}paste(e,t,o){if(!t?.cellPositions)return;if(o?.pasteOption)return;if(!("zones"in e)||!e.zones.length)return;const s=e.zones,i=this.getters.getActiveSheetId();o?.isCutOperation?this.pasteFromCut(i,s,t):this.pasteFromCopy(i,s,t.cellPositions)}pasteFromCut(e,t,o){const s=t[0];this.pasteZone(e,s.left,s.top,o.cellPositions,{isCutOperation:!0})}pasteZone(e,t,o,s,i){for(const[n,r]of s.entries())for(const[s,a]of r.entries()){const r={col:t+s,row:o+n,sheetId:e};this.pasteDataValidation(a,r,i?.isCutOperation)}}pasteDataValidation(e,t,o){const s=this.getters.getValidationRuleForCell(e);if(!s){const e=this.getters.getValidationRuleForCell(t);return void(e&&this.adaptDataValidationRule(t.sheetId,e,[],[on(t)]))}const i=on(t);for(const n of s.ranges)if(Yi(e.col,e.row,n.zone)){const n=[];if(o&&n.push(on(e)),e.sheetId===t.sheetId)this.adaptDataValidationRule(e.sheetId,s,[i],n);else{this.adaptDataValidationRule(e.sheetId,s,[],n);const o=this.getDataValidationRuleToCopyTo(t.sheetId,s);this.adaptDataValidationRule(t.sheetId,o,[i],[])}}}getDataValidationRuleToCopyTo(e,t){const o=this.getters.getDataValidationRules(e).find((e=>Be(t.criterion,e.criterion)&&t.isBlocking===e.isBlocking));return o||{...t,id:this.uuidGenerator.uuidv4(),ranges:[]}}adaptDataValidationRule(e,t,o,s){const i=t.ranges.map((e=>e.zone)),n=Oi([...i,...o],s);0!==n.length?this.dispatch("ADD_DATA_VALIDATION_RULE",{rule:t,ranges:n.map((t=>this.getters.getRangeDataFromZone(e,t))),sheetId:e}):this.dispatch("REMOVE_DATA_VALIDATION_RULE",{sheetId:e,id:t.id})}}).add("cell",wr).add("sheet",class extends qn{isPasteAllowed(e,t,o,s){if(!("cells"in o))return"Success";const{xSplit:i,ySplit:n}=this.getters.getPaneDivisions(e);for(const e of Gn(t,o.cells))if(e.left<i&&e.right>=i||e.top<n&&e.bottom>=n)return"FrozenPaneOverlap";return"Success"}}).add("merge",class extends qn{isPasteAllowed(e,t,o){if(!("cells"in o))return"Success";const s=o.cells.length,i=o.cells[0].length;for(const n of Gn(t,o.cells))if(this.getters.doesIntersectMerge(e,n)&&(t.length>1||!this.getters.isSingleCellOrMerge(e,t[0])||s*i!=1))return"WillRemoveExistingMerge";return"Success"}paste(e,t,o){if(o?.isCutOperation||!("zones"in e)||!e.zones.length)return;const s=this.getters.getActiveSheetId();this.pasteFromCopy(s,e.zones,t.cells,o)}pasteZone(e,t,o,s){for(const[i,n]of s.entries())for(const[s,r]of n.entries()){if(!r.position)continue;const n={col:t+s,row:o+i,sheetId:e};this.pasteMergeIfExist(r.position,n)}}pasteMergeIfExist(e,t){let{sheetId:o,col:s,row:i}=e;const{col:n,row:r}=this.getters.getMainCellPosition(e);if(n===s&&r===i){const n=this.getters.getMerge(e);if(!n)return;({sheetId:o,col:s,row:i}=t),this.dispatch("ADD_MERGE",{sheetId:o,force:!0,target:[{left:s,top:i,right:s+n.right-n.left,bottom:i+n.bottom-n.top}]})}}}).add("border",class extends qn{copy(e){const t=this.getters.getActiveSheetId();if(0===e.zones.length)return;const{rowsIndexes:o,columnsIndexes:s}=e,i=[];for(const e of o){const o=[];for(const i of s){const s={col:i,row:e,sheetId:t};o.push(this.getters.getCellBorder(s))}i.push(o)}return{borders:i}}paste(e,t,o){if(!t)return;const s=this.getters.getActiveSheetId();if("asValue"===o?.pasteOption)return;if(!("borders"in t)||!("zones"in e)||!e.zones.length)return;const i=e.zones;if(o?.isCutOperation){const{left:e,top:o}=i[0];this.pasteZone(s,e,o,t.borders)}else this.pasteFromCopy(s,i,t.borders)}pasteZone(e,t,o,s){for(const[i,n]of s.entries())for(const[s,r]of n.entries()){const n={col:t+s,row:o+i,sheetId:e};this.pasteBorder(r,n)}}pasteBorder(e,t){const o={...this.getters.getCellBorder(t),...e};this.dispatch("SET_BORDER",{...t,border:o})}}).add("table",class extends qn{copy(e){const t=this.getters.getActiveSheetId(),{rowsIndexes:o,columnsIndexes:s,zones:i}=e;if(!i||!o.length||!s.length)return{tableCells:[[]],sheetId:t};const n=new Set,r=[];for(let e of o){let o=[];r.push(o);for(let r of s){const s={col:r,row:e,sheetId:t},a=this.getters.getTable(s);if(!a||n.has(a.id)){o.push({});continue}const l=this.getters.getCoreTable(s),c=l?.range.zone;if(l&&c&&i.some((e=>ji(c,e)))){n.add(l.id);const e=[];for(const o of ve(c.left,c.right+1))e.push(this.getters.getFilterHiddenValues({sheetId:t,col:o,row:c.top}));o.push({table:{range:l.range,config:l.config,type:l.type}})}else a&&o.push({style:this.getTableStyleToCopy(s)})}}return{tableCells:r,sheetId:this.getters.getActiveSheetId()}}getTableStyleToCopy(e){const t=this.getters.getCellTableStyle(e),o=this.getters.getCellStyle(e),s=this.getters.getCellTableBorder(e),i=this.getters.getCellBorder(e);return{style:{...t,...$e(o)},border:{...s,...$e(i)}}}paste(e,t,o){if(!t||!t.tableCells)return;const s=e.zones,i=this.getters.getActiveSheetId();o?.isCutOperation?this.pasteFromCut(i,s,t,o):this.pasteFromCopy(i,s,t.tableCells,o)}pasteFromCut(e,t,o,s){for(const e of o.tableCells)for(const t of e)t.table&&this.dispatch("REMOVE_TABLE",{sheetId:o.sheetId,target:[t.table.range.zone]});const i=t[0];this.pasteZone(e,i.left,i.top,o.tableCells,s)}pasteZone(e,t,o,s,i){for(let n=0;n<s.length;n++){const r=s[n];for(let s=0;s<r.length;s++){const a=r[s];if(!a)continue;const l={col:t+s,row:o+n,sheetId:e};this.pasteTableCell(e,a,l,i)}}if(1===s.length)for(let i=0;i<s[0].length;i++)this.dispatch("AUTOFILL_TABLE_COLUMN",{col:t+i,row:o,sheetId:e})}pasteTableCell(e,t,o,s){if(t.table&&!s?.pasteOption){const{range:s}=t.table,i=Xi(s.zone),n={left:o.col,top:o.row,right:o.col+i.numberOfCols-1,bottom:o.row+i.numberOfRows-1};this.dispatch("CREATE_TABLE",{sheetId:o.sheetId,ranges:[this.getters.getRangeDataFromZone(e,n)],config:t.table.config,tableType:t.table.type})}this.getters.getCoreTable(o)||(t.style?.style&&"asValue"!==s?.pasteOption&&this.dispatch("UPDATE_CELL",{...o,style:t.style.style}),t.style?.border&&this.dispatch("SET_BORDER",{...o,border:t.style.border}))}}).add("conditionalFormat",class extends qn{uuidGenerator=new Vn;copy(e){if(!e.zones.length)return;const{rowsIndexes:t,columnsIndexes:o}=e,s=this.getters.getActiveSheetId();return{cellPositions:t.map((e=>o.map((t=>({col:t,row:e,sheetId:s})))))}}paste(e,t,o){if(!t?.cellPositions||"asValue"===o?.pasteOption||!("zones"in e)||!e.zones.length)return;const s=e.zones,i=this.getters.getActiveSheetId();o?.isCutOperation?this.pasteFromCut(i,s,t):this.pasteFromCopy(i,s,t.cellPositions)}pasteFromCut(e,t,o){const s=t[0];this.pasteZone(e,s.left,s.top,o.cellPositions,{isCutOperation:!0})}pasteZone(e,t,o,s,i){for(const[n,r]of s.entries())for(const[s,a]of r.entries()){const r={col:t+s,row:o+n,sheetId:e};this.pasteCf(a,r,i?.isCutOperation)}}pasteCf(e,t,o){const s=on(t);for(const i of this.getters.getConditionalFormats(e.sheetId))for(const n of i.ranges)if(Yi(e.col,e.row,this.getters.getRangeFromSheetXC(e.sheetId,n).zone)){const n=[];if(o&&n.push(on(e)),e.sheetId===t.sheetId)this.adaptCFRules(e.sheetId,i,[s],n);else{this.adaptCFRules(e.sheetId,i,[],n);const o=this.getCFToCopyTo(t.sheetId,i);this.adaptCFRules(t.sheetId,o,[s],[])}}}adaptCFRules(e,t,o,s){const i=this.getters.getAdaptedCfRanges(e,t,o,s);i&&(0!==i.length?this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},ranges:i,sheetId:e}):this.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:t.id,sheetId:e}))}getCFToCopyTo(e,t){const o=this.getters.getConditionalFormats(e).find((e=>e.stopIfTrue===t.stopIfTrue&&Be(e.rule,t.rule)));return o||{...t,id:this.uuidGenerator.uuidv4(),ranges:[]}}});const Or=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,_r=["-","+"],Dr=["%"],Mr=["*","+","&"],Fr={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10};function Nr(e){const t=e.shift();if(!t)throw new ko;switch(t.type){case"DEBUGGER":const o=kr(e,1e3);return o.debug=!0,o;case"NUMBER":return{type:"NUMBER",value:ro(t.value,Ao)};case"STRING":return{type:"STRING",value:de(t.value)};case"INVALID_REFERENCE":throw new Vo;case"REFERENCE":if(":"===e[0]?.value&&"REFERENCE"===e[1]?.type){e.shift();const o=e.shift();return{type:"REFERENCE",value:`${t.value}:${o?.value}`}}return{type:"REFERENCE",value:t.value};case"SYMBOL":const s=t.value,i=e[0];if("LEFT_PAREN"===i?.type&&Or.test(t.value)){const t=function(e){Lr(e,"LEFT_PAREN",uo("Missing opening parenthesis"));const t=e[0];if("RIGHT_PAREN"===t?.type)return Lr(e,"RIGHT_PAREN"),[];const o=[];o.push(Pr(e));for(;"RIGHT_PAREN"!==e[0]?.type;)Lr(e,"ARG_SEPARATOR",uo("Wrong function call")),o.push(Pr(e));return Lr(e,"RIGHT_PAREN"),o}(e);return{type:"FUNCALL",value:s,args:t}}const n=s.toUpperCase();if("TRUE"===n||"FALSE"===n)return{type:"BOOLEAN",value:"TRUE"===n};throw new ko(uo("Invalid formula"));case"LEFT_PAREN":const r=kr(e);return Lr(e,"RIGHT_PAREN",uo("Missing closing parenthesis")),r;case"OPERATOR":const a=t.value;if(_r.includes(a))return{type:"UNARY_OPERATION",value:a,operand:kr(e,Fr[a])};throw new ko(uo("Unexpected token: %s",t.value));default:throw new ko(uo("Unexpected token: %s",t.value))}}function Pr(e){const t=e[0];return"ARG_SEPARATOR"===t?.type||"RIGHT_PAREN"===t?.type?{type:"EMPTY",value:""}:kr(e)}function Lr(e,t,o){const s=e.shift();if(!s||s.type!==t)throw new ko(o)}function kr(e,t=0){if(0===e.length)throw new ko;let o=Nr(e);for(;"OPERATOR"===e[0]?.type&&Fr[e[0].value]>t;){const t=e.shift().value;if(Dr.includes(t))o={type:"UNARY_OPERATION",value:t,operand:o,postfix:!0};else{o={type:"BIN_OPERATION",value:t,left:o,right:kr(e,Fr[t])}}}return o}function Vr(e){return Ur(jn(e))}function Ur(e){"="===(e=e.filter((e=>"SPACE"!==e.type)))[0].value&&e.splice(0,1);const t=kr(e);if(e.length)throw new ko;return t}function Br(e,t,o){return $r(e,(e=>e.type===t?o(e):e))}function Hr(e){return Array.from(zr(e))}function*zr(e){switch(yield e,e.type){case"FUNCALL":for(const t of e.args)yield*zr(t);break;case"UNARY_OPERATION":yield*zr(e.operand);break;case"BIN_OPERATION":yield*zr(e.left),yield*zr(e.right)}}function $r(e,t){switch((e=t(e)).type){case"FUNCALL":return{...e,args:e.args.map((e=>$r(e,t)))};case"UNARY_OPERATION":return{...e,operand:$r(e.operand,t)};case"BIN_OPERATION":return{...e,right:$r(e.right,t),left:$r(e.left,t)};default:return e}}function Gr(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>Gr(e)));return`${e.value}(${t.join(",")})`;case"NUMBER":return e.value.toString();case"REFERENCE":default:return e.value;case"STRING":return`"${e.value}"`;case"BOOLEAN":return e.value?"TRUE":"FALSE";case"UNARY_OPERATION":return e.postfix?Wr(e)+e.value:e.value+qr(e);case"BIN_OPERATION":return Wr(e)+e.value+qr(e)}}function Wr(e){const t=e.value,o="left"in e?e.left:e.operand,s=o.value;return"BIN_OPERATION"===o.type&&Fr[s]<Fr[t]?`(${Gr(o)})`:Gr(o)}function qr(e){const t=e.value,o="right"in e?e.right:e.operand,s=Fr[o.value],i=Fr[t];let n=!1;return"BIN_OPERATION"!==o.type?n=!1:s<i?n=!0:s!==i||Mr.includes(t)||(n=!0),n?`(${Gr(o)})`:Gr(o)}var Zr;!function(e){e[e.LeftRef=0]="LeftRef",e[e.RightRef=1]="RightRef",e[e.Separator=2]="Separator",e[e.FullColumnSeparator=3]="FullColumnSeparator",e[e.FullRowSeparator=4]="FullRowSeparator",e[e.RightColumnRef=5]="RightColumnRef",e[e.RightRowRef=6]="RightRowRef",e[e.Found=7]="Found"}(Zr||(Zr={}));const Yr=(e,t=(()=>!0))=>[{goTo:e,guard:t}],jr=(e,t=(()=>!0))=>({goTo:e,guard:t}),Xr={[Zr.LeftRef]:{REFERENCE:Yr(Zr.Separator),NUMBER:Yr(Zr.FullRowSeparator),SYMBOL:[jr(Zr.FullColumnSeparator,(e=>Ei(e.value))),jr(Zr.FullRowSeparator,(e=>xi(e.value)))]},[Zr.FullColumnSeparator]:{SPACE:Yr(Zr.FullColumnSeparator),OPERATOR:Yr(Zr.RightColumnRef,(e=>":"===e.value))},[Zr.FullRowSeparator]:{SPACE:Yr(Zr.FullRowSeparator),OPERATOR:Yr(Zr.RightRowRef,(e=>":"===e.value))},[Zr.Separator]:{SPACE:Yr(Zr.Separator),OPERATOR:Yr(Zr.RightRef,(e=>":"===e.value))},[Zr.RightRef]:{SPACE:Yr(Zr.RightRef),NUMBER:Yr(Zr.Found),REFERENCE:Yr(Zr.Found,(e=>Ri(e.value))),SYMBOL:Yr(Zr.Found,(e=>wi(e.value)||Ii(e.value)))},[Zr.RightColumnRef]:{SPACE:Yr(Zr.RightColumnRef),SYMBOL:Yr(Zr.Found,(e=>wi(e.value))),REFERENCE:Yr(Zr.Found,(e=>Ri(e.value)))},[Zr.RightRowRef]:{SPACE:Yr(Zr.RightRowRef),NUMBER:Yr(Zr.Found),REFERENCE:Yr(Zr.Found,(e=>Ri(e.value))),SYMBOL:Yr(Zr.Found,(e=>Ii(e.value)))},[Zr.Found]:{}};function Kr(e){let t=0,o=Xr[Zr.LeftRef],s="";for(;void 0!==o;){const i=e[t++];if(!i)return null;const n=o[i.type]?.find((e=>e.guard(i))),r=n?n.goTo:void 0;switch(r){case void 0:return null;case Zr.Found:return s+=i.value,e.splice(0,t),{type:"REFERENCE",value:s};default:o=Xr[r],s+=i.value}}return null}function Qr(e,t=Ao){const o=jn(e,t),s=[];for(;o.length;)s.push(Kr(o)||o.shift());return s}function Jr(e,t){return function(e){for(const t of e)if(t.functionContext){const{argsTokens:e,args:o}=t.functionContext;if(delete t.functionContext.argsTokens,o.length||!e)continue;"LEFT_PAREN"===e[0]?.[0]?.type&&(e[0]=e[0].slice(1));for(const t of e){let e=t;"ARG_SEPARATOR"===e.at(-1)?.type&&(e=e.slice(0,-1));try{o.push(Ur(e))}catch(e){o.push(void 0)}}}return e}(function(e){let t=[],o="";function s(e){if(0===t.length)return;const o=t.at(-1);if(o&&o.argsTokens){const{argsTokens:t,argPosition:s}=o;t[s]||(t[s]=[]),t[s].push({value:e.value,type:e.type})}}return e.map(((e,i)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(o=""),e.type){case"SYMBOL":s(e),o=e.value;break;case"LEFT_PAREN":t.push({parent:o,argPosition:0,argsTokens:[],args:[]}),s(e),o="";break;case"RIGHT_PAREN":const i=t.pop();i?.argsTokens?.flat().forEach(s),s(e);break;case"ARG_SEPARATOR":s(e),t.length&&t[t.length-1].argPosition++;break;default:s(e)}if(t.length){const o=t[t.length-1];o.parent&&(e.functionContext=Object.assign({},o))}return e}))}(function(e){let t=1;const o=[];return e.map((e=>("LEFT_PAREN"===e.type?(o.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=o.pop()),e)))}(function(e){let t=0;return e.map((e=>{const o=e.value.toString().length,s=Object.assign({},e,{start:t,end:t+o,length:o});return t=s.end,s}))}(Qr(e,t)))))}function ea(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}const ta=new zn;function oa(e,t){return{url:e=ea(e),label:t||e,isExternal:!0,isUrlEditable:!0}}ta.add("sheet_URL",{match:e=>Ae(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){const o=_e(e);return t.tryGetSheetName(o)||uo("Invalid sheet")},open(e,t){const o=_e(e);t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:o}).isCancelledBecause("SheetIsHidden")&&t.notifyUser({type:"warning",sticky:!1,text:uo("Cannot open the link because the linked sheet is hidden.")})},sequence:0});const sa={createLink:oa,match:e=>we(e),open:e=>window.open(e,"_blank"),urlRepresentation:e=>e,sequence:0};function ia(e){return ta.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((t=>t.match(e)))||sa}function na(e,t){return ia(e.url).urlRepresentation(e.url,t)}function ra(e,t){ia(e.url).open(e.url,t)}function aa(e){if("string"==typeof e){if(xe(e)){const{label:t,url:o}=Re(e);return ia(o).createLink(o,t)}return we(e)?oa(e):void 0}}function la(e="",t){return ha({value:t.format===Ro?e:ca(e,t.locale),format:t.format},t.locale)}function ca(e,t){if(e.startsWith("="))throw new Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);return""===e?null:io(e,Ao)?Zo(e,Ao):Ht(e,t)?Zo(e,t):function(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}(e)?"TRUE"===e.toUpperCase():e}function ha(e,t=Ao,o){const s=aa(e.value);if(!s)return da(e,t,o);return{...da({value:ca(s.label,t),format:e.format||ti(s.label,t)||oi(s.label)},t,o),link:s}}function da(e,t,o){let{value:s,format:i,message:n}=e;i=o?.format||i;const r=Hs(s,{format:i,locale:t});return Wo(s)?function(e,t){return{value:e,formattedValue:e,message:t,type:po.error,isAutoSummable:!1,defaultAlign:"center"}}(s,n):i===Ro?ua(ts(s),i,r):null===s?ga(i):"number"==typeof s?Ys(i||"")?function(e,t,o){return{value:e,format:t,formattedValue:o,type:po.number,isAutoSummable:!1,defaultAlign:"right"}}(s,i,r):function(e,t,o){return{value:e||0,format:t,formattedValue:o,type:po.number,isAutoSummable:!0,defaultAlign:"right"}}(s,i,r):"boolean"==typeof s?function(e,t,o){return{value:e,format:t,formattedValue:o,type:po.boolean,isAutoSummable:!1,defaultAlign:"center"}}(s,i,r):ua(s,i,r)}function ua(e,t,o){return{value:e,format:t,formattedValue:o,type:po.text,isAutoSummable:!0,defaultAlign:"left"}}const ga=Ye((function(e){return{value:null,format:e,formattedValue:"",type:po.empty,isAutoSummable:!0,defaultAlign:"left"}}));function pa(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:o}=Ti(e.value),[s,i]=t.split(":"),n=ma(s),r=i?`:${ma(i)}`:"";return{...e,value:Ai(o,n+r)}}function ma(e){switch(function(e){if(function(e){return e.startsWith("$")&&e.length>1&&e.slice(1).includes("$")}(e))return"colrow";if(function(e){return e.startsWith("$")}(e))return"col";if(function(e){return e.includes("$",1)}(e))return"row";return"none"}(e)){case"none":e=fa(e,"colrow");break;case"colrow":e=fa(e,"row");break;case"row":e=fa(e,"col");break;case"col":e=fa(e,"none")}return e}function fa(e,t){if(e.includes("!"))throw new Error("The given XC should not contain a sheet name");let o;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return o=e.search(/[0-9]/),e.slice(0,o)+"$"+e.slice(o);case"colrow":return o=e.search(/[0-9]/),-1===o||0===o?"$"+e:"$"+(e=e.slice(0,o)+"$"+e.slice(o));case"none":return e}}function ba(e,t,o){const s=(t.startsWith("=")?Jr(t,o):[]).filter((t=>t.start<=e.start&&t.end>=e.start||t.start>=e.start&&t.start<e.end)),i=s.filter((e=>"REFERENCE"===e.type));if(0===i.length)return;const n=s.map(pa).map((e=>e.value)).join(""),r=s[0].start,a=s[s.length-1].end,l=t.slice(0,r)+n+t.slice(a),c=l.length-t.length,h={start:i[0].start,end:i[i.length-1].end+c};return 1===i.length&&e.start===e.end&&(h.start=h.end),{content:l,selection:h}}const va=new zn,Sa={wrongPasteSelection:uo("This operation is not allowed with multiple selections."),willRemoveExistingMerge:uo("This operation is not possible due to a merge. Please remove the merges first than try again."),wrongFigurePasteOption:uo("Cannot do a special paste of a figure."),frozenPaneOverlap:uo("This operation is not allowed due to an overlapping frozen pane.")};function Ca(e,t){t.isSuccessful||(t.reasons.includes("WrongPasteSelection")?e.raiseError(Sa.wrongPasteSelection):t.reasons.includes("WillRemoveExistingMerge")?e.raiseError(Sa.willRemoveExistingMerge):t.reasons.includes("WrongFigurePasteOption")?e.raiseError(Sa.wrongFigurePasteOption):t.reasons.includes("FrozenPaneOverlap")&&e.raiseError(Sa.frozenPaneOverlap))}function ya(e,t,o){const s=e.model.dispatch("PASTE",{target:t,pasteOption:o});Ca(e,s)}function Ea(e,t,o,s){const i=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:o,pasteOption:s});Ca(e,i)}const xa={Errors:{InvalidRange:uo("The range is invalid"),FirstArgMissing:uo("The argument is missing. Please provide a value"),SecondArgMissing:uo("The second argument is missing. Please provide a value"),MinNaN:uo("The minpoint must be a number"),MidNaN:uo("The midpoint must be a number"),MaxNaN:uo("The maxpoint must be a number"),ValueUpperInflectionNaN:uo("The first value must be a number"),ValueLowerInflectionNaN:uo("The second value must be a number"),MinBiggerThanMax:uo("Minimum must be smaller then Maximum"),MinBiggerThanMid:uo("Minimum must be smaller then Midpoint"),MidBiggerThanMax:uo("Midpoint must be smaller then Maximum"),LowerBiggerThanUpper:uo("Lower inflection point must be smaller than upper inflection point"),MinInvalidFormula:uo("Invalid Minpoint formula"),MaxInvalidFormula:uo("Invalid Maxpoint formula"),MidInvalidFormula:uo("Invalid Midpoint formula"),ValueUpperInvalidFormula:uo("Invalid upper inflection point formula"),ValueLowerInvalidFormula:uo("Invalid lower inflection point formula"),EmptyRange:uo("A range needs to be defined"),Unexpected:uo("The rule is invalid for an unknown reason")},ColorScale:uo("Color scale"),IconSet:uo("Icon set")},wa={IsEmpty:uo("Is empty"),IsNotEmpty:uo("Is not empty"),ContainsText:uo("Contains"),NotContains:uo("Does not contain"),BeginsWith:uo("Starts with"),EndsWith:uo("Ends with"),Equal:uo("Is equal to"),NotEqual:uo("Is not equal to"),GreaterThan:uo("Is greater than"),GreaterThanOrEqual:uo("Is greater than or equal to"),LessThan:uo("Is less than"),LessThanOrEqual:uo("Is less than or equal to"),Between:uo("Is between"),NotBetween:uo("Is not between")},Ia={Series:uo("Series"),BackgroundColor:uo("Background color"),Errors:{Unexpected:uo("The chart definition is invalid for an unknown reason"),InvalidDataSet:uo("The dataset is invalid"),InvalidLabelRange:uo("Labels are invalid"),InvalidScorecardKeyValue:uo("The key value is invalid"),InvalidScorecardBaseline:uo("The baseline value is invalid"),InvalidGaugeDataRange:uo("The data range is invalid"),EmptyGaugeRangeMin:uo("A minimum range limit value is needed"),GaugeRangeMinNaN:uo("The minimum range limit value must be a number"),EmptyGaugeRangeMax:uo("A maximum range limit value is needed"),GaugeRangeMaxNaN:uo("The maximum range limit value must be a number"),GaugeRangeMinBiggerThanRangeMax:uo("Minimum range limit must be smaller than maximum range limit"),GaugeLowerInflectionPointNaN:uo("The lower inflection point value must be a number"),GaugeUpperInflectionPointNaN:uo("The upper inflection point value must be a number")}},Ra={Custom:uo("Custom")},Ta=uo("Merged cells are preventing this operation. Unmerge those cells and try again."),Aa={Errors:{Unexpected:uo("Cannot split the selection for an unknown reason"),NoSplitSeparatorInSelection:uo("There is no match for the selected separator in the selection"),MoreThanOneColumnSelected:uo("Only a selection from a single column can be split"),SplitWillOverwriteContent:uo("Splitting will overwrite existing content")}},Oa={Errors:{Unexpected:uo("Cannot remove duplicates for an unknown reason"),MoreThanOneRangeSelected:uo("Please select only one range of cells"),EmptyTarget:uo("Please select a range of cells containing values."),NoColumnsProvided:uo("Please select at latest one column to analyze."),WillRemoveExistingMerge:Sa.willRemoveExistingMerge}},_a={DateIs:{today:uo("today"),yesterday:uo("yesterday"),tomorrow:uo("tomorrow"),lastWeek:uo("in the past week"),lastMonth:uo("in the past month"),lastYear:uo("in the past year")},DateIsBefore:{today:uo("today"),yesterday:uo("yesterday"),tomorrow:uo("tomorrow"),lastWeek:uo("one week ago"),lastMonth:uo("one month ago"),lastYear:uo("one year ago")},CriterionError:{notEmptyValue:uo("The value must not be empty"),numberValue:uo("The value must be a number"),dateValue:uo("The value must be a date"),validRange:uo("The value must be a valid range")}},Da={Errors:{Unexpected:uo("The table zone is invalid for an unknown reason"),TableOverlap:uo("You cannot create overlapping tables."),NonContinuousTargets:uo("A table can only be created on a continuous selection."),InvalidRange:uo("The range is invalid"),TargetOutOfSheet:uo("The range is out of the sheet")},Checkboxes:{hasFilters:uo("Filter button"),headerRow:uo("Header row(s)"),bandedRows:uo("Banded rows"),firstColumn:uo("First column"),lastColumn:uo("Last column"),bandedColumns:uo("Banded columns"),automaticAutofill:uo("Automatically autofill formulas"),totalRow:uo("Total row"),isDynamic:uo("Auto-adjust to formula result")},Tooltips:{filterWithoutHeader:uo("Cannot have filters without a header row"),isDynamic:uo("For tables based on array formulas only")}},Ma=new zn;Ma.add("textContains",{type:"textContains",isValueValid:(e,t)=>String(e).toLowerCase().includes(t.values[0].toLowerCase()),getErrorString:e=>uo('The value must be a text that contains "%s"',e.values[0]),isCriterionValueValid:e=>!!e,criterionValueErrorString:_a.CriterionError.notEmptyValue,numberOfValues:()=>1,name:uo("Text contains"),getPreview:e=>uo('Text contains "%s"',e.values[0])}),Ma.add("textNotContains",{type:"textNotContains",isValueValid:(e,t)=>!String(e).toLowerCase().includes(t.values[0].toLowerCase()),getErrorString:e=>uo('The value must be a text that does not contain "%s"',e.values[0]),isCriterionValueValid:e=>!!e,criterionValueErrorString:_a.CriterionError.notEmptyValue,numberOfValues:()=>1,name:uo("Text does not contains"),getPreview:e=>uo('Text does not contain "%s"',e.values[0])}),Ma.add("textIs",{type:"textIs",isValueValid:(e,t)=>String(e).toLowerCase()===t.values[0].toLowerCase(),getErrorString:e=>uo('The value must be exactly "%s"',e.values[0]),isCriterionValueValid:e=>!!e,criterionValueErrorString:_a.CriterionError.notEmptyValue,numberOfValues:()=>1,name:uo("Text is exactly"),getPreview:e=>uo('Text is exactly "%s"',e.values[0])});const Fa=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$/;function Na(e,t){return e.values.map((e=>void 0!==e?ur(e,t):No.InvalidReference))}function Pa(e,t){return _s(e,Ao).map((e=>void 0!==e?Hs(e,{locale:t,format:t.dateFormat}):No.InvalidReference))}function La(e){return void 0!==Bt(e,Ao)}function ka(e){return void 0!==Yo(e,Ao)}function Va(e,t){const o=t.getLocale();return e.values.map((e=>{if(e.startsWith("="))return e;const t=ca(e,o);return"number"==typeof t?Hs(t,{format:o.dateFormat,locale:o}):""}))}Ma.add("textIsEmail",{type:"textIsEmail",isValueValid:e=>"string"==typeof e&&Fa.test(e),getErrorString:()=>uo("The value must be a valid email address"),isCriterionValueValid:()=>!0,criterionValueErrorString:"",numberOfValues:()=>0,name:uo("Text is valid email"),getPreview:()=>uo("Text is valid email")}),Ma.add("textIsLink",{type:"textIsLink",isValueValid:e=>void 0!==aa(e),getErrorString:()=>uo("The value must be a valid link"),isCriterionValueValid:()=>!0,criterionValueErrorString:"",numberOfValues:()=>0,name:uo("Text is valid link"),getPreview:()=>uo("Text is valid link")}),Ma.add("dateIs",{type:"dateIs",isValueValid:(e,t)=>{const o=_s(t,Ao)[0],s=Bt(e,Ao);if(void 0===s||void 0===o)return!1;if(["lastWeek","lastMonth","lastYear"].includes(t.dateValue)){return to(s,Wt(At.now()),o)}return i=s,n=o,Math.trunc(i)===Math.trunc(n);var i,n},getErrorString:(e,t)=>{const o=t.getLocale();return"exactDate"===e.dateValue?uo("The value must be the date %s",Pa(e,o)[0]):uo("The value must be %s",_a.DateIs[e.dateValue])},isCriterionValueValid:e=>La(e),criterionValueErrorString:_a.CriterionError.dateValue,numberOfValues:e=>"exactDate"===e.dateValue?1:0,name:uo("Date is"),getPreview:(e,t)=>"exactDate"===e.dateValue?uo("Date is %s",Va(e,t)[0]):uo("Date is %s",_a.DateIs[e.dateValue])}),Ma.add("dateIsBefore",{type:"dateIsBefore",isValueValid:(e,t)=>{const o=_s(t,Ao)[0],s=Bt(e,Ao);return void 0!==s&&void 0!==o&&function(e,t){return Math.trunc(e)<Math.trunc(t)}(s,o)},getErrorString:(e,t)=>{const o=t.getLocale();return"exactDate"===e.dateValue?uo("The value must be a date before %s",Pa(e,o)[0]):uo("The value must be a date before %s",_a.DateIsBefore[e.dateValue])},isCriterionValueValid:e=>La(e),criterionValueErrorString:_a.CriterionError.dateValue,numberOfValues:e=>"exactDate"===e.dateValue?1:0,name:uo("Date is before"),getPreview:(e,t)=>"exactDate"===e.dateValue?uo("Date is before %s",Va(e,t)[0]):uo("Date is before %s",_a.DateIsBefore[e.dateValue])}),Ma.add("dateIsOnOrBefore",{type:"dateIsOnOrBefore",isValueValid:(e,t)=>{const o=_s(t,Ao)[0],s=Bt(e,Ao);return void 0!==s&&void 0!==o&&function(e,t){return Math.trunc(e)<=Math.trunc(t)}(s,o)},getErrorString:(e,t)=>{const o=t.getLocale();return"exactDate"===e.dateValue?uo("The value must be a date on or before %s",Pa(e,o)[0]):uo("The value must be a date on or before %s",_a.DateIsBefore[e.dateValue])},isCriterionValueValid:e=>La(e),criterionValueErrorString:_a.CriterionError.dateValue,numberOfValues:e=>"exactDate"===e.dateValue?1:0,name:uo("Date is on or before"),getPreview:(e,t)=>"exactDate"===e.dateValue?uo("Date is on or before %s",Va(e,t)[0]):uo("Date is on or before %s",_a.DateIsBefore[e.dateValue])}),Ma.add("dateIsAfter",{type:"dateIsAfter",isValueValid:(e,t)=>{const o=_s(t,Ao)[0],s=Bt(e,Ao);return void 0!==s&&void 0!==o&&function(e,t){return Math.trunc(e)>Math.trunc(t)}(s,o)},getErrorString:(e,t)=>{const o=t.getLocale();return"exactDate"===e.dateValue?uo("The value must be a date after %s",Pa(e,o)[0]):uo("The value must be a date after %s",_a.DateIsBefore[e.dateValue])},isCriterionValueValid:e=>La(e),criterionValueErrorString:_a.CriterionError.dateValue,numberOfValues:e=>"exactDate"===e.dateValue?1:0,name:uo("Date is after"),getPreview:(e,t)=>"exactDate"===e.dateValue?uo("Date is after %s",Va(e,t)[0]):uo("Date is after %s",_a.DateIsBefore[e.dateValue])}),Ma.add("dateIsOnOrAfter",{type:"dateIsOnOrAfter",isValueValid:(e,t)=>{const o=_s(t,Ao)[0],s=Bt(e,Ao);return void 0!==s&&void 0!==o&&function(e,t){return Math.trunc(e)>=Math.trunc(t)}(s,o)},getErrorString:(e,t)=>{const o=t.getLocale();return"exactDate"===e.dateValue?uo("The value must be a date on or after %s",Pa(e,o)[0]):uo("The value must be a date on or after %s",_a.DateIsBefore[e.dateValue])},isCriterionValueValid:e=>La(e),criterionValueErrorString:_a.CriterionError.dateValue,numberOfValues:e=>"exactDate"===e.dateValue?1:0,name:uo("Date is on or after"),getPreview:(e,t)=>"exactDate"===e.dateValue?uo("Date is on or after %s",Va(e,t)[0]):uo("Date is on or after %s",_a.DateIsBefore[e.dateValue])}),Ma.add("dateIsBetween",{type:"dateIsBetween",isValueValid:(e,t)=>{const o=_s(t,Ao),s=Bt(e,Ao);return void 0!==s&&void 0!==o[0]&&void 0!==o[1]&&to(s,o[0],o[1])},getErrorString:(e,t)=>{const o=Pa(e,t.getLocale());return uo("The value must be a date between %s and %s",o[0],o[1])},isCriterionValueValid:e=>La(e),criterionValueErrorString:_a.CriterionError.dateValue,numberOfValues:()=>2,name:uo("Date is between"),getPreview:(e,t)=>{const o=Va(e,t);return uo("Date is between %s and %s",o[0],o[1])}}),Ma.add("dateIsNotBetween",{type:"dateIsNotBetween",isValueValid:(e,t)=>{const o=_s(t,Ao),s=Bt(e,Ao);return void 0!==s&&void 0!==o[0]&&void 0!==o[1]&&!to(s,o[0],o[1])},getErrorString:(e,t)=>{const o=Pa(e,t.getLocale());return uo("The value must be a date not between %s and %s",o[0],o[1])},isCriterionValueValid:e=>La(e),criterionValueErrorString:_a.CriterionError.dateValue,numberOfValues:()=>2,name:uo("Date is not between"),getPreview:(e,t)=>{const o=Va(e,t);return uo("Date is not between %s and %s",o[0],o[1])}}),Ma.add("dateIsValid",{type:"dateIsValid",isValueValid:e=>void 0!==Bt(e,Ao),getErrorString:()=>uo("The value must be a valid date"),isCriterionValueValid:e=>La(e),criterionValueErrorString:"",numberOfValues:()=>0,name:uo("Is valid date"),getPreview:()=>uo("Date is valid")}),Ma.add("isEqual",{type:"isEqual",isValueValid:(e,t)=>{if("number"!=typeof e)return!1;const o=Ds(t,Ao)[0];return void 0!==o&&e===o},getErrorString:(e,t)=>{const o=Na(e,t.getLocale());return uo("The value must be equal to %s",o[0])},isCriterionValueValid:e=>ka(e),criterionValueErrorString:_a.CriterionError.numberValue,numberOfValues:()=>1,name:uo("Is equal to"),getPreview:e=>uo("Value is equal to %s",e.values[0])}),Ma.add("isNotEqual",{type:"isNotEqual",isValueValid:(e,t)=>{if("number"!=typeof e)return!1;const o=Ds(t,Ao)[0];return void 0!==o&&e!==o},getErrorString:(e,t)=>{const o=Na(e,t.getLocale());return uo("The value must not be equal to %s",o[0])},isCriterionValueValid:e=>ka(e),criterionValueErrorString:_a.CriterionError.numberValue,numberOfValues:()=>1,name:uo("Is not equal to"),getPreview:e=>uo("Value is not equal to %s",e.values[0])}),Ma.add("isGreaterThan",{type:"isGreaterThan",isValueValid:(e,t)=>{if("number"!=typeof e)return!1;const o=Ds(t,Ao)[0];return void 0!==o&&e>o},getErrorString:(e,t)=>{const o=Na(e,t.getLocale());return uo("The value must be greater than %s",o[0])},isCriterionValueValid:e=>ka(e),criterionValueErrorString:_a.CriterionError.numberValue,numberOfValues:()=>1,name:uo("Is greater than"),getPreview:e=>uo("Value is greater than %s",e.values[0])}),Ma.add("isGreaterOrEqualTo",{type:"isGreaterOrEqualTo",isValueValid:(e,t)=>{if("number"!=typeof e)return!1;const o=Ds(t,Ao)[0];return void 0!==o&&e>=o},getErrorString:(e,t)=>{const o=Na(e,t.getLocale());return uo("The value must be greater or equal to %s",o[0])},isCriterionValueValid:e=>ka(e),criterionValueErrorString:_a.CriterionError.numberValue,numberOfValues:()=>1,name:uo("Is greater or equal to"),getPreview:e=>uo("Value is greater or equal to %s",e.values[0])}),Ma.add("isLessThan",{type:"isLessThan",isValueValid:(e,t)=>{if("number"!=typeof e)return!1;const o=Ds(t,Ao)[0];return void 0!==o&&e<o},getErrorString:(e,t)=>{const o=Na(e,t.getLocale());return uo("The value must be less than %s",o[0])},isCriterionValueValid:e=>ka(e),criterionValueErrorString:_a.CriterionError.numberValue,numberOfValues:()=>1,name:uo("Is less than"),getPreview:e=>uo("Value is less than %s",e.values[0])}),Ma.add("isLessOrEqualTo",{type:"isLessOrEqualTo",isValueValid:(e,t)=>{if("number"!=typeof e)return!1;const o=Ds(t,Ao)[0];return void 0!==o&&e<=o},getErrorString:(e,t)=>{const o=Na(e,t.getLocale());return uo("The value must be less or equal to %s",o[0])},isCriterionValueValid:e=>ka(e),criterionValueErrorString:_a.CriterionError.numberValue,numberOfValues:()=>1,name:uo("Is less or equal to"),getPreview:e=>uo("Value is less or equal to %s",e.values[0])}),Ma.add("isBetween",{type:"isBetween",isValueValid:(e,t)=>{if("number"!=typeof e)return!1;const o=Ds(t,Ao);return void 0!==o[0]&&void 0!==o[1]&&Ke(e,o[0],o[1])},getErrorString:(e,t)=>{const o=Na(e,t.getLocale());return uo("The value must be between %s and %s",o[0],o[1])},isCriterionValueValid:e=>ka(e),criterionValueErrorString:_a.CriterionError.numberValue,numberOfValues:()=>2,name:uo("Is between"),getPreview:e=>uo("Value is between %s and %s",e.values[0],e.values[1])}),Ma.add("isNotBetween",{type:"isNotBetween",isValueValid:(e,t)=>{if("number"!=typeof e)return!1;const o=Ds(t,Ao);return void 0!==o[0]&&void 0!==o[1]&&!Ke(e,o[0],o[1])},getErrorString:(e,t)=>{const o=Na(e,t.getLocale());return uo("The value must not be between %s and %s",o[0],o[1])},isCriterionValueValid:e=>ka(e),criterionValueErrorString:_a.CriterionError.numberValue,numberOfValues:()=>2,name:uo("Is not between"),getPreview:e=>uo("Value is not between %s and %s",e.values[0],e.values[1])}),Ma.add("isBoolean",{type:"isBoolean",isValueValid:e=>""===e||"boolean"==typeof e,getErrorString:()=>uo("The value must be a boolean"),isCriterionValueValid:()=>!0,criterionValueErrorString:"",numberOfValues:()=>0,name:uo("Checkbox"),getPreview:()=>uo("Checkbox")}),Ma.add("isValueInList",{type:"isValueInList",isValueValid:(e,t)=>null!==e&&t.values.map((e=>e.toLowerCase())).includes(e.toString().toLowerCase()),getErrorString:e=>uo("The value must be one of: %s",e.values.join(", ")),isCriterionValueValid:()=>!0,criterionValueErrorString:"",numberOfValues:()=>{},allowedValues:"onlyLiterals",name:uo("Value in list"),getPreview:e=>uo("Value one of: %s",e.values.join(", "))}),Ma.add("isValueInRange",{type:"isValueInList",isValueValid:(e,t,o,s)=>{if(!e)return!1;const i=o.getRangeFromSheetXC(s,t.values[0]);return o.getRangeValues(i).filter(Me).map((e=>e.toString().toLowerCase())).includes(e.toString().toLowerCase())},getErrorString:e=>uo("The value must be a value in the range %s",e.values[0]),isCriterionValueValid:e=>yi.test(e),criterionValueErrorString:_a.CriterionError.validRange,numberOfValues:()=>1,allowedValues:"onlyLiterals",name:uo("Value in range"),getPreview:e=>uo("Value in range %s",e.values[0])}),Ma.add("customFormula",{type:"customFormula",isValueValid:(e,t)=>{const o=ca(t.values[0],Ao);return("number"==typeof o||"boolean"==typeof o)&&!!o},getErrorString:()=>uo("The value does not match the custom formula data validation rule"),isCriterionValueValid:()=>!0,criterionValueErrorString:"",numberOfValues:()=>1,allowedValues:"onlyFormulas",name:uo("Custom formula"),getPreview:e=>uo("Custom formula %s",e.values[0])});class Ua{subscriptions={};on(e,t,o){if(!o)throw new Error("Missing callback");this.subscriptions[e]||(this.subscriptions[e]=[]),this.subscriptions[e].push({owner:t,callback:o})}trigger(e,t){const o=this.subscriptions[e]||[];for(let e=0,s=o.length;e<s;e++){const s=o[e];s.callback.call(s.owner,t)}}off(e,t){const o=this.subscriptions[e];o&&(this.subscriptions[e]=o.filter((e=>e.owner!==t)))}clear(){this.subscriptions={}}}class Ba extends Ua{dependencies=new Map;factory=new Ha(this.get.bind(this));inject(e,t){if(this.dependencies.has(e)&&this.dependencies.get(e)!==t)throw new Error(`Store ${e.name} already has an instance`);this.dependencies.set(e,t)}get(e){return this.dependencies.has(e)||this.dependencies.set(e,this.instantiate(e)),this.dependencies.get(e)}instantiate(e,...t){return this.factory.build(e,...t)}resetStores(){this.dependencies.clear()}}class Ha{get;pendingBuilds=new Set;constructor(e){this.get=e}build(e,...t){if(this.pendingBuilds.has(e))throw new Error(`Circular dependency detected: ${[...this.pendingBuilds,e].map((e=>e.name)).join(" -> ")}`);this.pendingBuilds.add(e);const o=new e(this.get,...t);return this.pendingBuilds.delete(e),o}}class za{get;disposeCallbacks=[];constructor(e){this.get=e}onDispose(e){this.disposeCallbacks.push(e)}dispose(){this.disposeCallbacks.forEach((e=>e()))}}function $a(){const e=t.useEnv();if(e.__spreadsheet_stores__ instanceof Ba)return e.__spreadsheet_stores__;const o=new Ba;return t.useSubEnv({__spreadsheet_stores__:o,getStore:e=>Za(o.get(e),(()=>o.trigger("store-updated")))}),o}function Ga(e){const o=Ya(t.useEnv()),s=o.get(e);return qa(o,s)}function Wa(e,...o){const s=Ya(t.useEnv()),i=s.instantiate(e,...o);return t.onWillUnmount((()=>i.dispose())),qa(s,i)}function qa(e,o){const s=t.useComponent();return Za(o,(()=>{"mounted"===t.status(s)&&e.trigger("store-updated")}))}function Za(e,t){return new Proxy(e,{get(o,s,i){const n=o,r=Reflect.get(o,s,n);if(e.mutators?.includes(s)){const e=new Proxy(r,{apply(e,o,s){Reflect.apply(e,n,s),t()}});return e}return r}})}function Ya(e){const t=e.__spreadsheet_stores__;if(!(t instanceof Ba))throw new Error("No store provider found. Did you forget to call useStoreProvider()?");return t}const ja=(Xa="Model",class{constructor(e){throw new Error(`This is a abstract store for ${Xa}, it cannot be instantiated.\nDid you forget to inject your store instance?\n\nconst stores = useStoreProvider();\nstores.inject(MyMetaStore, storeInstance);\n`)}});var Xa;class Ka{mutators=["register","unRegister"];renderers={};register(e){if(e.renderingLayers.length)for(const t of e.renderingLayers)this.renderers[t]||(this.renderers[t]=[]),this.renderers[t].push(e)}unRegister(e){for(const t of Object.keys(this.renderers))this.renderers[t]=this.renderers[t].filter((t=>t!==e))}drawLayer(e,t){const o=this.renderers[t];if(o)for(const s of o)e.ctx.save(),s.drawLayer(e,t),e.ctx.restore()}}class Qa extends za{model=this.get(ja);getters=this.model.getters;renderer=this.get(Ka);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){}}function Ja(e,t,o){const{x:i,y:n,width:r,height:a}=o;if(r<0||a<0)return;const l=t.color||s,{ctx:c}=e;t.noBorder||(t.dashed&&c.setLineDash([5,3]),c.strokeStyle=l,t.thinLine?(c.lineWidth=1,c.strokeRect(i,n,r,a)):(c.lineWidth=2,c.strokeRect(i+.5,n+.5,r,a))),t.noFill||(c.fillStyle=function(e,t){return 1===t?nt(e).slice(0,7):ht({...dt(e),a:t})}(nt(l),t.fillAlpha??.12),c.fillRect(i,n,r,a))}class el extends Qa{mutators=["register","unRegister"];providers=[];constructor(e){super(e),this.onDispose((()=>{this.providers=[]}))}get renderingLayers(){return["Highlights"]}get highlights(){const e=this.getters.getActiveSheetId();return this.providers.flatMap((e=>e.highlights)).filter((t=>t.sheetId===e)).map((e=>{const{numberOfRows:t,numberOfCols:o}=Xi(e.zone),s=t*o==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:s}}))}register(e){this.providers.push(e)}unRegister(e){this.providers=this.providers.filter((t=>t!==e))}drawLayer(e,t){if("Highlights"===t)for(const t of this.highlights){Ja(e,t,this.getters.getVisibleRect(t.zone))}}}class tl{mutators=["notifyUser","raiseError","askConfirmation","updateNotificationCallbacks"];notifyUser=e=>window.alert(e.text);askConfirmation=(e,t,o)=>{window.confirm(e)?t():o?.()};raiseError=(e,t)=>{window.alert(e),t?.()};updateNotificationCallbacks(e){this.notifyUser=e.notifyUser||this.notifyUser,this.raiseError=e.raiseError||this.raiseError,this.askConfirmation=e.askConfirmation||this.askConfirmation}}const ol=uo("The cell you are trying to edit has been deleted.");class sl extends Qa{mutators=["startEdition","setCurrentContent","stopEdition","stopComposerRangeSelection","cancelEdition","cycleReferences","changeComposerCursorSelection","replaceComposerCursorSelection"];col=0;row=0;editionMode="inactive";sheetId="";_currentContent="";currentTokens=[];selectionStart=0;selectionEnd=0;initialContent="";colorIndexByRange={};notificationStore=this.get(tl);highlightStore=this.get(el);constructor(e){super(e),this.highlightStore.register(this),this.onDispose((()=>{this.highlightStore.unRegister(this)}))}canStopEdition(){return"inactive"===this.editionMode||this.checkDataValidation()}handleEvent(e){const t=this.getters.getActiveSheetId();let o;if(o=e.options.unbounded?this.getters.getUnboundedZone(t,e.anchor.zone):e.anchor.zone,"newAnchor"===e.mode)"selecting"===this.editionMode&&this.insertSelectedRange(o);else"selecting"===this.editionMode?this.replaceSelectedRange(o):this.updateComposerRange(e.previousAnchor.zone,o)}changeComposerCursorSelection(e,t){this.isSelectionValid(this._currentContent.length,e,t)&&(this.selectionStart=e,this.selectionEnd=t)}stopComposerRangeSelection(){this.isSelectingRange&&(this.editionMode="editing")}startEdition(e,t){if(t){const o=e||this.getComposerContent(this.getters.getActivePosition());if(!this.isSelectionValid(o.length,t.start,t.end))return}const{col:o,row:s}=this.getters.getActivePosition();this.model.dispatch("SELECT_FIGURE",{id:null}),this.model.dispatch("SCROLL_TO_CELL",{col:o,row:s}),"inactive"!==this.editionMode&&e?this.setContent(e,t):this._startEdition(e,t),this.updateRangeColor()}stopEdition(){if(this.canStopEdition())return this._stopEdition(),void(this.colorIndexByRange={});const e=this.currentEditedCell,t=Tt(e.col,e.row),o=this.getters.getValidationRuleForCell(e);if(!o)return;const s=Ma.get(o.criterion.type).getErrorString(o.criterion,this.getters,e.sheetId);this.notificationStore.raiseError(uo("The data you entered in %s violates the data validation rule set on the cell:\n%s",t,s)),this.cancelEdition(),this.colorIndexByRange={}}cancelEdition(){this.cancelEditionAndActivateSheet(),this.resetContent(),this.colorIndexByRange={}}setCurrentContent(e,t){t&&!this.isSelectionValid(e.length,t.start,t.end)||(this.setContent(e,t,!0),this.updateRangeColor())}replaceComposerCursorSelection(e){this.replaceSelection(e)}handle(e){switch(e.type){case"SELECT_FIGURE":e.id&&(this.cancelEditionAndActivateSheet(),this.resetContent());break;case"SET_FORMATTING":this.cancelEdition();break;case"ADD_COLUMNS_ROWS":this.onAddElements(e);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case"START_CHANGE_HIGHLIGHT":const{left:t,top:o}=e.zone;this.isSelectingRange&&(this.editionMode="editing"),this.model.selection.resetAnchor(this,{cell:{col:t,row:o},zone:e.zone});break;case"ACTIVATE_SHEET":if(this._currentContent.startsWith("=")||(this._cancelEdition(),this.resetContent()),e.sheetIdFrom!==e.sheetIdTo){const t=this.getters.getActivePosition(),{col:o,row:s}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:t.col,row:t.row}),i=this.getters.expandZone(e.sheetIdTo,on({col:o,row:s}));this.model.selection.resetAnchor(this,{cell:{col:o,row:s},zone:i})}break;case"DELETE_SHEET":case"UNDO":case"REDO":!!this.getters.tryGetSheet(this.sheetId)||"inactive"===this.editionMode||(this.sheetId=this.getters.getActiveSheetId(),this.cancelEditionAndActivateSheet(),this.resetContent(),this.notificationStore.raiseError(ol))}}get currentContent(){return"inactive"===this.editionMode?this.getComposerContent(this.getters.getActivePosition()):this._currentContent}get composerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}get currentEditedCell(){return{sheetId:this.sheetId,col:this.col,row:this.row}}get isSelectingRange(){return"selecting"===this.editionMode}get showSelectionIndicator(){return this.isSelectingRange&&this.canStartComposerRangeSelection()}get tokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((o=>o.start<=e&&o.end>=t))}cycleReferences(){const e=this.getters.getLocale(),t=ba(this.composerSelection,this._currentContent,e);void 0!==t&&this.setCurrentContent(t.content,t.selection)}isSelectionValid(e,t,o){return t>=0&&t<=e&&o>=0&&o<=e}onColumnsRemoved(e){if(e.elements.includes(this.col)&&"inactive"!==this.editionMode)return this.cancelEdition(),void this.notificationStore.raiseError(ol);const{top:t,left:o}=zi({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=o,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.editionMode)return this.cancelEdition(),void this.notificationStore.raiseError(ol);const{top:t,left:o}=zi({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=o,this.row=t}onAddElements(e){const{top:t,left:o}=Hi({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=o,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=on({col:this.col,row:this.row});this.model.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.editionMode="selecting"}_startEdition(e,t){const o=this.getters.getActiveCell(),s=this.getters.getLocale();e&&o.format?.includes("%")&&io(e,s)&&(t=t||{start:e.length,end:e.length},e=`${e}%`);const{col:i,row:n,sheetId:r}=this.getters.getActivePosition();this.col=i,this.sheetId=r,this.row=n,this.initialContent=this.getComposerContent({sheetId:r,col:i,row:n}),this.editionMode="editing",this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const a=on({col:this.col,row:this.row});this.model.selection.capture(this,{cell:{col:this.col,row:this.row},zone:a},{handleEvent:this.handleEvent.bind(this),release:()=>{this._stopEdition()}})}_stopEdition(){if("inactive"!==this.editionMode){this.cancelEditionAndActivateSheet();const e=this.col,t=this.row;let o=this.getCurrentCanonicalContent();if(!(this.initialContent!==o))return;if(o){const s=this.getters.getActiveSheetId(),i=this.getters.getEvaluatedCell({sheetId:s,col:this.col,row:this.row});if(o.startsWith("=")){const e=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length-this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length;e>0&&(o+=Le(new Array(e).fill(")")))}else i.link&&(o=Ie(o,i.link.url));this.addHeadersForSpreadingFormula(o),this.model.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:e,row:t,content:o})}else this.model.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:e,row:t});this.model.dispatch("AUTOFILL_TABLE_COLUMN",{col:e,row:t,sheetId:this.sheetId}),this.setContent("")}}getCurrentCanonicalContent(){return hr(this._currentContent,this.getters.getLocale())}cancelEditionAndActivateSheet(){if("inactive"===this.editionMode)return;this._cancelEdition();this.getters.getActiveSheetId()!==this.sheetId&&this.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}getComposerContent(e){const t=this.getters.getLocale(),o=this.getters.getCell(e);if(o?.isFormula)return pr(o.content,t);const{format:s,value:i,type:n,formattedValue:r}=this.getters.getEvaluatedCell(e);switch(n){case po.empty:return"";case po.text:case po.error:return i;case po.boolean:return r;case po.number:if(s&&Ys(s)){if(null!==$t(r,t))return r;return Hs(i,{locale:t,format:Number.isInteger(i)?t.dateFormat:Er(t)})}return this.numberComposerContent(i,s,t)}}numberComposerContent(e,t,o){return t?.includes("%")?`${Zs(100*e,o.decimalSeparator)}%`:Zs(e,o.decimalSeparator)}_cancelEdition(){"inactive"!==this.editionMode&&(this.editionMode="inactive",this.model.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,o){const s=this._currentContent!==e;if(this._currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,s||"inactive"!==this.editionMode){const t=this.getters.getLocale();this.currentTokens=e.startsWith("=")?Jr(e,t):[],this.currentTokens.length>100&&o&&this.notificationStore.raiseError(uo("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells"))}this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=this.getZoneReference(e);this.canStartComposerRangeSelection()?this.insertText(o,t):this.insertText(","+o,t)}replaceSelectedRange(e){const t=this.getZoneReference(e),o=this.tokenAtCursor,s="REFERENCE"===o?.type?o.start:this.selectionStart;this.replaceText(t,s,this.selectionEnd)}updateComposerRange(e,t){const o=this.getters.getActiveSheetId(),s=this.tokenAtCursor,i=(s?[s,...this.currentTokens]:this.currentTokens).filter((e=>"REFERENCE"===e.type)).find((t=>{const{xc:s,sheetName:i}=Ti(t.value),n=i||this.getters.getSheetName(this.sheetId);if(this.getters.getSheetName(o)!==n)return!1;const r=this.getters.getRangeFromSheetXC(o,s);return qi(this.getters.expandZone(o,r.zone),e)}));if(!i)throw new Error("Previous range not found");const n=this.getters.getRangeFromSheetXC(o,i.value);this.selectionStart=i.start,this.selectionEnd=this.selectionStart+i.value.length;const r=this.getters.getRangeFromZone(o,t),a=this.getRangeReference(r,n.parts);this.replaceSelection(a)}getZoneReference(e){const t=this.currentEditedCell.sheetId,o=this.getters.getActiveSheetId(),s=this.getters.getRangeFromZone(o,e);return this.getters.getSelectionRangeString(s,t)}getRangeReference(e,t){let o=[...t];const s=e.clone({parts:o});return this.getters.getSelectionRangeString(s,this.currentEditedCell.sheetId)}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,o)}replaceText(e,t,o){this._currentContent=this._currentContent.slice(0,t)+this._currentContent.slice(o,this._currentContent.length),this.insertText(e,t)}insertText(e,t){const o=this._currentContent.slice(0,t)+e+this._currentContent.slice(t),s=t+e.length;this.setCurrentContent(o,{start:s,end:s})}updateRangeColor(){if(!this._currentContent.startsWith("=")||"inactive"===this.editionMode)return;const e=this.currentEditedCell.sheetId,t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),o={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(o[e]=this.colorIndexByRange[e]);const s=new Set(Object.values(o));let i=0;const n=()=>{for(;s.has(i);)i++;return s.add(i),i};for(const e of t){const t=e in o?o[e]:n();o[e]=t}this.colorIndexByRange=o}addHeadersForSpreadingFormula(e){if(!e.startsWith("="))return;const t=this.getters.evaluateFormula(this.sheetId,e);if(!_o(t))return;const o=this.getters.getNumberRows(this.sheetId),s=this.getters.getNumberCols(this.sheetId),i=this.row+t[0].length-o,n=this.col+t.length-s;n>0&&this.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:this.sheetId,dimension:"COL",base:s-1,position:"after",quantity:n+20}),i>0&&this.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:this.sheetId,dimension:"ROW",base:o-1,position:"after",quantity:i+50})}get highlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.editionMode)return[];const e=this.currentEditedCell.sheetId,t=e=>{const t=this.colorIndexByRange[e];return st[t%st.length]};return this.getReferencedRanges().map((o=>{const s=this.getters.getRangeString(o,e),{numberOfRows:i,numberOfCols:n}=Xi(o.zone);return{zone:i*n==1?this.getters.expandZone(o.sheetId,o.zone):o.zone,color:t(s),sheetId:o.sheetId,interactive:!0}}))}getReferencedRanges(){const e=this.currentEditedCell.sheetId;return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value))).filter((e=>!e.invalidSheetName&&!e.invalidXc))}get autocompleteProvider(){const e=this.currentContent,t=e.startsWith("=")?this.tokenAtCursor:{type:"STRING",value:e};if("inactive"===this.editionMode||!t)return;const o={composer:this,getters:this.getters},s=va.getAll().sort(((e,t)=>(e.sequence??1/0)-(t.sequence??1/0))).map((s=>({...s,getProposals:s.getProposals.bind(o,t,e),selectProposal:s.selectProposal.bind(o,t)})));for(const e of s){let o=e.getProposals();const s=o?.find((e=>e.text===t.value)),i=t.value.replace(/[ ,\(\)]/g,"");if(s&&this._currentContent!==this.initialContent)return;if(i&&o&&!["ARG_SEPARATOR","LEFT_PAREN"].includes(t.type)){const e=fn(i,o,(e=>e.fuzzySearchKey||e.text));(!s||e.length>1)&&(o=e)}if(e.maxDisplayedProposals&&(o=o?.slice(0,e.maxDisplayedProposals)),o?.length)return{proposals:o,selectProposal:e.selectProposal,autoSelectFirstProposal:e.autoSelectFirstProposal??!1}}}canStartComposerRangeSelection(){if(this._currentContent.startsWith("=")){const e=this.tokenAtCursor;if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let o=t,s=e;for(;!["ARG_SEPARATOR","LEFT_PAREN","OPERATOR"].includes(s.type)||Zn.includes(s.value);){if("SPACE"!==s.type||o<1)return!1;o--,s=this.currentTokens[o]}for(o=t+1,s=this.currentTokens[o];s&&!["ARG_SEPARATOR","RIGHT_PAREN","OPERATOR"].includes(s.type);){if("SPACE"!==s.type)return!1;o++,s=this.currentTokens[o]}return!0}return!1}checkDataValidation(){const e={sheetId:this.sheetId,col:this.col,row:this.row};try{const t=this.getCurrentCanonicalContent(),o=t.startsWith("=")?this.getters.evaluateFormula(this.sheetId,t):ca(t,this.getters.getLocale());if(_o(o))return!0;const s=this.getters.getValidationResultForCellValue(o,e);return!(!s.isValid&&s.rule.isBlocking)}catch(e){return!0}}}class il extends Qa{mutators=["focusTopBarComposer","focusGridComposerContent","focusGridComposerCell"];composerStore=this.get(sl);topBarFocus="inactive";gridFocusMode="inactive";get topBarComposerFocus(){return"inactive"===this.composerStore.editionMode?"inactive":this.topBarFocus}get gridComposerFocus(){return"inactive"===this.composerStore.editionMode?"inactive":this.gridFocusMode}focusTopBarComposer(e){this.getters.isReadonly()||(this.topBarFocus="contentFocus",this.gridFocusMode="inactive",this.setComposerContent({selection:e}||{}))}focusGridComposerContent(){this.getters.isReadonly()||(this.topBarFocus="inactive",this.gridFocusMode="contentFocus",this.setComposerContent({}))}focusGridComposerCell(e,t){this.getters.isReadonly()||(this.topBarFocus="inactive",this.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}))}setComposerContent({content:e,selection:t}){"inactive"===this.composerStore.editionMode?this.composerStore.startEdition(e,t):e&&this.composerStore.setCurrentContent(e,t)}}const nl={id:"waterfallLinesPlugin",beforeDraw(e,t,o){if(!o.showConnectorLines)return;const s=e._metasets?.[0]?.data;if(!s)return;const i=e.ctx;i.save(),i.setLineDash([3,2]);for(let e=0;e<s.length;e++){const t=s[e];if(0===t.height)continue;const o=al(s,e);if(!o)break;const n=rl(t),r=rl(o),a=t.$context.raw,l=a[1]-a[0],c=Math.round(l<0?n.bottom-1:n.top),h=Math.round(n.right),d=Math.round(r.left);i.strokeStyle="#999",i.beginPath(),i.moveTo(h+1,c+.5),i.lineTo(d,c+.5),i.stroke()}i.restore()}};function rl(e){const t=e.base<e.y;return{left:e.x-e.width/2,right:e.x+e.width/2,bottom:t?e.base+e.height:e.y+e.height,top:t?e.base:e.y}}function al(e,t){return e.find(((e,o)=>o>t&&0!==e.height))}window.Chart?.register(nl);class ll extends t.Component{static template="o-spreadsheet-ChartJsComponent";static props={figure:Object};canvas=t.useRef("graphContainer");chart;currentRuntime;get background(){return this.chartRuntime.background}get canvasStyle(){return`background-color: ${this.background}`}get chartRuntime(){const e=this.env.model.getters.getChartRuntime(this.props.figure.id);if(!("chartJsConfig"in e))throw new Error("Unsupported chart runtime");return e}setup(){t.onMounted((()=>{const e=this.chartRuntime;this.currentRuntime=e,this.createChart(ge(e.chartJsConfig))})),t.onWillUnmount((()=>this.chart?.destroy())),t.useEffect((()=>{const e=this.chartRuntime;Be(e,this.currentRuntime,"ignoreFunctions")||(this.currentRuntime=e,this.updateChartJs(ge(e)))}))}createChart(e){const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e)}updateChartJs(e){const t=e.chartJsConfig;t.data&&t.data.datasets?(this.chart.data=t.data,t.options?.plugins?.title&&(this.chart.config.options.plugins.title=t.options.plugins.title)):this.chart.data.datasets=[],this.chart.config.options=t.options,this.chart.update()}}class cl{sheetId;title;getters;constructor(e,t,o){this.title=e.title,this.sheetId=t,this.getters=o}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function hl(e,t,o,s){let i=!1;const n=[];for(let s in o){let r=o[s];if(r.labelCell){const e=gl(r.labelCell,t);r.labelCell!==e&&(i=!0,r={...r,labelCell:e})}const a=gl(r.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===No.InvalidReference?(i=!0,r=void 0):a!==r.dataRange&&(i=!0,r={...r,dataRange:a}),n[s]=r}let r=s;const a=gl(r,t);a!==r&&(i=!0,r=a);return{isStale:i,dataSets:n.filter(De),labelRange:r}}function dl(e,t,o){return o.map((o=>({dataRange:gn(e,t,o.dataRange),labelCell:o.labelCell?gn(e,t,o.labelCell):void 0})))}function ul(e,t,o){return o?gn(e,t,o):void 0}function gl(e,t){if(!e)return;const o=t(e);switch(o.changeType){case"NONE":return e;case"REMOVE":return;default:return o.range}}function pl(e,t,o,s){const i=[];for(const n of t){const t=e.getRangeFromSheetXC(o,n.dataRange),{unboundedZone:r,sheetId:a,invalidSheetName:l,invalidXc:c}=t;if(!l&&!c)if(r.left!==r.right&&r.top!==r.bottom){if(void 0===r.right)continue;for(let t=r.left;t<=r.right;t++){const o={...r,left:t,right:t};i.push({...ml(e,a,o,s?{top:o.top,bottom:o.top,left:o.left,right:o.left}:void 0),backgroundColor:n.backgroundColor,rightYAxis:"y1"===n.yAxisId,customLabel:n.label})}}else i.push({...ml(e,a,r,s?{top:r.top,bottom:r.top,left:r.left,right:r.left}:void 0),backgroundColor:n.backgroundColor,rightYAxis:"y1"===n.yAxisId,customLabel:n.label})}return i}function ml(e,t,o,s){if(o.left!==o.right&&o.top!==o.bottom)throw new Error(`Zone should be a single column or row: ${Ui(o)}`);if(s){const i=Ui(o),n=Ui(s);return{labelCell:e.getRangeFromSheetXC(t,n),dataRange:e.getRangeFromSheetXC(t,i)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,Ui(o))}}function fl(e,t){const o=t.labelCell?.zone;let s=t.dataRange.zone;if(o){const{numberOfRows:e,numberOfCols:t}=Xi(s);1===e?s={...s,left:s.left+1}:1===t&&(s={...s,top:s.top+1})}const i=t.dataRange.clone({zone:s});let n={};return t.customLabel?n={text:t.customLabel}:t.labelCell&&(n={reference:e.getRangeString(t.labelCell,"forceSheetReference",{useFixedReference:!0})}),{label:n,range:e.getRangeString(i,"forceSheetReference",{useFixedReference:!0}),backgroundColor:t.backgroundColor,rightYAxis:t.rightYAxis}}function bl(e,t,o){if(!t)return;let s={...t.zone};o&&t.zone.bottom>t.zone.top&&(s.top=s.top+1);const i=t.clone({zone:s});return e.getRangeString(i,"forceSheetReference",{useFixedReference:!0})}function vl(e,t){let o;if(e.labelRange){const s=Tr(Pi(e.labelRange),t);o=s?Ui(s):void 0}const s=e.dataSets.map((e=>Pi(e.dataRange))).map((e=>Tr(e,t))).filter(De).map((e=>({dataRange:Ui(e)})));return{...e,labelRange:o,dataSets:s}}function Sl(e){return e&&ct(e)<.3?"#FFFFFF":"#000000"}function Cl(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!yi.test(e.dataRange)));if(t)return"InvalidDataSet";if(e.dataSets.map((e=>Pi(e.dataRange))).some((e=>e.top!==e.bottom&&nn(e))))return"InvalidDataSet"}return"Success"}function yl(e){if(e.labelRange){if(!yi.test(e.labelRange||""))return"InvalidLabelRange"}return"Success"}function El(e,t,o){if(!o)return!1;if(!e)return!1;if(!t)return!0;const s=rn(t.dataRange.zone);return!(rn(e.zone)<s)}function xl(e){if(e?.title?.text){const{text:t,color:o,align:s,italic:i,bold:n}=e.title;return{display:!0,text:t,color:o,font:{style:i?"italic":"normal",weight:n?"bold":"normal"},align:"left"===s?"start":"right"===s?"end":"center"}}}function wl(e){let t=!1,o=!1;for(const s of e.dataSets||[])"y1"===s.yAxisId?o=!0:t=!0;return t||=!o,{useLeftAxis:t,useRightAxis:o}}function Il(e,t,o,s,i){if("text"===t||"progress"===t||e?.type!==po.number||o?.type!==po.number)return;const n=o.value-e.value;return n>0?s:n<0?i:void 0}function Rl(e,t,o){if("text"===o||e?.type!==po.number||t?.type!==po.number)return"neutral";const s=t.value-e.value;return s>0?"up":s<0?"down":"neutral"}function Tl(e){return e.keyValue&&!yi.test(e.keyValue)?"InvalidScorecardKeyValue":"Success"}function Al(e){return e.baseline&&!yi.test(e.baseline)?"InvalidScorecardBaseline":"Success"}const Ol=new window.Path2D("M8.6 4.8a.5.5 0 0 1 0 .75l-3.9 3.9a.5 .5 0 0 1 -.75 0l-3.8 -3.9a.5 .5 0 0 1 0 -.75l.4-.4a.5.5 0 0 1 .75 0l2.3 2.4v-5.7c0-.25.25-.5.5-.5h.6c.25 0 .5.25.5.5v5.8l2.3 -2.4a.5.5 0 0 1 .75 0z"),_l=new window.Path2D("M8.7 5.5a.5.5 0 0 0 0-.75l-3.8-4a.5.5 0 0 0-.75 0l-3.8 4a.5.5 0 0 0 0 .75l.4.4a.5.5 0 0 0 .75 0l2.3-2.4v5.8c0 .25.25.5.5.5h.6c.25 0 .5-.25.5-.5v-5.8l2.2 2.4a.5.5 0 0 0 .75 0z");let Dl=class e extends cl{keyValue;baseline;baselineMode;baselineDescr;progressBar=!1;background;baselineColorUp;baselineColorDown;fontColor;humanize;type="scorecard";constructor(e,t,o){super(e,t,o),this.keyValue=pn(o,t,e.keyValue),this.baseline=pn(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown,this.humanize=e.humanize??!1}static validateChartDefinition(e,t){return e.checkValidations(t,Tl,Al)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0].dataRange:void 0,title:e.title||{text:""},baselineMode:Q,baselineColorUp:J,baselineColorDown:ee,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,s;return e.baseline&&(o=Tr(Pi(e.baseline),t)),e.keyValue&&(s=Tr(Pi(e.keyValue),t)),{...e,baseline:o?Ui(o):void 0,keyValue:s?Ui(s):void 0}}copyForSheetId(t){const o=ul(this.sheetId,t,this.baseline),s=ul(this.sheetId,t,this.keyValue),i=this.getDefinitionWithSpecificRanges(o,s,t);return new e(i,t,this.getters)}copyInSheetId(t){const o=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,t);return new e(o,t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{...this,range:this.keyValue?[{dataRange:this.getters.getRangeString(this.keyValue,this.sheetId)}]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,o){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,o||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,o||this.sheetId):void 0,humanize:this.humanize}}getDefinitionForExcel(){}updateRanges(t){const o=gl(this.baseline,t),s=gl(this.keyValue,t);if(this.baseline===o&&this.keyValue===s)return this;const i=this.getDefinitionWithSpecificRanges(o,s);return new e(i,this.sheetId,this.getters)}};function Ml(e,t){const o=t.getContext("2d");if(t.width=e.canvas.width,t.height=e.canvas.height,o.fillStyle=e.canvas.backgroundColor,o.fillRect(0,0,e.canvas.width,e.canvas.height),e.title){o.font=e.title.style.font,o.fillStyle=e.title.style.color;const s=o.textBaseline;o.textBaseline="middle",o.fillText(Pn(o,e.title.text,t.width-e.title.position.x),e.title.position.x,e.title.position.y),o.textBaseline=s}if(e.baseline&&(o.font=e.baseline.style.font,o.fillStyle=e.baseline.style.color,kn(o,e.baseline.text,e.baseline.position,e.baseline.style.underline,e.baseline.style.strikethrough)),e.baselineArrow&&e.baselineArrow.style.size>0){o.save(),o.fillStyle=e.baselineArrow.style.color,o.translate(e.baselineArrow.position.x,e.baselineArrow.position.y);const t=e.baselineArrow.style.size/10;switch(o.scale(t,t),e.baselineArrow.direction){case"down":o.fill(Ol);break;case"up":o.fill(_l)}o.restore()}if(e.baselineDescr){const s=e.baselineDescr[0];o.font=s.style.font,o.fillStyle=s.style.color;for(const s of e.baselineDescr)o.fillText(Pn(o,s.text,t.width-s.position.x),s.position.x,s.position.y)}if(e.key&&(o.font=e.key.style.font,o.fillStyle=e.key.style.color,kn(o,e.key.text,e.key.position,e.key.style.underline,e.key.style.strikethrough)),e.progressBar){if(o.fillStyle=e.progressBar.style.backgroundColor,o.beginPath(),o.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width,e.progressBar.dimension.height,e.progressBar.dimension.height/2),o.fill(),o.fillStyle=e.progressBar.style.color,o.beginPath(),e.progressBar.value>0)o.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width*Math.max(0,Math.min(1,e.progressBar.value)),e.progressBar.dimension.height,e.progressBar.dimension.height/2);else{const t=e.progressBar.dimension.width*Math.max(0,Math.min(1,-e.progressBar.value));o.roundRect(e.progressBar.position.x+e.progressBar.dimension.width-t,e.progressBar.position.y,t,e.progressBar.dimension.height,e.progressBar.dimension.height/2)}o.fill()}}const Fl=R,Nl=.05;function Pl({width:e,height:t},o){return new Ll({width:e,height:t},o).computeDesign()}class Ll{runtime;context;width;height;constructor({width:e,height:t},o){this.runtime=o;const s=document.createElement("canvas");this.width=s.width=e,this.height=s.height=t,this.context=s.getContext("2d")}computeDesign(){const e={canvas:{width:this.width,height:this.height,backgroundColor:this.backgroundColor}},t=this.getTextStyles();let o=0;if(this.title){let s,i;switch(({height:o,width:i}=this.getFullTextDimensions(this.title,t.title.font)),this.runtime.title.align){case"center":s=(this.width-i)/2;break;case"right":s=this.width-i-Fl;break;default:s=Fl}e.title={text:this.title,style:t.title,position:{x:s,y:Fl+o/2}}}const s=t.baselineArrow?.size??0;let{height:i,width:n}=this.getTextDimensions(this.baseline,t.baselineValue.font);this.baseline||(i=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).height);const r=t.baselineDescr.isSplit?Math.max(...Ln(this.baselineDescr).map((e=>this.getTextDimensions(e,t.baselineDescr.font).width))):this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).width;if(e.baseline={text:this.baseline,style:t.baselineValue,position:{x:(this.width-n-r+s)/2,y:this.keyValue?this.height*(1-Nl*(this.runtime.progressBar?1:2)):this.height-(this.height-o-i)/2-Fl}},t.baselineArrow&&!this.runtime.progressBar&&(e.baselineArrow={direction:this.baselineArrow,style:t.baselineArrow,position:{x:e.baseline.position.x-s,y:e.baseline.position.y-(i+s)/2}}),this.baselineDescr){const o={x:e.baseline.position.x+n,y:e.baseline.position.y};if(t.baselineDescr.isSplit){const s=Ln(this.baselineDescr),i=this.context.measureText(s[1]),n=i.fontBoundingBoxAscent+i.fontBoundingBoxDescent;e.baselineDescr=[{text:s[0],style:t.baselineDescr,position:{x:o.x,y:o.y-n}},{text:s[1],style:t.baselineDescr,position:o}]}else e.baselineDescr=[{text:this.baselineDescr,style:t.baselineDescr,position:o}]}let a=0;this.runtime.progressBar&&(a=.05*this.height,e.progressBar={position:{x:2*Fl,y:.9*this.height-i-a},dimension:{height:a,width:this.width-4*Fl},value:this.runtime.progressBar.value,style:{color:this.runtime.progressBar.color,backgroundColor:this.secondaryFontColor}});const{width:l,height:c}=this.getFullTextDimensions(this.keyValue,t.keyValue.font);return this.keyValue&&(e.key={text:this.keyValue,style:t.keyValue,position:{x:(this.width-l)/2,y:.4*this.height+(o+c/(this.baseline||this.baselineDescr?2:1.2))/2}}),e}get title(){return this.runtime.title.text??""}get keyValue(){return this.runtime.keyValue}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){return function(e,t){const o=e||"";return t&&o?" "+o:o}(this.runtime.baselineDescr,this.baseline)}get baselineArrow(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get secondaryFontColor(){return ct(this.backgroundColor)>.3?"#525252":"#C8C8C8"}getTextDimensions(e,t){this.context.font=t;const o=this.context.measureText(e);return{width:o.width,height:o.actualBoundingBoxAscent+o.actualBoundingBoxDescent}}getFullTextDimensions(e,t){this.context.font=t;const o=this.context.measureText(e);return{width:o.width,height:o.fontBoundingBoxAscent+o.fontBoundingBoxDescent}}getTextStyles(){const e=this.width-2*Fl,t=this.getDrawableHeight(),o=new Vl(this.runtime.keyValueStyle),s=o.getElementMaxFontSize(t,this),i=Mn(e,600,(e=>o.getElementWidth(e,this.context,this))),n=Math.min(s,i);let r=Math.floor(.5*n);this.context.font=yn(r,this.runtime.baselineStyle?.bold,this.runtime.baselineStyle?.italic);const a="neutral"!==this.baselineArrow?"A "+this.baseline:this.baseline,l=e-wn(this.context,a);let c=Mn(l,r,(e=>xn(this.context,this.baselineDescr,{fontSize:e}))),h=!1;if(c<r/2.5){h=!0,c=Math.floor(r/2.5);for(const e of Ln(this.baselineDescr)){const t=Mn(l,r,(t=>(this.context.font=yn(t),this.context.measureText(e).width)));c=Math.min(c,t)}}return this.runtime.progressBar&&(r/=1.5),{title:{font:yn(T,this.runtime.title.bold,this.runtime.title.italic),color:this.runtime.title.color??this.secondaryFontColor},keyValue:{color:this.runtime.keyValueStyle?.textColor||this.runtime.fontColor,font:yn(n,this.runtime.keyValueStyle?.bold,this.runtime.keyValueStyle?.italic),strikethrough:this.runtime.keyValueStyle?.strikethrough,underline:this.runtime.keyValueStyle?.underline},baselineValue:{font:yn(r,this.runtime.baselineStyle?.bold,this.runtime.baselineStyle?.italic),strikethrough:this.runtime.baselineStyle?.strikethrough,underline:this.runtime.baselineStyle?.underline,color:this.runtime.baselineStyle?.textColor||this.runtime.baselineColor||this.secondaryFontColor},baselineDescr:{font:yn(c),isSplit:h,color:this.secondaryFontColor},baselineArrow:"neutral"===this.baselineArrow||this.runtime.progressBar?void 0:{size:this.keyValue?.8*r:0,color:this.runtime.baselineColor||this.secondaryFontColor}}}getDrawableHeight(){const e=Fl+this.height*Nl;let t=this.height-2*e;return t-=this.title?1.2*T:0,t}}class kl{style;constructor(e={}){this.style=e}measureTextWidth(e,t,o){return e.font=yn(o,this.style.bold,this.style.italic),wn(e,t)}}class Vl extends kl{getElementWidth(e,t,o){if(!o.runtime)return 0;const s=o.keyValue||"";return this.measureTextWidth(t,s,e)}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.8*e:e)/1.2}}class Ul extends t.Component{static template="o-spreadsheet-ScorecardChart";static props={figure:Object};canvas=t.useRef("chartContainer");get runtime(){return this.env.model.getters.getChartRuntime(this.props.figure.id)}setup(){t.useEffect(this.createChart.bind(this),(()=>{const e=this.canvas.el.getBoundingClientRect();return[e.width,e.height,this.runtime,this.canvas.el]}))}createChart(){const e=this.canvas.el;Ml(Pl(e.getBoundingClientRect(),this.runtime),e)}}function Bl(e,t,o,s){const i=[];e=e.toLowerCase();for(const n of e){const e=t.toLocaleLowerCase().indexOf(n);-1!==e&&(i.push({value:t.slice(0,e),color:""},{value:t[e],color:o,class:s}),t=t.slice(e+1))}i.push({value:t});return i.filter((e=>e.value))}va.add("dataValidation",{getProposals(e,t){if(t.startsWith("="))return[];const o=this.composer.currentEditedCell,s=this.getters.getValidationRuleForCell(o);if(!s||"isValueInList"!==s.criterion.type&&"isValueInRange"!==s.criterion.type)return[];let i;if("isValueInList"===s.criterion.type)i=s.criterion.values;else{const e=this.getters.getRangeFromSheetXC(o.sheetId,s.criterion.values[0]);i=Array.from(new Set(this.getters.getRangeValues(e).filter(Me).map((e=>e.toString())).filter((e=>""!==e))))}return i.map((e=>({text:e})))},selectProposal(e,t){this.composer.setCurrentContent(t),this.composer.stopEdition()}});const Hl=/(.*?)\((.*?)\)(.*)/,zl=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function $l(e,t=""){return function(e,t){let o=e.match(Hl),s=o[1].trim();if(!s)throw new Error(`Function argument definition is missing a name: '${e}'.`);let i,n=[],r=!1,a=!1;for(let e of o[2].split(",")){const t=e.trim().toUpperCase();let o=zl.find((e=>t===e));o?n.push(o):"RANGE<ANY>"===t?n.push("RANGE"):"OPTIONAL"===t?r=!0:"REPEATING"===t?a=!0:t.startsWith("DEFAULT=")&&(i=e.trim().slice(8))}const l={name:s,description:t,type:n};r&&(l.optional=!0);a&&(l.repeating=!0);void 0!==i&&(l.default=!0,l.defaultValue=i);n.some((e=>e.startsWith("RANGE")))&&(l.acceptMatrix=!0);return l}(e,t)}function Gl(e){let t=0,o=0,s=0;for(let i of e.args)t++,i.optional||i.repeating||i.default||o++,i.repeating&&s++;const i=e;return i.minArgRequired=o,i.maxArgPossible=s?1/0:t,i.nbrArgRepeating=s,i.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const o=e-t;return e=>{if(e<=o)return e;return o+((e-o)%t||t)}}(t,s),i.hidden=e.hidden||!1,i}function Wl(e,t){$o((()=>1===t.length||1===t[0].length),e)}function ql(e,...t){if(t.every(_o)){const o=t[0].length,s=t[0][0].length;for(const i of t)$o((()=>i.length===o&&i[0].length===s),e)}else if(t.some((e=>Array.isArray(e)&&(1!==e.length||1!==e[0].length))))throw new Lo(e)}function Zl(e,t){$o((()=>t>0),e)}function Yl(e,t){$o((()=>t.length===t[0].length),e)}function jl(e){const t=Array(e);for(let o=0;o<e;o++)t[o]=Array(e).fill(0),t[o][o]=1;return t}function Xl(e){if(e.length!==e[0].length)throw new Lo(uo("Function [[FUNCTION_NAME]] invert matrix error, only square matrices are invertible"));let t=1;const o=e.length,s=jl(o),i=e.map((e=>e.slice()));for(let e=0;e<o;e++){let n=i[e][e];if(0===n){for(let n=e+1;n<o;n++)if(0!=i[e][n]){Kl(i,e,n),Kl(s,e,n),t*=-1;break}if(n=i[e][e],0===n)return{determinant:0}}for(let t=0;t<o;t++)i[t][e]=i[t][e]/n,s[t][e]=s[t][e]/n;t*=n;for(let t=0;t<o;t++){if(t===e)continue;const n=i[e][t];for(let r=0;r<o;r++)i[r][t]-=n*i[r][e],s[r][t]-=n*s[r][e]}}return{inverted:s,determinant:t}}function Kl(e,t,o){for(let s=0;s<e.length;s++){const i=e[s][t];e[s][t]=e[s][o],e[s][o]=i}}function Ql(e,t){if(e.length!==t[0].length)throw new Lo(uo("Cannot multiply matrices : incompatible matrices size."));const o=e[0].length,s=t.length,i=e.length,n=Array(s);for(let r=0;r<s;r++){n[r]=Array(o);for(let s=0;s<o;s++){let o=0;for(let n=0;n<i;n++)o+=e[n][s]*t[r][n];n[r][s]=o}}return n}function Jl(e){if(!_o(e))return e;if(1!==e.length||1!==e[0].length)throw new Lo(uo("The value should be a scalar or a 1x1 matrix"));return e[0][0]}const ec={description:uo("Returns a result array constrained to a specific width and height."),args:[$l("input_range (any, range<any>)",uo("The range to constrain.")),$l("rows (number)",uo("The number of rows in the constrained array.")),$l("columns (number)",uo("The number of columns in the constrained array."))],returns:["RANGE<ANY>"],compute:function(e,t,o){const s=Rs(e),i=Ko(t?.value,this.locale),n=Ko(o?.value,this.locale);Zl(uo("The rows argument (%s) must be strictly positive.",i.toString()),i),Zl(uo("The columns argument (%s) must be strictly positive.",i.toString()),n);const r=Math.min(i,s[0].length);return ps(Math.min(n,s.length),r,((e,t)=>s[e][t]))},isExported:!1},tc={description:uo("Creates a new array from the selected columns in the existing range."),args:[$l("array (any, range<any>)",uo("The array that contains the columns to be returned.")),$l("col_num (number, range<number>)",uo("The first column index of the columns to be returned.")),$l("col_num2 (number, range<number>, repeating)",uo("The columns indexes of the columns to be returned."))],returns:["RANGE<ANY>"],compute:function(e,...t){const o=Rs(e),s=Ts(t,(e=>Ko(e?.value,this.locale)));$o((()=>s.every((e=>e>0&&e<=o.length))),uo("The columns arguments must be between 1 and %s (got %s).",o.length.toString(),(s.find((e=>e<=0||e>o.length))||0).toString()));const i=Array(s.length);for(let e=0;e<s.length;e++){const t=s[e]-1;i[e]=o[t]}return i},isExported:!0},oc={description:uo("Creates a new array from the selected rows in the existing range."),args:[$l("array (any, range<any>)",uo("The array that contains the rows to be returned.")),$l("row_num (number, range<number>)",uo("The first row index of the rows to be returned.")),$l("row_num2 (number, range<number>, repeating)",uo("The rows indexes of the rows to be returned."))],returns:["RANGE<ANY>"],compute:function(e,...t){const o=Rs(e),s=Ts(t,(e=>Ko(e?.value,this.locale))),i=o.length;return $o((()=>s.every((e=>e>0&&e<=o[0].length))),uo("The rows arguments must be between 1 and %s (got %s).",o[0].length.toString(),(s.find((e=>e<=0||e>o[0].length))||0).toString())),ps(i,s.length,((e,t)=>o[e][s[t]-1]))},isExported:!0},sc={description:uo("Expands or pads an array to specified row and column dimensions."),args:[$l("array (any, range<any>)",uo("The array to expand.")),$l("rows (number)",uo("The number of rows in the expanded array. If missing, rows will not be expanded.")),$l("columns (number, optional)",uo("The number of columns in the expanded array. If missing, columns will not be expanded.")),$l("pad_with (any, default=0)",uo("The value with which to pad."))],returns:["RANGE<ANY>"],compute:function(e,t,o,s={value:0}){const i=Rs(e),n=Ko(t?.value,this.locale),r=void 0!==o?Ko(o.value,this.locale):i.length;return $o((()=>n>=i[0].length),uo("The rows arguments (%s) must be greater or equal than the number of rows of the array.",n.toString())),$o((()=>r>=i.length),uo("The columns arguments (%s) must be greater or equal than the number of columns of the array.",r.toString())),ps(r,n,((e,t)=>e>=i.length||t>=i[e].length?s:i[e][t]))},isExported:!0},ic={description:uo("Flattens all the values from one or more ranges into a single column."),args:[$l("range (any, range<any>)",uo("The first range to flatten.")),$l("range2 (any, range<any>, repeating)",uo("Additional ranges to flatten."))],returns:["RANGE<ANY>"],compute:function(...e){return[Ts(e,(e=>void 0===e?{value:""}:e))]},isExported:!1},nc={description:uo("Calculates the frequency distribution of a range."),args:[$l("data (range<number>)",uo("The array of ranges containing the values to be counted.")),$l("classes (number, range<number>)",uo("The range containing the set of classes."))],returns:["RANGE<NUMBER>"],compute:function(e,t){const o=Ts([e],(e=>e.value)).filter((e=>"number"==typeof e)),s=Ts([t],(e=>e.value)).filter((e=>"number"==typeof e)),i=s.map(((e,t)=>({initialIndex:t,value:e,count:0}))).sort(((e,t)=>e.value-t.value));i.push({initialIndex:i.length,value:1/0,count:0});const n=o.sort(((e,t)=>e-t));let r=0;for(const e of n){for(;e>i[r].value&&r<i.length-1;)r++;i[r].count++}return[i.sort(((e,t)=>e.initialIndex-t.initialIndex)).map((e=>e.count))]},isExported:!0},rc={description:uo("Appends ranges horizontally and in sequence to return a larger array."),args:[$l("range1 (any, range<any>)",uo("The first range to be appended.")),$l("range2 (any, range<any>, repeating)",uo("Additional ranges to add to range1."))],returns:["RANGE<ANY>"],compute:function(...e){const t=Math.max(...e.map((e=>e?.[0]?.length??0))),o=[];for(const s of e){const e=Rs(s);for(let s=0;s<e.length;s++){const i=Array(t).fill({value:null});for(let t=0;t<e[s].length;t++)i[t]=e[s][t];o.push(i)}}return o},isExported:!0},ac={description:uo("Returns the matrix determinant of a square matrix."),args:[$l("square_matrix (number, range<number>)",uo("An range with an equal number of rows and columns representing a matrix whose determinant will be calculated."))],returns:["NUMBER"],compute:function(e){const t=jo(e,"square_matrix");return Yl(uo("The argument square_matrix must have the same number of columns and rows."),t),Xl(t).determinant},isExported:!0},lc={description:uo("Returns the multiplicative inverse of a square matrix."),args:[$l("square_matrix (number, range<number>)",uo("An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated."))],returns:["RANGE<NUMBER>"],compute:function(e){const t=jo(e,"square_matrix");Yl(uo("The argument square_matrix must have the same number of columns and rows."),t);const{inverted:o}=Xl(t);if(!o)throw new Lo(uo("The matrix is not invertible."));return o},isExported:!0},cc={description:uo("Calculates the matrix product of two matrices."),args:[$l("matrix1 (number, range<number>)",uo("The first matrix in the matrix multiplication operation.")),$l("matrix2 (number, range<number>)",uo("The second matrix in the matrix multiplication operation."))],returns:["RANGE<NUMBER>"],compute:function(e,t){const o=jo(e,"matrix1"),s=jo(t,"matrix2");return $o((()=>o.length===s[0].length),uo("In [[FUNCTION_NAME]], the number of columns of the first matrix (%s) must be equal to the number of rows of the second matrix (%s).",o.length.toString(),s[0].length.toString())),Ql(o,s)},isExported:!0},hc={description:uo("Calculates the sum of the products of corresponding entries in equal-sized ranges."),args:[$l("range1 (number, range<number>)",uo("The first range whose entries will be multiplied with corresponding entries in the other ranges.")),$l("range2 (number, range<number>, repeating)",uo("The other range whose entries will be multiplied with corresponding entries in the other ranges."))],returns:["NUMBER"],compute:function(...e){ql(uo("All the ranges must have the same dimensions."),...e);const t=e.map(Rs);let o=0;for(let e=0;e<t[0].length;e++)for(let s=0;s<t[0][e].length;s++){if(!t.every((t=>"number"==typeof t[e][s].value)))continue;let i=1;for(const o of t)i*=Zo(o[e][s],this.locale);o+=i}return o},isExported:!0};function dc(e,t,o){ql("The arguments array_x and array_y must have the same dimensions.",e,t);const s=Rs(e),i=Rs(t);let n=!1,r=0;for(const e in s)for(const t in s[e]){const a=s[e][t].value,l=i[e][t].value;"number"==typeof a&&"number"==typeof l&&(n=!0,r+=o(a,l))}if(!n)throw new Lo(uo("The arguments array_x and array_y must contain at least one pair of numbers."));return r}const uc={description:uo("Calculates the sum of the difference of the squares of the values in two array."),args:[$l("array_x (number, range<number>)",uo("The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.")),$l("array_y (number, range<number>)",uo("The array or range of values whose squares will be subtracted from the squares of corresponding entries in array_x and added together."))],returns:["NUMBER"],compute:function(e,t){return dc(e,t,((e,t)=>e**2-t**2))},isExported:!0},gc={description:uo("Calculates the sum of the sum of the squares of the values in two array."),args:[$l("array_x (number, range<number>)",uo("The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.")),$l("array_y (number, range<number>)",uo("The array or range of values whose squares will be added to the squares of corresponding entries in array_x and added together."))],returns:["NUMBER"],compute:function(e,t){return dc(e,t,((e,t)=>e**2+t**2))},isExported:!0},pc={description:uo("Calculates the sum of squares of the differences of values in two array."),args:[$l("array_x (number, range<number>)",uo("The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.")),$l("array_y (number, range<number>)",uo("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."))],returns:["NUMBER"],compute:function(e,t){return dc(e,t,((e,t)=>(e-t)**2))},isExported:!0},mc=!1,fc=[$l("array (any, range<any>)",uo("The array which will be transformed.")),$l("ignore (number, default=0)",uo("The control to ignore blanks and errors. 0 (default) is to keep all values, 1 is to ignore blanks, 2 is to ignore errors, and 3 is to ignore blanks and errors.")),$l("scan_by_column (number, default=false)",uo("Whether the array should be scanned by column. True scans the array by column and false (default) scans the array by row."))];function bc(e){const t=Math.trunc(e);if(0===t)return()=>!0;if(1===t)return e=>null!==e.value;if(2===t)return e=>!Wo(e.value);if(3===t)return e=>null!==e.value&&!Wo(e.value);throw new Lo(uo("Argument ignore must be between 0 and 3"))}const vc={description:uo("Transforms a range of cells into a single column."),args:fc,returns:["RANGE<ANY>"],compute:function(e,t={value:0},o={value:mc}){const s=Rs(e),i=Zo(t.value,this.locale),n=(is(o.value)?s:fs(s)).flat().filter(bc(i));if(0===n.length)throw new Uo(uo("No results for the given arguments of TOCOL."));return[n]},isExported:!0},Sc={description:uo("Transforms a range of cells into a single row."),args:fc,returns:["RANGE<ANY>"],compute:function(e,t={value:0},o={value:mc}){const s=Rs(e),i=Zo(t.value,this.locale),n=(is(o.value)?s:fs(s)).flat().filter(bc(i)).map((e=>[e]));if(0===n.length||0===n[0].length)throw new Uo(uo("No results for the given arguments of TOROW."));return n},isExported:!0},Cc={description:uo("Transposes the rows and columns of a range."),args:[$l("range (any, range<any>)",uo("The range to be transposed."))],returns:["RANGE"],compute:function(e){const t=Rs(e);return ps(t[0].length,t.length,((e,o)=>t[o][e]))},isExported:!0},yc={description:uo("Appends ranges vertically and in sequence to return a larger array."),args:[$l("range1 (any, range<any>)",uo("The first range to be appended.")),$l("range2 (any, range<any>, repeating)",uo("Additional ranges to add to range1."))],returns:["RANGE<ANY>"],compute:function(...e){const t=Math.max(...e.map((e=>Rs(e).length))),o=e.reduce(((e,t)=>e+Rs(t)[0].length),0),s=Array(t).fill([]).map((()=>Array(o).fill({value:0})));let i=0;for(const t of e){const e=Rs(t);for(let t=0;t<e.length;t++)for(let o=0;o<e[t].length;o++)s[t][i+o]=e[t][o];i+=e[0].length}return s},isExported:!0},Ec={description:uo("Wraps the provided row or column of cells by columns after a specified number of elements to form a new array."),args:[$l("range (any, range<any>)",uo("The range to wrap.")),$l("wrap_count (number)",uo("The maximum number of cells for each column, rounded down to the nearest whole number.")),$l("pad_with (any, default=0)",uo("The value with which to fill the extra cells in the range."))],returns:["RANGE<ANY>"],compute:function(e,t,o={value:0}){const s=Rs(e),i=Ko(t?.value,this.locale);Wl(uo("Argument range must be a single row or column."),s);const n=s.flat();return ps(Math.ceil(n.length/i),i,((e,t)=>{const s=e*i+t;return s<n.length?n[s]:o}))},isExported:!0},xc={description:uo("Wraps the provided row or column of cells by rows after a specified number of elements to form a new array."),args:[$l("range (any, range<any>)",uo("The range to wrap.")),$l("wrap_count (number)",uo("The maximum number of cells for each row, rounded down to the nearest whole number.")),$l("pad_with (any, default=0)",uo("The value with which to fill the extra cells in the range."))],returns:["RANGE<ANY>"],compute:function(e,t,o={value:0}){const s=Rs(e),i=Ko(t?.value,this.locale);Wl(uo("Argument range must be a single row or column."),s);const n=s.flat(),r=Math.ceil(n.length/i);return ps(i,r,((e,t)=>{const s=t*i+e;return s<n.length?n[s]:o}))},isExported:!0};var wc=Object.freeze({__proto__:null,ARRAY_CONSTRAIN:ec,CHOOSECOLS:tc,CHOOSEROWS:oc,EXPAND:sc,FLATTEN:ic,FREQUENCY:nc,HSTACK:rc,MDETERM:ac,MINVERSE:lc,MMULT:cc,SUMPRODUCT:hc,SUMX2MY2:uc,SUMX2PY2:gc,SUMXMY2:pc,TOCOL:vc,TOROW:Sc,TRANSPOSE:Cc,VSTACK:yc,WRAPCOLS:Ec,WRAPROWS:xc});const Ic={description:uo("Apply a large number format"),args:[$l("value (number)",uo("The number.")),$l("unit (string, optional)",uo("The formatting unit. Use 'k', 'm', or 'b' to force the unit"))],returns:["NUMBER"],compute:function(e,t){return{value:Zo(e,this.locale),format:ri(e,t,this.locale)}}};var Rc=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:Ic});function Tc(e,t){return us(e,((e,t)=>e+t),0,t)}function Ac(e){return ds(e,((e,t)=>As(t)?e.add(t?.value):e),new Set).size}const Oc=/^-?[a-z0-9]+$/i,_c={description:uo("Absolute value of a number."),args:[$l("value (number)",uo("The number of which to return the absolute value."))],returns:["NUMBER"],compute:function(e){return Math.abs(Zo(e,this.locale))},isExported:!0},Dc={description:uo("Inverse cosine of a value, in radians."),args:[$l("value (number)",uo("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return $o((()=>Math.abs(t)<=1),uo("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},Mc={description:uo("Inverse hyperbolic cosine of a number."),args:[$l("value (number)",uo("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return $o((()=>t>=1),uo("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},Fc={description:uo("Inverse cotangent of a value."),args:[$l("value (number)",uo("The value for which to calculate the inverse cotangent."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},Nc={description:uo("Inverse hyperbolic cotangent of a value."),args:[$l("value (number)",uo("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return $o((()=>Math.abs(t)>1),uo("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},Pc={description:uo("Inverse sine of a value, in radians."),args:[$l("value (number)",uo("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return $o((()=>Math.abs(t)<=1),uo("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Lc={description:uo("Inverse hyperbolic sine of a number."),args:[$l("value (number)",uo("The value for which to calculate the inverse hyperbolic sine."))],returns:["NUMBER"],compute:function(e){return Math.asinh(Zo(e,this.locale))},isExported:!0},kc={description:uo("Inverse tangent of a value, in radians."),args:[$l("value (number)",uo("The value for which to calculate the inverse tangent."))],returns:["NUMBER"],compute:function(e){return Math.atan(Zo(e,this.locale))},isExported:!0},Vc={description:uo("Angle from the X axis to a point (x,y), in radians."),args:[$l("x (number)",uo("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),$l("y (number)",uo("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis."))],returns:["NUMBER"],compute:function(e,t){const o=Zo(e,this.locale),s=Zo(t,this.locale);return $o((()=>0!==o||0!==s),uo("Function [[FUNCTION_NAME]] caused a divide by zero error."),No.DivisionByZero),Math.atan2(s,o)},isExported:!0},Uc={description:uo("Inverse hyperbolic tangent of a number."),args:[$l("value (number)",uo("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return $o((()=>Math.abs(t)<1),uo("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},Bc={description:uo("Rounds number up to nearest multiple of factor."),args:[$l("value (number)",uo("The value to round up to the nearest integer multiple of factor.")),$l("factor (number, default=1)",uo("The number to whose multiples value will be rounded."))],returns:["NUMBER"],compute:function(e,t={value:1}){const o=Zo(e,this.locale),s=Zo(t,this.locale);return $o((()=>s>=0||o<=0),uo("The factor (%s) must be positive when the value (%s) is positive.",s.toString(),o.toString())),{value:s?Math.ceil(o/s)*s:0,format:e?.format}},isExported:!0};function Hc(e,t,o=0){return 0===t?0:(t=Math.abs(t),e>=0?Math.ceil(e/t)*t:0===o?-Math.floor(Math.abs(e)/t)*t:-Math.ceil(Math.abs(e)/t)*t)}const zc={description:uo("Rounds number up to nearest multiple of factor."),args:[$l("number (number)",uo("The value to round up to the nearest integer multiple of significance.")),$l("significance (number, default=1)",uo("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),$l("mode (number, default=0)",uo("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero."))],returns:["NUMBER"],compute:function(e,t={value:1},o={value:0}){const s=Zo(t,this.locale);return{value:Hc(Zo(e,this.locale),s,Zo(o,this.locale)),format:e?.format}},isExported:!0},$c={description:uo("Rounds number up to nearest multiple of factor."),args:[$l("number (number)",uo("The value to round up to the nearest integer multiple of significance.")),$l("significance (number, default=1)",uo("The number to whose multiples number will be rounded."))],returns:["NUMBER"],compute:function(e,t={value:1}){const o=Zo(t,this.locale);return{value:Hc(Zo(e,this.locale),o),format:e?.format}},isExported:!0},Gc={description:uo("Cosine of an angle provided in radians."),args:[$l("angle (number)",uo("The angle to find the cosine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.cos(Zo(e,this.locale))},isExported:!0},Wc={description:uo("Hyperbolic cosine of any real number."),args:[$l("value (number)",uo("Any real value to calculate the hyperbolic cosine of."))],returns:["NUMBER"],compute:function(e){return Math.cosh(Zo(e,this.locale))},isExported:!0},qc={description:uo("Cotangent of an angle provided in radians."),args:[$l("angle (number)",uo("The angle to find the cotangent of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return es(t),1/Math.tan(t)},isExported:!0},Zc={description:uo("Hyperbolic cotangent of any real number."),args:[$l("value (number)",uo("Any real value to calculate the hyperbolic cotangent of."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return es(t),1/Math.tanh(t)},isExported:!0},Yc={description:uo("Number of empty values."),args:[$l("value1 (any, range)",uo("The first value or range in which to count the number of blanks.")),$l("value2 (any, range, repeating)",uo("Additional values or ranges in which to count the number of blanks."))],returns:["NUMBER"],compute:function(...e){return ds(e,((e,t)=>void 0===t||null===t.value||""===t.value?e+1:e),0)},isExported:!0},jc={description:uo("A conditional count across a range."),args:[$l("range (range)",uo("The range that is tested against criterion.")),$l("criterion (string)",uo("The pattern or test to apply to range."))],returns:["NUMBER"],compute:function(...e){let t=0;return ys(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0},Xc={description:uo("Count values depending on multiple criteria."),args:[$l("criteria_range1 (range)",uo("The range to check against criterion1.")),$l("criterion1 (string)",uo("The pattern or test to apply to criteria_range1.")),$l("criteria_range2 (any, range, repeating)",uo("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),$l("criterion2 (string, repeating)",uo("Additional criteria to check."))],returns:["NUMBER"],compute:function(...e){let t=0;return ys(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0},Kc={description:uo("Counts number of unique values in a range."),args:[$l("value1 (any, range)",uo("The first value or range to consider for uniqueness.")),$l("value2 (any, range, repeating)",uo("Additional values or ranges to consider for uniqueness."))],returns:["NUMBER"],compute:function(...e){return Ac(e)}},Qc={description:uo("Counts number of unique values in a range, filtered by a set of criteria."),args:[$l("range (range)",uo("The range of cells from which the number of unique values will be counted.")),$l("criteria_range1 (range)",uo("The range of cells over which to evaluate criterion1.")),$l("criterion1 (string)",uo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),$l("criteria_range2 (any, range, repeating)",uo("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),$l("criterion2 (string, repeating)",uo("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=new Set;return ys(t,((t,s)=>{const i=e[t]?.[s];As(i)&&o.add(i.value)}),this.locale),o.size}},Jc={description:uo("Cosecant of an angle provided in radians."),args:[$l("angle (number)",uo("The angle to find the cosecant of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return es(t),1/Math.sin(t)},isExported:!0},eh={description:uo("Hyperbolic cosecant of any real number."),args:[$l("value (number)",uo("Any real value to calculate the hyperbolic cosecant of."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return es(t),1/Math.sinh(t)},isExported:!0},th={description:uo("Converts from another base to decimal."),args:[$l("value (string)",uo("The number to convert.")),$l("base (number)",uo("The base to convert the value from."))],returns:["NUMBER"],compute:function(e,t){let o=Zo(t,this.locale);o=Math.floor(o),$o((()=>2<=o&&o<=36),uo("The base (%s) must be between 2 and 36 inclusive.",o.toString()));const s=ts(e);if(""===s)return 0;$o((()=>!!Oc.test(s)),uo("The value (%s) must be a valid base %s representation.",s,o.toString()));const i=parseInt(s,o);return $o((()=>!isNaN(i)),uo("The value (%s) must be a valid base %s representation.",s,o.toString())),i},isExported:!0},oh={description:uo("Converts an angle value in radians to degrees."),args:[$l("angle (number)",uo("The angle to convert from radians to degrees."))],returns:["NUMBER"],compute:function(e){return 180*Zo(e,this.locale)/Math.PI},isExported:!0},sh={description:uo("Euler's number, e (~2.718) raised to a power."),args:[$l("value (number)",uo("The exponent to raise e."))],returns:["NUMBER"],compute:function(e){return Math.exp(Zo(e,this.locale))},isExported:!0},ih={description:uo("Rounds number down to nearest multiple of factor."),args:[$l("value (number)",uo("The value to round down to the nearest integer multiple of factor.")),$l("factor (number, default=1)",uo("The number to whose multiples value will be rounded."))],returns:["NUMBER"],compute:function(e,t={value:1}){const o=Zo(e,this.locale),s=Zo(t,this.locale);return $o((()=>s>=0||o<=0),uo("The factor (%s) must be positive when the value (%s) is positive.",s.toString(),o.toString())),{value:s?Math.floor(o/s)*s:0,format:e?.format}},isExported:!0};function nh(e,t,o=0){return 0===t?0:(t=Math.abs(t),e>=0?Math.floor(e/t)*t:0===o?-Math.ceil(Math.abs(e)/t)*t:-Math.floor(Math.abs(e)/t)*t)}const rh={description:uo("Rounds number down to nearest multiple of factor."),args:[$l("number (number)",uo("The value to round down to the nearest integer multiple of significance.")),$l("significance (number, default=1)",uo("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),$l("mode (number, default=0)",uo("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero."))],returns:["NUMBER"],compute:function(e,t={value:1},o={value:0}){const s=Zo(t,this.locale);return{value:nh(Zo(e,this.locale),s,Zo(o,this.locale)),format:e?.format}},isExported:!0},ah={description:uo("Rounds number down to nearest multiple of factor."),args:[$l("number (number)",uo("The value to round down to the nearest integer multiple of significance.")),$l("significance (number, default=1)",uo("The number to whose multiples number will be rounded."))],returns:["NUMBER"],compute:function(e,t={value:1}){const o=Zo(t,this.locale);return{value:nh(Zo(e,this.locale),o),format:e?.format}},isExported:!0},lh={description:uo("Whether the provided value is even."),args:[$l("value (number)",uo("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Xo(e,this.locale);return!(1&Math.floor(Math.abs(t)))},isExported:!0},ch={description:uo("Rounds number up to nearest multiple of factor."),args:[$l("number (number)",uo("The value to round up to the nearest integer multiple of significance.")),$l("significance (number, default=1)",uo("The number to whose multiples number will be rounded."))],returns:["NUMBER"],compute:function(e,t={value:1}){return{value:Hc(Zo(e,this.locale),Zo(t,this.locale)),format:e?.format}},isExported:!0},hh={description:uo("Whether the provided value is even."),args:[$l("value (number)",uo("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Xo(e,this.locale);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},dh={description:uo("The logarithm of a number, base e (euler's number)."),args:[$l("value (number)",uo("The value for which to calculate the logarithm, base e."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return $o((()=>t>0),uo("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0};function uh(e,t){$o((()=>0!==t),uo("The divisor must be different from 0."),No.DivisionByZero);const o=e%t;return o>0&&t<0||o<0&&t>0?o+t:o}const gh={description:uo("Modulo (remainder) operator."),args:[$l("dividend (number)",uo("The number to be divided to find the remainder.")),$l("divisor (number)",uo("The number to divide by."))],returns:["NUMBER"],compute:function(e,t){const o=Zo(t,this.locale);return{value:uh(Zo(e,this.locale),o),format:e?.format}},isExported:!0},ph={description:uo("Returns a n x n unit matrix, where n is the input dimension."),args:[$l("dimension (number)",uo("An integer specifying the dimension size of the unit matrix. It must be positive."))],returns:["RANGE<NUMBER>"],compute:function(e){const t=Ko(e,this.locale);return Zl(uo("The argument dimension must be positive"),t),jl(t)},isExported:!0},mh={description:uo("Rounds a number up to the nearest odd integer."),args:[$l("value (number)",uo("The value to round to the next greatest odd number."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);let o=Math.ceil(Math.abs(t));return o=1&o?o:o+1,{value:t<0?-o:o,format:e?.format}},isExported:!0},fh={description:uo("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},bh={description:uo("A number raised to a power."),args:[$l("base (number)",uo("The number to raise to the exponent power.")),$l("exponent (number)",uo("The exponent to raise base to."))],returns:["NUMBER"],compute:function(e,t){const o=Zo(e,this.locale),s=Zo(t,this.locale);return $o((()=>o>=0||Number.isInteger(s)),uo("The exponent (%s) must be an integer when the base is negative.",s.toString())),{value:Math.pow(o,s),format:e?.format}},isExported:!0},vh={description:uo("Result of multiplying a series of numbers together."),args:[$l("factor1 (number, range<number>)",uo("The first number or range to calculate for the product.")),$l("factor2 (number, range<number>, repeating)",uo("More numbers or ranges to calculate for the product."))],returns:["NUMBER"],compute:function(...e){let t=0,o=1;for(let s of e)if(_o(s))for(let e of s)for(let s of e){const e=s.value;if("number"==typeof e&&(o*=e,t+=1),Wo(e))throw s}else void 0!==s&&null!==s.value&&(o*=Xo(s,this.locale),t+=1);return{value:0===t?0:o,format:Go(e[0])}},isExported:!0},Sh={description:uo("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},Ch={description:uo("Returns a grid of random numbers between 0 inclusive and 1 exclusive."),args:[$l("rows (number, default=1)",uo("The number of rows to be returned.")),$l("columns (number, default=1)",uo("The number of columns to be returned.")),$l("min (number, default=0)",uo("The minimum number you would like returned.")),$l("max (number, default=1)",uo("The maximum number you would like returned.")),$l("whole_number (number, default=FALSE)",uo("Return a whole number or a decimal value."))],returns:["RANGE<NUMBER>"],compute:function(e={value:1},t={value:1},o={value:0},s={value:1},i={value:!1}){const n=Ko(t,this.locale),r=Ko(e,this.locale),a=Zo(o,this.locale),l=Zo(s,this.locale),c=is(i);Zl(uo("The number columns (%s) must be positive.",n.toString()),n),Zl(uo("The number rows (%s) must be positive.",r.toString()),r),$o((()=>a<=l),uo("The maximum (%s) must be greater than or equal to the minimum (%s).",l.toString(),a.toString())),c&&$o((()=>Number.isInteger(a)&&Number.isInteger(l)),uo("The maximum (%s) and minimum (%s) must be integers when whole_number is TRUE.",l.toString(),a.toString()));const h=Array(n);for(let e=0;e<n;e++){h[e]=Array(r);for(let t=0;t<r;t++)h[e][t]=c?Math.floor(Math.random()*(l-a+1)+a):a+Math.random()*(l-a)}return h},isExported:!0},yh={description:uo("Random integer between two values, inclusive."),args:[$l("low (number)",uo("The low end of the random range.")),$l("high (number)",uo("The high end of the random range."))],returns:["NUMBER"],compute:function(e,t){let o=Zo(e,this.locale);Number.isInteger(o)||(o=Math.ceil(o));let s=Zo(t,this.locale);return Number.isInteger(s)||(s=Math.floor(s)),$o((()=>o<=s),uo("The high (%s) must be greater than or equal to the low (%s).",s.toString(),o.toString())),{value:o+Math.ceil((s-o+1)*Math.random())-1,format:e?.format}},isExported:!0},Eh={description:uo("Rounds a number according to standard rules."),args:[$l("value (number)",uo("The value to round to places number of places.")),$l("places (number, default=0)",uo("The number of decimal places to which to round."))],returns:["NUMBER"],compute:function(e,t={value:0}){const o=Zo(e,this.locale);let s=Zo(t,this.locale);const i=Math.abs(o);let n;return 0===s?n=Math.round(i):(Number.isInteger(s)||(s=Math.trunc(s)),n=Math.round(i*Math.pow(10,s))/Math.pow(10,s)),{value:o>=0?n:-n,format:e?.format}},isExported:!0},xh={description:uo("Rounds down a number."),args:[$l("value (number)",uo("The value to round to places number of places, always rounding down.")),$l("places (number, default=0)",uo("The number of decimal places to which to round."))],returns:["NUMBER"],compute:function(e,t={value:0}){const o=Zo(e,this.locale);let s=Zo(t,this.locale);const i=Math.abs(o);let n;return 0===s?n=Math.floor(i):(Number.isInteger(s)||(s=Math.trunc(s)),n=Math.floor(i*Math.pow(10,s))/Math.pow(10,s)),{value:o>=0?n:-n,format:e?.format}},isExported:!0},wh={description:uo("Rounds up a number."),args:[$l("value (number)",uo("The value to round to places number of places, always rounding up.")),$l("places (number, default=0)",uo("The number of decimal places to which to round."))],returns:["NUMBER"],compute:function(e,t={value:0}){const o=Zo(e,this.locale);let s=Zo(t,this.locale);const i=Math.abs(o);let n;return 0===s?n=Math.ceil(i):(Number.isInteger(s)||(s=Math.trunc(s)),n=Math.ceil(i*Math.pow(10,s))/Math.pow(10,s)),{value:o>=0?n:-n,format:e?.format}},isExported:!0},Ih={description:uo("Secant of an angle provided in radians."),args:[$l("angle (number)",uo("The angle to find the secant of, in radians."))],returns:["NUMBER"],compute:function(e){return 1/Math.cos(Zo(e,this.locale))},isExported:!0},Rh={description:uo("Hyperbolic secant of any real number."),args:[$l("value (number)",uo("Any real value to calculate the hyperbolic secant of."))],returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Zo(e,this.locale))},isExported:!0},Th={description:uo("Sine of an angle provided in radians."),args:[$l("angle (number)",uo("The angle to find the sine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.sin(Zo(e,this.locale))},isExported:!0},Ah={description:uo("Hyperbolic sine of any real number."),args:[$l("value (number)",uo("Any real value to calculate the hyperbolic sine of."))],returns:["NUMBER"],compute:function(e){return Math.sinh(Zo(e,this.locale))},isExported:!0},Oh={description:uo("Positive square root of a positive number."),args:[$l("value (number)",uo("The number for which to calculate the positive square root."))],returns:["NUMBER"],compute:function(e){const t=Zo(e,this.locale);return $o((()=>t>=0),uo("The value (%s) must be positive or null.",t.toString())),{value:Math.sqrt(t),format:e?.format}},isExported:!0},_h={description:uo("Sum of a series of numbers and/or cells."),args:[$l("value1 (number, range<number>)",uo("The first number or range to add together.")),$l("value2 (number, range<number>, repeating)",uo("Additional numbers or ranges to add to value1."))],returns:["NUMBER"],compute:function(...e){const t=e[0];return{value:Tc(e,this.locale),format:Go(t)}},isExported:!0},Dh={description:uo("A conditional sum across a range."),args:[$l("criteria_range (range)",uo("The range which is tested against criterion.")),$l("criterion (string)",uo("The pattern or test to apply to range.")),$l("sum_range (range, default=criteria_range)",uo("The range to be summed, if different from range."))],returns:["NUMBER"],compute:function(e,t,o){void 0===o&&(o=e);let s=0;return ys([e,t],((e,t)=>{const i=o[e]?.[t]?.value;"number"==typeof i&&(s+=i)}),this.locale),s},isExported:!0},Mh={description:uo("Sums a range depending on multiple criteria."),args:[$l("sum_range (range)",uo("The range to sum.")),$l("criteria_range1 (range)",uo("The range to check against criterion1.")),$l("criterion1 (string)",uo("The pattern or test to apply to criteria_range1.")),$l("criteria_range2 (any, range, repeating)",uo("Additional ranges to check.")),$l("criterion2 (string, repeating)",uo("Additional criteria to check."))],returns:["NUMBER"],compute:function(e,...t){let o=0;return ys(t,((t,s)=>{const i=e[t]?.[s]?.value;"number"==typeof i&&(o+=i)}),this.locale),o},isExported:!0},Fh={description:uo("Tangent of an angle provided in radians."),args:[$l("angle (number)",uo("The angle to find the tangent of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.tan(Zo(e,this.locale))},isExported:!0},Nh={description:uo("Hyperbolic tangent of any real number."),args:[$l("value (number)",uo("Any real value to calculate the hyperbolic tangent of."))],returns:["NUMBER"],compute:function(e){return Math.tanh(Zo(e,this.locale))},isExported:!0};function Ph(e,t){return 0===t?Math.trunc(e):(Number.isInteger(t)||(t=Math.trunc(t)),Math.trunc(e*Math.pow(10,t))/Math.pow(10,t))}const Lh={description:uo("Truncates a number."),args:[$l("value (number)",uo("The value to be truncated.")),$l("places (number, default=0)",uo("The number of significant digits to the right of the decimal point to retain."))],returns:["NUMBER"],compute:function(e,t={value:0}){return{value:Ph(Zo(e,this.locale),Zo(t,this.locale)),format:e?.format}},isExported:!0},kh={description:uo("Rounds a number down to the nearest integer that is less than or equal to it."),args:[$l("value (number)",uo("The number to round down to the nearest integer."))],returns:["NUMBER"],compute:function(e){return Math.floor(Zo(e,this.locale))},isExported:!0};var Vh=Object.freeze({__proto__:null,ABS:_c,ACOS:Dc,ACOSH:Mc,ACOT:Fc,ACOTH:Nc,ASIN:Pc,ASINH:Lc,ATAN:kc,ATAN2:Vc,ATANH:Uc,CEILING:Bc,CEILING_MATH:zc,CEILING_PRECISE:$c,COS:Gc,COSH:Wc,COT:qc,COTH:Zc,COUNTBLANK:Yc,COUNTIF:jc,COUNTIFS:Xc,COUNTUNIQUE:Kc,COUNTUNIQUEIFS:Qc,CSC:Jc,CSCH:eh,DECIMAL:th,DEGREES:oh,EXP:sh,FLOOR:ih,FLOOR_MATH:rh,FLOOR_PRECISE:ah,INT:kh,ISEVEN:lh,ISODD:hh,ISO_CEILING:ch,LN:dh,MOD:gh,MUNIT:ph,ODD:mh,PI:fh,POWER:bh,PRODUCT:vh,RAND:Sh,RANDARRAY:Ch,RANDBETWEEN:yh,ROUND:Eh,ROUNDDOWN:xh,ROUNDUP:wh,SEC:Ih,SECH:Rh,SIN:Th,SINH:Ah,SQRT:Oh,SUM:_h,SUMIF:Dh,SUMIFS:Mh,TAN:Fh,TANH:Nh,TRUNC:Lh});function Uh(...e){const t=e[0].length;e.forEach(((e,o)=>$o((()=>e.length===t),uo("[[FUNCTION_NAME]] has mismatched dimensions for argument %s (%s vs %s).",o.toString(),t.toString(),e.length.toString()))))}function Bh(e,t){let o=0;const s=us(e,((e,t)=>(o+=1,e+t)),0,t);return es(o),s/o}function Hh(e,t){let o=0;for(let s of e)if(_o(s))for(let e of s)for(let t of e)"number"==typeof t.value&&(o+=1);else{const e=s?.value;Wo(e)||"string"==typeof e&&!io(e,t)&&!$t(e,t)||(o+=1)}return o}function zh(e){return ds(e,((e,t)=>void 0!==t&&null!==t.value?e+1:e),0)}function $h(e,t){const o=us(e,((e,t)=>e<t?t:e),-1/0,t);return o===-1/0?0:o}function Gh(e,t){const o=us(e,((e,t)=>t<e?t:e),1/0,t);return o===1/0?0:o}function Wh(e,t){const o=[],s=[];let i=0,n=0;ls([e],(e=>{o.push(e),i+=1})),ls([t],(e=>{s.push(e),n+=1})),$o((()=>i===n),uo("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",i,n));const r=[],a=[];for(let e=0;e<i;e++){const t=o[e]?.value,i=s[e]?.value;"number"==typeof t&&"number"==typeof i&&(a.push(t),r.push(i))}return{flatDataX:r,flatDataY:a}}function qh(e,t,o){const{flatDataX:s,flatDataY:i}=Wh(e,t),n=i.length;$o((()=>0!==n&&(!o||1!==n)),uo("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."),No.DivisionByZero);let r=0,a=0;for(let e=0;e<n;e++)r+=i[e],a+=s[e];const l=r/n,c=a/n;let h=0;for(let e=0;e<n;e++)h+=(i[e]-l)*(s[e]-c);return h/(n-(o?1:0))}function Zh(e,t,o,s){let i=0,n=0;const r=o?gs:us;n=r(e,((e,t)=>(i+=1,e+t)),0,s),$o((()=>0!==i&&(!t||1!==i)),uo("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."),No.DivisionByZero);const a=n/i;return r(e,((e,t)=>e+Math.pow(t-a,2)),0,s)/(i-(t?1:0))}function Yh(e,t,o,s){const i=Zo(t,s);$o((()=>o?0<=i&&i<=1:0<i&&i<1),uo("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let n,r=[],a=0;return ls(e,(e=>{const t=e?.value;"number"==typeof t&&(n=Es(r,e,"nextSmaller","asc",r.length,((e,t)=>e[t])),r.splice(n+1,0,t),a++)})),$o((()=>0!==a),uo("[[FUNCTION_NAME]] has no valid input data.")),o||$o((()=>1/(a+1)<=i&&i<=a/(a+1)),uo("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),ao(r,i,o)}function jh(e,t,o){const s=e[0].length?e:[ve(1,t.flat().length+1)],i=s.length;let n=o[0].length?o:s;return n=n.length===i?fs(n):n,{_X:s,_newX:n}}function Xh(e,t,o=!0,s=!1){const i=t.flat(),n=i.length;let{_X:r}=jh(e,t,[[]]);r=r.length===n?fs(r):r.slice(),Uh(r[0],i);const a=r.length,l=n-a-(o?1:0),c=[i],h=fs(r.reverse());let d=[];for(let e=0;e<a;e++)if(d.push(0),o){for(const t of r[e])d[e]+=t;d[e]/=n}let u=0;if(o){for(const e of i)u+=e;u/=n}const g=h.map((e=>e.map(((e,t)=>e-d[t]))));o&&h.forEach((e=>e.push(1)));const p=Qh(h,c);if(o||p.push([0]),!s)return p;const m=Ql(g,fs(g)),{inverted:f}=Xl(m);if(void 0===f)throw new Lo(uo("Matrix is not invertible"));let b=0,v=0;for(let e=0;e<n;e++){const t=i[e]-u;let o=0;for(let t=0;t<a;t++){o+=g[e][t]*p[t][0]}const s=t-o;b+=s*s,v+=o*o}const S=Math.sqrt(b/l),C=v/(v+b),y=v/a/(b/l),E=[];for(let e=0;e<a;e++)E.push(S*Math.sqrt(f[e][e]));if(o){const e=Ql(f,[d]),t=Ql(fs([d]),e);E.push(S*Math.sqrt(t[0][0]+1/i.length))}const x=[[p[0][0],E[0],C,y,v],[p[1][0],E[1],S,l,b]];for(let e=2;e<a;e++)x.push([p[e][0],E[e],"","",""]);return o?x.push([p[a][0],E[a],"","",""]):x.push([0,"","","",""]),x}function Kh(e,t,o,s){Uh(t,e),$o((()=>o>=1),uo("Function [[FUNCTION_NAME]] A regression of order less than 1 cannot be possible."));const i=[e],n=t.map((e=>ve(0,o).map((t=>Math.pow(e,o-t)))));s&&n.forEach((e=>e.push(1)));const r=Qh(n,i);return s||r.push([0]),r}function Qh(e,t){const o=Ql(e,fs(e)),{inverted:s}=Xl(o);if(void 0===s)throw new Lo(uo("Matrix is not invertible"));const i=Ql(e,t);return fs(Ql(s,i))}function Jh(e){return e.map((e=>e.map((e=>Math.log(e)))))}function ed(e,t,o,s){const{_X:i,_newX:n}=jh(t,e,o),r=Xh(i,e,s,!1),a=r.length-1,l=n.map((e=>{let t=0;for(let o=0;o<a;o++)t+=r[o][0]*e[a-o-1];return t+=r[a][0],[t]}));return l.length===o.length?l:fs(l)}const td={description:uo("Average magnitude of deviations from mean."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the sample.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){let t=0;const o=us(e,((e,o)=>(t+=1,e+o)),0,this.locale);es(t);const s=o/t;return us(e,((e,t)=>e+Math.abs(s-t)),0,this.locale)/t},isExported:!0},od={description:uo("Numerical average value in a dataset, ignoring text."),args:[$l("value1 (number, range<number>)",uo("The first value or range to consider when calculating the average value.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],compute:function(...e){return{value:Bh(e,this.locale),format:Go(e[0])}},isExported:!0},sd=uo("[[FUNCTION_NAME]] has mismatched range sizes."),id=uo("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),nd={description:uo("Weighted average."),args:[$l("values (number, range<number>)",uo("Values to average.")),$l("weights (number, range<number>)",uo("Weights for each corresponding value.")),$l("additional_values (number, range<number>, repeating)",uo("Additional values to average.")),$l("additional_weights (number, range<number>, repeating)",uo("Additional weights."))],returns:["NUMBER"],compute:function(...e){let t=0,o=0;for(let s=0;s<e.length-1;s+=2){const i=e[s],n=e[s+1];if(ql(sd,i,n),_o(i))for(let e=0;e<i.length;e++)for(let s=0;s<i[0].length;s++){const r=i[e][s].value,a=_o(n)?n?.[e][s].value:Zo(n,this.locale),l="number"==typeof r,c="number"==typeof a;l&&c?($o((()=>a>=0),id),t+=r*a,o+=a):$o((()=>l===c),uo("[[FUNCTION_NAME]] expects number values."))}else{const e=Zo(i,this.locale),s=_o(n)?n?.[0][0].value:Zo(n,this.locale);"number"==typeof s&&($o((()=>s>=0),id),t+=e*s,o+=s)}}return es(o),{value:t/o,format:Go(e[0])}}},rd={description:uo("Numerical average value in a dataset."),args:[$l("value1 (number, range<number>)",uo("The first value or range to consider when calculating the average value.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],compute:function(...e){let t=0;const o=gs(e,((e,o)=>(t+=1,e+o)),0,this.locale);return es(t),{value:o/t,format:Go(e[0])}},isExported:!0},ad={description:uo("Average of values depending on criteria."),args:[$l("criteria_range (number, range<number>)",uo("The range to check against criterion.")),$l("criterion (string)",uo("The pattern or test to apply to criteria_range.")),$l("average_range (number, range<number>, default=criteria_range)",uo("The range to average. If not included, criteria_range is used for the average instead."))],returns:["NUMBER"],compute:function(e,t,o){const s=Rs(void 0===o?e:o);let i=0,n=0;return ys([e,t],((e,t)=>{const o=s[e]?.[t]?.value;"number"==typeof o&&(i+=1,n+=o)}),this.locale),es(i),n/i},isExported:!0},ld={description:uo("Average of values depending on multiple criteria."),args:[$l("average_range (range)",uo("The range to average.")),$l("criteria_range1 (range)",uo("The range to check against criterion1.")),$l("criterion1 (string)",uo("The pattern or test to apply to criteria_range1.")),$l("criteria_range2 (any, range, repeating)",uo("Additional criteria_range and criterion to check.")),$l("criterion2 (string, repeating)",uo("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){const o=Rs(e);let s=0,i=0;return ys(t,((e,t)=>{const n=o[e]?.[t]?.value;"number"==typeof n&&(s+=1,i+=n)}),this.locale),es(s),i/s},isExported:!0},cd={description:uo("The number of numeric values in dataset."),args:[$l("value1 (number, range<number>)",uo("The first value or range to consider when counting.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){return Hh(e,this.locale)},isExported:!0},hd={description:uo("The number of values in a dataset."),args:[$l("value1 (any, range)",uo("The first value or range to consider when counting.")),$l("value2 (any, range, repeating)",uo("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){return zh(e)},isExported:!0},dd={description:uo("The covariance of a dataset."),args:[$l("data_y (any, range)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (any, range)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return qh(e,t,!1)},isExported:!0},ud={description:uo("The covariance of a dataset."),args:[$l("data_y (any, range)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (any, range)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return qh(e,t,!1)},isExported:!0},gd={description:uo("The sample covariance of a dataset."),args:[$l("data_y (any, range)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (any, range)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return qh(e,t,!0)},isExported:!0},pd={description:uo("Calculates the expected y-value for a specified x based on a linear regression of a dataset."),args:[$l("x (number, range<number>)",uo("The value(s) on the x-axis to forecast.")),$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t,o){const{flatDataX:s,flatDataY:i}=Wh(t,o);return ed([i],[s],ms(Rs(e),(e=>Zo(e,this.locale))),!0)},isExported:!0},md={description:uo("Fits points to exponential growth trend."),args:[$l("known_data_y (range<number>)",uo("The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.")),$l("known_data_x (range<number>, default={1;2;3;...})",uo("The values of the independent variable(s) corresponding with known_data_y.")),$l("new_data_x (any, range, default=known_data_x)",uo("The data points to return the y values for on the ideal curve fit.")),$l("b (boolean, default=TRUE)",uo("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."))],returns:["NUMBER"],compute:function(e,t=[[]],o=[[]],s={value:!0}){return ed(Jh(jo(e,"the first argument (known_data_y)")),jo(t,"the second argument (known_data_x)"),jo(o,"the third argument (new_data_y)"),is(s)).map((e=>e.map((e=>Math.exp(e)))))}},fd={description:uo("Compute the intercept of the linear regression."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Wh(e,t),[[],[i]]=Xh([o],[s]);return i},isExported:!0},bd={description:uo("Nth largest element from a data set."),args:[$l("data (any, range)",uo("Array or range containing the dataset to consider.")),$l("n (number)",uo("The rank from largest to smallest of the element to return."))],returns:["NUMBER"],compute:function(e,t){const o=Math.trunc(Zo(t?.value,this.locale));let s,i=[],n=0;ls([e],(e=>{"number"==typeof e?.value&&(s=Es(i,e,"nextSmaller","asc",i.length,((e,t)=>e[t].value)),i.splice(s+1,0,e),n++,n>o&&(i.shift(),n--))}));const r=i.shift();return $o((()=>void 0!==r),uo("[[FUNCTION_NAME]] has no valid input data.")),$o((()=>n>=o),uo("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o)),r},isExported:!0},vd={description:uo("Compute the intercept of the linear regression."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>, default={1;2;3;...})",uo("The range representing the array or matrix of independent data.")),$l("calculate_b (boolean, default=TRUE)",uo("A flag specifying wheter to compute the slope or not")),$l("verbose (boolean, default=FALSE)",uo("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept"))],returns:["NUMBER"],compute:function(e,t=[[]],o={value:!0},s={value:!1}){return Xh(jo(t,"the first argument (data_y)"),jo(e,"the second argument (data_x)"),is(o),is(s))},isExported:!0},Sd={description:uo("Compute the intercept of the linear regression."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>, optional, default={1;2;3;...})",uo("The range representing the array or matrix of independent data.")),$l("calculate_b (boolean, default=TRUE)",uo("A flag specifying wheter to compute the slope or not")),$l("verbose (boolean, default=FALSE)",uo("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept"))],returns:["NUMBER"],compute:function(e,t=[[]],o={value:!0},s={value:!1}){const i=Xh(jo(t,"the second argument (data_x)"),Jh(jo(e,"the first argument (data_y)")),is(o),is(s));for(let e=0;e<i.length;e++)i[e][0]=Math.exp(i[e][0]);return i},isExported:!0},Cd={description:uo("Compute the Matthews correlation coefficient of a dataset."),args:[$l("data_x (range)",uo("The range representing the array or matrix of observed data.")),$l("data_y (range)",uo("The range representing the array or matrix of predicted data."))],returns:["NUMBER"],compute:function(e,t){const o=e.flat(),s=t.flat();if(Uh(o,s),0===o.length)throw new Lo(uo("[[FUNCTION_NAME]] expects non-empty ranges for both parameters."));const i=o.length;let n=0,r=0,a=0,l=0;for(let e=0;e<i;++e){const t=is(o[e]);t===is(s[e])?t?r++:n++:t?l++:a++}return(r*n-a*l)/Math.sqrt((r+a)*(r+l)*(n+a)*(n+l))},isExported:!1},yd={description:uo("Maximum value in a numeric dataset."),args:[$l("value1 (number, range<number>)",uo("The first value or range to consider when calculating the maximum value.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],compute:function(...e){return{value:$h(e,this.locale),format:Go(e[0])}},isExported:!0},Ed={description:uo("Maximum numeric value in a dataset."),args:[$l("value1 (any, range)",uo("The first value or range to consider when calculating the maximum value.")),$l("value2 (any, range, repeating)",uo("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],compute:function(...e){const t=gs(e,((e,t)=>Math.max(t,e)),-1/0,this.locale);return{value:t===-1/0?0:t,format:Go(e[0])}},isExported:!0},xd={description:uo("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:[$l("range (range)",uo("The range of cells from which the maximum will be determined.")),$l("criteria_range1 (range)",uo("The range of cells over which to evaluate criterion1.")),$l("criterion1 (string)",uo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),$l("criteria_range2 (any, range, repeating)",uo("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),$l("criterion2 (string, repeating)",uo("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=-1/0;return ys(t,((t,s)=>{const i=e[t]?.[s]?.value;"number"==typeof i&&(o=o<i?i:o)}),this.locale),o===-1/0?0:o},isExported:!0},wd={description:uo("Median value in a numeric dataset."),args:[$l("value1 (any, range)",uo("The first value or range to consider when calculating the median value.")),$l("value2 (any, range, repeating)",uo("Additional values or ranges to consider when calculating the median value."))],returns:["NUMBER"],compute:function(...e){let t=[];return cs(e,(e=>{t.push({value:e})}),this.locale),{value:Yh(t,{value:.5},!0,this.locale),format:Go(e[0])}},isExported:!0},Id={description:uo("Minimum value in a numeric dataset."),args:[$l("value1 (number, range<number>)",uo("The first value or range to consider when calculating the minimum value.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],compute:function(...e){return{value:Gh(e,this.locale),format:Go(e[0])}},isExported:!0},Rd={description:uo("Minimum numeric value in a dataset."),args:[$l("value1 (number, range<number>)",uo("The first value or range to consider when calculating the minimum value.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],compute:function(...e){const t=gs(e,((e,t)=>Math.min(t,e)),1/0,this.locale);return{value:t===1/0?0:t,format:Go(e[0])}},isExported:!0},Td={description:uo("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:[$l("range (range)",uo("The range of cells from which the minimum will be determined.")),$l("criteria_range1 (range)",uo("The range of cells over which to evaluate criterion1.")),$l("criterion1 (string)",uo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),$l("criteria_range2 (any, range, repeating)",uo("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),$l("criterion2 (string, repeating)",uo("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=1/0;return ys(t,((t,s)=>{const i=e[t]?.[s]?.value;"number"==typeof i&&(o=o>i?i:o)}),this.locale),o===1/0?0:o},isExported:!0};function Ad(e,t){const{flatDataX:o,flatDataY:s}=Wh(e,t);if(0===o.length)throw new Lo(uo("[[FUNCTION_NAME]] expects non-empty ranges for both parameters."));if(o.length<2)throw new Lo(uo("[[FUNCTION_NAME]] needs at least two values for both parameters."));const i=o.length;let n=0,r=0,a=0,l=0,c=0;for(let e=0;e<i;e++){const t=o[e],i=s[e];n+=t,r+=i,a+=t*i,l+=t*t,c+=i*i}return(i*a-n*r)/Math.sqrt((i*l-n*n)*(i*c-r*r))}const Od={description:uo("Compute the Pearson product-moment correlation coefficient of a dataset."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return Ad(e,t)},isExported:!0},_d=Od,Dd={description:uo("Value at a given percentile of a dataset."),args:[$l("data (any, range)",uo("The array or range containing the dataset to consider.")),$l("percentile (number)",uo("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],compute:function(e,t){return Fd.compute.bind(this)(e,t)},isExported:!0},Md={description:uo("Value at a given percentile of a dataset exclusive of 0 and 1."),args:[$l("data (any, range)",uo("The array or range containing the dataset to consider.")),$l("percentile (number)",uo("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned."))],returns:["NUMBER"],compute:function(e,t){return{value:Yh([e],t,!1,this.locale),format:Go(e)}},isExported:!0},Fd={description:uo("Value at a given percentile of a dataset."),args:[$l("data (any, range)",uo("The array or range containing the dataset to consider.")),$l("percentile (number)",uo("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],compute:function(e,t){return{value:Yh([e],t,!0,this.locale),format:Go(e)}},isExported:!0},Nd={description:uo("Compute the coefficients of polynomial regression of the dataset."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data.")),$l("order (number)",uo("The order of the polynomial to fit the data, between 1 and 6.")),$l("intercept (boolean, default=TRUE)",uo("A flag specifying whether to compute the intercept or not."))],returns:["RANGE<NUMBER>"],compute:function(e,t,o,s={value:!0}){const{flatDataX:i,flatDataY:n}=Wh(e,t);return Kh(n,i,Zo(o,this.locale),is(s))},isExported:!1},Pd={description:uo("Predict value by computing a polynomial regression of the dataset."),args:[$l("x (number, range<number>)",uo("The value(s) on the x-axis to forecast.")),$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data.")),$l("order (number)",uo("The order of the polynomial to fit the data, between 1 and 6.")),$l("intercept (boolean, default=TRUE)",uo("A flag specifying whether to compute the intercept or not."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:!0}){const n=Zo(s,this.locale),{flatDataX:r,flatDataY:a}=Wh(t,o),l=Kh(a,r,n,is(i)).flat();return ms(Rs(e),(e=>function(e,t,o){return e.reduce(((e,s,i)=>e+s*Math.pow(t,o-i)),0)}(l,Zo(e,this.locale),n)))},isExported:!1},Ld={description:uo("Value nearest to a specific quartile of a dataset."),args:[$l("data (any, range)",uo("The array or range containing the dataset to consider.")),$l("quartile_number (number)",uo("Which quartile value to return."))],returns:["NUMBER"],compute:function(e,t){return Vd.compute.bind(this)(e,t)},isExported:!0},kd={description:uo("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:[$l("data (any, range)",uo("The array or range containing the dataset to consider.")),$l("quartile_number (number)",uo("Which quartile value, exclusive of 0 and 4, to return."))],returns:["NUMBER"],compute:function(e,t){return{value:Yh([e],{value:.25*Math.trunc(Zo(t,this.locale))},!1,this.locale),format:Go(e)}},isExported:!0},Vd={description:uo("Value nearest to a specific quartile of a dataset."),args:[$l("data (any, range)",uo("The array or range containing the dataset to consider.")),$l("quartile_number (number)",uo("Which quartile value to return."))],returns:["NUMBER"],compute:function(e,t){return{value:Yh([e],{value:.25*Math.trunc(Zo(t,this.locale))},!0,this.locale),format:Go(e)}},isExported:!0},Ud={description:uo("Returns the rank of a specified value in a dataset."),args:[$l("value (number)",uo("The value whose rank will be determined.")),$l("data (range)",uo("The range containing the dataset to consider.")),$l("is_ascending (boolean, default=FALSE)",uo("Whether to consider the values in data in descending or ascending order."))],returns:["ANY"],compute:function(e,t,o={value:!1}){const s=is(o),i=Zo(e,this.locale);let n=1,r=!1;for(const e of t)for(const t of e){if("number"!=typeof t.value)continue;const e=Zo(t,this.locale);e===i?r=!0:e>i!==s&&n++}if(!r)throw new Uo(uo("Value not found in the given data."));return n},isExported:!0},Bd={description:uo("Compute the square of r, the Pearson product-moment correlation coefficient of a dataset."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return Math.pow(Ad(t,e),2)},isExported:!0},Hd={description:uo("Compute the slope of the linear regression."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Wh(e,t),[[i]]=Xh([o],[s]);return i},isExported:!0},zd={description:uo("Nth smallest element in a data set."),args:[$l("data (any, range)",uo("The array or range containing the dataset to consider.")),$l("n (number)",uo("The rank from smallest to largest of the element to return."))],returns:["NUMBER"],compute:function(e,t){const o=Math.trunc(Zo(t?.value,this.locale));let s,i=[],n=0;ls([e],(e=>{"number"==typeof e?.value&&(s=Es(i,e,"nextSmaller","asc",i.length,((e,t)=>e[t].value)),i.splice(s+1,0,e),n++,n>o&&(i.pop(),n--))}));const r=i.pop();return $o((()=>void 0!==r),uo("[[FUNCTION_NAME]] has no valid input data.")),$o((()=>n>=o),uo("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o)),r},isExported:!0},$d={description:uo("Compute the Spearman rank correlation coefficient of a dataset."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Wh(t,e),i=o.length,n=o.map(((e,t)=>[e,s[t]]));n.sort(((e,t)=>e[0]-t[0]));for(let e=0;e<i;++e)n[e][0]=e;n.sort(((e,t)=>e[1]-t[1]));let r=0;for(let e=0;e<i;++e)r+=(n[e][0]-e)**2;return 1-6*r/(i**3-i)},isExported:!1},Gd={description:uo("Standard deviation."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the sample.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Qd.compute.bind(this)(...e))},isExported:!0},Wd={description:uo("Standard deviation of entire population."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the population.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Jd.compute.bind(this)(...e))},isExported:!0},qd={description:uo("Standard deviation."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the sample.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(eu.compute.bind(this)(...e))},isExported:!0},Zd={description:uo("Standard deviation of sample (text as 0)."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the sample.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(tu.compute.bind(this)(...e))},isExported:!0},Yd={description:uo("Standard deviation of entire population."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the population.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(ou.compute.bind(this)(...e))},isExported:!0},jd={description:uo("Standard deviation of entire population (text as 0)."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the population.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(su.compute.bind(this)(...e))},isExported:!0},Xd={description:uo("Calculates the standard error of the predicted y-value for each x in the regression of a dataset."),args:[$l("data_y (range<number>)",uo("The range representing the array or matrix of dependent data.")),$l("data_x (range<number>)",uo("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Wh(e,t);return Xh([o],[s],!0,!0)[1][2]},isExported:!0},Kd={description:uo("Fits points to linear trend derived via least-squares."),args:[$l("known_data_y (number, range<number>)",uo("The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.")),$l("known_data_x (number, range<number>, optional, default={1;2;3;...})",uo("The values of the independent variable(s) corresponding with known_data_y.")),$l("new_data_x (number, range<number>, optional, default=known_data_x)",uo("The data points to return the y values for on the ideal curve fit.")),$l("b (boolean, optional, default=TRUE)",uo("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."))],returns:["NUMBER"],compute:function(e,t=[[]],o=[[]],s={value:!0}){return ed(jo(e,"the first argument (known_data_y)"),jo(t,"the second argument (known_data_x)"),jo(o,"the third argument (new_data_y)"),is(s))}},Qd={description:uo("Variance."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the sample.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Zh(e,!0,!1,this.locale)},isExported:!0},Jd={description:uo("Variance of entire population."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the population.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Zh(e,!1,!1,this.locale)},isExported:!0},eu={description:uo("Variance."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the sample.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Zh(e,!0,!1,this.locale)},isExported:!0},tu={description:uo("Variance of sample (text as 0)."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the sample.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Zh(e,!0,!0,this.locale)},isExported:!0},ou={description:uo("Variance of entire population."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the population.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Zh(e,!1,!1,this.locale)},isExported:!0},su={description:uo("Variance of entire population (text as 0)."),args:[$l("value1 (number, range<number>)",uo("The first value or range of the population.")),$l("value2 (number, range<number>, repeating)",uo("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Zh(e,!1,!0,this.locale)},isExported:!0};var iu=Object.freeze({__proto__:null,AVEDEV:td,AVERAGE:od,AVERAGEA:rd,AVERAGEIF:ad,AVERAGEIFS:ld,AVERAGE_WEIGHTED:nd,CORREL:_d,COUNT:cd,COUNTA:hd,COVAR:dd,COVARIANCE_P:ud,COVARIANCE_S:gd,FORECAST:pd,GROWTH:md,INTERCEPT:fd,LARGE:bd,LINEST:vd,LOGEST:Sd,MATTHEWS:Cd,MAX:yd,MAXA:Ed,MAXIFS:xd,MEDIAN:wd,MIN:Id,MINA:Rd,MINIFS:Td,PEARSON:Od,PERCENTILE:Dd,PERCENTILE_EXC:Md,PERCENTILE_INC:Fd,POLYFIT_COEFFS:Nd,POLYFIT_FORECAST:Pd,QUARTILE:Ld,QUARTILE_EXC:kd,QUARTILE_INC:Vd,RANK:Ud,RSQ:Bd,SLOPE:Hd,SMALL:zd,SPEARMAN:$d,STDEV:Gd,STDEVA:Zd,STDEVP:Yd,STDEVPA:jd,STDEV_P:Wd,STDEV_S:qd,STEYX:Xd,TREND:Kd,VAR:Qd,VARA:tu,VARP:ou,VARPA:su,VAR_P:Jd,VAR_S:eu});function nu(e,t,o,s){const i=new Map,n=e.length;for(let t=n-1;t>=0;t--)i.set(ts(e[t][0]).toUpperCase(),t);const r=t?.value;if("number"!=typeof r&&"string"!=typeof r)throw new Lo(uo("The field must be a number or a string"));let a;if("number"==typeof r){if(a=Math.trunc(r)-1,a<0||n-1<a)throw new Lo(uo("The field (%(fieldValue)s) must be one of %(dimRowDB)s or must be a number between 1 and %s inclusive.",{fieldValue:r.toString(),dimRowDB:n.toString()}))}else{const e=ts(t).toUpperCase();if(a=i.get(e)??-1,-1===a)throw new Lo(uo("The field (%s) must be one of %s.",ts(t),[...i.keys()].toString()))}const l=o[0].length;if(l<2)throw new Lo(uo("The criteria range contains %s row, it must be at least 2 rows.",l.toString()));let c=new Set;const h=e[0].length;for(let t=1;t<l;t++){let n=[],r=!0;for(let s=0;s<o.length;s++){const a=ts(o[s][0]).toUpperCase(),l=i.get(a),c=o[s][t];if(null!==c.value){if(void 0===l){r=!1;break}n.push([e[l].slice(1,h)]),n.push(c)}}if(r){if(!(n.length>0)){c=new Set(Array(h-1).keys());break}ys(n,((e,t)=>{c.add(t)}),s,!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const ru=[$l("database (range)",uo("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.")),$l("field (any)",uo("Indicates which column in database contains the values to be extracted and operated on.")),$l("criteria (range)",uo("An array or range containing zero or more criteria to filter the database values by before operating."))],au={description:uo("Average of a set of values from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return od.compute.bind(this)([s])},isExported:!0},lu={description:uo("Counts values from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return cd.compute.bind(this)([s])},isExported:!0},cu={description:uo("Counts values and text from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return hd.compute.bind(this)([s])},isExported:!0},hu={description:uo("Single value from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return $o((()=>1===s.length),uo("More than one match found in DGET evaluation.")),s[0]},isExported:!0},du={description:uo("Maximum of values from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return yd.compute.bind(this)([s])},isExported:!0},uu={description:uo("Minimum of values from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return Id.compute.bind(this)([s])},isExported:!0},gu={description:uo("Product of values from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return vh.compute.bind(this)([s])},isExported:!0},pu={description:uo("Standard deviation of population sample from table."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return Gd.compute.bind(this)([s])},isExported:!0},mu={description:uo("Standard deviation of entire population from table."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return Yd.compute.bind(this)([s])},isExported:!0},fu={description:uo("Sum of values from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return _h.compute.bind(this)([s])},isExported:!0},bu={description:uo("Variance of population sample from table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return Qd.compute.bind(this)([s])},isExported:!0},vu={description:uo("Variance of a population from a table-like range."),args:ru,returns:["NUMBER"],compute:function(e,t,o){const s=nu(e,t,o,this.locale);return ou.compute.bind(this)([s])},isExported:!0};var Su=Object.freeze({__proto__:null,DAVERAGE:au,DCOUNT:lu,DCOUNTA:cu,DGET:hu,DMAX:du,DMIN:uu,DPRODUCT:gu,DSTDEV:pu,DSTDEVP:mu,DSUM:fu,DVAR:bu,DVARP:vu});var Cu;!function(e){e.WHOLE_YEARS="Y",e.WHOLE_MONTHS="M",e.WHOLE_DAYS="D",e.DAYS_WITHOUT_WHOLE_MONTHS="MD",e.MONTH_WITHOUT_WHOLE_YEARS="YM",e.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR="YD"}(Cu||(Cu={}));const yu={description:uo("Converts year/month/day into a date."),args:[$l("year (number)",uo("The year component of the date.")),$l("month (number)",uo("The month component of the date.")),$l("day (number)",uo("The day component of the date."))],returns:["DATE"],compute:function(e,t,o){let s=Math.trunc(Zo(e,this.locale));const i=Math.trunc(Zo(t,this.locale)),n=Math.trunc(Zo(o,this.locale));$o((()=>0<=s&&s<=9999),uo("The year (%s) must be between 0 and 9999 inclusive.",s.toString())),s<1900&&(s+=1900);const r=Wt(new At(s,i-1,n));return $o((()=>r>=0),uo("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),{value:r,format:this.locale.dateFormat}},isExported:!0},Eu={description:uo("Calculates the number of days, months, or years between two dates."),args:[$l("start_date (date)",uo("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.")),$l("end_date (date)",uo("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.")),$l("unit (string)",uo('A text abbreviation for unit of time. Accepted values are "Y" (the number of whole years between start_date and end_date), "M" (the number of whole months between start_date and end_date), "D" (the number of days between start_date and end_date), "MD" (the number of days between start_date and end_date after subtracting whole months), "YM" (the number of whole months between start_date and end_date after subtracting whole years), "YD" (the number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart).'))],returns:["NUMBER"],compute:function(e,t,o){const s=ts(o).toUpperCase();$o((()=>Object.values(Cu).includes(s)),((e,t)=>{const o=e.map((e=>`'${e}'`)).join(", ");return uo("The function [[FUNCTION_NAME]] has an argument with value '%s'. It should be one of: %s.",t,o)})(Object.values(Cu),ts(o)));const i=Math.trunc(Zo(e,this.locale)),n=Math.trunc(Zo(t,this.locale)),r=Gt(i),a=Gt(n);switch($o((()=>n>=i),uo("start_date (%s) should be on or before end_date (%s).",r.toLocaleDateString(),a.toLocaleDateString())),s){case Cu.WHOLE_YEARS:return eo(r,a);case Cu.WHOLE_MONTHS:return Qt(r,a);case Cu.WHOLE_DAYS:return Jt(r,a);case Cu.MONTH_WITHOUT_WHOLE_YEARS:return Qt(r,a)-12*eo(r,a);case Cu.DAYS_WITHOUT_WHOLE_MONTHS:let e=a.getDate()-r.getDate();if(e<0){e=Zt(new At(a.getFullYear(),a.getMonth()-1,1))-Math.abs(e)}return e;case Cu.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR:{if(function(e,t){return Kt(e,t,1)<1}(i,n))return Jt(r,a);const e=new At(r.getFullYear(),a.getMonth(),a.getDate());let t=Jt(r,e);return t<0&&(e.setFullYear(r.getFullYear()+1),t=Jt(r,e)),t}}},isExported:!0},xu={description:uo("Converts a date string to a date value."),args:[$l("date_string (string)",uo("The string representing the date."))],returns:["NUMBER"],compute:function(e){const t=ts(e),o=$t(t,this.locale);return $o((()=>null!==o),uo("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(o.value)},isExported:!0},wu={description:uo("Day of the month that a specific date falls on."),args:[$l("date (string)",uo("The date from which to extract the day."))],returns:["NUMBER"],compute:function(e){return ns(e,this.locale).getDate()},isExported:!0},Iu={description:uo("Number of days between two dates."),args:[$l("end_date (date)",uo("The end of the date range.")),$l("start_date (date)",uo("The start of the date range."))],returns:["NUMBER"],compute:function(e,t){const o=ns(e,this.locale),s=ns(t,this.locale),i=o.getTime()-s.getTime();return Math.round(i/_t)},isExported:!0},Ru={description:uo("Number of days between two dates on a 360-day year (months of 30 days)."),args:[$l("start_date (date)",uo("The start date to consider in the calculation.")),$l("end_date (date)",uo("The end date to consider in the calculation.")),$l("method (number, default=0)",uo("An indicator of what day count method to use. (0) US NASD method (1) European method"))],returns:["NUMBER"],compute:function(e,t,o={value:0}){const s=Math.trunc(Zo(e,this.locale)),i=Math.trunc(Zo(t,this.locale)),n=Kt(s,i,is(o)?4:0);return Math.sign(i-s)*Math.round(360*n)},isExported:!0},Tu={description:uo("Date a number of months before/after another date."),args:[$l("start_date (date)",uo("The date from which to calculate the result.")),$l("months (number)",uo("The number of months before (negative) or after (positive) 'start_date' to calculate."))],returns:["DATE"],compute:function(e,t){return{value:Wt(jt(ns(e,this.locale),Math.trunc(Zo(t,this.locale)),!1)),format:this.locale.dateFormat}},isExported:!0},Au={description:uo("Last day of a month before or after a date."),args:[$l("start_date (date)",uo("The date from which to calculate the result.")),$l("months (number)",uo("The number of months before (negative) or after (positive) 'start_date' to consider."))],returns:["DATE"],compute:function(e,t){const o=ns(e,this.locale),s=Math.trunc(Zo(t,this.locale)),i=o.getFullYear(),n=o.getMonth();return{value:Wt(new At(i,n+s+1,0)),format:this.locale.dateFormat}},isExported:!0},Ou={description:uo("Hour component of a specific time."),args:[$l("time (date)",uo("The time from which to calculate the hour component."))],returns:["NUMBER"],compute:function(e){return ns(e,this.locale).getHours()},isExported:!0},_u={description:uo("ISO week number of the year."),args:[$l("date (date)",uo("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."))],returns:["NUMBER"],compute:function(e){const t=ns(e,this.locale),o=t.getFullYear();let s=1;for(;4!==new At(o,0,s).getDay();)s+=1;const i=new At(o,0,s-3);let n=31;for(;4!==new At(o,11,n).getDay();)n-=1;const r=new At(o,11,n+3);let a,l;switch(a=i.getTime()<=t.getTime()?t.getTime()<=r.getTime()?0:1:-1,a){case 0:l=i;break;case 1:l=new At(o,11,n+3+1);break;case-1:let e=1;for(;4!==new At(o-1,0,e).getDay();)e+=1;l=new At(o-1,0,e-3)}const c=(t.getTime()-l.getTime())/_t;return Math.floor(c/7)+1},isExported:!0},Du={description:uo("Minute component of a specific time."),args:[$l("time (date)",uo("The time from which to calculate the minute component."))],returns:["NUMBER"],compute:function(e){return ns(e,this.locale).getMinutes()},isExported:!0},Mu={description:uo("Month of the year a specific date falls in"),args:[$l("date (date)",uo("The date from which to extract the month."))],returns:["NUMBER"],compute:function(e){return ns(e,this.locale).getMonth()+1},isExported:!0},Fu={description:uo("Net working days between two provided days."),args:[$l("start_date (date)",uo("The start date of the period from which to calculate the number of net working days.")),$l("end_date (date)",uo("The end date of the period from which to calculate the number of net working days.")),$l("holidays (date, range<date>, optional)",uo("A range or array constant containing the date serial numbers to consider holidays."))],returns:["NUMBER"],compute:function(e,t,o){return Pu.compute.bind(this)(e,t,{value:1},o)},isExported:!0};function Nu(e){const t=e?.value;if("string"==typeof t){$o((()=>{if(7!==t.length)return!1;for(let e of t)if("0"!==e&&"1"!==e)return!1;return!0}),uo('When weekend is a string (%s) it must be composed of "0" or "1".',t));let e=[];for(let o=0;o<7;o++)"1"===t[o]&&e.push((o+1)%7);return e}if("number"==typeof t)return $o((()=>1<=t&&t<=7||11<=t&&t<=17),uo("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 Lo(uo("The weekend must be a number or a string."))}const Pu={description:uo("Net working days between two dates (specifying weekends)."),args:[$l("start_date (date)",uo("The start date of the period from which to calculate the number of net working days.")),$l("end_date (date)",uo("The end date of the period from which to calculate the number of net working days.")),$l("weekend (any, default=1)",uo("A number or string representing which days of the week are considered weekends.")),$l("holidays (date, range<date>, optional)",uo("A range or array constant containing the dates to consider as holidays."))],returns:["NUMBER"],compute:function(e,t,o={value:1},s){const i=ns(e,this.locale),n=ns(t,this.locale),r=Nu(o);let a=new Set;void 0!==s&&ls([s],(e=>{const t=ns(e,this.locale);a.add(t.getTime())}));const l=i.getTime()>n.getTime(),c=At.fromTimestamp((l?i:n).getTime());let h=At.fromTimestamp((l?n:i).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)r.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},Lu={description:uo("Current date and time as a date value."),args:[],returns:["DATE"],compute:function(){const e=At.now(),t=e.getTime()-Ot.getTime(),o=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return{value:Math.floor(t/_t)+o,format:Er(this.locale)}},isExported:!0},ku={description:uo("Minute component of a specific time."),args:[$l("time (date)",uo("The time from which to calculate the second component."))],returns:["NUMBER"],compute:function(e){return ns(e,this.locale).getSeconds()},isExported:!0},Vu={description:uo("Converts hour/minute/second into a time."),args:[$l("hour (number)",uo("The hour component of the time.")),$l("minute (number)",uo("The minute component of the time.")),$l("second (number)",uo("The second component of the time."))],returns:["DATE"],compute:function(e,t,o){let s=Math.trunc(Zo(e,this.locale)),i=Math.trunc(Zo(t,this.locale)),n=Math.trunc(Zo(o,this.locale));return i+=Math.floor(n/60),n=n%60+(n<0?60:0),s+=Math.floor(i/60),i=i%60+(i<0?60:0),s%=24,$o((()=>s>=0),uo("The function [[FUNCTION_NAME]] result cannot be negative")),{value:s/24+i/1440+n/86400,format:this.locale.timeFormat}},isExported:!0},Uu={description:uo("Converts a time string into its serial number representation."),args:[$l("time_string (string)",uo("The string that holds the time representation."))],returns:["NUMBER"],compute:function(e){const t=ts(e),o=$t(t,this.locale);$o((()=>null!==o),uo("The time_string (%s) cannot be parsed to date/time.",t));const s=o.value-Math.trunc(o.value);return s<0?1+s:s},isExported:!0},Bu={description:uo("Current date as a date value."),args:[],returns:["DATE"],compute:function(){const e=At.now();return{value:Wt(new At(e.getFullYear(),e.getMonth(),e.getDate())),format:this.locale.dateFormat}},isExported:!0},Hu={description:uo("Day of the week of the date provided (as number)."),args:[$l("date (date)",uo("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.")),$l("type (number, default=1)",uo("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1."))],returns:["NUMBER"],compute:function(e,t={value:1}){const o=ns(e,this.locale),s=Math.round(Zo(t,this.locale)),i=o.getDay();return $o((()=>[1,2,3].includes(s)),uo("The type (%s) must be 1, 2 or 3.",s.toString())),1===s?i+1:2===s?0===i?7:i:0===i?6:i-1},isExported:!0},zu={description:uo("Week number of the year."),args:[$l("date (date)",uo("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.")),$l("type (number, default=1)",uo("A number representing the day that a week starts on. Sunday = 1."))],returns:["NUMBER"],compute:function(e,t={value:1}){const o=ns(e,this.locale),s=Math.round(Zo(t,this.locale));if($o((()=>1===s||2===s||11<=s&&s<=17||21===s),uo("The type (%s) is out of range.",s.toString())),21===s)return _u.compute.bind(this)(e);let i;i=1===s||2===s?s-1:s-10==7?0:s-10;const n=o.getFullYear();let r=1,a=new At(n,0,r);for(;a.getDay()!==i;)r+=1,a=new At(n,0,r);const l=(o.getTime()-a.getTime())/_t;return l<0?1:Math.floor(l/7)+(1===r?1:2)},isExported:!0},$u={description:uo("Date after a number of workdays."),args:[$l("start_date (date)",uo("The date from which to begin counting.")),$l("num_days (number)",uo("The number of working days to advance from start_date. If negative, counts backwards.")),$l("holidays (date, range<date>, optional)",uo("A range or array constant containing the dates to consider holidays."))],returns:["NUMBER"],compute:function(e,t,o={value:null}){return Gu.compute.bind(this)(e,t,{value:1},o)},isExported:!0},Gu={description:uo("Date after a number of workdays (specifying weekends)."),args:[$l("start_date (date)",uo("The date from which to begin counting.")),$l("num_days (number)",uo("The number of working days to advance from start_date. If negative, counts backwards.")),$l("weekend (any, default=1)",uo("A number or string representing which days of the week are considered weekends.")),$l("holidays (date, range<date>, optional)",uo("A range or array constant containing the dates to consider holidays."))],returns:["DATE"],compute:function(e,t,o={value:1},s){let i=ns(e,this.locale),n=Math.trunc(Zo(t,this.locale));"string"==typeof o.value&&$o((()=>"1111111"!==o.value),uo("The weekend must be different from '1111111'."));const r=Nu(o);let a=new Set;void 0!==s&&ls([s],(e=>{const t=ns(e,this.locale);a.add(t.getTime())}));let l=At.fromTimestamp(i.getTime()),c=l.getTime();const h=Math.sign(n);let d=Math.abs(n);for(;d>0;)l.setDate(l.getDate()+h),c=l.getTime(),r.includes(l.getDay())||a.has(c)||(d-=1);const u=c-Ot.getTime();return{value:Math.round(u/_t),format:this.locale.dateFormat}},isExported:!0},Wu={description:uo("Year specified by a given date."),args:[$l("date (date)",uo("The date from which to extract the year."))],returns:["NUMBER"],compute:function(e){return ns(e,this.locale).getFullYear()},isExported:!0},qu={description:uo("Exact number of years between two dates."),args:[$l("start_date (date)",uo("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.")),$l("end_date (date)",uo("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.")),$l("day_count_convention (number, default=0)",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o={value:0}){let s=Math.trunc(Zo(e,this.locale)),i=Math.trunc(Zo(t,this.locale));const n=Math.trunc(Zo(o,this.locale));return $o((()=>s>=0),uo("The start_date (%s) must be positive or null.",s.toString())),$o((()=>i>=0),uo("The end_date (%s) must be positive or null.",i.toString())),$o((()=>0<=n&&n<=4),uo("The day_count_convention (%s) must be between 0 and 4 inclusive.",n.toString())),Kt(s,i,n)}},Zu={description:uo("First day of the month preceding a date."),args:[$l("date (date)",uo("The date from which to calculate the result."))],returns:["DATE"],compute:function(e){const t=ns(e,this.locale),o=t.getFullYear(),s=t.getMonth();return{value:Wt(new At(o,s,1)),format:this.locale.dateFormat}}},Yu={description:uo("Last day of the month following a date."),args:[$l("date (date)",uo("The date from which to calculate the result."))],returns:["DATE"],compute:function(e){return Au.compute.bind(this)(e,{value:0})}},ju={description:uo("Quarter of the year a specific date falls in"),args:[$l("date (date)",uo("The date from which to extract the quarter."))],returns:["NUMBER"],compute:function(e){return Math.ceil((ns(e,this.locale).getMonth()+1)/3)}},Xu={description:uo("First day of the quarter of the year a specific date falls in."),args:[$l("date (date)",uo("The date from which to calculate the start of quarter."))],returns:["DATE"],compute:function(e){const t=ju.compute.bind(this)(e),o=Wu.compute.bind(this)(e);return{value:Wt(new At(o,3*(t-1),1)),format:this.locale.dateFormat}}},Ku={description:uo("Last day of the quarter of the year a specific date falls in."),args:[$l("date (date)",uo("The date from which to calculate the end of quarter."))],returns:["DATE"],compute:function(e){const t=ju.compute.bind(this)(e),o=Wu.compute.bind(this)(e);return{value:Wt(new At(o,3*t,0)),format:this.locale.dateFormat}}},Qu={description:uo("First day of the year a specific date falls in."),args:[$l("date (date)",uo("The date from which to calculate the start of the year."))],returns:["DATE"],compute:function(e){const t=Wu.compute.bind(this)(e);return{value:Wt(new At(t,0,1)),format:this.locale.dateFormat}}},Ju={description:uo("Last day of the year a specific date falls in."),args:[$l("date (date)",uo("The date from which to calculate the end of the year."))],returns:["DATE"],compute:function(e){const t=Wu.compute.bind(this)(e);return{value:Wt(new At(t+1,0,0)),format:this.locale.dateFormat}}};var eg=Object.freeze({__proto__:null,DATE:yu,DATEDIF:Eu,DATEVALUE:xu,DAY:wu,DAYS:Iu,DAYS360:Ru,EDATE:Tu,EOMONTH:Au,HOUR:Ou,ISOWEEKNUM:_u,MINUTE:Du,MONTH:Mu,MONTH_END:Yu,MONTH_START:Zu,NETWORKDAYS:Fu,NETWORKDAYS_INTL:Pu,NOW:Lu,QUARTER:ju,QUARTER_END:Ku,QUARTER_START:Xu,SECOND:ku,TIME:Vu,TIMEVALUE:Uu,TODAY:Bu,WEEKDAY:Hu,WEEKNUM:zu,WORKDAY:$u,WORKDAY_INTL:Gu,YEAR:Wu,YEARFRAC:qu,YEAR_END:Ju,YEAR_START:Qu});const tg={description:uo("Compare two numeric values, returning 1 if they're equal."),args:[$l("number1 (number)",uo("The first number to compare.")),$l("number2 (number, default=0)",uo("The second number to compare."))],returns:["NUMBER"],compute:function(e,t={value:0}){return Zo(e,this.locale)===Zo(t,this.locale)?1:0},isExported:!0};var og=Object.freeze({__proto__:null,DELTA:tg});const sg=[po.number,po.error,po.text,po.boolean];function ig(e){const t="ascending"===e?1:-1;return(e,o)=>{if(e.type===po.empty)return o.type===po.empty?0:1;if(o.type===po.empty)return-1;let s=sg.indexOf(e.type)-sg.indexOf(o.type);return 0===s&&(s=e.type===po.text||e.type===po.error?e.value.localeCompare(o.value):e.value-o.value),t*s}}function ng(e,t,o,s,i){let n=xo.Success,r=s.right>s.left;if(e.model.getters.doesIntersectMerge(t,s)){let o;r=!1;for(let i=s.top;i<=s.bottom;i++){o=[];for(let n=s.left;n<=s.right;n++){let s=e.model.getters.getMerge({sheetId:t,col:n,row:i});s&&!o.includes(s.id.toString())&&o.push(s.id.toString())}if(o.length>=2){r=!0;break}}}const{col:a,row:l}=o;if(r)n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:a,row:l,zone:s,sortDirection:i});else{const o=e.model.getters.getContiguousZone(t,s);qi(o,s)?n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:a,row:l,zone:s,sortDirection:i}):e.askConfirmation(uo("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>{s=o,n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:a,row:l,zone:s,sortDirection:i})}),(()=>{n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:a,row:l,zone:s,sortDirection:i})}))}if(n.isCancelledBecause("InvalidSortZone")){const{col:t,row:i}=o;e.model.selection.selectZone({cell:{col:t,row:i},zone:s}),e.raiseError(uo("Cannot sort. To sort, select only cells or only merges that have the same size."))}}function rg(e,t,...o){for(const[e,t]of o.entries())$o((()=>void 0!==t),uo("Value for parameter %d is missing, while the function [[FUNCTION_NAME]] expect a number or a range.",e+1));const s=[],i=[],n=e.length;for(let r=0;r<o.length;r+=2){s.push(is(Jl(o[r+1])?.value)?"ascending":"descending");const a=o[r];if(_o(a)&&(a.length>1||a[0].length>1))$o((()=>1===a.length&&a[0].length===n),uo("Wrong size for %s. Expected a range of size 1x%s. Got %sx%s.",`sort_column${r+1}`,n,a.length,a[0].length)),i.push(a.flat().map((e=>e.value)));else{const o=Zo(Jl(a)?.value,t);if(o<1||o>e[0].length)return e;i.push(e.map((e=>e[o-1].value)))}}if(0===i.length)for(let t=0;t<e[0].length;t++)i.push(e.map((e=>e[t].value))),s.push("ascending");const r={descending:ig("descending"),ascending:ig("ascending")},a=ve(0,e.length);return a.sort(((e,t)=>{for(const[o,n]of i.entries()){const i=n[e],a=n[t],l={value:i,type:null===i?po.empty:"string"==typeof i?po.text:typeof i},c={value:a,type:null===a?po.empty:"string"==typeof a?po.text:typeof a},h=r[s[o]](l,c);if(0!==h)return h}return 0})),a.map((t=>e[t]))}const ag={description:uo("Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions."),args:[$l("range (any, range<any>)",uo("The data to be filtered.")),$l("condition1 (boolean, range<boolean>)",uo("A column or row containing true or false values corresponding to the first column or row of range.")),$l("condition2 (boolean, range<boolean>, repeating)",uo("Additional column or row containing true or false values."))],returns:["RANGE<ANY>"],compute:function(e,...t){let o=Rs(e);const s=t.map((e=>ms(Rs(e),(e=>e.value))));s.map((e=>Wl(uo("The arguments condition must be a single column or row."),e))),ql(uo("The arguments conditions must have the same dimensions."),...t);const i=s.map((e=>e.flat())),n=1===s[0].length?"row":"col";o="row"===n?fs(o):o,$o((()=>i.every((e=>e.length===o.length))),uo("FILTER has mismatched sizes on the range and conditions."));const r=[];for(let e=0;e<o.length;e++){const t=o[e];i.every((t=>t[e]))&&r.push(t)}if(!r.length)throw new Uo(uo("No match found in FILTER evaluation"));return"row"===n?fs(r):r},isExported:!0},lg={description:uo("Sorts the rows of a given array or range by the values in one or more columns."),args:[$l("range (range)",uo("The data to be sorted.")),$l("sort_column (any, range<number>, repeating)",uo("The index of the column in range or a range outside of range containing the values by which to sort.")),$l("is_ascending (boolean, repeating)",uo("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order."))],returns:["RANGE"],compute:function(e,...t){const o=fs(e);return fs(rg(o,this.locale,...t))},isExported:!0},cg={description:uo("Returns the first n items in a data set after performing a sort."),args:[$l("range (range)",uo("The data to be sorted.")),$l("n (number, default=1)",uo("The number of items to return.")),$l("display_ties_mode (number, default=0)",uo("A number representing the way to display ties.")),$l("sort_column (number, range<number>, repeating)",uo("The index of the column in range or a range outside of range containing the values by which to sort.")),$l("is_ascending (boolean, repeating)",uo("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order."))],returns:["RANGE"],compute:function(e,t,o,...s){const i=Zo(t?.value??1,this.locale);$o((()=>i>=0),uo("Wrong value of 'n'. Expected a positive number. Got %s.",i));const n=Zo(o?.value??0,this.locale);$o((()=>n>=0&&n<=3),uo("Wrong value of 'display_ties_mode'. Expected a positive number between 0 and 3. Got %s.",n));const r=rg(fs(e),this.locale,...s),a=(e,t)=>JSON.stringify(r[e].map((e=>e.value)))===JSON.stringify(r[t].map((e=>e.value)));switch(n){case 0:return fs(r.slice(0,i));case 1:for(let e=i;e<r.length;e++)if(!a(e,i-1))return fs(r.slice(0,e));return fs(r);case 2:{const e=[r[0]];for(let t=1;t<r.length;t++)for(let o=0;o<t&&!a(t,o);o++)o===t-1&&e.push(r[t]);return fs(e.slice(0,i))}case 3:{const e=[r[0]];let t=1;for(let o=1;o<r.length&&(a(o,o-1)||t++,!(t>i));o++)e.push(r[o]);return fs(e)}}},isExported:!0},hg={description:uo("Unique rows in the provided source range."),args:[$l("range (any, range<any>)",uo("The data to filter by unique entries.")),$l("by_column (boolean, default=FALSE)",uo("Whether to filter the data by columns or by rows.")),$l("exactly_once (boolean, default=FALSE)",uo("Whether to return only entries with no duplicates."))],returns:["RANGE<NUMBER>"],compute:function(e={value:""},t,o){if(!_o(e))return[[e]];const s=is(t?.value)||!1,i=is(o?.value)||!1;s||(e=fs(e));const n=new Map;for(const t of e){const e=JSON.stringify(t.map((e=>e.value))),o=n.get(e);o?o.count++:n.set(e,{data:t,count:1})}const r=[];for(const e of n.values())i&&e.count>1||r.push(e.data);if(!r.length)throw new Lo(uo("No unique values found"));return s?r:fs(r)},isExported:!0};var dg=Object.freeze({__proto__:null,FILTER:ag,SORT:lg,SORTN:cg,UNIQUE:hg});function ug(e,t){$o((()=>e<t),uo("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function gg(e,t){$o((()=>t<e),uo("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function pg(e){$o((()=>[1,2,4].includes(e)),uo("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function mg(e){$o((()=>0<=e&&e<=4),uo("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function fg(e){$o((()=>e>0),uo("The redemption (%s) must be strictly positive.",e.toString()))}function bg(e){$o((()=>e>0),uo("The price (%s) must be strictly positive.",e.toString()))}function vg(e){$o((()=>e>0),uo("The number_of_periods (%s) must be greater than 0.",e.toString()))}function Sg(e){$o((()=>e>0),uo("The rate (%s) must be strictly positive.",e.toString()))}function Cg(e){$o((()=>e>0),uo("The life (%s) must be strictly positive.",e.toString()))}function yg(e){$o((()=>e>=0),uo("The cost (%s) must be positive or null.",e.toString()))}function Eg(e){$o((()=>e>0),uo("The period (%s) must be strictly positive.",e.toString()))}function xg(e){$o((()=>e>=0),uo("The salvage (%s) must be positive or null.",e.toString()))}function wg(e){$o((()=>e>0),uo("The present value (%s) must be strictly positive.",e.toString()))}function Ig(e,t){$o((()=>e<=t),uo("The period (%s) must be less than or equal life (%s).",e.toString(),t.toString()))}function Rg(e){$o((()=>e>0),uo("The investment (%s) must be strictly positive.",e.toString()))}function Tg(e){$o((()=>e>0),uo("The discount (%s) must be strictly positive.",e.toString()))}function Ag(e){$o((()=>e<1),uo("The discount (%s) must be smaller than 1.",e.toString()))}function Og(e){$o((()=>e>0),uo("The depreciation factor (%s) must be strictly positive.",e.toString()))}function _g(e,t,o){const s=ns(e,o),i=ns(t,o),n=ns(e,o);n.setFullYear(s.getFullYear()+1),$o((()=>i.getTime()<=n.getTime()),uo("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function Dg(e,t,o){vg(o),$o((()=>e>0),uo("The first_period (%s) must be strictly positive.",e.toString())),$o((()=>t>0),uo("The last_period (%s) must be strictly positive.",t.toString())),$o((()=>e<=t),uo("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),$o((()=>t<=o),uo("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),o.toString()))}function Mg(e){$o((()=>e>-1),uo("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function Fg(e,t){$o((()=>e.length===t.length&&e[0].length===t[0].length),uo("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function Ng(e){$o((()=>e.every((t=>t>=e[0]))),uo("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const Pg=[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("frequency (number)",uo("The number of interest or coupon payments per year (1, 2, or 4).")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))];function Lg(e,t,o,s,i=1e-10,n){let r,a,l,c,h=o,d=!1,u=0;do{l=e(h),isNaN(l)?($o((()=>u<s&&void 0!==n),uo("Function [[FUNCTION_NAME]] didn't find any result.")),u++,h=n(c),c=h):(r=h-l/t(h),a=Math.abs(r-h),h=r,d=a<i||Math.abs(l)<i,$o((()=>u<s),uo("Function [[FUNCTION_NAME]] didn't find any result.")),u++)}while(!d);return h}const kg={description:uo("Accrued interest of security paying at maturity."),args:[$l("issue (date)",uo("The date the security was initially issued.")),$l("maturity (date)",uo("The maturity date of the security.")),$l("rate (number)",uo("The annualized rate of interest.")),$l("redemption (number)",uo("The redemption amount per 100 face value, or par.")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:0}){const n=Math.trunc(Zo(e,this.locale)),r=Math.trunc(Zo(t,this.locale)),a=Zo(s,this.locale),l=Zo(o,this.locale),c=Math.trunc(Zo(i,this.locale));!function(e){$o((()=>e>=0),uo("The issue (%s) must be positive or null.",e.toString()))}(n),gg(r,n),mg(c),fg(a),Sg(l);return a*l*Kt(n,r,c)},isExported:!0},Vg={description:uo("Depreciation for an accounting period."),args:[$l("cost (number)",uo("The initial cost of the asset.")),$l("purchase_date (date)",uo("The date the asset was purchased.")),$l("first_period_end (date)",uo("The date the first period ended.")),$l("salvage (number)",uo("The value of the asset at the end of depreciation.")),$l("period (number)",uo("The single period within life for which to calculate depreciation.")),$l("rate (number)",uo("The deprecation rate.")),$l("day_count_convention (number, optional)",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=Zo(e,this.locale),l=Math.trunc(Zo(t,this.locale)),c=Math.trunc(Zo(o,this.locale)),h=Zo(s,this.locale),d=Zo(i,this.locale),u=Zo(n,this.locale),g=Math.trunc(Zo(r,this.locale));!function(e){$o((()=>e>0),uo("The cost (%s) must be strictly positive.",e.toString()))}(a),function(e){$o((()=>e>=0),uo("The purchase_date (%s) must be positive or null.",e.toString()))}(l),xg(h),function(e,t){$o((()=>e<=t),uo("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(h,a),function(e){$o((()=>e>=0),uo("The period (%s) must be positive or null.",e.toString()))}(d),Sg(u),mg(g),$o((()=>l<=c),uo("The purchase_date (%s) must be before the first_period_end (%s).",l.toString(),c.toString()));const p=d<1&&d>0?1:Math.trunc(d),m=a*u,f=Kt(l,c,g),b=l===c?m:m*f,v=a-b-m*p;return v>=h?0===p?b:m:h-v<m?m-(h-v):0},isExported:!0},Ug={description:uo("Days in coupon period containing settlement date."),args:Pg,returns:["NUMBER"],compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Zo(e,this.locale)),n=Math.trunc(Zo(t,this.locale)),r=Math.trunc(Zo(o,this.locale)),a=Math.trunc(Zo(s,this.locale));if(ug(i,n),pg(r),mg(a),1===a){const i=Gg.compute.bind(this)(e,t,o,s).value;return zg.compute.bind(this)(e,t,o,s).value-i}return(3===a?365:360)/r},isExported:!0},Bg={description:uo("Days from settlement until next coupon."),args:Pg,returns:["NUMBER"],compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Zo(e,this.locale)),n=Math.trunc(Zo(t,this.locale)),r=Math.trunc(Zo(o,this.locale)),a=Math.trunc(Zo(s,this.locale));ug(i,n),pg(r),mg(a);const l=Gg.compute.bind(this)(e,t,o,s).value;if([1,2,3].includes(a))return i-l;if(4===a){const e=Kt(l,i,a);return Math.round(360*e)}const c=ns(i,this.locale),h=ns(l,this.locale),d=h.getFullYear(),u=c.getFullYear(),g=h.getMonth()+1,p=c.getMonth()+1;let m=h.getDate(),f=c.getDate();return 2===g&&2===p&&Yt(h)&&Yt(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&Yt(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Hg={description:uo("Days from settlement until next coupon."),args:Pg,returns:["NUMBER"],compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Zo(e,this.locale)),n=Math.trunc(Zo(t,this.locale)),r=Math.trunc(Zo(o,this.locale)),a=Math.trunc(Zo(s,this.locale));ug(i,n),pg(r),mg(a);const l=zg.compute.bind(this)(e,t,o,s).value;if([1,2,3].includes(a))return l-i;if(4===a){const e=Kt(i,l,a);return Math.round(360*e)}const c=Bg.compute.bind(this)(e,t,o,s);return Ug.compute.bind(this)(e,t,o,s)-c},isExported:!0},zg={description:uo("Next coupon date after the settlement date."),args:Pg,returns:["NUMBER"],compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Zo(e,this.locale)),n=Math.trunc(Zo(t,this.locale)),r=Math.trunc(Zo(o,this.locale)),a=Math.trunc(Zo(s,this.locale));ug(i,n),pg(r),mg(a);const l=12/r,c=$g.compute.bind(this)(e,t,o,s);return{value:Wt(jt(ns(n,this.locale),-(c-1)*l,!0)),format:this.locale.dateFormat}},isExported:!0},$g={description:uo("Number of coupons between settlement and maturity."),args:Pg,returns:["NUMBER"],compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Zo(e,this.locale)),n=Math.trunc(Zo(t,this.locale)),r=Math.trunc(Zo(o,this.locale)),a=Math.trunc(Zo(s,this.locale));ug(i,n),pg(r),mg(a);let l=1,c=n;const h=12/r;for(;c>i;)c=Wt(jt(ns(c,this.locale),-h,!1)),l++;return l-1},isExported:!0},Gg={description:uo("Last coupon date prior to or on the settlement date."),args:Pg,returns:["NUMBER"],compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(Zo(e,this.locale)),n=Math.trunc(Zo(t,this.locale)),r=Math.trunc(Zo(o,this.locale)),a=Math.trunc(Zo(s,this.locale));ug(i,n),pg(r),mg(a);const l=12/r,c=$g.compute.bind(this)(e,t,o,s);return{value:Wt(jt(ns(n,this.locale),-c*l,!0)),format:this.locale.dateFormat}},isExported:!0},Wg={description:uo("Cumulative interest paid over a set of periods."),args:[$l("rate (number)",uo("The interest rate.")),$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("present_value (number)",uo("The current value of the annuity.")),$l("first_period (number)",uo("The number of the payment period to begin the cumulative calculation.")),$l("last_period (number)",uo("The number of the payment period to end the cumulative calculation.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n={value:0}){const r=Zo(s,this.locale),a=Zo(i,this.locale),l=Zo(e,this.locale),c=Zo(o,this.locale),h=Zo(t,this.locale),d=is(n)?1:0;Dg(r,a,h),Sg(l),wg(c);let u=0;for(let e=r;e<=a;e++)u+=np(l,e,h,c,0,d);return u},isExported:!0},qg={description:uo("Cumulative principal paid over a set of periods."),args:[$l("rate (number)",uo("The interest rate.")),$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("present_value (number)",uo("The current value of the annuity.")),$l("first_period (number)",uo("The number of the payment period to begin the cumulative calculation.")),$l("last_period (number)",uo("The number of the payment period to end the cumulative calculation.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n={value:0}){const r=Zo(s,this.locale),a=Zo(i,this.locale),l=Zo(e,this.locale),c=Zo(o,this.locale),h=Zo(t,this.locale),d=is(n)?1:0;Dg(r,a,h),Sg(l),wg(c);let u=0;for(let e=r;e<=a;e++)u+=vp(l,e,h,c,0,d);return u},isExported:!0},Zg={description:uo("Depreciation via declining balance method."),args:[$l("cost (number)",uo("The initial cost of the asset.")),$l("salvage (number)",uo("The value of the asset at the end of depreciation.")),$l("life (number)",uo("The number of periods over which the asset is depreciated.")),$l("period (number)",uo("The single period within life for which to calculate depreciation.")),$l("month (number, optional)",uo("The number of months in the first year of depreciation."))],returns:["NUMBER"],compute:function(e,t,o,s,...i){const n=Zo(e,this.locale),r=Zo(t,this.locale),a=Zo(o,this.locale),l=Math.trunc(Zo(s,this.locale)),c=i.length?Math.trunc(Zo(i[0],this.locale)):12,h=a+(12===c?0:1);yg(n),xg(r),Eg(l),Cg(a),$o((()=>1<=c&&c<=12),uo("The month (%s) must be between 1 and 12 inclusive.",c.toString())),$o((()=>l<=h),uo("The period (%s) must be less than or equal to %s.",l.toString(),h.toString()));const d=c/12;let u=1-Math.pow(r/n,1/a);u=Math.round(1e3*u)/1e3;let g=n,p=n*(1-u*d);for(let e=1;e<l;e++)g=p,p=g*(1-u),e===a&&(p=g*(1-u*(1-d)));return{value:g-p,format:"#,##0.00"}},isExported:!0};function Yg(e,t,o,s,i){if(yg(e),xg(t),Eg(s),Cg(o),Ig(s,o),Og(i),0===e||t>=e)return 0;const n=i/o;if(n>1)return 1===s?e-t:0;if(s<=1)return e*n;const r=e*Math.pow(1-n,s-1),a=e*Math.pow(1-n,s),l=a<t?r-t:r-a;return Math.max(l,0)}const jg={description:uo("Depreciation via double-declining balance method."),args:[$l("cost (number)",uo("The initial cost of the asset.")),$l("salvage (number)",uo("The value of the asset at the end of depreciation.")),$l("life (number)",uo("The number of periods over which the asset is depreciated.")),$l("period (number)",uo("The single period within life for which to calculate depreciation.")),$l("factor (number, default=2)",uo("The factor by which depreciation decreases."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:2}){return{value:Yg(Zo(e,this.locale),Zo(t,this.locale),Zo(o,this.locale),Zo(s,this.locale),Zo(i,this.locale)),format:"#,##0.00"}},isExported:!0},Xg={description:uo("Discount rate of a security based on price."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("price (number)",uo("The price at which the security is bought per 100 face value.")),$l("redemption (number)",uo("The redemption amount per 100 face value, or par.")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(Zo(e,this.locale)),r=Math.trunc(Zo(t,this.locale)),a=Zo(o,this.locale),l=Zo(s,this.locale),c=Math.trunc(Zo(i,this.locale));ug(n,r),mg(c),bg(a),fg(l);return(l-a)/l/Kt(n,r,c)},isExported:!0},Kg={description:uo("Convert a decimal fraction to decimal value."),args:[$l("fractional_price (number)",uo("The price quotation given using fractional decimal conventions.")),$l("unit (number)",uo("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const o=Zo(e,this.locale),s=Math.trunc(Zo(t,this.locale));$o((()=>s>0),uo("The unit (%s) must be strictly positive.",s.toString()));const i=Math.trunc(o);return i+(o-i)*(10**Math.ceil(Math.log10(s))/s)},isExported:!0},Qg={description:uo("Convert a decimal value to decimal fraction."),args:[$l("decimal_price (number)",uo("The price quotation given as a decimal value.")),$l("unit (number)",uo("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const o=Zo(e,this.locale),s=Math.trunc(Zo(t,this.locale));$o((()=>s>0),uo("The unit (%s) must be strictly positive.",s.toString()));const i=Math.trunc(o);return i+(o-i)*(s/10**Math.ceil(Math.log10(s)))},isExported:!0},Jg={description:uo("Number of periods for an investment to reach a value."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("rate (number)",uo("The annualized rate of interest.")),$l("yield (number)",uo("The expected annual yield of the security.")),$l("frequency (number)",uo("The number of interest or coupon payments per year (1, 2, or 4).")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n={value:0}){const r=Math.trunc(Zo(e,this.locale)),a=Math.trunc(Zo(t,this.locale)),l=Zo(o,this.locale),c=Zo(s,this.locale),h=Math.trunc(Zo(i,this.locale)),d=Math.trunc(Zo(n,this.locale));ug(r,a),pg(h),mg(d),$o((()=>l>=0),uo("The rate (%s) must be positive or null.",l.toString())),$o((()=>c>=0),uo("The yield (%s) must be positive or null.",c.toString()));const u=Kt(r,a,d),g=u-Math.trunc(u)||1/h,p=Math.ceil(u*h),m=l/h,f=c/h;let b=0,v=0;for(let e=1;e<=p;e++){const t=(m+(e===p?1:0))/(1+f)**e;v+=(g+(e-1)/h)*t,b+=t}return 0===b?0:v/b},isExported:!0},ep={description:uo("Annual effective interest rate."),args:[$l("nominal_rate (number)",uo("The nominal interest rate per year.")),$l("periods_per_year (number)",uo("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const o=Zo(e,this.locale),s=Math.trunc(Zo(t,this.locale));return $o((()=>o>0),uo("The nominal rate (%s) must be strictly greater than 0.",o.toString())),$o((()=>s>0),uo("The number of periods by year (%s) must strictly greater than 0.",s.toString())),Math.pow(1+o/s,s)-1},isExported:!0};function tp(e,t,o,s,i){return 0===e?-(s+o*t):-s*(1+e)**t-o*(1+e*i)*((1+e)**t-1)/e}const op={description:uo("Future value of an annuity investment."),args:[$l("rate (number)",uo("The interest rate.")),$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("payment_amount (number)",uo("The amount per period to be paid.")),$l("present_value (number, default=0)",uo("The current value of the annuity.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;return{value:tp(Zo(e,this.locale),Zo(t,this.locale),Zo(o,this.locale),Zo(s,this.locale),is(i)?1:0),format:"#,##0.00"}},isExported:!0},sp={description:uo("Future value of principal from series of rates."),args:[$l("principal (number)",uo("The amount of initial capital or value to compound against.")),$l("rate_schedule (number, range<number>)",uo("A series of interest rates to compound against the principal."))],returns:["NUMBER"],compute:function(e,t){return ds([t],((e,t)=>e*(1+Zo(t,this.locale))),Zo(e,this.locale))},isExported:!0},ip={description:uo("Calculates effective interest rate."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("investment (number)",uo("The amount invested in the security.")),$l("redemption (number)",uo("The amount to be received at maturity.")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:0}){const n=Math.trunc(Zo(e,this.locale)),r=Math.trunc(Zo(t,this.locale)),a=Zo(s,this.locale),l=Zo(o,this.locale),c=Math.trunc(Zo(i,this.locale));ug(n,r),Rg(l),fg(a),mg(c);return(a-l)/l/Kt(n,r,c)},isExported:!0};function np(e,t,o,s,i,n){return fp(e,o,s,i,n)-vp(e,t,o,s,i,n)}const rp={description:uo("Payment on the principal of an investment."),args:[$l("rate (number)",uo("The annualized rate of interest.")),$l("period (number)",uo("The amortization period, in terms of number of periods.")),$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("present_value (number)",uo("The current value of the annuity.")),$l("future_value (number, default=0)",uo("The future value remaining after the final payment has been made.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:0},n={value:0}){return{value:np(Zo(e,this.locale),Zo(t,this.locale),Zo(o,this.locale),Zo(s,this.locale),Zo(i,this.locale),is(n)?1:0),format:"#,##0.00"}},isExported:!0},ap={description:uo("Internal rate of return given periodic cashflows."),args:[$l("cashflow_amounts (number, range<number>)",uo("An array or range containing the income or payments associated with the investment.")),$l("rate_guess (number, default=0.1)",uo("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],compute:function(e,t={value:.1}){const o=Zo(t,this.locale);Mg(o);let s=!1,i=!1,n=[];cs([e],(e=>{e>0&&(s=!0),e<0&&(i=!0),n.push(e)}),this.locale),$o((()=>s&&i),uo("The cashflow_amounts must include negative and positive values."));const r=n.shift();return{value:Lg((function(e){return function(e,t,o){const s=o.length;let i=0;return o.reduce(((t,o)=>(i++,t+o*e**(s-i))),t*e**s)}(e,r,n)}),(function(e){return function(e,t,o){const s=o.length;let i=0;return o.reduce(((t,o)=>(i++,t+o*(s-i)*e**(s-i-1))),t*s*e**(s-1))}(e,r,n)}),o+1,20,1e-5)-1,format:"0%"}},isExported:!0},lp={description:uo("Returns the interest paid at a particular period of an investment."),args:[$l("rate (number)",uo("The interest rate.")),$l("period (number)",uo("The period for which you want to view the interest payment.")),$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("present_value (number)",uo("The current value of the annuity."))],returns:["NUMBER"],compute:function(e,t,o,s){const i=Zo(e,this.locale),n=Zo(t,this.locale),r=Zo(o,this.locale),a=Zo(s,this.locale);$o((()=>0!==r),uo("The number of periods must be different than 0.",r.toString()));return-1*(a-a*(n/r))*i},isExported:!0},cp={description:uo("Modified Macaulay duration."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("rate (number)",uo("The annualized rate of interest.")),$l("yield (number)",uo("The expected annual yield of the security.")),$l("frequency (number)",uo("The number of interest or coupon payments per year (1, 2, or 4).")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n={value:0}){return Jg.compute.bind(this)(e,t,o,s,i,n)/(1+Zo(s,this.locale)/Math.trunc(Zo(i,this.locale)))},isExported:!0},hp={description:uo("Modified internal rate of return."),args:[$l("cashflow_amounts (range<number>)",uo("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")),$l("financing_rate (number)",uo("The interest rate paid on funds invested.")),$l("reinvestment_return_rate (number)",uo("The return (as a percentage) earned on reinvestment of income received from the investment."))],returns:["NUMBER"],compute:function(e,t,o){const s=Zo(t,this.locale),i=Zo(o,this.locale),n=fs(e).flat().filter((e=>null!==e.value)).map((e=>Zo(e,this.locale))),r=n.length;let a=0,l=0;for(const e of ve(0,r)){const t=n[e];t>=0?a+=t*(i+1)**(r-e-1):l+=t/(s+1)**e}$o((()=>0!==l&&0!==a),uo("There must be both positive and negative values in cashflow_amounts."));return(-a/l)**(1/(r-1))-1},isExported:!0},dp={description:uo("Annual nominal interest rate."),args:[$l("effective_rate (number)",uo("The effective interest rate per year.")),$l("periods_per_year (number)",uo("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const o=Zo(e,this.locale),s=Math.trunc(Zo(t,this.locale));return $o((()=>o>0),uo("The effective rate (%s) must must strictly greater than 0.",o.toString())),$o((()=>s>0),uo("The number of periods by year (%s) must strictly greater than 0.",s.toString())),(Math.pow(o+1,1/s)-1)*s},isExported:!0},up={description:uo("Number of payment periods for an investment."),args:[$l("rate (number)",uo("The interest rate.")),$l("payment_amount (number)",uo("The amount of each payment made.")),$l("present_value (number)",uo("The current value of the annuity.")),$l("future_value (number, default=0)",uo("The future value remaining after the final payment has been made.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;const n=Zo(e,this.locale),r=Zo(t,this.locale),a=Zo(o,this.locale),l=Zo(s,this.locale),c=is(i)?1:0;if(0===n)return-(l+a)/r;const h=r*(1+n*c)/n;return Math.log((h-l)/(a+h))/Math.log(1+n)},isExported:!0};function gp(e,t,o,s){let i=0;return us(o,((t,o)=>(i++,t+o/(1+e)**i)),t,s)}const pp={description:uo("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:[$l("discount (number)",uo("The discount rate of the investment over one period.")),$l("cashflow1 (number, range<number>)",uo("The first future cash flow.")),$l("cashflow2 (number, range<number>, repeating)",uo("Additional future cash flows."))],returns:["NUMBER"],compute:function(e,...t){const o=Zo(e,this.locale);return $o((()=>-1!==o),uo("The discount (%s) must be different from -1.",o.toString())),{value:gp(o,0,t,this.locale),format:"#,##0.00"}},isExported:!0},mp={description:uo("Computes the number of periods needed for an investment to reach a value."),args:[$l("rate (number)",uo("The rate at which the investment grows each period.")),$l("present_value (number)",uo("The investment's current value.")),$l("future_value (number)",uo("The investment's desired future value."))],returns:["NUMBER"],compute:function(e,t,o){const s=Zo(e,this.locale),i=Zo(t,this.locale),n=Zo(o,this.locale);return Sg(s),$o((()=>i>0),uo("The present_value (%s) must be strictly positive.",i.toString())),$o((()=>n>0),uo("The future_value (%s) must be strictly positive.",n.toString())),(Math.log(n)-Math.log(i))/Math.log(1+s)},isExported:!0};function fp(e,t,o,s,i){if(vg(t),0===e)return-(s+o)/t;let n=-(o*(1+e)**t+s);return n=n*e/((1+e*i)*((1+e)**t-1)),n}const bp={description:uo("Periodic payment for an annuity investment."),args:[$l("rate (number)",uo("The annualized rate of interest.")),$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("present_value (number)",uo("The current value of the annuity.")),$l("future_value (number, default=0)",uo("The future value remaining after the final payment has been made.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s={value:0},i={value:0}){const n=Zo(t,this.locale),r=Zo(e,this.locale),a=is(i)?1:0,l=Zo(s,this.locale);return{value:fp(r,n,Zo(o,this.locale),l,a),format:"#,##0.00"}},isExported:!0};function vp(e,t,o,s,i,n){vg(o),$o((()=>t>0&&t<=o),uo("The period must be between 1 and number_of_periods (%s)",o));const r=fp(e,o,s,i,n);if(1===n&&1===t)return r;return r+-tp(e,0===n?t-1:t-2,r,s+r*n,0)*e}const Sp={description:uo("Payment on the principal of an investment."),args:[$l("rate (number)",uo("The annualized rate of interest.")),$l("period (number)",uo("The amortization period, in terms of number of periods.")),$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("present_value (number)",uo("The current value of the annuity.")),$l("future_value (number, default=0)",uo("The future value remaining after the final payment has been made.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:0},n={value:0}){const r=Zo(o,this.locale),a=Zo(e,this.locale),l=Zo(t,this.locale),c=is(n)?1:0,h=Zo(i,this.locale);return{value:vp(a,l,r,Zo(s,this.locale),h,c),format:"#,##0.00"}},isExported:!0},Cp={description:uo("Present value of an annuity investment."),args:[$l("rate (number)",uo("The interest rate.")),$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("payment_amount (number)",uo("The amount per period to be paid.")),$l("future_value (number, default=0)",uo("The future value remaining after the final payment has been made.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;const n=Zo(e,this.locale),r=Zo(t,this.locale),a=Zo(o,this.locale),l=Zo(s,this.locale),c=is(i)?1:0;return{value:n?-(a*(1+n*c)*((1+n)**r-1)/n+l)/(1+n)**r:-(l+a*r),format:"#,##0.00"}},isExported:!0},yp={description:uo("Price of a security paying periodic interest."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("rate (number)",uo("The annualized rate of interest.")),$l("yield (number)",uo("The expected annual yield of the security.")),$l("redemption (number)",uo("The redemption amount per 100 face value, or par.")),$l("frequency (number)",uo("The number of interest or coupon payments per year (1, 2, or 4).")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=Math.trunc(Zo(e,this.locale)),l=Math.trunc(Zo(t,this.locale)),c=Zo(o,this.locale),h=Zo(s,this.locale),d=Zo(i,this.locale),u=Math.trunc(Zo(n,this.locale)),g=Math.trunc(Zo(r,this.locale));ug(a,l),pg(u),mg(g),$o((()=>c>=0),uo("The rate (%s) must be positive or null.",c.toString())),$o((()=>h>=0),uo("The yield (%s) must be positive or null.",h.toString())),fg(d);const p=Kt(a,l,g)*u,m=Math.ceil(p),f=p-Math.floor(p)||1,b=1+h/u,v=100*c/u;if(1===m)return(v+d)/(f*h/u+1)-v*(1-f);let S=0;for(let e=1;e<=m;e++)S+=v/b**(e-1+f);return d/b**(m-1+f)+S-v*(1-f)},isExported:!0},Ep={description:uo("Price of a discount security."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("discount (number)",uo("The discount rate of the security at time of purchase.")),$l("redemption (number)",uo("The redemption amount per 100 face value, or par.")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(Zo(e,this.locale)),r=Math.trunc(Zo(t,this.locale)),a=Zo(o,this.locale),l=Zo(s,this.locale),c=Math.trunc(Zo(i,this.locale));ug(n,r),mg(c),Tg(a),fg(l);return l-a*l*Kt(n,r,c)},isExported:!0},xp={description:uo("Calculates the price of a security paying interest at maturity, based on expected yield."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("issue (date)",uo("The date the security was initially issued.")),$l("rate (number)",uo("The annualized rate of interest.")),$l("yield (number)",uo("The expected annual yield of the security.")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n={value:0}){n=n||0;const r=Math.trunc(Zo(e,this.locale)),a=Math.trunc(Zo(t,this.locale)),l=Math.trunc(Zo(o,this.locale)),c=Zo(s,this.locale),h=Zo(i,this.locale),d=Math.trunc(Zo(n,this.locale));gg(r,l),ug(r,a),mg(d),$o((()=>c>=0),uo("The rate (%s) must be positive or null.",c.toString())),$o((()=>h>=0),uo("The yield (%s) must be positive or null.",h.toString()));const u=Kt(r,a,d),g=Kt(r,l,d);return(100+Kt(l,a,d)*c*100)/(1+u*h)-g*c*100},isExported:!0},wp=.1,Ip={description:uo("Interest rate of an annuity investment."),args:[$l("number_of_periods (number)",uo("The number of payments to be made.")),$l("payment_per_period (number)",uo("The amount per period to be paid.")),$l("present_value (number)",uo("The current value of the annuity.")),$l("future_value (number, default=0)",uo("The future value remaining after the final payment has been made.")),$l("end_or_beginning (number, default=0)",uo("Whether payments are due at the end (0) or beginning (1) of each period.")),$l("rate_guess (number, default=0.1)",uo("An estimate for what the interest rate will be."))],returns:["NUMBER"],compute:function(e,t,o,s={value:0},i={value:0},n={value:wp}){const r=Zo(e,this.locale),a=Zo(t,this.locale),l=is(i)?1:0,c=Zo(n,this.locale)||wp;let h=Zo(s,this.locale),d=Zo(o,this.locale);vg(r),$o((()=>[a,d,h].some((e=>e>0))&&[a,d,h].some((e=>e<0))),uo("There must be both positive and negative values in [payment_amount, present_value, future_value].",r.toString())),Mg(c),h-=a*l,d+=a*l;return{value:Lg((e=>{const t=Math.pow(1+e,r);return h+d*t+a*((t-1)/e)}),(e=>{const t=Math.pow(1+e,r-1),o=Math.pow(1+e,r);return d*r*t+a*(r*t/e-(o-1)/e/e)}),c,40,1e-5),format:"0%"}},isExported:!0},Rp={description:uo("Amount received at maturity for a security."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("investment (number)",uo("The amount invested (irrespective of face value of each security).")),$l("discount (number)",uo("The discount rate of the security invested in.")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(Zo(e,this.locale)),r=Math.trunc(Zo(t,this.locale)),a=Zo(o,this.locale),l=Zo(s,this.locale),c=Math.trunc(Zo(i,this.locale));ug(n,r),mg(c),Rg(a),Tg(l);return a/(1-l*Kt(n,r,c))},isExported:!0},Tp={description:uo("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:[$l("number_of_periods (number)",uo("The number of periods.")),$l("present_value (number)",uo("The present value of the investment.")),$l("future_value (number)",uo("The future value of the investment."))],returns:["NUMBER"],compute:function(e,t,o){const s=Zo(e,this.locale),i=Zo(t,this.locale),n=Zo(o,this.locale);return vg(s),(n/i)**(1/s)-1},isExported:!0},Ap={description:uo("Depreciation of an asset using the straight-line method."),args:[$l("cost (number)",uo("The initial cost of the asset.")),$l("salvage (number)",uo("The value of the asset at the end of depreciation.")),$l("life (number)",uo("The number of periods over which the asset is depreciated."))],returns:["NUMBER"],compute:function(e,t,o){return{value:(Zo(e,this.locale)-Zo(t,this.locale))/Zo(o,this.locale),format:"#,##0.00"}},isExported:!0},Op={description:uo("Depreciation via sum of years digit method."),args:[$l("cost (number)",uo("The initial cost of the asset.")),$l("salvage (number)",uo("The value of the asset at the end of depreciation.")),$l("life (number)",uo("The number of periods over which the asset is depreciated.")),$l("period (number)",uo("The single period within life for which to calculate depreciation."))],returns:["NUMBER"],compute:function(e,t,o,s){const i=Zo(e,this.locale),n=Zo(t,this.locale),r=Zo(o,this.locale),a=Zo(s,this.locale);Eg(a),Cg(r),Ig(a,r);return{value:(r-a+1)/(r*(r+1)/2)*(i-n),format:"#,##0.00"}},isExported:!0};function _p(e,t,o){return 100*(1-o*Kt(e,t,2))}const Dp={description:uo("Price of a US Treasury bill."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("discount (number)",uo("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,o){const s=Math.trunc(Zo(e,this.locale)),i=Math.trunc(Zo(t,this.locale)),n=Zo(o,this.locale);return ug(s,i),_g(s,i,this.locale),Tg(n),Ag(n),_p(s,i,n)},isExported:!0},Mp={description:uo("Equivalent rate of return for a US Treasury bill."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("discount (number)",uo("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,o){const s=Math.trunc(Zo(e,this.locale)),i=Math.trunc(Zo(t,this.locale)),n=Zo(o,this.locale);ug(s,i),_g(s,i,this.locale),Tg(n),Ag(n);const r=Iu.compute.bind(this)({value:i},{value:s});if(r<=182)return 365*n/(360-n*r);const a=_p(s,i,n)/100,l=r/(366===r?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},Fp={description:uo("The yield of a US Treasury bill based on price."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("price (number)",uo("The price at which the security is bought per 100 face value."))],returns:["NUMBER"],compute:function(e,t,o){const s=Math.trunc(Zo(e,this.locale)),i=Math.trunc(Zo(t,this.locale)),n=Zo(o,this.locale);ug(s,i),_g(s,i,this.locale),bg(n);return(100-n)/n*(1/Kt(s,i,2))},isExported:!0},Np={description:uo("Variable declining balance. WARNING : does not handle decimal periods."),args:[$l("cost (number)",uo("The initial cost of the asset.")),$l("salvage (number)",uo("The value of the asset at the end of depreciation.")),$l("life (number)",uo("The number of periods over which the asset is depreciated.")),$l("start (number)",uo("Starting period to calculate depreciation.")),$l("end (number)",uo("Ending period to calculate depreciation.")),$l("factor (number, default=2)",uo("The number of months in the first year of depreciation.")),$l("no_switch (number, default=false)",uo("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n={value:2},r={value:false}){n=n||0;const a=Zo(e,this.locale),l=Zo(t,this.locale),c=Zo(o,this.locale),h=Math.trunc(Zo(s,this.locale)),d=Math.trunc(Zo(i,this.locale)),u=Zo(n,this.locale),g=is(r);if(yg(a),xg(l),function(e,t,o){Cg(o),$o((()=>e>=0),uo("The start_period (%s) must be greater or equal than 0.",e.toString())),$o((()=>t>=0),uo("The end_period (%s) must be greater or equal than 0.",t.toString())),$o((()=>e<=t),uo("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),$o((()=>t<=o),uo("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),o.toString()))}(h,d,c),Og(u),0===a)return 0;if(l>=a)return h<1?a-l:0;const p=u/c;if(p>=1)return h<1?a-l:0;let m=a,f=0,b=0,v=!1;for(let e=0;e<d;e++){if(!v||g){const t=m*p,o=(m-l)/(c-e);!g&&o>t?(v=!0,f=o):f=t}const t=Math.max(m-f,l);e>=h&&(b+=m-t),m=t}return b},isExported:!0},Pp={description:uo("Internal rate of return given non-periodic cash flows."),args:[$l("cashflow_amounts (range<number>)",uo("An range containing the income or payments associated with the investment.")),$l("cashflow_dates (range<number>)",uo("An range with dates corresponding to the cash flows in cashflow_amounts.")),$l("rate_guess (number, default=0.1)",uo("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],compute:function(e,t,o={value:wp}){const s=Zo(o,this.locale),i=e.flat().map((e=>Zo(e,this.locale))),n=t.flat().map((e=>Zo(e,this.locale)));var r;Fg(e,t),r=i,$o((()=>r.some((e=>e>0))&&r.some((e=>e<0))),uo("There must be both positive and negative values in cashflow_amounts.")),Ng(n),Mg(s);const a=new Map;for(const e of ve(0,n.length)){const t=n[e];a.has(t)?a.set(t,a.get(t)+i[e]):a.set(t,i[e])}const l=Array.from(a.keys()),c=l.map((e=>a.get(e)));return Lg((e=>{let t=c[0];for(const o of ve(1,c.length)){const s=(l[0]-l[o])/365;t+=c[o]*(1+e)**s}return t}),(e=>{let t=0;for(const o of ve(1,c.length)){const s=(l[0]-l[o])/365;t+=s*c[o]*(1+e)**(s-1)}return t}),s,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},Lp={description:uo("Net present value given to non-periodic cash flows.."),args:[$l("discount (number)",uo("The discount rate of the investment over one period.")),$l("cashflow_amounts (number, range<number>)",uo("An range containing the income or payments associated with the investment.")),$l("cashflow_dates (number, range<number>)",uo("An range with dates corresponding to the cash flows in cashflow_amounts."))],returns:["NUMBER"],compute:function(e,t,o){const s=Zo(e,this.locale),i=_o(t)?t.flat().map((e=>Xo(e,this.locale))):[Xo(t,this.locale)],n=_o(o)?o.flat().map((e=>Xo(e,this.locale))):[Xo(o,this.locale)];if(_o(o)&&_o(t)?Fg(t,o):$o((()=>i.length===n.length),uo("There must be the same number of values in cashflow_amounts and cashflow_dates.")),Ng(n),Sg(s),1===i.length)return i[0];const r=new Map;for(const e of ve(0,n.length)){const t=n[e];r.has(t)?r.set(t,r.get(t)+i[e]):r.set(t,i[e])}const a=Array.from(r.keys()),l=a.map((e=>r.get(e)));let c=l[0];for(const e of ve(1,l.length)){const t=(a[0]-a[e])/365;c+=l[e]*(1+s)**t}return c},isExported:!0},kp={description:uo("Annual yield of a security paying periodic interest."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("rate (number)",uo("The annualized rate of interest.")),$l("price (number)",uo("The price at which the security is bought per 100 face value.")),$l("redemption (number)",uo("The redemption amount per 100 face value, or par.")),$l("frequency (number)",uo("The number of interest or coupon payments per year (1, 2, or 4).")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=Math.trunc(Zo(e,this.locale)),l=Math.trunc(Zo(t,this.locale)),c=Zo(o,this.locale),h=Zo(s,this.locale),d=Zo(i,this.locale),u=Math.trunc(Zo(n,this.locale)),g=Math.trunc(Zo(r,this.locale));ug(a,l),pg(u),mg(g),$o((()=>c>=0),uo("The rate (%s) must be positive or null.",c.toString())),bg(h),fg(d);const p=Kt(a,l,g)*u,m=Math.ceil(p),f=p-Math.floor(p)||1,b=100*c/u;if(1===m){const e=h+b*(1-f);return(d+b-e)*u*(1/f)/e}const v=Lg((function(e){return function(e,t,o,s,i,n){let r=n-(e+i*(1-t))*s**(o-1+t);for(let e=1;e<=o;e++)r+=i*s**(e-1);return r}(h,f,m,e,b,d)}),(function(e){return function(e,t,o,s,i){let n=-(e+i*(1-t))*(o-1+t)*s**(o-2+t);for(let e=1;e<=o;e++)n+=i*(e-1)*s**(e-2);return n}(h,f,m,e,b)}),1+(c+1)/u,100,1e-5);return(v-1)*u},isExported:!0},Vp={description:uo("Annual yield of a discount security."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("price (number)",uo("The price at which the security is bought per 100 face value.")),$l("redemption (number)",uo("The redemption amount per 100 face value, or par.")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(Zo(e,this.locale)),r=Math.trunc(Zo(t,this.locale)),a=Zo(o,this.locale),l=Zo(s,this.locale),c=Math.trunc(Zo(i,this.locale));ug(n,r),mg(c),bg(a),fg(l);return(l/a-1)/Kt(n,r,c)},isExported:!0},Up={description:uo("Annual yield of a security paying interest at maturity."),args:[$l("settlement (date)",uo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),$l("maturity (date)",uo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),$l("issue (date)",uo("The date the security was initially issued.")),$l("rate (number)",uo("The annualized rate of interest.")),$l("price (number)",uo("The price at which the security is bought.")),$l("day_count_convention (number, default=0 )",uo("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,i,n={value:0}){n=n||0;const r=Math.trunc(Zo(e,this.locale)),a=Math.trunc(Zo(t,this.locale)),l=Math.trunc(Zo(o,this.locale)),c=Zo(s,this.locale),h=Zo(i,this.locale),d=Math.trunc(Zo(n,this.locale));ug(r,a),mg(d),$o((()=>r>=l),uo("The settlement (%s) must be greater than or equal to the issue (%s).",r.toString(),l.toString())),$o((()=>c>=0),uo("The rate (%s) must be positive or null.",c.toString())),bg(h);const u=Kt(l,a,d),g=Kt(l,r,d),p=Kt(r,a,d);return(100*(1+c*u)/(h+100*c*g)-1)/p},isExported:!0};var Bp=Object.freeze({__proto__:null,ACCRINTM:kg,AMORLINC:Vg,COUPDAYBS:Bg,COUPDAYS:Ug,COUPDAYSNC:Hg,COUPNCD:zg,COUPNUM:$g,COUPPCD:Gg,CUMIPMT:Wg,CUMPRINC:qg,DB:Zg,DDB:jg,DISC:Xg,DOLLARDE:Kg,DOLLARFR:Qg,DURATION:Jg,EFFECT:ep,FV:op,FVSCHEDULE:sp,INTRATE:ip,IPMT:rp,IRR:ap,ISPMT:lp,MDURATION:cp,MIRR:hp,NOMINAL:dp,NPER:up,NPV:pp,PDURATION:mp,PMT:bp,PPMT:Sp,PRICE:yp,PRICEDISC:Ep,PRICEMAT:xp,PV:Cp,RATE:Ip,RECEIVED:Rp,RRI:Tp,SLN:Ap,SYD:Op,TBILLEQ:Mp,TBILLPRICE:Dp,TBILLYIELD:Fp,VDB:Np,XIRR:Pp,XNPV:Lp,YIELD:kp,YIELDDISC:Vp,YIELDMAT:Up});const Hp=["address","col","contents","format","row","type"],zp={description:uo("Gets information about a cell."),args:[$l("info_type (string)",uo("The type of information requested. Can be one of %s",Hp.join(", "))),$l("reference (meta)",uo("The reference to the cell."))],returns:["ANY"],compute:function(e,t){const o=ts(e).toLowerCase();$o((()=>Hp.includes(o)),uo("The info_type should be one of %s.",Hp.join(", ")));const s=this.__originSheetId,i=ts(t),n=i.includes(":")?i.split(":")[0]:i;let{sheetName:r,xc:a}=Ti(n);r=r===this.getters.getSheetName(s)?void 0:r;const l=Ai(r,fa(a,"colrow")),c=this.getters.getRangeFromSheetXC(s,l);switch(o){case"address":return this.getters.getRangeString(c,s);case"col":return c.zone.left+1;case"contents":{const e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top};return this.getters.getEvaluatedCell(e).value}case"format":{const e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top};return this.getters.getEvaluatedCell(e).format||""}case"row":return c.zone.top+1;case"type":{const e={sheetId:c.sheetId,col:c.zone.left,row:c.zone.top},t=this.getters.getEvaluatedCell(e).type;return t===po.empty?"b":t===po.text?"l":"v"}}return""},isExported:!0},$p={description:uo("Whether a value is an error other than #N/A."),args:[$l("value (any)",uo("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){const t=e?.value;return Wo(t)&&t!==No.NotAvailable},isExported:!0},Gp={description:uo("Whether a value is an error."),args:[$l("value (any)",uo("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){const t=e?.value;return Wo(t)},isExported:!0},Wp={description:uo("Whether a value is `true` or `false`."),args:[$l("value (any)",uo("The value to be verified as a logical TRUE or FALSE."))],returns:["BOOLEAN"],compute:function(e){return"boolean"==typeof e?.value},isExported:!0},qp={description:uo("Whether a value is the error #N/A."),args:[$l("value (any)",uo("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){return e?.value===No.NotAvailable},isExported:!0},Zp={description:uo("Whether a value is non-textual."),args:[$l("value (any)",uo("The value to be checked."))],returns:["BOOLEAN"],compute:function(e){return!jp.compute.bind(this)(e)},isExported:!0},Yp={description:uo("Whether a value is a number."),args:[$l("value (any)",uo("The value to be verified as a number."))],returns:["BOOLEAN"],compute:function(e){return"number"==typeof e?.value},isExported:!0},jp={description:uo("Whether a value is text."),args:[$l("value (any)",uo("The value to be verified as text."))],returns:["BOOLEAN"],compute:function(e){return"string"==typeof e?.value&&!1===Wo(e?.value)},isExported:!0},Xp={description:uo("Whether the referenced cell is empty"),args:[$l("value (any)",uo("Reference to the cell that will be checked for emptiness."))],returns:["BOOLEAN"],compute:function(e){return null===e?.value},isExported:!0},Kp={description:uo("Returns the error value #N/A."),args:[],returns:["BOOLEAN"],compute:function(){return{value:No.NotAvailable}},isExported:!0};var Qp=Object.freeze({__proto__:null,CELL:zp,ISBLANK:Xp,ISERR:$p,ISERROR:Gp,ISLOGICAL:Wp,ISNA:qp,ISNONTEXT:Zp,ISNUMBER:Yp,ISTEXT:jp,NA:Kp});function Jp(e){let t=!1,o=!0;return bs(e,(e=>(t=!0,o=o&&e,o))),{foundBoolean:t,result:o}}function em(e){let t=!1,o=!1;return bs(e,(e=>(t=!0,o=o||e,!o))),{foundBoolean:t,result:o}}const tm={description:uo("Logical `and` operator."),args:[$l("logical_expression1 (boolean, range<boolean>)",uo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),$l("logical_expression2 (boolean, range<boolean>, repeating)",uo("More expressions that represent logical values."))],returns:["BOOLEAN"],compute:function(...e){const{result:t,foundBoolean:o}=Jp(e);return $o((()=>o),uo("[[FUNCTION_NAME]] has no valid input data.")),t},isExported:!0},om={description:uo("Logical value `false`."),args:[],returns:["BOOLEAN"],compute:function(){return!1},isExported:!0},sm={description:uo("Returns value depending on logical expression."),args:[$l("logical_expression (boolean)",uo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")),$l("value_if_true (any)",uo("The value the function returns if logical_expression is TRUE.")),$l("value_if_false (any, default=FALSE)",uo("The value the function returns if logical_expression is FALSE."))],returns:["ANY"],compute:function(e,t,o){const s=is(e?.value)?t:o;return void 0===s?{value:""}:(null===s.value&&(s.value=""),s)},isExported:!0},im={description:uo("Value if it is not an error, otherwise 2nd argument."),args:[$l("value (any)",uo("The value to return if value itself is not an error.")),$l('value_if_error (any, default="empty")',uo("The value the function returns if value is an error."))],returns:["ANY"],compute:function(e,t={value:""}){const o=Wo(e?.value)?t:e;return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)},isExported:!0},nm={description:uo("Value if it is not an #N/A error, otherwise 2nd argument."),args:[$l("value (any)",uo("The value to return if value itself is not #N/A an error.")),$l('value_if_error (any, default="empty")',uo("The value the function returns if value is an #N/A error."))],returns:["ANY"],compute:function(e,t={value:""}){const o=e?.value===No.NotAvailable?t:e;return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)},isExported:!0},rm={description:uo("Returns a value depending on multiple logical expressions."),args:[$l("condition1 (boolean)",uo("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")),$l("value1 (any)",uo("The returned value if condition1 is TRUE.")),$l("condition2 (boolean, repeating)",uo("Additional conditions to be evaluated if the previous ones are FALSE.")),$l("value2 (any, repeating)",uo("Additional values to be returned if their corresponding conditions are TRUE."))],returns:["ANY"],compute:function(...e){$o((()=>e.length%2==0),uo("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(is(e[t]?.value)){const o=e[t+1];return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)}throw new Lo(uo("No match."))},isExported:!0},am={description:uo("Returns opposite of provided logical value."),args:[$l("logical_expression (boolean)",uo("An expression or reference to a cell holding an expression that represents some logical value."))],returns:["BOOLEAN"],compute:function(e){return!is(e)},isExported:!0},lm={description:uo("Logical `or` operator."),args:[$l("logical_expression1 (boolean, range<boolean>)",uo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),$l("logical_expression2 (boolean, range<boolean>, repeating)",uo("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){const{result:t,foundBoolean:o}=em(e);return $o((()=>o),uo("[[FUNCTION_NAME]] has no valid input data.")),t},isExported:!0},cm={description:uo("Logical value `true`."),args:[],returns:["BOOLEAN"],compute:function(){return!0},isExported:!0},hm={description:uo("Logical `xor` operator."),args:[$l("logical_expression1 (boolean, range<boolean>)",uo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),$l("logical_expression2 (boolean, range<boolean>, repeating)",uo("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return bs(e,(e=>(t=!0,o=o?!e:e,!0))),$o((()=>t),uo("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0};var dm=Object.freeze({__proto__:null,AND:tm,FALSE:om,IF:sm,IFERROR:im,IFNA:nm,IFS:rm,NOT:am,OR:lm,TRUE:cm,XOR:hm});const um=new zn;function gm(e,t){const o=t.getPivotId(e);if(!o)throw new Lo(uo('There is no pivot with id "%s"',e));return o}function pm(e){if(e.length%2!=0)throw new Lo(uo("Function PIVOT takes an even number of arguments."))}function mm(e,t){if("SPREADSHEET"!==t.type||!t.dataSet)return;const{sheetId:o,zone:s}=t.dataSet;let i;const n=e.__originSheetId,r=e.__originCellXC?.();if(r){const t=Li(r);i={sheetId:n,col:t.left,row:t.top},e.updateDependencies?.(i)}const a=Ui(s),l=e.getters.getRangeFromSheetXC(o,a);if(void 0===l||l.invalidXc||l.invalidSheetName)throw new Vo;i&&e.addDependencies?.(i,[l])}um.add("SPREADSHEET",!1);const fm=!0;function bm(e){return{value:No.NotAvailable,message:uo("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ts(e))}}const vm={description:uo("Returns a cell reference as a string. "),args:[$l("row (number)",uo("The row number of the cell reference. ")),$l("column (number)",uo("The column number (not name) of the cell reference. A is column number 1. ")),$l("absolute_relative_mode (number, default=1)",uo("An indicator of whether the reference is row/column absolute. 1 is row and column absolute (e.g. $A$1), 2 is row absolute and column relative (e.g. A$1), 3 is row relative and column absolute (e.g. $A1), and 4 is row and column relative (e.g. A1).")),$l("use_a1_notation (boolean, default=TRUE)",uo("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).")),$l("sheet (string, optional)",uo("A string indicating the name of the sheet into which the address points."))],returns:["STRING"],compute:function(e,t,o={value:1},s={value:!0},i){const n=Qo(e,this.locale),r=Qo(t,this.locale);Jo(n),Jo(r);const a=Qo(o,this.locale);var l,c;$o((()=>[1,2,3,4].includes(a)),(l=4,c=a,uo("The function [[FUNCTION_NAME]] expects a number value between %s and %s inclusive, but receives %s.",1..toString(),l.toString(),c.toString())));let h;if(is(s)){h=Tt(r-1,n-1,{rowFixed:!![1,2].includes(a),colFixed:!![1,3].includes(a)})}else{h=([1,2].includes(a)?`R${n}`:`R[${n}]`)+([1,3].includes(a)?`C${r}`:`C[${r}]`)}return void 0!==i?Ai(ts(i),h):h},isExported:!0},Sm={description:uo("Column number of a specified cell."),args:[$l("cell_reference (meta, default='this cell')",uo("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."))],returns:["NUMBER"],compute:function(e){if(Wo(e?.value))throw e;const t=void 0===e?this.__originCellXC?.():e.value;$o((()=>!!t),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Li(t).left+1},isExported:!0},Cm={description:uo("Number of columns in a specified array or range."),args:[$l("range (meta)",uo("The range whose column count will be returned."))],returns:["NUMBER"],compute:function(e){if(Wo(e?.value))throw e;const t=Li(e.value);return t.right-t.left+1},isExported:!0},ym={description:uo("Horizontal lookup"),args:[$l("search_key (any)",uo("The value to search for. For example, 42, 'Cats', or I24.")),$l("range (range)",uo("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")),$l("index (number)",uo("The row index of the value to be returned, where the first row in range is numbered 1.")),$l("is_sorted (boolean, default=true)",uo("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."))],returns:["ANY"],compute:function(e,t,o,s={value:fm}){const i=Math.trunc(Zo(o?.value,this.locale));if($o((()=>1<=i&&i<=t[0].length),uo("[[FUNCTION_NAME]] evaluates to an out of bounds range.")),e&&Wo(e.value))return e;const n=(e,t)=>e[t][0].value,r=is(s.value)?Es(t,e,"nextSmaller","asc",t.length,n):xs(t,e,"wildcard",t.length,n),a=t[r];return void 0===a?bm(e):a[i-1]},isExported:!0},Em={description:uo("Returns the content of a cell, specified by row and column offset."),args:[$l("reference (any, range)",uo("The range of cells from which the values are returned.")),$l("row (number, default=0)",uo("The index of the row to be returned from within the reference range of cells.")),$l("column (number, default=0)",uo("The index of the column to be returned from within the reference range of cells."))],returns:["ANY"],compute:function(e,t={value:0},o={value:0}){const s=Rs(e),i=Zo(t.value,this.locale),n=Zo(o.value,this.locale);return $o((()=>n>=0&&n-1<s.length&&i>=0&&i-1<s[0].length),uo("Index out of range.")),0===i&&0===n?s:0===i?[s[n-1]]:0===n?s.map((e=>[e[i-1]])):s[n-1][i-1]},isExported:!0},xm={description:uo("Returns the content of a cell, specified by a string."),args:[$l("reference (string)",uo("The range of cells from which the values are returned.")),$l("use_a1_notation (boolean, default=TRUE)",uo("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE)."))],returns:["ANY"],compute:function(e,t={value:!0}){let o=e?.value?.toString();if(!o)throw new Vo(uo("Reference should be defined."));if(!is(t))throw new Lo(uo("R1C1 notation is not supported."));const s=this.__originSheetId;let i;const n=this.__originCellXC?.();if(n){const e=Li(n);i={sheetId:s,col:e.left,row:e.top},this.updateDependencies?.(i)}const r=this.getters.getRangeFromSheetXC(s,o);if(void 0===r||r.invalidXc||r.invalidSheetName)throw new Vo;i&&this.addDependencies?.(i,[r]);const a=[];for(let e=r.zone.left;e<=r.zone.right;e++){const t=[];for(let o=r.zone.top;o<=r.zone.bottom;o++){const s={sheetId:r.sheetId,col:e,row:o};t.push(this.getters.getEvaluatedCell(s))}a.push(t)}return 1===a.length&&1===a[0].length?a[0][0]:a},isExported:!0},wm={description:uo("Look up a value."),args:[$l("search_key (any)",uo("The value to search for. For example, 42, 'Cats', or I24.")),$l("search_array (range)",uo("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.")),$l("result_range (range, optional)",uo("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."))],returns:["ANY"],compute:function(e,t,o){let s=t.length,i=t[0].length;const n=i>=s,r=n?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,a=Es(t,e,"nextSmaller","asc",n?i:s,r);return-1===a||n&&void 0===t[0][a]||!n&&void 0===t[a][i-1]?bm(e):void 0===o?n?t[s-1][a]:t[a][i-1]:(s=o.length,i=o[0].length,$o((()=>1===s||1===i),uo("The result_range must be a single row or a single column.")),s>1?($o((()=>a<=s-1),uo("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(a+1).toString())),o[a][0]):($o((()=>a<=i-1),uo("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(a+1).toString())),o[0][a]))},isExported:!0},Im={description:uo("Position of item in range that matches value."),args:[$l("search_key (any)",uo("The value to search for. For example, 42, 'Cats', or I24.")),$l("range (any, range)",uo("The one-dimensional array to be searched.")),$l("search_type (number, default=1)",uo("The search method. 1 (default) finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order."))],returns:["NUMBER"],compute:function(e,t,o={value:1}){let s=Zo(o,this.locale);const i=t.length,n=t[0].length;$o((()=>1===i||1===n),uo("The range must be a single row or a single column."));let r=-1;const a=1===i?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,l=1===i?t[0].length:t.length;switch(s=Math.sign(s),s){case 1:r=Es(t,e,"nextSmaller","asc",l,a);break;case 0:r=xs(t,e,"wildcard",l,a);break;case-1:r=Es(t,e,"nextGreater","desc",l,a)}return 1===i&&void 0===t[0][r]||1!==i&&void 0===t[r]?bm(e):r+1},isExported:!0},Rm={description:uo("Row number of a specified cell."),args:[$l("cell_reference (meta, default='this cell')",uo("The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered."))],returns:["NUMBER"],compute:function(e){if(Wo(e?.value))throw e;const t=void 0===e?this.__originCellXC?.():e.value;$o((()=>!!t),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Li(t).top+1},isExported:!0},Tm={description:uo("Number of rows in a specified array or range."),args:[$l("range (meta)",uo("The range whose row count will be returned."))],returns:["NUMBER"],compute:function(e){if(Wo(e?.value))throw e;const t=Li(e.value);return t.bottom-t.top+1},isExported:!0},Am={description:uo("Vertical lookup."),args:[$l("search_key (any)",uo("The value to search for. For example, 42, 'Cats', or I24.")),$l("range (any, range)",uo("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")),$l("index (number)",uo("The column index of the value to be returned, where the first column in range is numbered 1.")),$l("is_sorted (boolean, default=true)",uo("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."))],returns:["ANY"],compute:function(e,t,o,s={value:fm}){const i=Math.trunc(Zo(o?.value,this.locale));if($o((()=>1<=i&&i<=t.length),uo("[[FUNCTION_NAME]] evaluates to an out of bounds range.")),e&&Wo(e.value))return e;const n=(e,t)=>e[0][t].value,r=is(s.value)?Es(t,e,"nextSmaller","asc",t[0].length,n):xs(t,e,"wildcard",t[0].length,n),a=t[i-1][r];return void 0===a?bm(e):a},isExported:!0},Om={0:"strict",1:"nextGreater","-1":"nextSmaller",2:"wildcard"},_m={description:uo("Search a range for a match and return the corresponding item from a second range."),args:[$l("search_key (any)",uo("The value to search for.")),$l("lookup_range (any, range)",uo("The range to consider for the search. Should be a single column or a single row.")),$l("return_range (any, range)",uo("The range containing the return value. Should have the same dimensions as lookup_range.")),$l("if_not_found (any, optional)",uo("If a valid match is not found, return this value.")),$l("match_mode (any, default=0)",uo("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match. (2) Wildcard match.")),$l("search_mode (any, default=1)",uo("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. "))],returns:["ANY"],compute:function(e,t,o,s,i={value:0},n={value:1}){const r=Math.trunc(Zo(i.value,this.locale)),a=Math.trunc(Zo(n.value,this.locale));$o((()=>1===t.length||1===t[0].length),uo("lookup_range should be either a single row or single column.")),$o((()=>[-1,1,-2,2].includes(a)),uo("search_mode should be a value in [-1, 1, -2, 2].")),$o((()=>[-1,0,1,2].includes(r)),uo("match_mode should be a value in [-1, 0, 1, 2]."));const l=1===t.length?"col":"row";if($o((()=>!(2===r&&[-2,2].includes(a))),uo("the search and match mode combination is not supported for XLOOKUP evaluation.")),$o((()=>"col"===l?o[0].length===t[0].length:o.length===t.length),uo("return_range should have the same dimensions as lookup_range.")),e&&Wo(e.value))return[[e]];const c="col"===l?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,h="col"===l?t[0].length:t.length,d=Om[r],u=-1===a,g=2===a||-2===a?Es(t,e,d,2===a?"asc":"desc",h,c):xs(t,e,d,h,c,u);return-1!==g?"col"===l?o.map((e=>[e[g]])):[o[g]]:void 0===s?bm(e):[[s]]},isExported:!0},Dm={description:uo("Get the value from a pivot."),args:[$l("pivot_id (string)",uo("ID of the pivot.")),$l("measure_name (string)",uo("Name of the measure.")),$l("domain_field_name (string,optional,repeating)",uo("Field name.")),$l("domain_value (string,optional,repeating)",uo("Value."))],compute:function(e,t,...o){const s=ts(e),i=ts(t),n=o.map(ts),r=gm(s,this.getters);!function(e,t,o){const{measures:s}=o.getPivotCoreDefinition(e);if(!s.find((e=>e.name===t))){const e=`(${s.map((e=>e.name)).join(", ")})`;throw new Lo(uo("The argument %s is not a valid measure. Here are the measures: %s",t,e))}}(r,i,this.getters),pm(n);const a=this.getters.getPivot(r),l=this.getters.getPivotCoreDefinition(r);if(!um.get(l.type))return{value:No.GenericError,message:uo("This pivot does not support PIVOT.VALUE formula")};mm(this,l);const c=a.assertIsValid({throwOnError:!1});if(c)return c;const{value:h,format:d}=a.getPivotCellValueAndFormat(i,n);return h||this.getters.areDomainArgsFieldsValid(r,n)?{value:h,format:d}:{value:No.GenericError,message:uo("Dimensions don't match the pivot definition")}},returns:["NUMBER","STRING"]},Mm={description:uo("Get the header of a pivot."),args:[$l("pivot_id (string)",uo("ID of the pivot.")),$l("domain_field_name (string,optional,repeating)",uo("Field name.")),$l("domain_value (string,optional,repeating)",uo("Value."))],compute:function(e,...t){const o=ts(e),s=t.map(ts),i=gm(o,this.getters);pm(s);const n=this.getters.getPivot(i),r=this.getters.getPivotCoreDefinition(i);if(!um.get(r.type))return{value:No.GenericError,message:uo("This pivot does not support PIVOT.VALUE formula")};mm(this,r);const a=n.assertIsValid({throwOnError:!1});if(a)return a;const l=s.at(-2),c=s.at(-1);if(!this.getters.areDomainArgsFieldsValid(i,"measure"===l?s.slice(0,-2):s))return{value:No.GenericError,message:uo("Dimensions don't match the pivot definition")};const{value:h,format:d}=n.getPivotHeaderValueAndFormat(s);return{value:h,format:l&&"measure"!==l&&"false"!==c?d:void 0}},returns:["NUMBER","STRING"]},Fm={description:uo("Get a pivot table."),args:[$l("pivot_id (string)",uo("ID of the pivot.")),$l("row_count (number, optional, default=10000)",uo("number of rows")),$l("include_total (boolean, default=TRUE)",uo("Whether to include total/sub-totals or not.")),$l("include_column_titles (boolean, default=TRUE)",uo("Whether to include the column titles or not."))],compute:function(e,t={value:1e4},o={value:!0},s={value:!0}){const i=gm(ts(e),this.getters),n=this.getters.getPivot(i);mm(this,this.getters.getPivotCoreDefinition(i)),n.init({reload:n.needsReevaluation});const r=n.assertIsValid({throwOnError:!1});if(r)return r;const a=n.getTableStructure(),l=is(s),c=a.getPivotCells(is(o),l),h=l?a.columns.length:0,d=this.getters.getPivotDisplayName(i),u=Zo(t,this.locale);if(u<0)throw new Lo(uo("The number of rows must be positive."));const g=Math.min(h+u,c[0].length);if(0===g)return[[{value:d}]];const p=c.length,m=ve(0,g),f=[];for(const e of ve(0,p)){f[e]=[];for(const t of m){const o=c[e][t];if(o.domain)if(o.isHeader)f[e].push(n.getPivotHeaderValueAndFormat(o.domain));else{if(!o.measure)throw new Error("Measure is missing");f[e].push(n.getPivotCellValueAndFormat(o.measure,o.domain))}else f[e].push({value:"",format:void 0})}}return l&&(f[0][0]={value:d}),f},returns:["RANGE<ANY>"]};var Nm=Object.freeze({__proto__:null,ADDRESS:vm,COLUMN:Sm,COLUMNS:Cm,HLOOKUP:ym,INDEX:Em,INDIRECT:xm,LOOKUP:wm,MATCH:Im,PIVOT:Fm,PIVOT_HEADER:Mm,PIVOT_VALUE:Dm,ROW:Rm,ROWS:Tm,VLOOKUP:Am,XLOOKUP:_m});const Pm={description:uo("Sum of two numbers."),args:[$l("value1 (number)",uo("The first addend.")),$l("value2 (number)",uo("The second addend."))],returns:["NUMBER"],compute:function(e,t){return{value:Zo(e,this.locale)+Zo(t,this.locale),format:e?.format||t?.format}}},Lm={description:uo("Concatenation of two values."),args:[$l("value1 (string)",uo("The value to which value2 will be appended.")),$l("value2 (string)",uo("The value to append to value1."))],returns:["STRING"],compute:function(e,t){return ts(e)+ts(t)},isExported:!0},km={description:uo("One number divided by another."),args:[$l("dividend (number)",uo("The number to be divided.")),$l("divisor (number)",uo("The number to divide by."))],returns:["NUMBER"],compute:function(e,t){const o=Zo(t,this.locale);return $o((()=>0!==o),uo("The divisor must be different from zero."),No.DivisionByZero),{value:Zo(e,this.locale)/o,format:e?.format||t?.format}}};function Vm(e){return void 0===e||null===e.value}const Um={number:0,string:"",boolean:!1},Bm={description:uo("Equal."),args:[$l("value1 (any)",uo("The first value.")),$l("value2 (any)",uo("The value to test against value1 for equality."))],returns:["BOOLEAN"],compute:function(e,t){let o=Vm(e)?Um[typeof t?.value]:e?.value,s=Vm(t)?Um[typeof e?.value]:t?.value;if("string"==typeof o&&(o=o.toUpperCase()),"string"==typeof s&&(s=s.toUpperCase()),Wo(o))throw e;if(Wo(s))throw t;return o===s}};function Hm(e,t,o){let s=Vm(e)?Um[typeof t?.value]:e?.value,i=Vm(t)?Um[typeof e?.value]:t?.value;if(Wo(s))throw e;if(Wo(i))throw t;"number"!=typeof s&&(s=ts(s).toUpperCase()),"number"!=typeof i&&(i=ts(i).toUpperCase());const n=typeof s,r=typeof i;return"string"===n&&"number"===r||("string"!==r||"number"!==n)&&o(s,i)}const zm={description:uo("Strictly greater than."),args:[$l("value1 (any)",uo("The value to test as being greater than value2.")),$l("value2 (any)",uo("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return Hm(e,t,((e,t)=>e>t))}},$m={description:uo("Greater than or equal to."),args:[$l("value1 (any)",uo("The value to test as being greater than or equal to value2.")),$l("value2 (any)",uo("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return Hm(e,t,((e,t)=>e>=t))}},Gm={description:uo("Less than."),args:[$l("value1 (any)",uo("The value to test as being less than value2.")),$l("value2 (any)",uo("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!$m.compute.bind(this)(e,t)}},Wm={description:uo("Less than or equal to."),args:[$l("value1 (any)",uo("The value to test as being less than or equal to value2.")),$l("value2 (any)",uo("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!zm.compute.bind(this)(e,t)}},qm={description:uo("Difference of two numbers."),args:[$l("value1 (number)",uo("The minuend, or number to be subtracted from.")),$l("value2 (number)",uo("The subtrahend, or number to subtract from value1."))],returns:["NUMBER"],compute:function(e,t){return{value:Zo(e,this.locale)-Zo(t,this.locale),format:e?.format||t?.format}}},Zm={description:uo("Product of two numbers"),args:[$l("factor1 (number)",uo("The first multiplicand.")),$l("factor2 (number)",uo("The second multiplicand."))],returns:["NUMBER"],compute:function(e,t){return{value:Zo(e,this.locale)*Zo(t,this.locale),format:e?.format||t?.format}}},Ym={description:uo("Not equal."),args:[$l("value1 (any)",uo("The first value.")),$l("value2 (any)",uo("The value to test against value1 for inequality."))],returns:["BOOLEAN"],compute:function(e,t){return!Bm.compute.bind(this)(e,t)}},jm={description:uo("A number raised to a power."),args:[$l("base (number)",uo("The number to raise to the exponent power.")),$l("exponent (number)",uo("The exponent to raise base to."))],returns:["NUMBER"],compute:function(e,t){return bh.compute.bind(this)(e,t)}},Xm={description:uo("A number with the sign reversed."),args:[$l("value (number)",uo("The number to have its sign reversed. Equivalently, the number to multiply by -1."))],returns:["NUMBER"],compute:function(e){return{value:-Zo(e,this.locale),format:e?.format}}},Km={description:uo("Value interpreted as a percentage."),args:[$l("percentage (number)",uo("The value to interpret as a percentage."))],returns:["NUMBER"],compute:function(e){return Zo(e,this.locale)/100}},Qm={description:uo("A specified number, unchanged."),args:[$l("value (any)",uo("The number to return."))],returns:["ANY"],compute:function(e={value:null}){return e}};var Jm=Object.freeze({__proto__:null,ADD:Pm,CONCAT:Lm,DIVIDE:km,EQ:Bm,GT:zm,GTE:$m,LT:Gm,LTE:Wm,MINUS:qm,MULTIPLY:Zm,NE:Ym,POW:jm,UMINUS:Xm,UNARY_PERCENT:Km,UPLUS:Qm});const ef=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,tf={description:uo("Gets character associated with number."),args:[$l("table_number (number)",uo("The number of the character to look up from the current Unicode table in decimal format."))],returns:["STRING"],compute:function(e){const t=Math.trunc(Zo(e,this.locale));return $o((()=>t>=1),uo("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},of={description:uo("Remove non-printable characters from a piece of text."),args:[$l("text (string)",uo("The text whose non-printable characters are to be removed."))],returns:["STRING"],compute:function(e){const t=ts(e);let o="";for(const e of t)e&&e.charCodeAt(0)>31&&(o+=e);return o},isExported:!0},sf={description:uo("Appends strings to one another."),args:[$l("string1 (string, range<string>)",uo("The initial string.")),$l("string2 (string, range<string>, repeating)",uo("More strings to append in sequence."))],returns:["STRING"],compute:function(...e){return ds(e,((e,t)=>e+ts(t)),"")},isExported:!0},nf={description:uo("Tests whether two strings are identical."),args:[$l("string1 (string)",uo("The first string to compare.")),$l("string2 (string)",uo("The second string to compare."))],returns:["BOOLEAN"],compute:function(e,t){return ts(e)===ts(t)},isExported:!0},rf={description:uo("First position of string found in text, case-sensitive."),args:[$l("search_for (string)",uo("The string to look for within text_to_search.")),$l("text_to_search (string)",uo("The text to search for the first occurrence of search_for.")),$l("starting_at (number, default=1)",uo("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,o={value:1}){const s=ts(e),i=ts(t),n=Zo(o,this.locale);$o((()=>""!==i),uo("The text_to_search must be non-empty.")),$o((()=>n>=1),uo("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const r=i.indexOf(s,n-1);return $o((()=>r>=0),uo("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",s.toString(),i)),r+1},isExported:!0},af={description:uo("Concatenates elements of arrays with delimiter."),args:[$l("delimiter (string)",uo("The character or string to place between each concatenated value.")),$l("value_or_array1 (string, range<string>)",uo("The value or values to be appended using delimiter.")),$l("value_or_array2 (string, range<string>, repeating)",uo("More values to be appended using delimiter."))],returns:["STRING"],compute:function(e,...t){const o=ts(e);return ds(t,((e,t)=>(e?e+o:"")+ts(t)),"")}},lf={description:uo("Substring from beginning of specified string."),args:[$l("text (string)",uo("The string from which the left portion will be returned.")),$l("number_of_characters (number, optional)",uo("The number of characters to return from the left side of string."))],returns:["STRING"],compute:function(e,...t){const o=t.length?Zo(t[0],this.locale):1;return $o((()=>o>=0),uo("The number_of_characters (%s) must be positive or null.",o.toString())),ts(e).substring(0,o)},isExported:!0},cf={description:uo("Length of a string."),args:[$l("text (string)",uo("The string whose length will be returned."))],returns:["NUMBER"],compute:function(e){return ts(e).length},isExported:!0},hf={description:uo("Converts a specified string to lowercase."),args:[$l("text (string)",uo("The string to convert to lowercase."))],returns:["STRING"],compute:function(e){return ts(e).toLowerCase()},isExported:!0},df={description:uo("A segment of a string."),args:[$l("text (string)",uo("The string to extract a segment from.")),$l("starting_at (number)",uo("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),$l("extract_length (number)",uo("The length of the segment to extract."))],returns:["STRING"],compute:function(e,t,o){const s=ts(e),i=Zo(t,this.locale),n=Zo(o,this.locale);return $o((()=>i>=1),uo("The starting_at argument (%s) must be positive greater than one.",i.toString())),$o((()=>n>=0),uo("The extract_length argument (%s) must be positive or null.",n.toString())),s.slice(i-1,i+n-1)},isExported:!0},uf={description:uo("Capitalizes each word in a specified string."),args:[$l("text_to_capitalize (string)",uo("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase."))],returns:["STRING"],compute:function(e){return ts(e).replace(ef,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},gf={description:uo("Replaces part of a text string with different text."),args:[$l("text (string)",uo("The text, a part of which will be replaced.")),$l("position (number)",uo("The position where the replacement will begin (starting from 1).")),$l("length (number)",uo("The number of characters in the text to be replaced.")),$l("new_text (string)",uo("The text which will be inserted into the original text."))],returns:["STRING"],compute:function(e,t,o,s){const i=Zo(t,this.locale);$o((()=>i>=1),uo("The position (%s) must be greater than or equal to 1.",i.toString()));const n=ts(e),r=Zo(o,this.locale),a=ts(s);return n.substring(0,i-1)+a+n.substring(i-1+r)},isExported:!0},pf={description:uo("A substring from the end of a specified string."),args:[$l("text (string)",uo("The string from which the right portion will be returned.")),$l("number_of_characters (number, optional)",uo("The number of characters to return from the right side of string."))],returns:["STRING"],compute:function(e,...t){const o=t.length?Zo(t[0],this.locale):1;$o((()=>o>=0),uo("The number_of_characters (%s) must be positive or null.",o.toString()));const s=ts(e),i=s.length;return s.substring(i-o,i)},isExported:!0},mf={description:uo("First position of string found in text, ignoring case."),args:[$l("search_for (string)",uo("The string to look for within text_to_search.")),$l("text_to_search (string)",uo("The text to search for the first occurrence of search_for.")),$l("starting_at (number, default=1)",uo("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,o={value:1}){const s=ts(e).toLowerCase(),i=ts(t).toLowerCase(),n=Zo(o,this.locale);$o((()=>""!==i),uo("The text_to_search must be non-empty.")),$o((()=>n>=1),uo("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const r=i.indexOf(s,n-1);return $o((()=>r>=0),uo("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",s,i)),r+1},isExported:!0},ff={description:uo("Split text by specific character delimiter(s)."),args:[$l("text (string)",uo("The text to divide.")),$l("delimiter (string)",uo("The character or characters to use to split text.")),$l("split_by_each (boolean, default=true})",uo("Whether or not to divide text around each character contained in delimiter.")),$l("remove_empty_text (boolean, default=true)",uo("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."))],returns:["RANGE<STRING>"],compute:function(e,t,o={value:true},s={value:true}){const i=ts(e),n=ue(ts(t)),r=is(o),a=is(s);$o((()=>n.length>0),uo("The _delimiter (%s) must be not be empty.",n));const l=r?new RegExp(`[${n}]`,"g"):new RegExp(n,"g");let c=i.split(l);return a&&(c=c.filter((e=>""!==e))),fs([c])},isExported:!0},bf={description:uo("Replaces existing text with new text in a string."),args:[$l("text_to_search (string)",uo("The text within which to search and replace.")),$l("search_for (string)",uo("The string to search for within text_to_search.")),$l("replace_with (string)",uo("The string that will replace search_for.")),$l("occurrence_number (number, optional)",uo("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."))],returns:["NUMBER"],compute:function(e,t,o,s){const i=Zo(s,this.locale);$o((()=>i>=0),uo("The occurrenceNumber (%s) must be positive or null.",i.toString()));const n=ts(e),r=ts(t);if(""===r)return n;const a=ts(o),l=new RegExp(ue(r),"g");if(0===i)return n.replace(l,a);let c=0;return n.replace(l,(e=>++c===i?a:e))},isExported:!0},vf={description:uo("Combines text from multiple strings and/or arrays."),args:[$l("delimiter (string)",uo(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")),$l("ignore_empty (boolean)",uo("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")),$l("text1 (string, range<string>)",uo("Any text item. This could be a string, or an array of strings in a range.")),$l("text2 (string, range<string>, repeating)",uo("Additional text item(s)."))],returns:["STRING"],compute:function(e,t,...o){const s=ts(e),i=is(t);let n=0;return ds(o,((e,t)=>i&&""===ts(t)?e:(n++?e+s:"")+ts(t)),"")},isExported:!0},Sf={description:uo("Removes space characters."),args:[$l("text (string)",uo("The text or reference to a cell containing text to be trimmed."))],returns:["STRING"],compute:function(e){return Xe(ts(e))},isExported:!0},Cf={description:uo("Converts a specified string to uppercase."),args:[$l("text (string)",uo("The string to convert to uppercase."))],returns:["STRING"],compute:function(e){return ts(e).toUpperCase()},isExported:!0},yf={description:uo("Converts a number to text according to a specified format."),args:[$l("number (number)",uo("The number, date or time to format.")),$l("format (string)",uo("The pattern by which to format the number, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){return Hs(Zo(e,this.locale),{format:ts(t),locale:this.locale})},isExported:!0};var Ef=Object.freeze({__proto__:null,CHAR:tf,CLEAN:of,CONCATENATE:sf,EXACT:nf,FIND:rf,JOIN:af,LEFT:lf,LEN:cf,LOWER:hf,MID:df,PROPER:uf,REPLACE:gf,RIGHT:pf,SEARCH:mf,SPLIT:ff,SUBSTITUTE:bf,TEXT:yf,TEXTJOIN:vf,TRIM:Sf,UPPER:Cf});const xf={description:uo("Creates a hyperlink in a cell."),args:[$l("url (string)",uo("The full URL of the link enclosed in quotation marks.")),$l("link_label (string, optional)",uo("The text to display in the cell, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){const o=ts(e).trim(),s=ts(t)||o;return""===o?s:Ie(s,o)},isExported:!0};var wf=Object.freeze({__proto__:null,HYPERLINK:xf});const If=[{name:uo("Array"),functions:wc},{name:uo("Database"),functions:Su},{name:uo("Date"),functions:eg},{name:uo("Filter"),functions:dg},{name:uo("Financial"),functions:Bp},{name:uo("Info"),functions:Qp},{name:uo("Lookup"),functions:Nm},{name:uo("Logical"),functions:dm},{name:uo("Math"),functions:Vh},{name:uo("Misc"),functions:Rc},{name:uo("Operator"),functions:Jm},{name:uo("Statistical"),functions:iu},{name:uo("Text"),functions:Ef},{name:uo("Engineering"),functions:og},{name:uo("Web"),functions:wf}],Rf=/^[A-Z0-9\_\.]+$/;const Tf=uo("An unexpected error occurred. Submit a support ticket at odoo.com/help.");function Af(e){return void 0!==e?.message&&"string"==typeof e.message}function Of(e,t){e.message?.includes("[[FUNCTION_NAME]]")&&(e.message=e.message.replace("[[FUNCTION_NAME]]",t))}const _f=new class extends zn{mapping={};add(e,t){if(e=e.toUpperCase(),!Rf.test(e))throw new Error(uo("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const o=Gl(t);var s,i;return function(e){let t=!1,o=!1,s=!1;for(let i of e){if(i.type.includes("META")&&i.type.length>1)throw new Error(uo("Function ${name} has an argument that has been declared with more than one type whose type 'META'. The 'META' type can only be declared alone."));if(t&&!i.repeating)throw new Error(uo("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=o||t||s,n=!(i.optional||i.repeating||i.default);if(e&&n)throw new Error(uo("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=i.repeating,o=i.optional,s=i.default}}(o.args),this.mapping[e]=function(e,t){return function(...o){try{return e.apply(this,o)}catch(e){return function(e,t){if(o=e,void 0!==o?.value&&"string"==typeof o.value&&Wo(e.value))return Af(e)&&Of(e,t),e;var o;return console.error(e),new Lo(Tf+(Af(e)?" "+e.message:""))}(e,t)}}}((s=function(e){function t(...t){for(let o=0;o<t.length;o++){const s=e.args[e.getArgToFocus(o+1)-1],i=t[o];if(_o(i)&&!s.acceptMatrix){if(1!==i.length||1!==i[0].length)throw new Lo(uo("Function [[FUNCTION_NAME]] expects the parameter '%s' to be a single value or a single cell reference, not a range.",s.name));t[o]=i[0][0]}}return e.compute.apply(this,t)}return t}(o),i=e,function(...e){const t=s.apply(this,e);return _o(t)?"object"==typeof t[0][0]&&null!==t[0][0]&&"value"in t[0][0]?(function(e,t){const o=e.length,s=e[0]?.length??0;for(let i=0;i<o;i++)for(let o=0;o<s;o++)t(e[i][o])}(t,(e=>Of(e,i))),t):ms(t,(e=>({value:e}))):"object"==typeof t&&null!==t&&"value"in t?(Of(t,i),t):{value:t}}),e),super.add(e,o),this}};for(let e of If){const t=e.functions;for(let o in t){const s=t[o];s.category=s.category||e.name,o=o.replace(/_/g,"."),_f.add(o,{isExported:!1,...s})}}va.add("functions",{sequence:100,autoSelectFirstProposal:!0,maxDisplayedProposals:10,getProposals(e){if("SYMBOL"!==e.type)return[];const t=e.value,o=t.toUpperCase();if(!this.composer.currentContent.startsWith("=")||"TRUE"===o||"FALSE"===o)return[];const s=Object.entries(_f.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:o}])=>({text:e,description:o,htmlContent:Bl(t,e,E,"o-semi-bold")}))).sort(((e,t)=>e.text.length-t.text.length||e.text.localeCompare(t.text)));return s},selectProposal(e,t){let o=e.end,s=e.end;["SYMBOL","FUNCTION"].includes(e.type)&&(o=e.start);const i=this.composer.currentTokens;t+="(";const n=i.map((e=>e.start)).indexOf(e.start);if(n+1<i.length){const e=i[n+1];"LEFT_PAREN"===e?.type&&s++}this.composer.changeComposerCursorSelection(o,s),this.composer.replaceComposerCursorSelection(t)}});class Df{mutators=["setFocusableElement","focus"];focusableElement=void 0;setFocusableElement(e){this.focusableElement=e}focus(){this.focusableElement?.focus()}}const Mf={};let Ff=0;function Nf(e,...t){const o="__sheet__"+Ff++;return function(e,t){const o=document.createElement("style");o.textContent=function(e){const t=e.split(/(\{|\}|;)/).map((e=>e.trim())),o=[],s=[];let i=[];function n(e,t){const s=[];for(const i of o[e]){let r=t&&t+" "+i||i;r.includes("&")&&(r=i.replace(/&/g,t||"")),e<o.length-1&&(r=n(e+1,r)),s.push(r)}return s.join(", ")}function r(){i.length&&(s.push(n(0)+" {"),s.push(...i),s.push("}"),i=[])}for(;t.length;){let e=t.shift();"}"===e?(r(),o.pop()):("{"===t[0]&&(r(),o.push(e.split(/\s*,\s*/)),t.shift()),";"===t[0]&&i.push(" "+e+";"))}return s.join("\n")}(t),Mf[e]=o}(o,String.raw(e,...t)),function(e){const t=Mf[e];t.setAttribute("component",e),document.head.appendChild(t)}(o),o}function Pf({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function Lf(e){const t=function(e){const t={};if(!e)return t;e.bold&&(t["font-weight"]="bold");e.italic&&(t["font-style"]="italic");if(e.strikethrough||e.underline){let o=e.strikethrough?"line-through":"";o=e.underline?o+" underline":o,t["text-decoration"]=o}e.textColor&&(t.color=e.textColor);return t}(e);return e?(e.fillColor&&(t.background=e.fillColor),t):t}function kf(e){let t="";for(const o in e)e[o]&&(t+=`${o}:${e[o]}; `);return t}const Vf=/Mac/i,Uf=["Shift","Control","Alt","Meta"];function Bf(e,t){return!!t.target&&e.contains(t.target)}function Hf(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:o}=e?.getBoundingClientRect();return{top:t,left:o}}throw new Error("Can't find spreadsheet position")}function zf(e){const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}function*$f(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*$f(t)}const Gf=/^[a-zA-Z]$/;function Wf(e,t="key"){let o="";Uf.includes(e.key)||(Zf(e)&&(o+="Ctrl+"),e.altKey&&(o+="Alt+"),e.shiftKey&&(o+="Shift+"));const s="key"===t?e.key:e.code;return o+=Gf.test(s)?s.toUpperCase():s,o}function qf(){return Boolean(Vf.test(navigator.userAgent))}function Zf(e){return qf()?e.metaKey:e.ctrlKey}const Yf={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"};function jf(e,t){const o=Yf[e.key];e.shiftKey?t.resizeAnchorZone(o,Zf(e)?"end":1):t.moveAnchorCell(o,Zf(e)?"end":1)}Nf`
|
|
2
2
|
.o-autocomplete-dropdown {
|
|
3
3
|
pointer-events: auto;
|
|
4
4
|
cursor: pointer;
|
|
@@ -1163,7 +1163,7 @@
|
|
|
1163
1163
|
background-color: white;
|
|
1164
1164
|
}
|
|
1165
1165
|
}
|
|
1166
|
-
`;class $w extends t.Component{static template="o-spreadsheet-PivotDimension";static props={dimension:Object,onRemoved:{type:Function,optional:!0},slots:{type:Object,optional:!0}}}class Gw extends t.Component{static template="o-spreadsheet-PivotDimensionGranularity";static props={dimension:Object,onUpdated:Function,availableGranularities:Set,allGranularities:Array};periods=Mb}class Ww extends t.Component{static template="o-spreadsheet-PivotDimensionOrder";static props={dimension:Object,onUpdated:Function}}class qw extends t.Component{static template="o-spreadsheet-PivotLayoutConfigurator";static components={AddDimensionButton:zw,PivotDimension:$w,PivotDimensionOrder:Ww,PivotDimensionGranularity:Gw};static props={definition:Object,onDimensionsUpdated:Function,unusedGroupableFields:Array,unusedMeasureFields:Array,unusedDateTimeGranularities:Object,allGranularities:Array};dimensionsRef=t.useRef("pivot-dimensions");dragAndDrop=hw();AGGREGATORS=Rb;isDateField=Pb;startDragAndDrop(e,t){if(0!==t.button||"SELECT"===t.target.tagName)return;const o=this.getDimensionElementsRects(),s=this.props.definition,{columns:i,rows:n}=s,r=[...i.map((e=>e.nameWithGranularity)),"__rows_title__",...n.map((e=>e.nameWithGranularity))],a=r.map(((e,t)=>({id:e,size:o[t+1].height,position:o[t+1].y})));this.dragAndDrop.start("vertical",{draggedItemId:e.nameWithGranularity,initialMousePosition:t.clientY,items:a,containerEl:this.dimensionsRef.el,onDragEnd:(e,t)=>{const o=r.findIndex((t=>t===e));if(o===t)return;const s=[...r];s.splice(o,1),s.splice(t,0,e);const i=s.slice(0,s.indexOf("__rows_title__")),n=s.slice(s.indexOf("__rows_title__")+1);this.props.onDimensionsUpdated({columns:i.map(Nb),rows:n.map(Nb)})}})}startDragAndDropMeasures(e,t){if(0!==t.button||"SELECT"===t.target.tagName)return;const o=this.getDimensionElementsRects(),s=this.props.definition,{measures:i,columns:n,rows:r}=s,a=i.map((e=>e.name)),l=3+n.length+r.length,c=a.map(((e,t)=>({id:e,size:o[t+l].height,position:o[t+l].y})));this.dragAndDrop.start("vertical",{draggedItemId:e.name,initialMousePosition:t.clientY,items:c,containerEl:this.dimensionsRef.el,onDragEnd:(e,t)=>{const o=a.findIndex((t=>t===e));if(o===t)return;const s=[...a];s.splice(o,1),s.splice(t,0,e),this.props.onDimensionsUpdated({measures:s.map((e=>i.find((t=>t.name===e)))).filter(De)})}})}getDimensionElementsRects(){return Array.from(this.dimensionsRef.el.children).map((e=>{const t=getComputedStyle(e),o=e.getBoundingClientRect();return{x:o.x,y:o.y,width:o.width+parseInt(t.marginLeft||"0")+parseInt(t.marginRight||"0"),height:o.height+parseInt(t.marginTop||"0")+parseInt(t.marginBottom||"0")}}))}removeDimension(e){const{columns:t,rows:o}=this.props.definition;this.props.onDimensionsUpdated({columns:t.filter((t=>t.nameWithGranularity!==e.nameWithGranularity)),rows:o.filter((t=>t.nameWithGranularity!==e.nameWithGranularity))})}removeMeasureDimension(e){const{measures:t}=this.props.definition;this.props.onDimensionsUpdated({measures:t.filter((t=>t.name!==e.name))})}addColumnDimension(e){const{columns:t}=this.props.definition;this.props.onDimensionsUpdated({columns:t.concat([{name:e,order:"asc"}])})}addRowDimension(e){const{rows:t}=this.props.definition;this.props.onDimensionsUpdated({rows:t.concat([{name:e,order:"asc"}])})}addMeasureDimension(e){const{measures:t}=this.props.definition;this.props.onDimensionsUpdated({measures:t.concat([{name:e}])})}updateAggregator(e,t){const{measures:o}=this.props.definition;this.props.onDimensionsUpdated({measures:o.map((o=>o===e?{...o,aggregator:t}:o))})}updateOrder(e,t){const{rows:o,columns:s}=this.props.definition;this.props.onDimensionsUpdated({rows:o.map((o=>o.nameWithGranularity===e.nameWithGranularity?{...o,order:t||void 0}:o)),columns:s.map((o=>o.nameWithGranularity===e.nameWithGranularity?{...o,order:t||void 0}:o))})}updateGranularity(e,t){const{rows:o,columns:s}=this.props.definition;this.props.onDimensionsUpdated({rows:o.map((o=>o.nameWithGranularity===e.nameWithGranularity?{...o,granularity:t}:o)),columns:s.map((o=>o.nameWithGranularity===e.nameWithGranularity?{...o,granularity:t}:o))})}}class Zw{measures;columns;rows;constructor(e,t){this.measures=e.measures.map((e=>function(e,t){const o=t.name,s="__count"===o?{name:"__count",string:uo("Count"),type:"integer",aggregator:"sum"}:e[o],i=t.aggregator||s?.aggregator;return{nameWithAggregator:o+(i?`:${i}`:""),displayName:s?.string??o,name:o,aggregator:i,type:"__count"===o?"integer":s?.type??"integer",isValid:!!s}}(t,e))),this.columns=e.columns.map((e=>Yw(t,e))),this.rows=e.rows.map((e=>Yw(t,e)))}getDimension(e){const t=this.columns.find((t=>t.nameWithGranularity===e))||this.rows.find((t=>t.nameWithGranularity===e));if(!t)throw new Lo(uo("Dimension %s does not exist",e));return t}getMeasure(e){const t=this.measures.find((t=>t.name===e));if(!t)throw new Lo(uo("Field %s does not exist",e));return t}}function Yw(e,t){const o=e[t.name],s=o?.type??"integer",i=o&&Pb(o)?t.granularity??"month_number":void 0;return{displayName:o?.string??t.name,nameWithGranularity:t.name+(i?`:${i}`:""),name:t.name,granularity:i,type:s,order:t.order,isValid:!!o}}class jw extends Zw{range;constructor(e,t,o){if(super(e,t),e.dataSet){const{sheetId:t,zone:s}=e.dataSet;this.range=o.getRangeFromZone(t,s)}}}class Xw{columns;rows;measures;rowTitle;maxIndent;pivotCells={};constructor(e,t,o,s=""){this.columns=e.map((e=>{let t=1;return e.map((e=>(e={...e,offset:t},t+=e.width,e)))})),this.rows=t,this.measures=o,this.rowTitle=s,this.maxIndent=Math.max(...this.rows.map((e=>e.indent)))}getNumberOfDataColumns(){return this.columns.at(-1)?.length||0}getPivotCells(e=!0,t=!0){const o=JSON.stringify({includeTotal:e,includeColumnHeaders:t});if(!this.pivotCells[o]){const s=this.rows.length,i=this.getNumberOfDataColumns();let n=this.columns.length+s,r=1+i;e||1===s||(n-=1),e||i===this.measures.length||(r-=this.measures.length);const a=[],l=t?0:this.columns.length;for(let t=0;t<r;t++){a.push([]);for(let o=l;o<n;o++)(e||o!==n)&&a[t].push(this.getPivotCell(t,o,e))}this.pivotCells[o]=a}return this.pivotCells[o]}isTotalRow(e){return this.rows[e].indent!==this.maxIndent}getPivotCell(e,t,o=!0){const s=this.columns.length;if(0===e&&t===s-1)return{content:this.rowTitle,isHeader:!0};if(t<=s-1){return{domain:this.getColHeaderDomain(e,t),isHeader:!0}}if(0===e){const e=t-s;return{domain:this.getRowDomain(e),isHeader:!0}}{const i=t-s;if(!o&&this.isTotalRow(i))return{isHeader:!1};return{domain:[...this.getRowDomain(i),...this.getColDomain(e)],isHeader:!1,measure:this.getColMeasure(e)}}}getColHeaderDomain(e,t){if(0===e)return;const o=[],s=this.columns[t].find((t=>t.offset===e));if(s){for(let e=0;e<s.fields.length;e++)o.push(s.fields[e]),o.push(s.values[e]);return o}}getColDomain(e){const t=this.getColHeaderDomain(e,this.columns.length-1);return t?t.slice(0,-2):[]}getColMeasure(e){const t=this.getColHeaderDomain(e,this.columns.length-1);return t?.at(-1)}getRowDomain(e){const t=[];for(let o=0;o<this.rows[e].fields.length;o++)t.push(this.rows[e].fields[o]),t.push(this.rows[e].values[o]);return t}export(){return{cols:this.columns,rows:this.rows,measures:this.measures,rowTitle:this.rowTitle}}}function Kw(e,t){const o=Jw(e,t.columns,0);eI(o,t.measures.length);const s=function(e,t){const o=t.columns.map((e=>e.nameWithGranularity)),s=o.length,i=t.measures.length,n=new Array(s).fill(0).map((()=>[]));function r(e,t,i){const a=n[t];for(const n of e){const e=i.concat([n.value]),l={fields:o.slice(0,t+1),values:e,width:n.width,offset:0};a.push(l),t<=s-1&&r(n.children,t+1,e)}}r(e,0,[]);const a=o.length>0,l=[];a&&n[n.length-1].forEach((e=>{t.measures.forEach((t=>{const o={fields:[...e.fields,"measure"],values:[...e.values,t.name],width:1,offset:0};l.push(o)}))}));t.measures.forEach((e=>{const t={fields:["measure"],values:[e.name],width:1,offset:0};l.push(t)})),n.push(l),1===n.length&&n.unshift([]);return n[n.length-2].push({fields:[],values:[],width:i,offset:0}),n}(o,t),i=Qw(e,0,t.rows,[],[]);i.push({fields:[],values:[],indent:0});const n=t.measures.map((e=>e.name)),r=i.length>0?i[0].values[0]:"";return new Xw(s,i,n,r)}function Qw(e,t,o,s,i){if(t>=o.length)return[];const n=o[t],r=n.nameWithGranularity,a=tI(e,n),l=oI(a,n),c=[],h=s.concat(r);for(const e of l){const s=i.concat(e);c.push({fields:h,values:s,indent:t});const n=a[e];n&&c.push(...Qw(n,t+1,o,h,s))}return c}function Jw(e,t,o){if(o>=t.length)return[];const s=t[o],i=t[o].nameWithGranularity,n=tI(e,s);return oI(n,t[o]).map((e=>({value:e,field:i,children:Jw(n[e]||[],t,o+1),width:0})))}function eI(e,t){for(const o in e){const s=e[o];0===s.children.length?s.width=t:(eI(s.children,t),s.width=s.children.reduce(((e,t)=>e+t.width),0))}}function tI(e,t){return Object.groupBy(e,function(e){const t=e.nameWithGranularity;return e=>`${e[t]?.value??null}`}(t))}function oI(e,t){return t.order?Object.keys(e).sort(((e,o)=>function(e,t,o){if("integer"===e.type||"date"===e.type)return"asc"===e.order?Number(t)-Number(o):Number(o)-Number(t);return"asc"===e.order?t.localeCompare(o):o.localeCompare(t)}(t,e,o))):Object.keys(e)}function sI(e,t,o){const s=e.granularity||"month_number";if(!(s in iI))throw new Error(`Unknown date granularity: ${s}`);if(!iI[s].set.has(t)){iI[s].set.add(t);const e=ns(t,o);let i=0;switch(s){case"year_number":i=e.getFullYear();break;case"quarter_number":i=Math.floor(e.getMonth()/3)+1;break;case"month_number":i=e.getMonth();break;case"iso_week_number":i=e.getIsoWeek();break;case"day_of_month":i=e.getDate();break;case"day":i=Math.floor(Zo(t,o))}iI[s].values[`${t}`]=i}return iI[s].values[`${t}`]}const iI={year_number:{set:new Set,values:{}},quarter_number:{set:new Set,values:{}},month_number:{set:new Set,values:{}},iso_week_number:{set:new Set,values:{}},day_of_month:{set:new Set,values:{}},day:{set:new Set,values:{}}};const nI=new zn;nI.add("SPREADSHEET",{ui:class{type="SPREADSHEET";getters;_definition;coreDefinition;dataEntries=[];fields={};fieldKeys=[];table;invalidRangeError;needsReevaluation=!0;constructor(e,t){this.getters=t.getters,this.coreDefinition=t.definition}init(e={}){if(!this._definition||e.reload){if(this.invalidRangeError=void 0,this.coreDefinition.dataSet){const{zone:e,sheetId:t}=this.coreDefinition.dataSet,o=this.getters.getRangeFromZone(t,e);try{({fields:this.fields,fieldKeys:this.fieldKeys}=this.extractFieldsFromRange(o))}catch(e){this.fields={},this.fieldKeys=[],this.invalidRangeError=e}}else this.invalidRangeError=new Lo(uo("The pivot cannot be created because the dataset is missing."));this._definition=new jw(this.coreDefinition,this.fields,this.getters),this.table=void 0,this.dataEntries=[];const e=this._definition.range;this.isValid()&&e&&(this.dataEntries=this.extractDataEntriesFromRange(e)),this.needsReevaluation=!1}}get isInvalidRange(){return!!this.invalidRangeError}get invalidRangeMessage(){return this.invalidRangeError?.message}get definition(){if(!this._definition)throw new Error("Pivot not loaded yet");return this._definition}isValid(){if(this.invalidRangeError||!this._definition)return!1;for(const e of this.definition.measures)if(!e.isValid)return!1;for(const e of this.definition.columns)if(!e.isValid)return!1;for(const e of this.definition.rows)if(!e.isValid)return!1;return!0}assertIsValid({throwOnError:e}){if(!this.isValid()){if(e)throw this.invalidRangeError?this.invalidRangeError:new Lo(uo("At least one measure and/or dimension is not correct."));return{value:No.GenericError,message:this.invalidRangeError?.message??uo("At least one measure and/or dimension is not correct.")}}}markAsDirtyForEvaluation(){this.needsReevaluation=!0}getMeasure(e){return this.definition.getMeasure(e)}getPivotHeaderValueAndFormat(e){const t=Bb(e),o=t.at(-1);if(!o)return{value:uo("Total")};if("measure"===o.field)return{value:this.getMeasure(o.value).displayName};const s=this.getDimension(o.field),i=this.filterDataEntriesFromDomain(this.dataEntries,t),n=i[0]?.[s.nameWithGranularity];if(!n)return{value:""};if(null===n.value)return{value:uo("(Undefined)")};if("date"===s.type){if("day"===s.granularity)return{value:Zo(n.value,this.getters.getLocale()),format:this.getters.getLocale().dateFormat};if("month_number"===s.granularity)return{value:ks[Zo(n.value,this.getters.getLocale())].toString()}}return{value:n.value,format:n.format}}getPivotCellValueAndFormat(e,t){const o=Bb(t),s=this.filterDataEntriesFromDomain(this.dataEntries,o);if(0===s.length)return{value:""};const i=s.map((t=>t[e])).filter((e=>e&&e.type!==po.empty)).filter(De),n=this.getMeasure(e).aggregator||"count",r=Tb[n];if(!r)throw new Error(`Aggregator ${n} does not exist`);return{value:i.length?r.fn([i],this.getters.getLocale()):"",format:r.format(i[0])}}getPossibleFieldValues(e){throw new Error("Method not implemented.")}getTableStructure(){if(!this.isValid())throw new Error("Pivot is not valid !");return this.table||(this.table=Kw(this.dataEntries,this.definition)),this.table}getFields(){return this.fields}filterDataEntriesFromDomain(e,t){return t.reduce(((e,t)=>this.filterDataEntriesFromDomainNode(e,t)),e)}filterDataEntriesFromDomainNode(e,t){const{field:o,value:s}=t,i=this.getDimension(o);return e.filter((e=>`${e[i.nameWithGranularity]?.value}`===s))}getDimension(e){return this.definition.getDimension(e)}getTypeFromZone(e,t){const o=this.getters.getEvaluatedCellsInZone(e,t).filter((e=>e.type!==po.empty));return 0===o.length?"integer":o.every((e=>e.format&&Ys(e.format)))?"date":o.every((e=>e.type===po.boolean))?"boolean":o.some((e=>e.type===po.text))?"char":"integer"}assertCellIsValidField(e,t,o){if(o.type===po.error)throw new Lo(uo("The pivot cannot be created because cell %s contains an error",Tt(e,t)));if(o.type===po.empty)throw new Lo(uo("The pivot cannot be created because cell %s is empty",Tt(e,t)));if("__count"===o.value)throw new Lo(uo("The pivot cannot be created because cell %s contains a reserved value",Tt(e,t)))}extractFieldsFromRange(e){const t={},o=[],s=e.sheetId,i=e.zone.top;for(let n=e.zone.left;n<=e.zone.right;n++){const r=this.getters.getEvaluatedCell({sheetId:s,col:n,row:i});this.assertCellIsValidField(n,i,r);const a=r.value?.toString();if(a){const i=this.getTypeFromZone(s,{top:e.zone.top+1,left:n,bottom:e.zone.bottom,right:n}),r=this.findName(a,t);t[r]={name:r,type:i,string:r,aggregator:"integer"===i?"sum":"count"},o.push(r)}}return{fields:t,fieldKeys:o}}findName(e,t){let o=1;const s=e;for(;e in t;)e=`${s}${++o}`;return e}extractDataEntriesFromRange(e){const t=[];for(let o=e.zone.top+1;o<=e.zone.bottom;o++){const s={top:o,bottom:o,left:e.zone.left,right:e.zone.right},i=this.getters.getEvaluatedCellsInZone(e.sheetId,s),n={};for(const e in i){const t=i[e],o=this.fields[this.fieldKeys[e]];if(!o)throw new Error(`Field ${this.fieldKeys[e]} does not exist`);""===t.value?n[o.name]={value:null,type:po.empty}:n[o.name]=t}n.__count={value:1,type:po.number},t.push(n)}const o=this.definition.columns.concat(this.definition.rows).filter((e=>"date"===e.type));if(o.length)for(const e of t)for(const t of o)e[t.nameWithGranularity]={value:`${sI(t,e[t.name]?.value||null,this.getters.getLocale())}`,type:e[t.name]?.type||po.empty,format:e[t.name]?.format};return t}},definition:jw,externalData:!1,onIterationEndEvaluation:e=>e.markAsDirtyForEvaluation(),granularities:["year_number","quarter_number","month_number","iso_week_number","day_of_month","day"],isMeasureCandidate:e=>!["date","boolean"].includes(e.type),isGroupable:()=>!0});class rI extends Qa{pivotId;mutators=["applyUpdate","renamePivot","update"];updatesAreDeferred=!0;draft=null;constructor(e,t){super(e),this.pivotId=t}handle(e){if("UPDATE_PIVOT"===e.type)e.pivotId===this.pivotId&&this.getters.getPivot(this.pivotId).init()}get fields(){const e=this.pivot.getFields();if(!e)throw new Error("Fields not found");return e}get pivot(){return this.getters.getPivot(this.pivotId)}get definition(){const e=nI.get(this.pivot.type).definition;return this.draft?new e(this.draft,this.fields,this.getters):this.pivot.definition}get isDirty(){return!!this.draft}get unusedMeasureFields(){const e=[{name:"__count",string:uo("Count"),type:"integer",aggregator:"sum"}],t=this.fields;for(const o in t){const s=t[o];s&&(nI.get(this.pivot.type).isMeasureCandidate(s)&&e.push(s))}const{rows:o,columns:s,measures:i}=this.definition,n=i.concat(o).concat(s).map((e=>e.name));return e.filter((e=>!n.includes(e.name))).sort(((e,t)=>e.string.localeCompare(t.string)))}get unusedGroupableFields(){const e=[],t=this.fields;for(const o in t){const s=t[o];s&&(nI.get(this.pivot.type).isGroupable(s)&&e.push(s))}const{columns:o,rows:s,measures:i}=this.definition,n=i.concat(s).concat(o).map((e=>e.name)),r=this.unusedDateTimeGranularities;return e.filter((e=>Pb(e)?!n.includes(e.name)||r[e.name].size>0:!n.includes(e.name))).sort(((e,t)=>e.string.localeCompare(t.string)))}get allGranularities(){return nI.get(this.pivot.type).granularities}get unusedDateTimeGranularities(){return this.getUnusedDateTimeGranularities(this.fields,this.draft??this.getters.getPivotCoreDefinition(this.pivotId))}reset(e){this.pivotId=e,this.updatesAreDeferred=!0,this.draft=null}deferUpdates(e){this.updatesAreDeferred=e,!1===e&&this.draft&&this.applyUpdate()}applyUpdate(){this.draft&&(this.model.dispatch("UPDATE_PIVOT",{pivotId:this.pivotId,pivot:this.draft}),this.draft=null)}discardPendingUpdate(){this.draft=null}renamePivot(e){const t=this.getters.getPivotCoreDefinition(this.pivotId);this.model.dispatch("UPDATE_PIVOT",{pivotId:this.pivotId,pivot:{...t,name:e}})}update(e){const t=this.getters.getPivotCoreDefinition(this.pivotId),o={...t,...this.draft,...e},s={...o,columns:o.columns.map((e=>({name:e.name,order:e.order,granularity:e.granularity}))),rows:o.rows.map((e=>({name:e.name,order:e.order,granularity:e.granularity}))),measures:o.measures.map((e=>({name:e.name,aggregator:e.aggregator})))};if(!this.draft&&Be(t,s))return;const i=this.addDefaultDateTimeGranularity(this.fields,s);this.updatesAreDeferred?this.draft=i:this.model.dispatch("UPDATE_PIVOT",{pivotId:this.pivotId,pivot:i})}addDefaultDateTimeGranularity(e,t){const{columns:o,rows:s}=t,i=ge(o),n=ge(s),r=this.getUnusedDateTimeGranularities(e,t);for(const t of i.concat(n)){const o=e[t.name]?.type;if(("date"===o||"datetime"===o)&&!t.granularity){const e=r[t.name]?.values().next().value||"year";r[t.name]?.delete(e),t.granularity=e}}return{...t,columns:i,rows:n}}getUnusedDateTimeGranularities(e,t){const{columns:o,rows:s}=t,i=o.concat(s).filter((t=>{const o=e[t.name]?.type;return"date"===o||"datetime"===o})),n=this.allGranularities,r={};for(const e of i)r[e.name]=new Set(n);for(const e of i)r[e.name].delete(e.granularity);return r}}class aI extends t.Component{static template="o-spreadsheet-PivotSpreadsheetSidePanel";static props={pivotId:String,onCloseSidePanel:Function};static components={PivotLayoutConfigurator:qw,Section:Ix,SelectionInput:Ax,EditableName:Hw,Checkbox:wx};store;state;setup(){this.store=Wa(rI,this.props.pivotId),this.pivot.init(),this.state=t.useState({range:void 0,rangeHasChanged:!1})}get shouldDisplayInvalidRangeError(){return(!this.store.isDirty||!this.state.rangeHasChanged)&&this.pivot.isInvalidRange}get ranges(){return this.state.range?[this.state.range]:this.definition.range?[this.env.model.getters.getRangeString(this.definition.range,"forceSheetReference")]:[]}get pivot(){return this.store.pivot}get name(){return this.env.model.getters.getPivotName(this.props.pivotId)}get displayName(){return this.env.model.getters.getPivotDisplayName(this.props.pivotId)}get definition(){return this.store.definition}get deferUpdatesLabel(){return uo("Defer updates")}get deferUpdatesTooltip(){return uo("Changing the pivot definition requires to reload the data. It may take some time.")}onSelectionChanged(e){this.state.rangeHasChanged=!0,this.state.range=e[0]}onSelectionConfirmed(){if(this.state.range){const{sheetName:e,xc:t}=Ti(this.state.range),o=e?this.env.model.getters.getSheetIdByName(e):this.env.model.getters.getActiveSheetId();if(!o)return;const s={sheetId:o,zone:Li(t)};this.store.update({dataSet:s}),this.store.applyUpdate()}}duplicatePivot(){const e=this.env.model.uuidGenerator.uuidv4(),t=this.env.model.dispatch("DUPLICATE_PIVOT",{pivotId:this.props.pivotId,newPivotId:e}),o=t.isSuccessful?uo("Pivot duplicated."):uo("Pivot duplication failed"),s=t.isSuccessful?"success":"danger";this.env.notifyUser({text:o,sticky:!1,type:s}),t.isSuccessful&&this.env.openSidePanel("PivotSidePanel",{pivotId:e})}onNameChanged(e){this.store.renamePivot(e)}onDimensionsUpdated(e){this.store.update(e)}back(){this.env.openSidePanel("PivotSidePanel",{})}delete(){this.env.model.dispatch("REMOVE_PIVOT",{pivotId:this.props.pivotId})}}const lI=new zn;lI.add("SPREADSHEET",{editor:aI}),Nf`
|
|
1166
|
+
`;class $w extends t.Component{static template="o-spreadsheet-PivotDimension";static props={dimension:Object,onRemoved:{type:Function,optional:!0},slots:{type:Object,optional:!0}}}class Gw extends t.Component{static template="o-spreadsheet-PivotDimensionGranularity";static props={dimension:Object,onUpdated:Function,availableGranularities:Set,allGranularities:Array};periods=Mb}class Ww extends t.Component{static template="o-spreadsheet-PivotDimensionOrder";static props={dimension:Object,onUpdated:Function}}class qw extends t.Component{static template="o-spreadsheet-PivotLayoutConfigurator";static components={AddDimensionButton:zw,PivotDimension:$w,PivotDimensionOrder:Ww,PivotDimensionGranularity:Gw};static props={definition:Object,onDimensionsUpdated:Function,unusedGroupableFields:Array,unusedMeasureFields:Array,unusedDateTimeGranularities:Object,allGranularities:Array};dimensionsRef=t.useRef("pivot-dimensions");dragAndDrop=hw();AGGREGATORS=Rb;isDateField=Pb;startDragAndDrop(e,t){if(0!==t.button||"SELECT"===t.target.tagName)return;const o=this.getDimensionElementsRects(),s=this.props.definition,{columns:i,rows:n}=s,r=[...i.map((e=>e.nameWithGranularity)),"__rows_title__",...n.map((e=>e.nameWithGranularity))],a=r.map(((e,t)=>({id:e,size:o[t+1].height,position:o[t+1].y})));this.dragAndDrop.start("vertical",{draggedItemId:e.nameWithGranularity,initialMousePosition:t.clientY,items:a,containerEl:this.dimensionsRef.el,onDragEnd:(e,t)=>{const o=r.findIndex((t=>t===e));if(o===t)return;const s=[...r];s.splice(o,1),s.splice(t,0,e);const i=s.slice(0,s.indexOf("__rows_title__")),n=s.slice(s.indexOf("__rows_title__")+1);this.props.onDimensionsUpdated({columns:i.map(Nb),rows:n.map(Nb)})}})}startDragAndDropMeasures(e,t){if(0!==t.button||"SELECT"===t.target.tagName)return;const o=this.getDimensionElementsRects(),s=this.props.definition,{measures:i,columns:n,rows:r}=s,a=i.map((e=>e.name)),l=3+n.length+r.length,c=a.map(((e,t)=>({id:e,size:o[t+l].height,position:o[t+l].y})));this.dragAndDrop.start("vertical",{draggedItemId:e.name,initialMousePosition:t.clientY,items:c,containerEl:this.dimensionsRef.el,onDragEnd:(e,t)=>{const o=a.findIndex((t=>t===e));if(o===t)return;const s=[...a];s.splice(o,1),s.splice(t,0,e),this.props.onDimensionsUpdated({measures:s.map((e=>i.find((t=>t.name===e)))).filter(De)})}})}getDimensionElementsRects(){return Array.from(this.dimensionsRef.el.children).map((e=>{const t=getComputedStyle(e),o=e.getBoundingClientRect();return{x:o.x,y:o.y,width:o.width+parseInt(t.marginLeft||"0")+parseInt(t.marginRight||"0"),height:o.height+parseInt(t.marginTop||"0")+parseInt(t.marginBottom||"0")}}))}removeDimension(e){const{columns:t,rows:o}=this.props.definition;this.props.onDimensionsUpdated({columns:t.filter((t=>t.nameWithGranularity!==e.nameWithGranularity)),rows:o.filter((t=>t.nameWithGranularity!==e.nameWithGranularity))})}removeMeasureDimension(e){const{measures:t}=this.props.definition;this.props.onDimensionsUpdated({measures:t.filter((t=>t.name!==e.name))})}addColumnDimension(e){const{columns:t}=this.props.definition;this.props.onDimensionsUpdated({columns:t.concat([{name:e,order:"asc"}])})}addRowDimension(e){const{rows:t}=this.props.definition;this.props.onDimensionsUpdated({rows:t.concat([{name:e,order:"asc"}])})}addMeasureDimension(e){const{measures:t}=this.props.definition;this.props.onDimensionsUpdated({measures:t.concat([{name:e}])})}updateAggregator(e,t){const{measures:o}=this.props.definition;this.props.onDimensionsUpdated({measures:o.map((o=>o===e?{...o,aggregator:t}:o))})}updateOrder(e,t){const{rows:o,columns:s}=this.props.definition;this.props.onDimensionsUpdated({rows:o.map((o=>o.nameWithGranularity===e.nameWithGranularity?{...o,order:t||void 0}:o)),columns:s.map((o=>o.nameWithGranularity===e.nameWithGranularity?{...o,order:t||void 0}:o))})}updateGranularity(e,t){const{rows:o,columns:s}=this.props.definition;this.props.onDimensionsUpdated({rows:o.map((o=>o.nameWithGranularity===e.nameWithGranularity?{...o,granularity:t}:o)),columns:s.map((o=>o.nameWithGranularity===e.nameWithGranularity?{...o,granularity:t}:o))})}}class Zw{measures;columns;rows;constructor(e,t){this.measures=e.measures.map((e=>function(e,t){const o=t.name,s="__count"===o?{name:"__count",string:uo("Count"),type:"integer",aggregator:"sum"}:e[o],i=t.aggregator||s?.aggregator;return{nameWithAggregator:o+(i?`:${i}`:""),displayName:s?.string??o,name:o,aggregator:i,type:"__count"===o?"integer":s?.type??"integer",isValid:!!s}}(t,e))),this.columns=e.columns.map((e=>Yw(t,e))),this.rows=e.rows.map((e=>Yw(t,e)))}getDimension(e){const t=this.columns.find((t=>t.nameWithGranularity===e))||this.rows.find((t=>t.nameWithGranularity===e));if(!t)throw new Lo(uo("Dimension %s does not exist",e));return t}getMeasure(e){const t=this.measures.find((t=>t.name===e));if(!t)throw new Lo(uo("Field %s does not exist",e));return t}}function Yw(e,t){const o=e[t.name],s=o?.type??"integer",i=o&&Pb(o)?t.granularity??"month_number":void 0;return{displayName:o?.string??t.name,nameWithGranularity:t.name+(i?`:${i}`:""),name:t.name,granularity:i,type:s,order:t.order,isValid:!!o}}class jw extends Zw{range;constructor(e,t,o){if(super(e,t),e.dataSet){const{sheetId:t,zone:s}=e.dataSet;this.range=o.getRangeFromZone(t,s)}}}class Xw{columns;rows;measures;rowTitle;maxIndent;pivotCells={};constructor(e,t,o,s=""){this.columns=e.map((e=>{let t=1;return e.map((e=>(e={...e,offset:t},t+=e.width,e)))})),this.rows=t,this.measures=o,this.rowTitle=s,this.maxIndent=Math.max(...this.rows.map((e=>e.indent)))}getNumberOfDataColumns(){return this.columns.at(-1)?.length||0}getPivotCells(e=!0,t=!0){const o=JSON.stringify({includeTotal:e,includeColumnHeaders:t});if(!this.pivotCells[o]){const s=this.rows.length,i=this.getNumberOfDataColumns();let n=this.columns.length+s,r=1+i;e||1===s||(n-=1),e||i===this.measures.length||(r-=this.measures.length);const a=[],l=t?0:this.columns.length;for(let t=0;t<r;t++){a.push([]);for(let o=l;o<n;o++)(e||o!==n)&&a[t].push(this.getPivotCell(t,o,e))}this.pivotCells[o]=a}return this.pivotCells[o]}isTotalRow(e){return this.rows[e].indent!==this.maxIndent}getPivotCell(e,t,o=!0){const s=this.columns.length;if(0===e&&t===s-1)return{content:this.rowTitle,isHeader:!0};if(t<=s-1){return{domain:this.getColHeaderDomain(e,t),isHeader:!0}}if(0===e){const e=t-s;return{domain:this.getRowDomain(e),isHeader:!0}}{const i=t-s;if(!o&&this.isTotalRow(i))return{isHeader:!1};return{domain:[...this.getRowDomain(i),...this.getColDomain(e)],isHeader:!1,measure:this.getColMeasure(e)}}}getColHeaderDomain(e,t){if(0===e)return;const o=[],s=this.columns[t].find((t=>t.offset===e));if(s){for(let e=0;e<s.fields.length;e++)o.push(s.fields[e]),o.push(s.values[e]);return o}}getColDomain(e){const t=this.getColHeaderDomain(e,this.columns.length-1);return t?t.slice(0,-2):[]}getColMeasure(e){const t=this.getColHeaderDomain(e,this.columns.length-1);return t?.at(-1)}getRowDomain(e){const t=[];for(let o=0;o<this.rows[e].fields.length;o++)t.push(this.rows[e].fields[o]),t.push(this.rows[e].values[o]);return t}export(){return{cols:this.columns,rows:this.rows,measures:this.measures,rowTitle:this.rowTitle}}}function Kw(e,t){const o=Jw(e,t.columns,0);eI(o,t.measures.length);const s=function(e,t){const o=t.columns.map((e=>e.nameWithGranularity)),s=o.length,i=t.measures.length,n=new Array(s).fill(0).map((()=>[]));function r(e,t,i){const a=n[t];for(const n of e){const e=i.concat([n.value]),l={fields:o.slice(0,t+1),values:e,width:n.width,offset:0};a.push(l),t<=s-1&&r(n.children,t+1,e)}}r(e,0,[]);const a=o.length>0,l=[];a&&n[n.length-1].forEach((e=>{t.measures.forEach((t=>{const o={fields:[...e.fields,"measure"],values:[...e.values,t.name],width:1,offset:0};l.push(o)}))}));t.measures.forEach((e=>{const t={fields:["measure"],values:[e.name],width:1,offset:0};l.push(t)})),n.push(l),1===n.length&&n.unshift([]);return n[n.length-2].push({fields:[],values:[],width:i,offset:0}),n}(o,t),i=Qw(e,0,t.rows,[],[]);i.push({fields:[],values:[],indent:0});const n=t.measures.map((e=>e.name)),r=i.length>0?i[0].values[0]:"";return new Xw(s,i,n,r)}function Qw(e,t,o,s,i){if(t>=o.length)return[];const n=o[t],r=n.nameWithGranularity,a=tI(e,n),l=oI(a,n),c=[],h=s.concat(r);for(const e of l){const s=i.concat(e);c.push({fields:h,values:s,indent:t});const n=a[e];n&&c.push(...Qw(n,t+1,o,h,s))}return c}function Jw(e,t,o){if(o>=t.length)return[];const s=t[o],i=t[o].nameWithGranularity,n=tI(e,s);return oI(n,t[o]).map((e=>({value:e,field:i,children:Jw(n[e]||[],t,o+1),width:0})))}function eI(e,t){for(const o in e){const s=e[o];0===s.children.length?s.width=t:(eI(s.children,t),s.width=s.children.reduce(((e,t)=>e+t.width),0))}}function tI(e,t){return Object.groupBy(e,function(e){const t=e.nameWithGranularity;return e=>`${e[t]?.value??null}`}(t))}function oI(e,t){return t.order?Object.keys(e).sort(((e,o)=>function(e,t,o){if("integer"===e.type||"date"===e.type)return"asc"===e.order?Number(t)-Number(o):Number(o)-Number(t);return"asc"===e.order?t.localeCompare(o):o.localeCompare(t)}(t,e,o))):Object.keys(e)}function sI(e,t,o){const s=e.granularity||"month_number";if(!(s in iI))throw new Error(`Unknown date granularity: ${s}`);if(!iI[s].set.has(t)){iI[s].set.add(t);const e=ns(t,o);let i=0;switch(s){case"year_number":i=e.getFullYear();break;case"quarter_number":i=Math.floor(e.getMonth()/3)+1;break;case"month_number":i=e.getMonth();break;case"iso_week_number":i=e.getIsoWeek();break;case"day_of_month":i=e.getDate();break;case"day":i=Math.floor(Zo(t,o))}iI[s].values[`${t}`]=i}return iI[s].values[`${t}`]}const iI={year_number:{set:new Set,values:{}},quarter_number:{set:new Set,values:{}},month_number:{set:new Set,values:{}},iso_week_number:{set:new Set,values:{}},day_of_month:{set:new Set,values:{}},day:{set:new Set,values:{}}};const nI=new zn;nI.add("SPREADSHEET",{ui:class{type="SPREADSHEET";getters;_definition;coreDefinition;dataEntries=[];fields={};fieldKeys=[];table;invalidRangeError;needsReevaluation=!0;constructor(e,t){this.getters=t.getters,this.coreDefinition=t.definition}init(e={}){if(!this._definition||e.reload){if(this.invalidRangeError=void 0,this.coreDefinition.dataSet){const{zone:e,sheetId:t}=this.coreDefinition.dataSet,o=this.getters.getRangeFromZone(t,e);try{({fields:this.fields,fieldKeys:this.fieldKeys}=this.extractFieldsFromRange(o))}catch(e){this.fields={},this.fieldKeys=[],this.invalidRangeError=e}}else this.invalidRangeError=new Lo(uo("The pivot cannot be created because the dataset is missing."));this._definition=new jw(this.coreDefinition,this.fields,this.getters),this.table=void 0,this.dataEntries=[];const e=this._definition.range;this.isValid()&&e&&(this.dataEntries=this.extractDataEntriesFromRange(e)),this.needsReevaluation=!1}}get isInvalidRange(){return!!this.invalidRangeError}get invalidRangeMessage(){return this.invalidRangeError?.message}get definition(){if(!this._definition)throw new Error("Pivot not loaded yet");return this._definition}isValid(){if(this.invalidRangeError||!this._definition)return!1;for(const e of this.definition.measures)if(!e.isValid)return!1;for(const e of this.definition.columns)if(!e.isValid)return!1;for(const e of this.definition.rows)if(!e.isValid)return!1;return!0}assertIsValid({throwOnError:e}){if(!this.isValid()){if(e)throw this.invalidRangeError?this.invalidRangeError:new Lo(uo("At least one measure and/or dimension is not correct."));return{value:No.GenericError,message:this.invalidRangeError?.message??uo("At least one measure and/or dimension is not correct.")}}}markAsDirtyForEvaluation(){this.needsReevaluation=!0}getMeasure(e){return this.definition.getMeasure(e)}getPivotHeaderValueAndFormat(e){const t=Bb(e),o=t.at(-1);if(!o)return{value:uo("Total")};if("measure"===o.field)return{value:this.getMeasure(o.value).displayName};const s=this.getDimension(o.field),i=this.filterDataEntriesFromDomain(this.dataEntries,t),n=i[0]?.[s.nameWithGranularity];if(!n)return{value:""};if(null===n.value)return{value:uo("(Undefined)")};if("date"===s.type){if("day"===s.granularity)return{value:Zo(n.value,this.getters.getLocale()),format:this.getters.getLocale().dateFormat};if("month_number"===s.granularity)return{value:ks[Zo(n.value,this.getters.getLocale())].toString()}}return{value:n.value,format:n.format}}getPivotCellValueAndFormat(e,t){const o=Bb(t),s=this.filterDataEntriesFromDomain(this.dataEntries,o);if(0===s.length)return{value:""};const i=s.map((t=>t[e])).filter((e=>e&&e.type!==po.empty)).filter(De),n=this.getMeasure(e).aggregator||"count",r=Tb[n];if(!r)throw new Error(`Aggregator ${n} does not exist`);return{value:i.length?r.fn([i],this.getters.getLocale()):"",format:r.format(i[0])}}getPossibleFieldValues(e){throw new Error("Method not implemented.")}getTableStructure(){if(!this.isValid())throw new Error("Pivot is not valid !");return this.table||(this.table=Kw(this.dataEntries,this.definition)),this.table}getFields(){return this.fields}filterDataEntriesFromDomain(e,t){return t.reduce(((e,t)=>this.filterDataEntriesFromDomainNode(e,t)),e)}filterDataEntriesFromDomainNode(e,t){const{field:o,value:s}=t,i=this.getDimension(o);return e.filter((e=>`${e[i.nameWithGranularity]?.value}`===s))}getDimension(e){return this.definition.getDimension(e)}getTypeFromZone(e,t){const o=this.getters.getEvaluatedCellsInZone(e,t).filter((e=>e.type!==po.empty));return 0===o.length?"integer":o.every((e=>e.format&&Ys(e.format)))?"date":o.every((e=>e.type===po.boolean))?"boolean":o.some((e=>e.type===po.text))?"char":"integer"}assertCellIsValidField(e,t,o){if(o.type===po.error)throw new Lo(uo("The pivot cannot be created because cell %s contains an error",Tt(e,t)));if(o.type===po.empty)throw new Lo(uo("The pivot cannot be created because cell %s is empty",Tt(e,t)));if("__count"===o.value)throw new Lo(uo("The pivot cannot be created because cell %s contains a reserved value",Tt(e,t)))}extractFieldsFromRange(e){const t={},o=[],s=e.sheetId,i=e.zone.top;for(let n=e.zone.left;n<=e.zone.right;n++){const r=this.getters.getEvaluatedCell({sheetId:s,col:n,row:i});this.assertCellIsValidField(n,i,r);const a=r.value?.toString();if(a){const i=this.getTypeFromZone(s,{top:e.zone.top+1,left:n,bottom:e.zone.bottom,right:n}),r=this.findName(a,t);t[r]={name:r,type:i,string:r,aggregator:"integer"===i?"sum":"count"},o.push(r)}}return{fields:t,fieldKeys:o}}findName(e,t){let o=1;const s=e;for(;e in t;)e=`${s}${++o}`;return e}extractDataEntriesFromRange(e){const t=[];for(let o=e.zone.top+1;o<=e.zone.bottom;o++){const s={top:o,bottom:o,left:e.zone.left,right:e.zone.right},i=this.getters.getEvaluatedCellsInZone(e.sheetId,s),n={};for(const e in i){const t=i[e],o=this.fields[this.fieldKeys[e]];if(!o)throw new Error(`Field ${this.fieldKeys[e]} does not exist`);""===t.value?n[o.name]={value:null,type:po.empty}:n[o.name]=t}n.__count={value:1,type:po.number},t.push(n)}const o=this.definition.columns.concat(this.definition.rows).filter((e=>"date"===e.type));if(o.length)for(const e of t)for(const t of o)e[t.nameWithGranularity]={value:`${sI(t,e[t.name]?.value||null,this.getters.getLocale())}`,type:e[t.name]?.type||po.empty,format:e[t.name]?.format};return t}},definition:jw,externalData:!1,onIterationEndEvaluation:e=>e.markAsDirtyForEvaluation(),granularities:["year_number","quarter_number","month_number","iso_week_number","day_of_month","day"],isMeasureCandidate:e=>!["date","boolean"].includes(e.type),isGroupable:()=>!0});class rI extends Qa{pivotId;mutators=["reset","deferUpdates","applyUpdate","discardPendingUpdate","renamePivot","update"];updatesAreDeferred=!0;draft=null;constructor(e,t){super(e),this.pivotId=t}handle(e){if("UPDATE_PIVOT"===e.type)e.pivotId===this.pivotId&&this.getters.getPivot(this.pivotId).init()}get fields(){const e=this.pivot.getFields();if(!e)throw new Error("Fields not found");return e}get pivot(){return this.getters.getPivot(this.pivotId)}get definition(){const e=nI.get(this.pivot.type).definition;return this.draft?new e(this.draft,this.fields,this.getters):this.pivot.definition}get isDirty(){return!!this.draft}get unusedMeasureFields(){const e=[{name:"__count",string:uo("Count"),type:"integer",aggregator:"sum"}],t=this.fields;for(const o in t){const s=t[o];s&&(nI.get(this.pivot.type).isMeasureCandidate(s)&&e.push(s))}const{rows:o,columns:s,measures:i}=this.definition,n=i.concat(o).concat(s).map((e=>e.name));return e.filter((e=>!n.includes(e.name))).sort(((e,t)=>e.string.localeCompare(t.string)))}get unusedGroupableFields(){const e=[],t=this.fields;for(const o in t){const s=t[o];s&&(nI.get(this.pivot.type).isGroupable(s)&&e.push(s))}const{columns:o,rows:s,measures:i}=this.definition,n=i.concat(s).concat(o).map((e=>e.name)),r=this.unusedDateTimeGranularities;return e.filter((e=>Pb(e)?!n.includes(e.name)||r[e.name].size>0:!n.includes(e.name))).sort(((e,t)=>e.string.localeCompare(t.string)))}get allGranularities(){return nI.get(this.pivot.type).granularities}get unusedDateTimeGranularities(){return this.getUnusedDateTimeGranularities(this.fields,this.draft??this.getters.getPivotCoreDefinition(this.pivotId))}reset(e){this.pivotId=e,this.updatesAreDeferred=!0,this.draft=null}deferUpdates(e){this.updatesAreDeferred=e,!1===e&&this.draft&&this.applyUpdate()}applyUpdate(){this.draft&&(this.model.dispatch("UPDATE_PIVOT",{pivotId:this.pivotId,pivot:this.draft}),this.draft=null)}discardPendingUpdate(){this.draft=null}renamePivot(e){const t=this.getters.getPivotCoreDefinition(this.pivotId);this.model.dispatch("UPDATE_PIVOT",{pivotId:this.pivotId,pivot:{...t,name:e}})}update(e){const t=this.getters.getPivotCoreDefinition(this.pivotId),o={...t,...this.draft,...e},s={...o,columns:o.columns.map((e=>({name:e.name,order:e.order,granularity:e.granularity}))),rows:o.rows.map((e=>({name:e.name,order:e.order,granularity:e.granularity}))),measures:o.measures.map((e=>({name:e.name,aggregator:e.aggregator})))};if(!this.draft&&Be(t,s))return;const i=this.addDefaultDateTimeGranularity(this.fields,s);this.updatesAreDeferred?this.draft=i:this.model.dispatch("UPDATE_PIVOT",{pivotId:this.pivotId,pivot:i})}addDefaultDateTimeGranularity(e,t){const{columns:o,rows:s}=t,i=ge(o),n=ge(s),r=this.getUnusedDateTimeGranularities(e,t);for(const t of i.concat(n)){const o=e[t.name]?.type;if(("date"===o||"datetime"===o)&&!t.granularity){const e=r[t.name]?.values().next().value||"year";r[t.name]?.delete(e),t.granularity=e}}return{...t,columns:i,rows:n}}getUnusedDateTimeGranularities(e,t){const{columns:o,rows:s}=t,i=o.concat(s).filter((t=>{const o=e[t.name]?.type;return"date"===o||"datetime"===o})),n=this.allGranularities,r={};for(const e of i)r[e.name]=new Set(n);for(const e of i)r[e.name].delete(e.granularity);return r}}class aI extends t.Component{static template="o-spreadsheet-PivotSpreadsheetSidePanel";static props={pivotId:String,onCloseSidePanel:Function};static components={PivotLayoutConfigurator:qw,Section:Ix,SelectionInput:Ax,EditableName:Hw,Checkbox:wx};store;state;setup(){this.store=Wa(rI,this.props.pivotId),this.pivot.init(),this.state=t.useState({range:void 0,rangeHasChanged:!1})}get shouldDisplayInvalidRangeError(){return(!this.store.isDirty||!this.state.rangeHasChanged)&&this.pivot.isInvalidRange}get ranges(){return this.state.range?[this.state.range]:this.definition.range?[this.env.model.getters.getRangeString(this.definition.range,"forceSheetReference")]:[]}get pivot(){return this.store.pivot}get name(){return this.env.model.getters.getPivotName(this.props.pivotId)}get displayName(){return this.env.model.getters.getPivotDisplayName(this.props.pivotId)}get definition(){return this.store.definition}get deferUpdatesLabel(){return uo("Defer updates")}get deferUpdatesTooltip(){return uo("Changing the pivot definition requires to reload the data. It may take some time.")}onSelectionChanged(e){this.state.rangeHasChanged=!0,this.state.range=e[0]}onSelectionConfirmed(){if(this.state.range){const{sheetName:e,xc:t}=Ti(this.state.range),o=e?this.env.model.getters.getSheetIdByName(e):this.env.model.getters.getActiveSheetId();if(!o)return;const s={sheetId:o,zone:Li(t)};this.store.update({dataSet:s}),this.store.applyUpdate()}}duplicatePivot(){const e=this.env.model.uuidGenerator.uuidv4(),t=this.env.model.dispatch("DUPLICATE_PIVOT",{pivotId:this.props.pivotId,newPivotId:e}),o=t.isSuccessful?uo("Pivot duplicated."):uo("Pivot duplication failed"),s=t.isSuccessful?"success":"danger";this.env.notifyUser({text:o,sticky:!1,type:s}),t.isSuccessful&&this.env.openSidePanel("PivotSidePanel",{pivotId:e})}onNameChanged(e){this.store.renamePivot(e)}onDimensionsUpdated(e){this.store.update(e)}back(){this.env.openSidePanel("PivotSidePanel",{})}delete(){this.env.model.dispatch("REMOVE_PIVOT",{pivotId:this.props.pivotId})}}const lI=new zn;lI.add("SPREADSHEET",{editor:aI}),Nf`
|
|
1167
1167
|
.o_pivot_list_item {
|
|
1168
1168
|
cursor: pointer;
|
|
1169
1169
|
&:hover {
|
|
@@ -1508,7 +1508,7 @@
|
|
|
1508
1508
|
background: ${f};
|
|
1509
1509
|
color: #fff;
|
|
1510
1510
|
}
|
|
1511
|
-
`;class nR extends t.Component{static template="o-spreadsheet-FilterIcon";static props={cellPosition:Object};cellPopovers;setup(){this.cellPopovers=Ga(gS)}onClick(){const e=this.props.cellPosition,t=this.cellPopovers.persistentCellPopover,{col:o,row:s}=e;t.isOpen&&t.col===o&&t.row===s&&"FilterMenu"===t.type?this.cellPopovers.close():this.cellPopovers.open({col:o,row:s},"FilterMenu")}get isFilterActive(){return this.env.model.getters.isFilterActive(this.props.cellPosition)}get iconClass(){return ct(this.env.model.getters.getCellComputedStyle(this.props.cellPosition).fillColor||"#fff")<.45?"o-high-contrast":""}}class rR extends t.Component{static template="o-spreadsheet-FilterIconsOverlay";static components={GridCellIcon:qI,FilterIcon:nR};getFilterHeadersPositions(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getFilterHeaders(e)}}Nf`
|
|
1511
|
+
`;class nR extends t.Component{static template="o-spreadsheet-FilterIcon";static props={cellPosition:Object};cellPopovers;setup(){this.cellPopovers=Ga(gS)}onClick(){const e=this.props.cellPosition,t=this.cellPopovers.persistentCellPopover,{col:o,row:s}=e;t.isOpen&&t.col===o&&t.row===s&&"FilterMenu"===t.type?this.cellPopovers.close():this.cellPopovers.open({col:o,row:s},"FilterMenu")}get isFilterActive(){return this.env.model.getters.isFilterActive(this.props.cellPosition)}get iconClass(){return ct(this.env.model.getters.getCellComputedStyle(this.props.cellPosition).fillColor||"#fff")<.45?"o-high-contrast":""}}class rR extends t.Component{static template="o-spreadsheet-FilterIconsOverlay";static props={};static components={GridCellIcon:qI,FilterIcon:nR};getFilterHeadersPositions(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getFilterHeaders(e)}}Nf`
|
|
1512
1512
|
.o-grid-add-rows {
|
|
1513
1513
|
input {
|
|
1514
1514
|
box-sizing: border-box;
|
|
@@ -2405,7 +2405,7 @@
|
|
|
2405
2405
|
margin: 0;
|
|
2406
2406
|
}
|
|
2407
2407
|
}
|
|
2408
|
-
`;class uD 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}};static components={TopBar:cD,Grid:AR,BottomBar:Z_,SidePanel:eD,SpreadsheetDashboard:j_,HeaderGroupContainer:J_};sidePanel;spreadsheetRef=t.useRef("spreadsheet");_focusGrid;keyDownMapping;isViewportTooSmall=!1;notificationStore;composerFocusStore;get model(){return this.props.model}getStyle(){return this.env.isDashboard()?"grid-template-rows: auto;":"grid-template-rows: 63px auto 37px"}setup(){const e=$a();e.inject(ja,this.model),this.notificationStore=Ga(tl),this.composerFocusStore=Ga(il),this.sidePanel=Ga(wR),this.keyDownMapping={"CTRL+H":()=>this.sidePanel.toggle("FindAndReplace",{}),"CTRL+F":()=>this.sidePanel.toggle("FindAndReplace",{})};const o=this.model.config.external.fileStore;t.useSubEnv({model:this.model,imageProvider:o?new U_(o):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),toggleSidePanel:this.sidePanel.toggle.bind(this.sidePanel),clipboard:this.env.clipboard||new hD(navigator.clipboard),startCellEdition:e=>this.composerFocusStore.focusGridComposerCell(e),notifyUser:e=>this.notificationStore.notifyUser(e),askConfirmation:(e,t,o)=>this.notificationStore.askConfirmation(e,t,o),raiseError:(e,t)=>this.notificationStore.raiseError(e,t)}),this.notificationStore.updateNotificationCallbacks({...this.props}),t.useEffect((()=>{!this.spreadsheetRef.el.contains(document.activeElement)&&document.activeElement?.contains(this.spreadsheetRef.el)&&this.focusGrid()}),(()=>[this.env.model.getters.getActiveSheetId()])),t.useExternalListener(window,"resize",(()=>this.render(!0))),t.useExternalListener(document.body,"wheel",(()=>{})),this.bindModelEvents(),t.onWillUpdateProps((e=>{if(e.model!==this.props.model)throw new Error("Changing the props model is not supported at the moment.");Be(e,this.props)||this.notificationStore.updateNotificationCallbacks({...e})}));const s=function(e){let t=!1;return async(...o)=>{t||(t=!0,await Promise.resolve(),t=!1,e(...o))}}(this.render.bind(this,!0));t.onMounted((()=>{this.checkViewportSize(),e.on("store-updated",this,s)})),t.onWillUnmount((()=>{this.unbindModelEvents(),e.off("store-updated",this)})),t.onPatched((()=>{this.checkViewportSize()}))}bindModelEvents(){this.model.on("update",this,(()=>this.render(!0))),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("notify-ui",this),this.model.off("raise-error-ui",this)}checkViewportSize(){const{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:uo("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()}onKeydown(e){let t="";Zf(e)&&(t+="CTRL+"),t+=e.key.toUpperCase();let o=this.keyDownMapping[t];if(o)return e.preventDefault(),e.stopPropagation(),void o()}get gridHeight(){const{height:e}=this.env.model.getters.getSheetViewDimension();return e}get gridContainerStyle(){const e=L*this.rowLayers.length,t=L*this.colLayers.length;return kf({"grid-template-columns":`${e?e+2:0}px auto`,"grid-template-rows":`${t?t+2:0}px auto`})}get rowLayers(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getVisibleGroupLayers(e,"ROW")}get colLayers(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getVisibleGroupLayers(e,"COL")}}class gD{listeners=[];sendMessage(e){for(const{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))}}function pD(e){return aS.get(e.type)(e)}class mD{buildTransformation;operations;constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){return this.operations[this.operations.length-1]?.id}getFirstOperationAmong(e,t){for(const o of this.operations){if(o.id===e)return e;if(o.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const o=this.buildTransformation.with(e.data),{before:s,operation:i,after:n}=this.locateOperation(t);this.operations=[...s,i,e,...n.map((e=>e.transformed(o)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new mD(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:o}=this.locateOperation(e);this.operations=t.concat([o])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class fD{id;data;constructor(e,t){this.id=e,this.data=t}transformed(e){return new bD(this.id,ke((()=>e(this.data))))}}class bD{id;lazyData;constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new bD(this.id,this.lazyData.map(e))}}class vD{operations;constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new vD(function*(e,t){for(const o of e)if(yield o,o.operation.id===t)return}(this.operations,e))}stopBefore(e){return new vD(function*(e,t){for(const o of e){if(o.operation.id===t)return;yield o}}(this.operations,e))}startAfter(e){return new vD(function*(e,t){let o=!0;for(const s of e)o||(yield s),s.operation.id===t&&(o=!1)}(this.operations,e))}}class SD{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 vD(Ce(this._execution(e),this._execution(e)))}revertedExecution(e){return new vD(Ce(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){const o=e.getLastOperationId()||this.previousBranch(e)?.getLastOperationId();e.append(t),o&&this.insertPrevious(e,t,o)}insertOperationAfter(e,t,o){e.insert(t,o),this.updateNextWith(e,t,o),this.insertPrevious(e,t,o)}undo(e,t){const o=this.buildTransformation.without(t.data),s=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const i=e.fork(t.id);s&&this.branchingOperationIds.set(i,s),this.insertBranchAfter(e,i),this.transform(i,o)}redo(e){const t=this.nextBranch(e);if(!t)return;const o=this.nextBranch(t);this.removeBranchFromTree(t);const s=this.branchingOperationIds.get(t);s?this.branchingOperationIds.set(e,s):this.branchingOperationIds.delete(e),o&&this.rebaseUp(o)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const o of this.revertedExecution(e))if(o.operation.id===t)return o;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:o}=this.findPreviousBranchingOperation(e);if(!t||!o)return;const s=this.buildTransformation.without(o.data),i=t.fork(o.id);this.branchingOperationIds.set(i,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,i),i.transform(s);const n=this.nextBranch(i);n&&this.rebaseUp(n)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const o=this.branches.findIndex((t=>t===e));this.branches.splice(o+1,0,t)}updateNextWith(e,t,o){const s=this.branchingOperationIds.get(e),i=this.nextBranch(e);if(s&&i)if(e.getFirstOperationAmong(o,s)===s){const n=this.addToNextBranch(e,i,s,t,o);this.updateNextWith(i,n,o)}else{const e=this.buildTransformation.with(t.data);this.transform(i,e)}}addToNextBranch(e,t,o,s,i){let n=s;return i===o?(n=this.getTransformedOperation(e,o,s),t.prepend(n)):t.contains(i)?(n=this.getTransformedOperation(e,o,s),t.insert(n,i)):t.append(s),n}getTransformedOperation(e,t,o){const s=e.getOperation(t),i=this.buildTransformation.without(s.data);return o.transformed(i)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const o=this.nextBranch(e);o&&this.transform(o,t)}insertPrevious(e,t,o){const{previousBranch:s,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!s||!i)return;const n=this.buildTransformation.with(i.data),r=e.fork(o);r.transform(n),s.cutAfter(o),s.appendBranch(r);const a=t.transformed(n);this.insertPrevious(s,a,o)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const o=this.branchingOperationIds.get(t);return o?{previousBranch:t,branchingOperation:t.getOperation(o)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let o=!!t;const s=e.getOperations();for(let i=s.length-1;i>=0;i--){const n=s[i];n.id===t&&(o=!1),o||(yield{operation:n,branch:e,isCancelled:!this.shouldExecute(e,n)})}const i=this.previousBranch(e);yield*i?this._revertedExecution(i):[]}*_execution(e){for(const t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){const t=this.nextBranch(e);return void(yield*t?this._execution(t):[])}if(!this.branchingOperationIds.get(e)){const t=this.nextBranch(e);yield*t?this._execution(t):[]}}}class CD{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 mD(this.buildTransformation),this.tree=new SD(this.buildTransformation,this.HEAD_BRANCH);const t=e.initialOperationId,o=new fD(t,this.buildEmpty(t));this.tree.insertOperationLast(this.HEAD_BRANCH,o),this.HEAD_OPERATION=o}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const o=new fD(e,t),s=this.tree.getLastBranch();this.tree.insertOperationLast(s,o),this.HEAD_BRANCH=s,this.HEAD_OPERATION=o}insert(e,t,o){const s=new fD(e,t);this.revertTo(o),this.tree.insertOperationAfter(this.HEAD_BRANCH,s,o),this.fastForward()}undo(e,t,o){const{branch:s,operation:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(s,i),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}redo(e,t,o){const{branch:s}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(s),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}drop(e){this.revertBefore(e),this.tree.drop(e)}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:o,isCancelled:s}of e)s||this.revertOperation(o.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:o,isCancelled:s}of e)s||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=o}}function yD(e){return new CD({initialOperationId:e.initialRevisionId,applyOperation:t=>{const o=t.commands.slice(),{changes:s}=e.recordChanges((()=>{for(const t of o)e.dispatch(t)}));t.setChanges(s)},revertOperation:e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){ED(t.changes[e])}}([e]),buildEmpty:e=>new m_(e,"empty",[]),buildTransformation:{with:e=>t=>new m_(t.id,t.clientId,g_(t.commands,e.commands),t.rootCommand,void 0,t.timestamp),without:e=>t=>new m_(t.id,t.clientId,g_(t.commands,e.commands.map(pD).flat()),t.rootCommand,void 0,t.timestamp)}})}function ED(e){const t=e.target,o=e.key,s=e.before;void 0===s?delete t[o]:t[o]=s}class xD{observers=new Map;defaultSubscription;mainSubscription;registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||(this.mainSubscription=this.defaultSubscription)}observe(e,t){this.observers.set(e,{owner:e,callbacks:t})}capture(e,t){if(this.observers.get(e))throw new 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)))}}class wD{getters;stream;anchor;defaultAnchor;constructor(e){this.getters=e,this.stream=new xD,this.anchor={cell:{col:0,row:0},zone:on({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,o){this.stream.capture(e,o),this.anchor=t}registerAsDefault(e,t,o){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,o),this.defaultAnchor=t,this.capture(e,t,o)}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)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}modifyAnchor(e,t,o){const s=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(s,e.zone)},this.processEvent({options:o,anchor:e,mode:t})}selectZone(e,t={scrollIntoView:!0}){return this.modifyAnchor(e,"overrideSelection",t)}selectCell(e,t){const o=on({col:e,row:t});return this.selectZone({zone:o,cell:{col:e,row:t}},{scrollIntoView:!0})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new xo("InvalidSelectionStep");const{col:o,row:s}=this.getNextAvailablePosition(e,t);return this.selectCell(o,s)}setAnchorCorner(e,t){const o=this.getters.getActiveSheetId(),{col:s,row:i}=this.anchor.cell,n={left:Math.min(s,e),top:Math.min(i,t),right:Math.max(s,e),bottom:Math.max(i,t)},r={zone:this.getters.expandZone(o,n),cell:{col:s,row:i}};return this.processEvent({mode:"updateAnchor",anchor:r,options:{scrollIntoView:!1}})}addCellToSelection(e,t){const o=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:o,col:e,row:t}));const s=this.getters.expandZone(o,on({col:e,row:t}));return this.processEvent({options:{scrollIntoView:!0},anchor:{zone:s,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new xo("InvalidSelectionStep");const o=this.getters.getActiveSheetId(),s=this.anchor,{col:i,row:n}=s.cell,{left:r,right:a,top:l,bottom:c}=s.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return xo.Success;let g=s.zone;const p=e=>{e=Ji(e);const{left:t,right:s,top:i,bottom:n}=this.getters.expandZone(o,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(o)-1,s),top:Math.max(0,i),bottom:Math.min(this.getters.getNumberRows(o)-1,n)}},{col:m,row:f}=this.getReferencePosition();let b=0;for(;null!==g;){if(b++,d<0){const e=this.getNextAvailableCol(d,a-(b-1),f);g=m<=a-b?p({top:l,left:r,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,r+(b-1),f);g=r+b<=m?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,m,c-(b-1));g=f<=c-b?p({top:l,left:r,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,m,l+(b-1));g=l+b<=f?p({top:e,left:r,bottom:c,right:a}):null}if(g=g?Ji(g):g,g&&!qi(g,s.zone))return this.processEvent({options:{scrollIntoView:!0},mode:"updateAnchor",anchor:{zone:g,cell:{col:i,row:n}}})}g=p(Gi({top:n,bottom:n,left:i,right:i},Ji({top:this.getNextAvailableRow(u,m,l),left:this.getNextAvailableCol(d,r,f),bottom:this.getNextAvailableRow(u,m,c),right:this.getNextAvailableCol(d,a,f)})));const v={zone:g,cell:{col:i,row:n}};return this.processEvent({anchor:v,mode:"updateAnchor",options:{scrollIntoView:!0}})}selectColumn(e,t){const o=this.getters.getActiveSheetId(),s=this.getters.getNumberRows(o)-1;let i={left:e,right:e,top:0,bottom:s};const n=this.getters.findFirstVisibleColRowIndex(o,"ROW");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=e,a=n;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),i=Gi(i,{left:r,right:r,top:n,bottom:s})}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:i,cell:{col:r,row:a}},mode:t})}selectRow(e,t){const o=this.getters.getActiveSheetId(),s=this.getters.getNumberCols(o)-1;let i={top:e,bottom:e,left:0,right:s};const n=this.getters.findFirstVisibleColRowIndex(o,"COL");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=n,a=e;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),i=Gi(i,{left:n,right:s,top:a,bottom:a})}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:i,cell:{col:r,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor;if(qi(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:on(t.cell)},"updateAnchor",{scrollIntoView:!1});const o=this.getters.getContiguousZone(e,t.zone);return Be(o,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:o},"updateAnchor",{scrollIntoView:!1})}selectTableAroundSelection(){const e=this.getters.getActiveSheetId(),t=this.getters.getContiguousZone(e,this.anchor.zone);return this.modifyAnchor({...this.anchor,zone:t},"updateAnchor",{scrollIntoView:!1})}selectAll(){const 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){const t={...e,previousAnchor:ge(this.anchor)},o=this.checkEventAnchorZone(t);return"Success"!==o?new xo(o):(this.anchor=t.anchor,this.stream.send(t),xo.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:o}=e;if(!Yi(t.col,t.row,o))return"InvalidAnchorZone";const{left:s,right:i,top:n,bottom:r}=o,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",s,i);return void 0===this.getters.findVisibleHeader(a,"ROW",n,r)||void 0===l?"SelectionOutOfBound":"Success"}checkAnchorZoneOrThrow(e){if("InvalidAnchorZone"===this.checkAnchorZone(e))throw new Error(uo("The provided anchor is invalid. The cell must be part of the zone."))}getNextAvailablePosition(e,t=1){const{col:o,row:s}=this.anchor.cell,i=this.deltaToTarget({col:o,row:s},e,t);return{col:this.getNextAvailableCol(i[0],o,s),row:this.getNextAvailableRow(i[1],o,s)}}getNextAvailableCol(e,t,o){const s=this.getters.getActiveSheetId(),i={col:t,row:o};return this.getNextAvailableHeader(e,"COL",t,i,(e=>this.getters.isInSameMerge(s,t,o,e,o)))}getNextAvailableRow(e,t,o){const s=this.getters.getActiveSheetId(),i={col:t,row:o};return this.getNextAvailableHeader(e,"ROW",o,i,(e=>this.getters.isInSameMerge(s,t,o,t,e)))}getNextAvailableHeader(e,t,o,s,i){const n=this.getters.getActiveSheetId();if(0===e)return o;const r=Math.sign(e);let a=o+e;for(;i(a);)a+=r;for(;this.getters.isHeaderHidden(n,t,a);)a+=r;return a<0||a>this.getters.getNumberHeaders(n,t)-1?this.getters.isHeaderHidden(n,t,o)?this.getNextAvailableHeader(-r,t,o,s,i):o:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:o,right:s,top:i,bottom:n}=t.zone,{col:r,row:a}=t.cell;return{col:this.getters.isColHidden(e,r)&&this.getters.findVisibleHeader(e,"COL",o,s)||r,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",i,n)||a}}deltaToTarget(e,t,o){switch(t){case"up":return"end"!==o?[0,-o]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==o?[0,o]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==o?[-o,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==o?[o,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:o}=this.getPosition();const s=this.anchor.zone;switch(e){case"down":case"up":o=o===s.top?s.bottom:s.top;break;case"left":case"right":t=t===s.right?s.left:s.right}return{col:t,row:o}}getEndOfCluster(e,t,o){const s=this.getters.getActiveSheetId();let i=e;const n=this.getNextCellPosition(e,t,o);let r=this.isCellSkippableInCluster({...i,sheetId:s})||this.isCellSkippableInCluster({...n,sheetId:s})?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(i,t,o);if(i.col===e.col&&i.row===e.row)break;const n=this.isCellSkippableInCluster({...e,sheetId:s});if("endOfCluster"===r&&n)break;if("nextCluster"===r&&!n){i=e;break}i=e}return"cols"===t?i.col:i.row}getNextCellPosition(e,t,o){const s="cols"===t?"col":"row",i={...e},n="cols"===t?this.getNextAvailableCol(o,i.col,i.row):this.getNextAvailableRow(o,i.col,i.row);return i[s]=n,{col:i.col,row:i.row}}getPosition(){return{...this.anchor.cell}}isCellSkippableInCluster(e){const t=this.getters.getMainCellPosition(e),o=this.getters.getEvaluatedCell(t);return o.type===po.empty||o.type===po.text&&""===o.value}}function ID(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class RD{changes=[];commands=[];recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop();let o=e[0],s=e.at(-1);const i=e.length-2;for(let t=1;t<=i;t++){const s=e[t];if(void 0===o[s]){const i=e[t+1];o[s]=ID(i)}o=o[s]}o[s]!==t&&(this.changes.push({key:s,target:o,before:o[s]}),void 0===t?delete o[s]:o[s]=t)}}const TD=17781237,AD=88853993;function OD(e,t,o){const s=[["xmlns:r",GR],["xmlns:a",BR],["xmlns:c",HR]],i=_D({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let n=FA``;if(e.data.title?.text){const t=e.data.title.color?fv(e.data.title.color):e.data.fontColor;n=FA`
|
|
2408
|
+
`;class uD 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}};static components={TopBar:cD,Grid:AR,BottomBar:Z_,SidePanel:eD,SpreadsheetDashboard:j_,HeaderGroupContainer:J_};sidePanel;spreadsheetRef=t.useRef("spreadsheet");_focusGrid;keyDownMapping;isViewportTooSmall=!1;notificationStore;composerFocusStore;get model(){return this.props.model}getStyle(){return this.env.isDashboard()?"grid-template-rows: auto;":"grid-template-rows: 63px auto 37px"}setup(){const e=$a();e.inject(ja,this.model),this.notificationStore=Ga(tl),this.composerFocusStore=Ga(il),this.sidePanel=Ga(wR),this.keyDownMapping={"CTRL+H":()=>this.sidePanel.toggle("FindAndReplace",{}),"CTRL+F":()=>this.sidePanel.toggle("FindAndReplace",{})};const o=this.model.config.external.fileStore;t.useSubEnv({model:this.model,imageProvider:o?new U_(o):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),toggleSidePanel:this.sidePanel.toggle.bind(this.sidePanel),clipboard:this.env.clipboard||new hD(navigator.clipboard),startCellEdition:e=>this.composerFocusStore.focusGridComposerCell(e),notifyUser:e=>this.notificationStore.notifyUser(e),askConfirmation:(e,t,o)=>this.notificationStore.askConfirmation(e,t,o),raiseError:(e,t)=>this.notificationStore.raiseError(e,t)}),this.notificationStore.updateNotificationCallbacks({...this.props}),t.useEffect((()=>{!this.spreadsheetRef.el.contains(document.activeElement)&&document.activeElement?.contains(this.spreadsheetRef.el)&&this.focusGrid()}),(()=>[this.env.model.getters.getActiveSheetId()])),t.useExternalListener(window,"resize",(()=>this.render(!0))),t.useExternalListener(document.body,"wheel",(()=>{})),this.bindModelEvents(),t.onWillUpdateProps((e=>{if(e.model!==this.props.model)throw new 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})}));const s=function(e){let t=!1;return async(...o)=>{t||(t=!0,await Promise.resolve(),t=!1,e(...o))}}(this.render.bind(this,!0));t.onMounted((()=>{this.checkViewportSize(),e.on("store-updated",this,s)})),t.onWillUnmount((()=>{this.unbindModelEvents(),e.off("store-updated",this)})),t.onPatched((()=>{this.checkViewportSize()}))}bindModelEvents(){this.model.on("update",this,(()=>this.render(!0))),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("notify-ui",this),this.model.off("raise-error-ui",this)}checkViewportSize(){const{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:uo("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()}onKeydown(e){let t="";Zf(e)&&(t+="CTRL+"),t+=e.key.toUpperCase();let o=this.keyDownMapping[t];if(o)return e.preventDefault(),e.stopPropagation(),void o()}get gridHeight(){const{height:e}=this.env.model.getters.getSheetViewDimension();return e}get gridContainerStyle(){const e=L*this.rowLayers.length,t=L*this.colLayers.length;return kf({"grid-template-columns":`${e?e+2:0}px auto`,"grid-template-rows":`${t?t+2:0}px auto`})}get rowLayers(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getVisibleGroupLayers(e,"ROW")}get colLayers(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getVisibleGroupLayers(e,"COL")}}class gD{listeners=[];sendMessage(e){for(const{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))}}function pD(e){return aS.get(e.type)(e)}class mD{buildTransformation;operations;constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){return this.operations[this.operations.length-1]?.id}getFirstOperationAmong(e,t){for(const o of this.operations){if(o.id===e)return e;if(o.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const o=this.buildTransformation.with(e.data),{before:s,operation:i,after:n}=this.locateOperation(t);this.operations=[...s,i,e,...n.map((e=>e.transformed(o)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new mD(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:o}=this.locateOperation(e);this.operations=t.concat([o])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class fD{id;data;constructor(e,t){this.id=e,this.data=t}transformed(e){return new bD(this.id,ke((()=>e(this.data))))}}class bD{id;lazyData;constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new bD(this.id,this.lazyData.map(e))}}class vD{operations;constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new vD(function*(e,t){for(const o of e)if(yield o,o.operation.id===t)return}(this.operations,e))}stopBefore(e){return new vD(function*(e,t){for(const o of e){if(o.operation.id===t)return;yield o}}(this.operations,e))}startAfter(e){return new vD(function*(e,t){let o=!0;for(const s of e)o||(yield s),s.operation.id===t&&(o=!1)}(this.operations,e))}}class SD{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 vD(Ce(this._execution(e),this._execution(e)))}revertedExecution(e){return new vD(Ce(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){const o=e.getLastOperationId()||this.previousBranch(e)?.getLastOperationId();e.append(t),o&&this.insertPrevious(e,t,o)}insertOperationAfter(e,t,o){e.insert(t,o),this.updateNextWith(e,t,o),this.insertPrevious(e,t,o)}undo(e,t){const o=this.buildTransformation.without(t.data),s=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const i=e.fork(t.id);s&&this.branchingOperationIds.set(i,s),this.insertBranchAfter(e,i),this.transform(i,o)}redo(e){const t=this.nextBranch(e);if(!t)return;const o=this.nextBranch(t);this.removeBranchFromTree(t);const s=this.branchingOperationIds.get(t);s?this.branchingOperationIds.set(e,s):this.branchingOperationIds.delete(e),o&&this.rebaseUp(o)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const o of this.revertedExecution(e))if(o.operation.id===t)return o;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:o}=this.findPreviousBranchingOperation(e);if(!t||!o)return;const s=this.buildTransformation.without(o.data),i=t.fork(o.id);this.branchingOperationIds.set(i,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,i),i.transform(s);const n=this.nextBranch(i);n&&this.rebaseUp(n)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const o=this.branches.findIndex((t=>t===e));this.branches.splice(o+1,0,t)}updateNextWith(e,t,o){const s=this.branchingOperationIds.get(e),i=this.nextBranch(e);if(s&&i)if(e.getFirstOperationAmong(o,s)===s){const n=this.addToNextBranch(e,i,s,t,o);this.updateNextWith(i,n,o)}else{const e=this.buildTransformation.with(t.data);this.transform(i,e)}}addToNextBranch(e,t,o,s,i){let n=s;return i===o?(n=this.getTransformedOperation(e,o,s),t.prepend(n)):t.contains(i)?(n=this.getTransformedOperation(e,o,s),t.insert(n,i)):t.append(s),n}getTransformedOperation(e,t,o){const s=e.getOperation(t),i=this.buildTransformation.without(s.data);return o.transformed(i)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const o=this.nextBranch(e);o&&this.transform(o,t)}insertPrevious(e,t,o){const{previousBranch:s,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!s||!i)return;const n=this.buildTransformation.with(i.data),r=e.fork(o);r.transform(n),s.cutAfter(o),s.appendBranch(r);const a=t.transformed(n);this.insertPrevious(s,a,o)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const o=this.branchingOperationIds.get(t);return o?{previousBranch:t,branchingOperation:t.getOperation(o)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let o=!!t;const s=e.getOperations();for(let i=s.length-1;i>=0;i--){const n=s[i];n.id===t&&(o=!1),o||(yield{operation:n,branch:e,isCancelled:!this.shouldExecute(e,n)})}const i=this.previousBranch(e);yield*i?this._revertedExecution(i):[]}*_execution(e){for(const t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){const t=this.nextBranch(e);return void(yield*t?this._execution(t):[])}if(!this.branchingOperationIds.get(e)){const t=this.nextBranch(e);yield*t?this._execution(t):[]}}}class CD{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 mD(this.buildTransformation),this.tree=new SD(this.buildTransformation,this.HEAD_BRANCH);const t=e.initialOperationId,o=new fD(t,this.buildEmpty(t));this.tree.insertOperationLast(this.HEAD_BRANCH,o),this.HEAD_OPERATION=o}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const o=new fD(e,t),s=this.tree.getLastBranch();this.tree.insertOperationLast(s,o),this.HEAD_BRANCH=s,this.HEAD_OPERATION=o}insert(e,t,o){const s=new fD(e,t);this.revertTo(o),this.tree.insertOperationAfter(this.HEAD_BRANCH,s,o),this.fastForward()}undo(e,t,o){const{branch:s,operation:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(s,i),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}redo(e,t,o){const{branch:s}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(s),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}drop(e){this.revertBefore(e),this.tree.drop(e)}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:o,isCancelled:s}of e)s||this.revertOperation(o.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:o,isCancelled:s}of e)s||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=o}}function yD(e){return new CD({initialOperationId:e.initialRevisionId,applyOperation:t=>{const o=t.commands.slice(),{changes:s}=e.recordChanges((()=>{for(const t of o)e.dispatch(t)}));t.setChanges(s)},revertOperation:e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){ED(t.changes[e])}}([e]),buildEmpty:e=>new m_(e,"empty",[]),buildTransformation:{with:e=>t=>new m_(t.id,t.clientId,g_(t.commands,e.commands),t.rootCommand,void 0,t.timestamp),without:e=>t=>new m_(t.id,t.clientId,g_(t.commands,e.commands.map(pD).flat()),t.rootCommand,void 0,t.timestamp)}})}function ED(e){const t=e.target,o=e.key,s=e.before;void 0===s?delete t[o]:t[o]=s}class xD{observers=new Map;defaultSubscription;mainSubscription;registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||(this.mainSubscription=this.defaultSubscription)}observe(e,t){this.observers.set(e,{owner:e,callbacks:t})}capture(e,t){if(this.observers.get(e))throw new 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)))}}class wD{getters;stream;anchor;defaultAnchor;constructor(e){this.getters=e,this.stream=new xD,this.anchor={cell:{col:0,row:0},zone:on({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,o){this.stream.capture(e,o),this.anchor=t}registerAsDefault(e,t,o){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,o),this.defaultAnchor=t,this.capture(e,t,o)}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)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}modifyAnchor(e,t,o){const s=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(s,e.zone)},this.processEvent({options:o,anchor:e,mode:t})}selectZone(e,t={scrollIntoView:!0}){return this.modifyAnchor(e,"overrideSelection",t)}selectCell(e,t){const o=on({col:e,row:t});return this.selectZone({zone:o,cell:{col:e,row:t}},{scrollIntoView:!0})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new xo("InvalidSelectionStep");const{col:o,row:s}=this.getNextAvailablePosition(e,t);return this.selectCell(o,s)}setAnchorCorner(e,t){const o=this.getters.getActiveSheetId(),{col:s,row:i}=this.anchor.cell,n={left:Math.min(s,e),top:Math.min(i,t),right:Math.max(s,e),bottom:Math.max(i,t)},r={zone:this.getters.expandZone(o,n),cell:{col:s,row:i}};return this.processEvent({mode:"updateAnchor",anchor:r,options:{scrollIntoView:!1}})}addCellToSelection(e,t){const o=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:o,col:e,row:t}));const s=this.getters.expandZone(o,on({col:e,row:t}));return this.processEvent({options:{scrollIntoView:!0},anchor:{zone:s,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new xo("InvalidSelectionStep");const o=this.getters.getActiveSheetId(),s=this.anchor,{col:i,row:n}=s.cell,{left:r,right:a,top:l,bottom:c}=s.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return xo.Success;let g=s.zone;const p=e=>{e=Ji(e);const{left:t,right:s,top:i,bottom:n}=this.getters.expandZone(o,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(o)-1,s),top:Math.max(0,i),bottom:Math.min(this.getters.getNumberRows(o)-1,n)}},{col:m,row:f}=this.getReferencePosition();let b=0;for(;null!==g;){if(b++,d<0){const e=this.getNextAvailableCol(d,a-(b-1),f);g=m<=a-b?p({top:l,left:r,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,r+(b-1),f);g=r+b<=m?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,m,c-(b-1));g=f<=c-b?p({top:l,left:r,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,m,l+(b-1));g=l+b<=f?p({top:e,left:r,bottom:c,right:a}):null}if(g=g?Ji(g):g,g&&!qi(g,s.zone))return this.processEvent({options:{scrollIntoView:!0},mode:"updateAnchor",anchor:{zone:g,cell:{col:i,row:n}}})}g=p(Gi({top:n,bottom:n,left:i,right:i},Ji({top:this.getNextAvailableRow(u,m,l),left:this.getNextAvailableCol(d,r,f),bottom:this.getNextAvailableRow(u,m,c),right:this.getNextAvailableCol(d,a,f)})));const v={zone:g,cell:{col:i,row:n}};return this.processEvent({anchor:v,mode:"updateAnchor",options:{scrollIntoView:!0}})}selectColumn(e,t){const o=this.getters.getActiveSheetId(),s=this.getters.getNumberRows(o)-1;let i={left:e,right:e,top:0,bottom:s};const n=this.getters.findFirstVisibleColRowIndex(o,"ROW");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=e,a=n;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),i=Gi(i,{left:r,right:r,top:n,bottom:s})}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:i,cell:{col:r,row:a}},mode:t})}selectRow(e,t){const o=this.getters.getActiveSheetId(),s=this.getters.getNumberCols(o)-1;let i={top:e,bottom:e,left:0,right:s};const n=this.getters.findFirstVisibleColRowIndex(o,"COL");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=n,a=e;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),i=Gi(i,{left:n,right:s,top:a,bottom:a})}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:i,cell:{col:r,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor;if(qi(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:on(t.cell)},"updateAnchor",{scrollIntoView:!1});const o=this.getters.getContiguousZone(e,t.zone);return Be(o,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:o},"updateAnchor",{scrollIntoView:!1})}selectTableAroundSelection(){const e=this.getters.getActiveSheetId(),t=this.getters.getContiguousZone(e,this.anchor.zone);return this.modifyAnchor({...this.anchor,zone:t},"updateAnchor",{scrollIntoView:!1})}selectAll(){const 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){const t={...e,previousAnchor:ge(this.anchor)},o=this.checkEventAnchorZone(t);return"Success"!==o?new xo(o):(this.anchor=t.anchor,this.stream.send(t),xo.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:o}=e;if(!Yi(t.col,t.row,o))return"InvalidAnchorZone";const{left:s,right:i,top:n,bottom:r}=o,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",s,i);return void 0===this.getters.findVisibleHeader(a,"ROW",n,r)||void 0===l?"SelectionOutOfBound":"Success"}checkAnchorZoneOrThrow(e){if("InvalidAnchorZone"===this.checkAnchorZone(e))throw new Error(uo("The provided anchor is invalid. The cell must be part of the zone."))}getNextAvailablePosition(e,t=1){const{col:o,row:s}=this.anchor.cell,i=this.deltaToTarget({col:o,row:s},e,t);return{col:this.getNextAvailableCol(i[0],o,s),row:this.getNextAvailableRow(i[1],o,s)}}getNextAvailableCol(e,t,o){const s=this.getters.getActiveSheetId(),i={col:t,row:o};return this.getNextAvailableHeader(e,"COL",t,i,(e=>this.getters.isInSameMerge(s,t,o,e,o)))}getNextAvailableRow(e,t,o){const s=this.getters.getActiveSheetId(),i={col:t,row:o};return this.getNextAvailableHeader(e,"ROW",o,i,(e=>this.getters.isInSameMerge(s,t,o,t,e)))}getNextAvailableHeader(e,t,o,s,i){const n=this.getters.getActiveSheetId();if(0===e)return o;const r=Math.sign(e);let a=o+e;for(;i(a);)a+=r;for(;this.getters.isHeaderHidden(n,t,a);)a+=r;return a<0||a>this.getters.getNumberHeaders(n,t)-1?this.getters.isHeaderHidden(n,t,o)?this.getNextAvailableHeader(-r,t,o,s,i):o:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:o,right:s,top:i,bottom:n}=t.zone,{col:r,row:a}=t.cell;return{col:this.getters.isColHidden(e,r)&&this.getters.findVisibleHeader(e,"COL",o,s)||r,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",i,n)||a}}deltaToTarget(e,t,o){switch(t){case"up":return"end"!==o?[0,-o]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==o?[0,o]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==o?[-o,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==o?[o,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:o}=this.getPosition();const s=this.anchor.zone;switch(e){case"down":case"up":o=o===s.top?s.bottom:s.top;break;case"left":case"right":t=t===s.right?s.left:s.right}return{col:t,row:o}}getEndOfCluster(e,t,o){const s=this.getters.getActiveSheetId();let i=e;const n=this.getNextCellPosition(e,t,o);let r=this.isCellSkippableInCluster({...i,sheetId:s})||this.isCellSkippableInCluster({...n,sheetId:s})?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(i,t,o);if(i.col===e.col&&i.row===e.row)break;const n=this.isCellSkippableInCluster({...e,sheetId:s});if("endOfCluster"===r&&n)break;if("nextCluster"===r&&!n){i=e;break}i=e}return"cols"===t?i.col:i.row}getNextCellPosition(e,t,o){const s="cols"===t?"col":"row",i={...e},n="cols"===t?this.getNextAvailableCol(o,i.col,i.row):this.getNextAvailableRow(o,i.col,i.row);return i[s]=n,{col:i.col,row:i.row}}getPosition(){return{...this.anchor.cell}}isCellSkippableInCluster(e){const t=this.getters.getMainCellPosition(e),o=this.getters.getEvaluatedCell(t);return o.type===po.empty||o.type===po.text&&""===o.value}}function ID(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class RD{changes=[];commands=[];recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop();let o=e[0],s=e.at(-1);const i=e.length-2;for(let t=1;t<=i;t++){const s=e[t];if(void 0===o[s]){const i=e[t+1];o[s]=ID(i)}o=o[s]}o[s]!==t&&(this.changes.push({key:s,target:o,before:o[s]}),void 0===t?delete o[s]:o[s]=t)}}const TD=17781237,AD=88853993;function OD(e,t,o){const s=[["xmlns:r",GR],["xmlns:a",BR],["xmlns:c",HR]],i=_D({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let n=FA``;if(e.data.title?.text){const t=e.data.title.color?fv(e.data.title.color):e.data.fontColor;n=FA`
|
|
2409
2409
|
<c:title>
|
|
2410
2410
|
${MD(e.data.title.text,t,T,e.data.title)}
|
|
2411
2411
|
<c:overlay val="0" />
|
|
@@ -3049,4 +3049,4 @@
|
|
|
3049
3049
|
<tableParts count="${e.tables.length}">
|
|
3050
3050
|
${MA(a)}
|
|
3051
3051
|
</tableParts>
|
|
3052
|
-
`}var pM;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(pM||(pM={}));function mM(e,t={}){const o=ge(t);return o.type=e,o}const fM={},bM={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:O,HEADER_WIDTH:_,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:D,DEFAULT_CELL_HEIGHT:M,SCROLLBAR_WIDTH:F},vM={autoCompleteProviders:va,autofillModifiersRegistry:Hb,autofillRulesRegistry:zb,cellMenuRegistry:My,colMenuRegistry:fx,errorTypes:Po,linkMenuRegistry:VS,functionRegistry:_f,featurePluginRegistry:P_,statefulUIPluginRegistry:L_,coreViewsPluginRegistry:k_,corePluginRegistry:N_,rowMenuRegistry:Cx,sidePanelRegistry:MI,figureRegistry:sS,chartSidePanelComponentRegistry:sw,chartComponentRegistry:Qv,chartRegistry:Kv,topbarMenuRegistry:Ex,topbarComponentRegistry:FI,clickableCellRegistry:V_,otRegistry:xx,inverseCommandRegistry:aS,urlRegistry:ta,cellPopoverRegistry:Yb,numberFormatMenuRegistry:bx,repeatLocalCommandTransformRegistry:__,repeatCommandTransformRegistry:O_,clipboardHandlersRegistries:Rr,pivotRegistry:nI,pivotTimeAdapterRegistry:OR,pivotSidePanelRegistry:lI,supportedPivotExplodedFormulaRegistry:um},SM={arg:$l,isEvaluationError:Wo,toBoolean:is,toJsDate:ns,toNumber:Zo,toString:ts,toXC:Tt,toZone:Li,toUnboundedZone:Pi,toCartesian:Rt,numberToLetters:yt,lettersToNumber:xt,UuidGenerator:Vn,formatValue:Hs,createCurrencyFormat:si,ColorGenerator:Ct,computeTextWidth:xn,createEmptyWorkbookData:aO,createEmptySheet:rO,createEmptyExcelSheet:lO,getDefaultChartJsRuntime:yv,chartFontColor:Sl,getChartAxisTitleRuntime:xl,getFillingMode:Iv,rgbaToHex:ht,colorToRGBA:dt,positionToZone:on,isDefined:De,isMatrix:_o,lazy:ke,genericRepeat:D_,createAction:Hn,createActions:Un,transformRangeData:Ar,deepEquals:Be,overlap:Zi,union:Gi,isInside:Yi,deepCopy:ge,expandZoneOnInsertion:Bi,reduceZoneOnDeletion:$i,unquote:me,makePivotFormula:Ab,getMaxObjectId:Ob,getFunctionsFromTokens:yb,getFirstPivotFunction:_b,getNumberOfPivotFunctions:Db,parseDimension:Nb,isDateField:Pb,makeFieldProposal:Lb,insertTokenAfterArgSeparator:kb,insertTokenAfterLeftParenthesis:Vb,mergeContiguousZones:dn,getPivotHighlights:yx,pivotTimeAdapter:function(e){return OR.get(e)},UNDO_REDO_PIVOT_COMMANDS:o_},CM={isMarkdownLink:xe,parseMarkdownLink:Re,markdownLink:Ie,openLink:ra,urlRepresentation:na},yM={Checkbox:wx,Section:Ix,RoundColorPicker:Wx,ChartDataSeries:Ox,ChartErrorSection:Dx,ChartLabelRange:Mx,ChartTitle:qx,ChartPanel:nw,ChartFigure:eS,ChartJsComponent:ll,Grid:AR,GridOverlay:cR,ScorecardChart:Ul,LineConfigPanel:Qx,BarConfigPanel:Nx,PieChartDesignPanel:Jx,GenericChartConfigPanel:Fx,ChartWithAxisDesignPanel:jx,GaugeChartConfigPanel:Xx,GaugeChartDesignPanel:Kx,ScorecardChartConfigPanel:ew,ScorecardChartDesignPanel:tw,FigureComponent:NI,Menu:US,Popover:SS,SelectionInput:Ax,ValidationMessages:_x,AddDimensionButton:zw,PivotDimensionGranularity:Gw,PivotDimensionOrder:Ww,PivotDimension:$w,PivotLayoutConfigurator:qw,EditableName:Hw},EM={useDragAndDropListItems:hw,useHighlights:bw,useHighlightsOnHover:fw},xM={useStoreProvider:$a,DependencyContainer:Ba,CellPopoverStore:gS,ComposerFocusStore:il,ComposerStore:sl,FindAndReplaceStore:kw,HighlightStore:el,HoveredCellStore:uS,ModelStore:ja,NotificationStore:tl,RendererStore:Ka,SelectionInputStore:Tx,SpreadsheetStore:Qa,useStore:Ga,useLocalStore:Wa,SidePanelStore:wR,PivotSidePanelStore:rI};const wM={DEFAULT_LOCALE:Ao,HIGHLIGHT_COLOR:s,PIVOT_TABLE_CONFIG:he};e.AbstractCellClipboardHandler=qn,e.AbstractChart=cl,e.AbstractFigureClipboardHandler=Ir,e.CellErrorType=No,e.CorePlugin=hO,e.DispatchResult=xo,e.EvaluationError=Lo,e.Model=class extends Ua{corePlugins=[];featurePlugins=[];statefulUIPlugins=[];coreViewsPlugins=[];range;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},o={},s=[],i=new Vn,n=!0){const r=performance.now();console.group("Model creation"),super(),s=sO(e,s);const a=tO(e,n);this.state=new RD,this.uuidGenerator=i,this.config=this.setupConfig(o),this.session=this.setupSession(a.revisionId),this.coreGetters={},this.range=new fO(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.coreGetters.recomputeRanges=this.range.recomputeRanges.bind(this.range),this.coreGetters.isRangeValid=this.range.isRangeValid.bind(this.range),this.coreGetters.extendRange=this.range.extendRange.bind(this.range),this.coreGetters.getRangesUnion=this.range.getRangesUnion.bind(this.range),this.coreGetters.removeRangesSheetPrefix=this.range.removeRangesSheetPrefix.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new wD(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of N_.getAll())this.setupCorePlugin(e,a);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(s);for(let e of k_.getAll()){const t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of L_.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of P_.getAll()){const t=this.setupUiPlugin(e);this.featurePlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}if(this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.joinSession(),o.snapshotRequested){const e=performance.now();console.info("Snapshot requested"),this.session.snapshot(this.exportData()),this.garbageCollectExternalResources(),console.info("Snapshot taken in",performance.now()-e,"ms")}t.markRaw(this),console.info("Model created in",performance.now()-r,"ms"),console.groupEnd()}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}for(const o of e.layers)this.renderers[o]||(this.renderers[o]=[]),this.renderers[o].push(t);return t}setupCorePlugin(e,t){const o=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in o))throw new Error(`Invalid getter name: ${t} for plugin ${o.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=o[t].bind(o)}o.import(t),this.corePlugins.push(o),this.coreHandlers.push(o),this.handlers.push(o)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new b_(yD({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1)}}),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-undone",this,(({commands:e})=>{this.dispatchFromCorePlugin("UNDO",{commands:e}),this.finalize()})),this.session.on("revision-redone",this,(({commands:e})=>{this.dispatchFromCorePlugin("REDO",{commands:e}),this.finalize()})),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:uo("Anonymous").toString()},o=e.transportService||new gD;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:o,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e),raiseBlockingErrorUI:e=>this.trigger("raise-error-ui",{text:e}),customColors:e.customColors||[]}}setupExternalConfig(e){const t=e.loadLocales||(()=>Promise.resolve(To));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,canDispatch:this.canDispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrencyFormat:this.config.defaultCurrencyFormat,customColors:this.config.customColors||[]}}checkDispatchAllowed(e){const t=Eo(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some((e=>"Success"!==e))?new xo(t.flat()):xo.Success}checkDispatchAllowedCoreCommand(e){const t=this.corePlugins.map((t=>t.allowDispatch(e)));return t.push(this.range.allowDispatch(e)),t}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map((t=>t.allowDispatch(e)))}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0,this.trigger("command-finalized")}canDispatch=(e,t)=>this.checkDispatchAllowed(mM(e,t));dispatch=(e,t)=>{const o=mM(e,t);let s=this.status;if(this.getters.isReadonly()&&(i=o,!Co.has(i.type)))return new xo("Readonly");var i;if(!this.session.canApplyOptimisticUpdate())return new xo("WaitingSessionConfirmation");switch(s){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return t;this.status=1;const{changes:s,commands:i}=this.state.recordChanges((()=>{const t=performance.now();Eo(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize();const s=performance.now()-t;s>5&&console.info(e,s,"ms")}));this.session.save(o,i,s),this.status=0,this.trigger("update");break;case 1:if(Eo(o)){const e=this.checkDispatchAllowed(o);if(!e.isSuccessful)return e;this.state.addCommand(o)}this.dispatchToHandlers(this.handlers,o);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(Eo(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return xo.Success};dispatchFromCorePlugin=(e,t)=>{const o=mM(e,t),s=this.status;this.status=2;const i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,o),this.status=s,xo.Success};dispatchToHandlers(e,t){const o=Eo(t);for(const s of e)!o&&s instanceof hO||s.beforeHandle(t);for(const s of e)!o&&s instanceof hO||s.handle(t);this.trigger("command-dispatched",t)}drawLayer(e,t){const o=this.renderers[t];if(o)for(const s of o)e.ctx.save(),s.drawLayer(e,t),e.ctx.restore()}exportData(){let e=aO();for(let t of this.handlers)t instanceof hO&&t.export(e);return e.revisionId=this.session.getRevisionId()||Y,e=ge(e),e}updateMode(e){this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...aO(),sheets:[lO(eO,"Sheet1")]};for(let t of this.handlers)t instanceof cO&&t.exportForExcel(e);return e=ge(e),uM(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.PivotRuntimeDefinition=Zw,e.Registry=zn,e.Revision=m_,e.SPREADSHEET_DIMENSIONS=bM,e.Spreadsheet=uD,e.SpreadsheetPivotTable=Xw,e.UIPlugin=vO,e.__info__=fM,e.addFunction=function e(t,o){return _f.add(t,o),{addFunction:(t,o)=>e(t,o)}},e.addRenderingLayer=function(e,t){if(Mo[e])throw new Error(`Layer ${e} already exists`);Mo[e]=t},e.astToFormula=Gr,e.compile=mb,e.compileTokens=fb,e.components=yM,e.constants=wM,e.convertAstNodes=Br,e.coreTypes=yo,e.findCellInNewZone=tn,e.functionCache=pb,e.helpers=SM,e.hooks=EM,e.invalidateCFEvaluationCommands=vo,e.invalidateDependenciesCommands=bo,e.invalidateEvaluationCommands=fo,e.iterateAstNodes=Hr,e.links=CM,e.load=tO,e.parse=Vr,e.parseTokens=Ur,e.readonlyAllowedCommands=Co,e.registries=vM,e.setDefaultSheetViewSize=function(e){re=e},e.setTranslationMethod=function(e,t=(()=>!0)){lo=e,co=t},e.stores=xM,e.tokenColors=nb,e.tokenize=jn,fM.version="17.4.0-alpha.0",fM.date="2024-05-31T15:37:08.535Z",fM.hash="9094f27"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|
|
3052
|
+
`}var pM;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(pM||(pM={}));function mM(e,t={}){const o=ge(t);return o.type=e,o}const fM={},bM={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:O,HEADER_WIDTH:_,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:D,DEFAULT_CELL_HEIGHT:M,SCROLLBAR_WIDTH:F},vM={autoCompleteProviders:va,autofillModifiersRegistry:Hb,autofillRulesRegistry:zb,cellMenuRegistry:My,colMenuRegistry:fx,errorTypes:Po,linkMenuRegistry:VS,functionRegistry:_f,featurePluginRegistry:P_,statefulUIPluginRegistry:L_,coreViewsPluginRegistry:k_,corePluginRegistry:N_,rowMenuRegistry:Cx,sidePanelRegistry:MI,figureRegistry:sS,chartSidePanelComponentRegistry:sw,chartComponentRegistry:Qv,chartRegistry:Kv,topbarMenuRegistry:Ex,topbarComponentRegistry:FI,clickableCellRegistry:V_,otRegistry:xx,inverseCommandRegistry:aS,urlRegistry:ta,cellPopoverRegistry:Yb,numberFormatMenuRegistry:bx,repeatLocalCommandTransformRegistry:__,repeatCommandTransformRegistry:O_,clipboardHandlersRegistries:Rr,pivotRegistry:nI,pivotTimeAdapterRegistry:OR,pivotSidePanelRegistry:lI,supportedPivotExplodedFormulaRegistry:um},SM={arg:$l,isEvaluationError:Wo,toBoolean:is,toJsDate:ns,toNumber:Zo,toString:ts,toXC:Tt,toZone:Li,toUnboundedZone:Pi,toCartesian:Rt,numberToLetters:yt,lettersToNumber:xt,UuidGenerator:Vn,formatValue:Hs,createCurrencyFormat:si,ColorGenerator:Ct,computeTextWidth:xn,createEmptyWorkbookData:aO,createEmptySheet:rO,createEmptyExcelSheet:lO,getDefaultChartJsRuntime:yv,chartFontColor:Sl,getChartAxisTitleRuntime:xl,getFillingMode:Iv,rgbaToHex:ht,colorToRGBA:dt,positionToZone:on,isDefined:De,isMatrix:_o,lazy:ke,genericRepeat:D_,createAction:Hn,createActions:Un,transformRangeData:Ar,deepEquals:Be,overlap:Zi,union:Gi,isInside:Yi,deepCopy:ge,expandZoneOnInsertion:Bi,reduceZoneOnDeletion:$i,unquote:me,makePivotFormula:Ab,getMaxObjectId:Ob,getFunctionsFromTokens:yb,getFirstPivotFunction:_b,getNumberOfPivotFunctions:Db,parseDimension:Nb,isDateField:Pb,makeFieldProposal:Lb,insertTokenAfterArgSeparator:kb,insertTokenAfterLeftParenthesis:Vb,mergeContiguousZones:dn,getPivotHighlights:yx,pivotTimeAdapter:function(e){return OR.get(e)},UNDO_REDO_PIVOT_COMMANDS:o_},CM={isMarkdownLink:xe,parseMarkdownLink:Re,markdownLink:Ie,openLink:ra,urlRepresentation:na},yM={Checkbox:wx,Section:Ix,RoundColorPicker:Wx,ChartDataSeries:Ox,ChartErrorSection:Dx,ChartLabelRange:Mx,ChartTitle:qx,ChartPanel:nw,ChartFigure:eS,ChartJsComponent:ll,Grid:AR,GridOverlay:cR,ScorecardChart:Ul,LineConfigPanel:Qx,BarConfigPanel:Nx,PieChartDesignPanel:Jx,GenericChartConfigPanel:Fx,ChartWithAxisDesignPanel:jx,GaugeChartConfigPanel:Xx,GaugeChartDesignPanel:Kx,ScorecardChartConfigPanel:ew,ScorecardChartDesignPanel:tw,FigureComponent:NI,Menu:US,Popover:SS,SelectionInput:Ax,ValidationMessages:_x,AddDimensionButton:zw,PivotDimensionGranularity:Gw,PivotDimensionOrder:Ww,PivotDimension:$w,PivotLayoutConfigurator:qw,EditableName:Hw},EM={useDragAndDropListItems:hw,useHighlights:bw,useHighlightsOnHover:fw},xM={useStoreProvider:$a,DependencyContainer:Ba,CellPopoverStore:gS,ComposerFocusStore:il,ComposerStore:sl,FindAndReplaceStore:kw,HighlightStore:el,HoveredCellStore:uS,ModelStore:ja,NotificationStore:tl,RendererStore:Ka,SelectionInputStore:Tx,SpreadsheetStore:Qa,useStore:Ga,useLocalStore:Wa,SidePanelStore:wR,PivotSidePanelStore:rI};const wM={DEFAULT_LOCALE:Ao,HIGHLIGHT_COLOR:s,PIVOT_TABLE_CONFIG:he};e.AbstractCellClipboardHandler=qn,e.AbstractChart=cl,e.AbstractFigureClipboardHandler=Ir,e.CellErrorType=No,e.CorePlugin=hO,e.DispatchResult=xo,e.EvaluationError=Lo,e.Model=class extends Ua{corePlugins=[];featurePlugins=[];statefulUIPlugins=[];coreViewsPlugins=[];range;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},o={},s=[],i=new Vn,n=!0){const r=performance.now();console.group("Model creation"),super(),s=sO(e,s);const a=tO(e,n);this.state=new RD,this.uuidGenerator=i,this.config=this.setupConfig(o),this.session=this.setupSession(a.revisionId),this.coreGetters={},this.range=new fO(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.coreGetters.recomputeRanges=this.range.recomputeRanges.bind(this.range),this.coreGetters.isRangeValid=this.range.isRangeValid.bind(this.range),this.coreGetters.extendRange=this.range.extendRange.bind(this.range),this.coreGetters.getRangesUnion=this.range.getRangesUnion.bind(this.range),this.coreGetters.removeRangesSheetPrefix=this.range.removeRangesSheetPrefix.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new wD(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of N_.getAll())this.setupCorePlugin(e,a);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(s);for(let e of k_.getAll()){const t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of L_.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of P_.getAll()){const t=this.setupUiPlugin(e);this.featurePlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}if(this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.joinSession(),o.snapshotRequested){const e=performance.now();console.info("Snapshot requested"),this.session.snapshot(this.exportData()),this.garbageCollectExternalResources(),console.info("Snapshot taken in",performance.now()-e,"ms")}t.markRaw(this),console.info("Model created in",performance.now()-r,"ms"),console.groupEnd()}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}for(const o of e.layers)this.renderers[o]||(this.renderers[o]=[]),this.renderers[o].push(t);return t}setupCorePlugin(e,t){const o=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in o))throw new Error(`Invalid getter name: ${t} for plugin ${o.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=o[t].bind(o)}o.import(t),this.corePlugins.push(o),this.coreHandlers.push(o),this.handlers.push(o)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new b_(yD({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1)}}),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-undone",this,(({commands:e})=>{this.dispatchFromCorePlugin("UNDO",{commands:e}),this.finalize()})),this.session.on("revision-redone",this,(({commands:e})=>{this.dispatchFromCorePlugin("REDO",{commands:e}),this.finalize()})),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:uo("Anonymous").toString()},o=e.transportService||new gD;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:o,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e),raiseBlockingErrorUI:e=>this.trigger("raise-error-ui",{text:e}),customColors:e.customColors||[]}}setupExternalConfig(e){const t=e.loadLocales||(()=>Promise.resolve(To));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,canDispatch:this.canDispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrencyFormat:this.config.defaultCurrencyFormat,customColors:this.config.customColors||[]}}checkDispatchAllowed(e){const t=Eo(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some((e=>"Success"!==e))?new xo(t.flat()):xo.Success}checkDispatchAllowedCoreCommand(e){const t=this.corePlugins.map((t=>t.allowDispatch(e)));return t.push(this.range.allowDispatch(e)),t}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map((t=>t.allowDispatch(e)))}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0,this.trigger("command-finalized")}canDispatch=(e,t)=>this.checkDispatchAllowed(mM(e,t));dispatch=(e,t)=>{const o=mM(e,t);let s=this.status;if(this.getters.isReadonly()&&(i=o,!Co.has(i.type)))return new xo("Readonly");var i;if(!this.session.canApplyOptimisticUpdate())return new xo("WaitingSessionConfirmation");switch(s){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return t;this.status=1;const{changes:s,commands:i}=this.state.recordChanges((()=>{const t=performance.now();Eo(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize();const s=performance.now()-t;s>5&&console.info(e,s,"ms")}));this.session.save(o,i,s),this.status=0,this.trigger("update");break;case 1:if(Eo(o)){const e=this.checkDispatchAllowed(o);if(!e.isSuccessful)return e;this.state.addCommand(o)}this.dispatchToHandlers(this.handlers,o);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(Eo(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return xo.Success};dispatchFromCorePlugin=(e,t)=>{const o=mM(e,t),s=this.status;this.status=2;const i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,o),this.status=s,xo.Success};dispatchToHandlers(e,t){const o=Eo(t);for(const s of e)!o&&s instanceof hO||s.beforeHandle(t);for(const s of e)!o&&s instanceof hO||s.handle(t);this.trigger("command-dispatched",t)}drawLayer(e,t){const o=this.renderers[t];if(o)for(const s of o)e.ctx.save(),s.drawLayer(e,t),e.ctx.restore()}exportData(){let e=aO();for(let t of this.handlers)t instanceof hO&&t.export(e);return e.revisionId=this.session.getRevisionId()||Y,e=ge(e),e}updateMode(e){this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...aO(),sheets:[lO(eO,"Sheet1")]};for(let t of this.handlers)t instanceof cO&&t.exportForExcel(e);return e=ge(e),uM(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.PivotRuntimeDefinition=Zw,e.Registry=zn,e.Revision=m_,e.SPREADSHEET_DIMENSIONS=bM,e.Spreadsheet=uD,e.SpreadsheetPivotTable=Xw,e.UIPlugin=vO,e.__info__=fM,e.addFunction=function e(t,o){return _f.add(t,o),{addFunction:(t,o)=>e(t,o)}},e.addRenderingLayer=function(e,t){if(Mo[e])throw new Error(`Layer ${e} already exists`);Mo[e]=t},e.astToFormula=Gr,e.compile=mb,e.compileTokens=fb,e.components=yM,e.constants=wM,e.convertAstNodes=Br,e.coreTypes=yo,e.findCellInNewZone=tn,e.functionCache=pb,e.helpers=SM,e.hooks=EM,e.invalidateCFEvaluationCommands=vo,e.invalidateDependenciesCommands=bo,e.invalidateEvaluationCommands=fo,e.iterateAstNodes=Hr,e.links=CM,e.load=tO,e.parse=Vr,e.parseTokens=Ur,e.readonlyAllowedCommands=Co,e.registries=vM,e.setDefaultSheetViewSize=function(e){re=e},e.setTranslationMethod=function(e,t=(()=>!0)){lo=e,co=t},e.stores=xM,e.tokenColors=nb,e.tokenize=jn,fM.version="17.4.0-alpha.1",fM.date="2024-06-03T15:30:28.283Z",fM.hash="cb56c37"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|