@odoo/o-spreadsheet 18.0.14 → 18.0.15

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";function o(e){return e.map(i).sort(((e,t)=>e.sequence-t.sequence))}let s=1;function i(e){const t=e.name,o=e.children,n=e.description,r=e.icon,a=e.secondaryIcon;return{id:(e.id||s++).toString(),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(i):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:"function"==typeof r?r:()=>r||"",iconColor:e.iconColor,secondaryIcon:"function"==typeof a?a:()=>a||"",description:"function"==typeof n?n:()=>n||"",textColor:e.textColor,sequence:e.sequence||0,onStartHover:e.onStartHover,onStopHover:e.onStopHover}}class n{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]}}const r=.5,a="#37A850",l="#f5f5f5",c="#F8F9FA",h="#E8EAED",d="#595959",u="#666666",g="#c9ccd2",p="#3266ca",m="#FFFFFF",f="#CACACA",v=11982760,b="#017E84",S="#188038",y="#E0E2E4",C="#4A4F59",w="#999",E="#E2E3E3",x="#BCBCBC",I="#9B359B",R="#4EA7F2",T="#EA6175",A="#AAAAAA",_="#111827",D="#D8DADD",O="#E7E9ED",F="#F9FAFB",M="#374151",N=M+"C2",P="#111827",k="#714B67",L=O,V=D,U="#111827",H="#e6f2f3",B="#111827",z="#017E84",$="#D44C591A",G="#C34A41",W="#E6F2F3",q=20,Z=22,j=["#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"],Y=26,X=48,K=96,Q=23,J=15,ee=4,te=ee,oe=21,se=17,ie=2*Q,ne=250,re={align:"left",verticalAlign:"bottom",wrapping:"overflow",bold:!1,italic:!1,strikethrough:!1,underline:!1,fontSize:10,fillColor:"",textColor:""},ae=re.verticalAlign,le=re.wrapping,ce="400",he=re.fontSize,de="'Roboto', arial",ue="thin",ge="#000000",pe="START_REVISION",me=1,fe=20,ve="??",be="difference",Se="#43C5B1",ye="#EA6175",Ce=.4,we=["'","*","?","/","\\","[","]"],Ee=/'|\*|\?|\/|\\|\[|\]/,xe="|";var Ie;!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"}(Ie||(Ie={}));let Re=0;function Te(){return Re}const Ae="\n",_e=[6,7,8,9,10,11,12,14,18,24,36],De={hasFilters:!1,totalRow:!1,firstColumn:!0,lastColumn:!1,numberOfHeaders:1,bandedRows:!0,bandedColumns:!1,styleId:"TableStyleMedium5",automaticAutofill:!1},Oe={symbol:"$",position:"before",decimalPlaces:2,code:"",name:"Dollar"},Fe=new RegExp(Ee,"g");function Me(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function Ne(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pe(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&&null!==e&&(e?.constructor===Object||void 0===e?.constructor)}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");for(const o in e)t[o]=Pe(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 ke(e){return Le(e,"'")}function Le(e,t='"'){return e.startsWith(t)&&(e=e.slice(1)),e.endsWith(t)&&(e=e.slice(0,-1)),e}function Ve(e){return e.match(/\w/g)?.length!==e.length&&(e=`'${e}'`),e}function Ue(e,t=" "){return e.replace(Fe,t)}function He(e,t,o){return e<t?t:e>o?o:e}function Be(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 ze(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*$e(e,t){t.next();for(const o of e){const e=t.next();yield{...o,next:e.done?void 0:e.value}}}function Ge(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}const We=/^\[(.+)\]\((.+)\)$/,qe=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function Ze(e){return We.test(e)}function je(e){return qe.test(e)}function Ye(e,t){return`[${e}](${t})`}function Xe(e){const t=e.match(We)||[],o=t[1],s=t[2];if(!o||!s)throw new Error(`Could not parse markdown link ${e}.`);return{label:o,url:s}}const Ke="o-spreadsheet://";function Qe(e){return e.startsWith(Ke)}function Je(e){return`${Ke}${e}`}function et(e){if(e.startsWith(Ke))return e.substr(Ke.length);throw new Error(`${e} is not a valid sheet link`)}function tt(e){return void 0!==e}function ot(e){return null!==e}function st(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?st(e):!e))}function it(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 nt(e){let t="";for(let o=0,s=e.length;o<s;o++)t+=e[o];return t}function rt(e){let t,o=!1;const s=()=>(o||(t=e instanceof Function?e():e,o=!0),t);return s.map=e=>rt((()=>e(s()))),s}function at(e,t){let o=e.slice(t).find((e=>e));return o||(o=e.slice(0,t).reverse().find((e=>e))),o||""}function lt(e,t){return"after"===e?t+1:t}function ct(e,t){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 o in e){if(typeof e[o]!=typeof t[o])return!1;if("object"==typeof e[o]){if(!ct(e[o],t[o]))return!1}else if(e[o]!==t[o])return!1}return!0}function ht(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(!ct(e[o],t[o]))return!1;return!0}function dt(e,t){return t.every((t=>e.includes(t)))}function ut(e){if(!e)return e;const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}const gt=[" ","\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))],pt=new RegExp(gt.join("|"),"g"),mt=/(\r\n|\r)/g;function ft(e){return e?e.replace(mt,Ae):""}function vt(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 bt(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 St(e,t){return e.filter(((e,o)=>!t.includes(o)))}function yt(e,t,o){const s=[...e];return s.splice(o,0,...t),s}function Ct(e){return e.split("\n").map((e=>e.replace(/\s+/g," ").trim())).join("\n")}function wt(e,t,o){return t>o?wt(e,o,t):e>=t&&e<=o}function Et(e,t){let o=Ne(e);const s=t.matchCase?"":"i";return t.exactMatch&&(o=`^${o}$`),RegExp(o,s)}function xt(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 It(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}class Rt{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 Tt(e,t=(e=>e)){const o=new Set;return e.filter((e=>{const s=t(e);return!o.has(s)&&(o.add(s),!0)}))}function At(e){const t={};for(const o in e)for(const s in e[o])t[s]||(t[s]={}),t[s][o]=e[o][s];return t}const _t=/rgba?\(|\s+|\)/gi,Dt=/^#([A-F\d]{2}){3,4}$/,Ot=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function Ft(e){return Mt(e.toString(16).padStart(6,"0"))}function Mt(e){let t=e;if(e.startsWith("rgb")?t=function(e){const t=e.replace(_t,"").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"#"+nt(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}`),!Dt.test(t))throw new Error(`invalid color input: ${e}`);return t}function Nt(e){try{return Mt(e),!0}catch(e){return!1}}const Pt=e=>e>=0&&e<=255;function kt(e,t,o,s=1){if(!Pt(e)||!Pt(t)||!Pt(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 Lt(e){let{r:t,g:o,b:s}=Ut(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 Vt(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 Ut(e){let t,o,s,i;if(7===(e=Mt(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 Ht(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 Bt(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 zt(e){return Vt(Ht(e))}function $t(e){return Bt(Ut(e))}function Gt(e,t){return 1===t?Mt(e).slice(0,7):Vt({...Ut(e),a:t})}function Wt(e,t){const o=$t(e);return 1===t?"#fff":(o.l=t*(100-o.l)+o.l,zt(o))}function qt(e,t){const o=$t(e);return 1===t?"#000":(o.l=o.l-t*o.l,zt(o))}const Zt=["#4EA7F2","#EA6175","#43C5B1","#F4A261","#8481DD","#FFD86D"],jt=["#4EA7F2","#3188E6","#43C5B1","#00A78D","#EA6175","#CE4257","#F4A261","#F48935","#8481DD","#5752D1","#FFD86D","#FFBC2C"],Yt=["#4EA7F2","#3188E6","#056BD9","#A76DBC","#7F4295","#6D2387","#EA6175","#CE4257","#982738","#43C5B1","#00A78D","#0E8270","#F4A261","#F48935","#BE5D10","#8481DD","#5752D1","#3A3580","#A4A8B6","#7E8290","#545B70","#FFD86D","#FFBC2C","#C08A16"],Xt=["#4EA7F2","#3188E6","#056BD9","#155193","#A76DBC","#7F4295","#6D2387","#4F1565","#EA6175","#CE4257","#982738","#791B29","#43C5B1","#00A78D","#0E8270","#105F53","#F4A261","#F48935","#BE5D10","#7D380D","#8481DD","#5752D1","#3A3580","#26235F","#A4A8B6","#7E8290","#545B70","#3F4250","#FFD86D","#FFBC2C","#C08A16","#936A12"];function Kt(e,t){return t[e%t.length]}function Qt(e){return e<=6?Zt:e<=12?jt:e<=24?Yt:Xt}class Jt{preferredColors;currentColorIndex=0;palette;constructor(e,t=[]){this.preferredColors=t,this.palette=Qt(e).filter((e=>!t.includes(e)))}next(){return this.preferredColors?.[this.currentColorIndex]?this.preferredColors[this.currentColorIndex++]:Kt(this.currentColorIndex++,this.palette)}}function eo(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):eo(Math.floor(e/26)-1)+eo(e%26)}function to(e){let t=0;const o=e.length;for(let s=0;s<o;s++){const o=e.charCodeAt(s);t=26*t+(o>=65&&o<=90?o-64:o-96)}return t-1}function oo(e){return e>="0"&&e<="9"}function so(e){let t="",o="",s=0;for("$"===(e=e.trim())[s]&&s++;s<e.length&&((i=e[s])>="A"&&i<="Z"||i>="a"&&i<="z");)t+=e[s++];var i;if(0===t.length||t.length>3)throw new Error(`Invalid cell description: ${e}`);for("$"===e[s]&&s++;s<e.length&&oo(e[s]);)o+=e[s++];if(s!==e.length||0===o.length||o.length>7)throw new Error(`Invalid cell description: ${e}`);const n=to(t),r=Number(o)-1;if(isNaN(r))throw new Error(`Invalid cell description: ${e}`);return{col:n,row:r}}function io(e,t,o={colFixed:!1,rowFixed:!1}){return(o.colFixed?"$":"")+eo(e)+(o.rowFixed?"$":"")+String(t+1)}function no(e,t=[]){if(e.length<=1&&0===t.length)return e;const o=[0],s=new Map([[0,[]]]);return ro(o,s,e,!1),ro(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 ro(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=ao(e,t,o,!0,0),a=ao(e,t,n,!1,r);for(let o=r;o<=a;o++){lo(t.get(e[o]),i,s)}co(e,t,r,a)}}function ao(e,t,o,s,i){if(void 0===o)return e.length-1;const n=ho(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 lo(e,t,o=!1){const s=t.top,i=void 0===t.bottom?void 0:t.bottom+1,n=[],r=ho(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 co(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--)ht(t.get(e[o]),t.get(e[o-1]))&&(t.delete(e[o]),e.splice(o,1))}function ho(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}const uo=e=>e,go=()=>!1;let po=uo,mo=go;function fo(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 vo=function(e,...t){return mo()?fo(po(e),...t):new bo(e,t)};class bo extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return mo()?fo(po(e),...this.values):fo(e,...this.values)}toString(){return this.valueOf()}}const So=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),yo=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),Co=new RegExp(/^\$?([A-Z]{1,3})+$/,"i"),wo=new RegExp(/^\$?([0-9]{1,7})+$/,"i"),Eo=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),xo=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),Io=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[So.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 Ro(e){return Eo.test(e)}function To(e){return xo.test(e)}function Ao(e){return Co.test(e)}function _o(e){return wo.test(e)}function Do(e){return yo.test(e)}function Oo(e){if(!e.includes("!"))return{xc:e};const t=e.split("!"),o=t.pop();return{sheetName:ke(t.join("!"))||void 0,xc:o}}function Fo(e,t){return void 0!==e?`${Ve(e)}!${t}`:t}function Mo(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(Ro(r))i=n=to(r),o=s=0,a=!0;else if(To(r))o=s=parseInt(r,10)-1,i=n=0,l=!0;else{const e=so(r);i=n=e.col,o=s=e.row,c=!0}if(t)if(Ro(t))n=to(t),a=!0;else if(To(t))s=parseInt(t,10)-1,l=!0;else{const e=so(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 No(e){const t=Mo(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function Po(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))&&(ko(e)&&e.top>=0&&e.left>=0)}function ko(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 Lo(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?`${io(s,t)}:${eo(i)}`:`${eo(s)}:${eo(i)}`;if(void 0===i&&void 0!==o)return 0!==s||n?`${io(s,t)}:${o+1}`:`${t+1}:${o+1}`;if(void 0!==o&&void 0!==i)return r?io(s,t):`${io(s,t)}:${io(i,o)}`;throw new Error(vo("Bad zone format"))}function Vo(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?Jo(e,n,"RESIZE",i):r<e[t]?Jo(e,n,"MOVE",i):{...e}}function Uo(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?Jo(e,n,"RESIZE",i):r<e[t]?Jo(e,n,"MOVE",i):{...e}}function Ho(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 Bo(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 zo(...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 $o(e,t){if(Wo(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 Go(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function Wo(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function qo(e,t,o){const{left:s,right:i,top:n,bottom:r}=o;return e>=s&&e<=i&&t>=n&&t<=r}function Zo(e,t){return Go(zo(t,e),t)}function jo(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function Yo(e){const{numberOfCols:t,numberOfRows:o}=jo(e);return 1===t||1===o}function Xo(e){const t={};for(const o of e)t[o.sheetId]??=[],t[o.sheetId].push(ts(o));for(const e in t)t[e]=no(t[e]);return t}function Ko(e){const t=[],{left:o,right:s,top:i,bottom:n}=Qo(e);for(const e of Be(o,s+1))for(const o of Be(i,n+1))t.push({col:e,row:o});return t}function Qo(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 Jo(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?!(ss(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 es(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 ts(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function os(e){return{...e,right:e.left,bottom:e.top}}function ss(e){return void 0===e.right}function is(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function ns(e){return e.length<2||1===no(e).length}function rs(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)=>{return e!==o&&(n=s,((i=t).right+1===n.left||i.left===n.right+1?i.top<=n.bottom&&i.top>=n.top||n.top<=i.bottom&&n.top>=i.top:(i.bottom+1===n.top||i.top===n.bottom+1)&&(i.left<=n.right&&i.left>=n.left||n.left<=i.right&&n.left>=i.left))||Wo(t,s));var i,n}));if(-1!==i){t[e]=zo(t[i],s),t.splice(i,1),o=!0;break}}}return t}function as(e,t){for(const o in t)if(ct(t[o],e))return parseInt(o,10);const o=Object.keys(t),s=0===o.length?0:xt(o.map((e=>parseInt(e,10))));return t[s+1]=e,s+1}function ls(e){const t={};for(const o in e){const s=no(e[o].map(ts));for(const e of s)t[Lo(e)]=Number(o)}return t}class cs{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 cs(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds())}static now(){const e=new Date;return new cs(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 hs=new cs(1899,11,30),ds=864e5,us=2e3,gs=cs.now().getFullYear(),ps=cs.now().getMonth(),ms=cs.fromTimestamp(0).getTime()-hs.getTime(),fs=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,vs=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,bs=/\/|-|\s/,Ss=/^(\d{1,4})[\/-\s](\d{1,4})([\/-\s](\d{1,4}))?$/,ys=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function Cs(e,t){switch(typeof e){case"number":return e;case"string":return ws(e,t)?xs(e,t)?.value:!e||isNaN(Number(e))?void 0:Number(e);default:return}}function ws(e,t){return null!==xs(e,t)}const Es=new Map;function xs(e,t){return Es.has(t)||Es.set(t,new Map),Es.get(t).has(e)||Es.get(t).set(e,function(e,t){e=e.trim();let o=null;const s=e.match(ys);if(s){if(o=function(e){if(e=e.trim(),ys.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 cs(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(Ss);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(bs)[0];if(i=function(e,t){let{year:o,month:s,day:i}=e;const n=function(e){if(!e)return ps;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 gs;const t=Number(e);switch(e.length){case 1:return us+t;case 2:return us+(us+t>gs+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 cs(a,n,r);if(h.getMonth()!==n||h.getDate()!==r)return null;const d=h.getTime()-hs.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(tt).join(t);case"ymd":return[i,n,r].filter(tt).join(t);case"dmy":return[r,n,i].filter(tt).join(t)}}(e,t,l,c);return{value:Math.round(d/ds),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 cs(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)),Es.get(t).get(e)}function Is(e){const t=Math.trunc(e);let o=cs.fromTimestamp(t*ds-ms),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 Rs(e){return Math.round(Ts(e))}function Ts(e){return(e.getTime()-hs.getTime())/ds}function As(e){return new cs(e.getFullYear(),e.getMonth()+1,0).getDate()}function _s(e){return As(e)===e.getDate()}function Ds(e,t,o){const s=e.getFullYear(),i=e.getMonth(),n=e.getDate(),r=new cs(s,i+t,1);return o&&n===As(e)||n>As(r)?r.setDate(As(r)):r.setDate(n),r}function Os(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function Fs(e,t,o){if(e===t)return 0;if(e>t){const o=t;t=e,e=o}const s=Is(e),i=Is(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===(Os(c)?29:28)&&(n=30,1===l&&r===(Os(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+=Os(o)?366:365;o=t/e}else s?Os(c)&&(o=366):(Os(c)&&a<2&&(o=366),Os(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 Ms(e,t){const o=12*(t.getFullYear()-e.getFullYear())+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?o-1:o}function Ns(e,t){const o=e.getTime(),s=t.getTime();return Math.floor((s-o)/ds)}function Ps(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 ks(e,t,o){return t>o?ks(e,o,t):(e=Math.trunc(e),t=Math.trunc(t),o=Math.trunc(o),e>=t&&e<=o)}const Ls=bt((function(e){return e=Ne(e),new RegExp(`(?:^-?\\d+(?:${e}?\\d*(?:e\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)})),Vs=bt((function(e){const t=Ne(e.decimalSeparator),o="(?:\\s*"+`(?:\\d+(?:${Ne(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 Us(e,t){return!!e&&Vs(t).test(e.trim())}const Hs=bt((function(e){return new RegExp(`[$€${Ne(e.thousandsSeparator||"")}]`,"g")}));function Bs(e,t){e=e.replace(Hs(t),""),"."!==t.decimalSeparator&&(e=e.replace(t.decimalSeparator,"."));let o=Number(e);return isNaN(o)&&e.includes("%")&&(o=Number(e.split("%")[0]),!isNaN(o))?o/100:o}function zs(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)}var $s,Gs;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}($s||($s={})),function(e){e.PlainText="text/plain",e.Html="text/html"}(Gs||(Gs={}));const Ws=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"]),qs=new Set(["EVALUATE_CELLS","UPDATE_CELL","UNHIDE_COLUMNS_ROWS","HIDE_COLUMNS_ROWS","GROUP_HEADERS","UNGROUP_HEADERS","FOLD_ALL_HEADER_GROUPS","FOLD_HEADER_GROUP","FOLD_HEADER_GROUPS_IN_ZONE","UNFOLD_ALL_HEADER_GROUPS","UNFOLD_HEADER_GROUP","UNFOLD_HEADER_GROUPS_IN_ZONE","UPDATE_TABLE","UPDATE_FILTER","UNDO","REDO"]),Zs=new Set(["MOVE_RANGES"]),js=new Set(["DUPLICATE_SHEET","EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","CHANGE_CONDITIONAL_FORMAT_PRIORITY"]),Ys=new Set(["AUTOFILL_CELL","SET_BORDER","SET_ZONE_BORDERS"]),Xs=new Set(["START","ACTIVATE_SHEET","COPY","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","EVALUATE_CELLS","SET_FORMULA_VISIBILITY","UPDATE_FILTER"]),Ks=new Set(["UPDATE_CELL","UPDATE_CELL_POSITION","CLEAR_CELL","CLEAR_CELLS","DELETE_CONTENT","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","RESIZE_COLUMNS_ROWS","HIDE_COLUMNS_ROWS","UNHIDE_COLUMNS_ROWS","SET_GRID_LINES_VISIBILITY","UNFREEZE_COLUMNS","UNFREEZE_ROWS","FREEZE_COLUMNS","FREEZE_ROWS","UNFREEZE_COLUMNS_ROWS","ADD_MERGE","REMOVE_MERGE","CREATE_SHEET","DELETE_SHEET","DUPLICATE_SHEET","MOVE_SHEET","RENAME_SHEET","COLOR_SHEET","HIDE_SHEET","SHOW_SHEET","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 Qs(e){return Ks.has(e.type)}class Js{reasons;constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>"Success"!==e))}static get Success(){return ei}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}const ei=new Js;var ti;e.CommandResult=void 0,(ti=e.CommandResult||(e.CommandResult={})).Success="Success",ti.CancelledForUnknownReason="CancelledForUnknownReason",ti.WillRemoveExistingMerge="WillRemoveExistingMerge",ti.MergeIsDestructive="MergeIsDestructive",ti.CellIsMerged="CellIsMerged",ti.InvalidTarget="InvalidTarget",ti.EmptyUndoStack="EmptyUndoStack",ti.EmptyRedoStack="EmptyRedoStack",ti.NotEnoughElements="NotEnoughElements",ti.NotEnoughSheets="NotEnoughSheets",ti.MissingSheetName="MissingSheetName",ti.UnchangedSheetName="UnchangedSheetName",ti.DuplicatedSheetName="DuplicatedSheetName",ti.DuplicatedSheetId="DuplicatedSheetId",ti.ForbiddenCharactersInSheetName="ForbiddenCharactersInSheetName",ti.WrongSheetMove="WrongSheetMove",ti.WrongSheetPosition="WrongSheetPosition",ti.InvalidAnchorZone="InvalidAnchorZone",ti.SelectionOutOfBound="SelectionOutOfBound",ti.TargetOutOfSheet="TargetOutOfSheet",ti.WrongCutSelection="WrongCutSelection",ti.WrongPasteSelection="WrongPasteSelection",ti.WrongPasteOption="WrongPasteOption",ti.WrongFigurePasteOption="WrongFigurePasteOption",ti.EmptyClipboard="EmptyClipboard",ti.EmptyRange="EmptyRange",ti.InvalidRange="InvalidRange",ti.InvalidZones="InvalidZones",ti.InvalidSheetId="InvalidSheetId",ti.InvalidFigureId="InvalidFigureId",ti.InputAlreadyFocused="InputAlreadyFocused",ti.MaximumRangesReached="MaximumRangesReached",ti.MinimumRangesReached="MinimumRangesReached",ti.InvalidChartDefinition="InvalidChartDefinition",ti.InvalidDataSet="InvalidDataSet",ti.InvalidLabelRange="InvalidLabelRange",ti.InvalidScorecardKeyValue="InvalidScorecardKeyValue",ti.InvalidScorecardBaseline="InvalidScorecardBaseline",ti.InvalidGaugeDataRange="InvalidGaugeDataRange",ti.EmptyGaugeRangeMin="EmptyGaugeRangeMin",ti.GaugeRangeMinNaN="GaugeRangeMinNaN",ti.EmptyGaugeRangeMax="EmptyGaugeRangeMax",ti.GaugeRangeMaxNaN="GaugeRangeMaxNaN",ti.GaugeRangeMinBiggerThanRangeMax="GaugeRangeMinBiggerThanRangeMax",ti.GaugeLowerInflectionPointNaN="GaugeLowerInflectionPointNaN",ti.GaugeUpperInflectionPointNaN="GaugeUpperInflectionPointNaN",ti.GaugeLowerBiggerThanUpper="GaugeLowerBiggerThanUpper",ti.InvalidAutofillSelection="InvalidAutofillSelection",ti.MinBiggerThanMax="MinBiggerThanMax",ti.LowerBiggerThanUpper="LowerBiggerThanUpper",ti.MidBiggerThanMax="MidBiggerThanMax",ti.MinBiggerThanMid="MinBiggerThanMid",ti.FirstArgMissing="FirstArgMissing",ti.SecondArgMissing="SecondArgMissing",ti.MinNaN="MinNaN",ti.MidNaN="MidNaN",ti.MaxNaN="MaxNaN",ti.ValueUpperInflectionNaN="ValueUpperInflectionNaN",ti.ValueLowerInflectionNaN="ValueLowerInflectionNaN",ti.MinInvalidFormula="MinInvalidFormula",ti.MidInvalidFormula="MidInvalidFormula",ti.MaxInvalidFormula="MaxInvalidFormula",ti.ValueUpperInvalidFormula="ValueUpperInvalidFormula",ti.ValueLowerInvalidFormula="ValueLowerInvalidFormula",ti.InvalidSortZone="InvalidSortZone",ti.WaitingSessionConfirmation="WaitingSessionConfirmation",ti.MergeOverlap="MergeOverlap",ti.TooManyHiddenElements="TooManyHiddenElements",ti.Readonly="Readonly",ti.InvalidViewportSize="InvalidViewportSize",ti.InvalidScrollingDirection="InvalidScrollingDirection",ti.ViewportScrollLimitsReached="ViewportScrollLimitsReached",ti.FigureDoesNotExist="FigureDoesNotExist",ti.InvalidConditionalFormatId="InvalidConditionalFormatId",ti.InvalidCellPopover="InvalidCellPopover",ti.EmptyTarget="EmptyTarget",ti.InvalidFreezeQuantity="InvalidFreezeQuantity",ti.FrozenPaneOverlap="FrozenPaneOverlap",ti.ValuesNotChanged="ValuesNotChanged",ti.InvalidFilterZone="InvalidFilterZone",ti.TableNotFound="TableNotFound",ti.TableOverlap="TableOverlap",ti.InvalidTableConfig="InvalidTableConfig",ti.InvalidTableStyle="InvalidTableStyle",ti.FilterNotFound="FilterNotFound",ti.MergeInTable="MergeInTable",ti.NonContinuousTargets="NonContinuousTargets",ti.DuplicatedFigureId="DuplicatedFigureId",ti.InvalidSelectionStep="InvalidSelectionStep",ti.DuplicatedChartId="DuplicatedChartId",ti.ChartDoesNotExist="ChartDoesNotExist",ti.InvalidHeaderIndex="InvalidHeaderIndex",ti.InvalidQuantity="InvalidQuantity",ti.MoreThanOneColumnSelected="MoreThanOneColumnSelected",ti.EmptySplitSeparator="EmptySplitSeparator",ti.SplitWillOverwriteContent="SplitWillOverwriteContent",ti.NoSplitSeparatorInSelection="NoSplitSeparatorInSelection",ti.NoActiveSheet="NoActiveSheet",ti.InvalidLocale="InvalidLocale",ti.MoreThanOneRangeSelected="MoreThanOneRangeSelected",ti.NoColumnsProvided="NoColumnsProvided",ti.ColumnsNotIncludedInZone="ColumnsNotIncludedInZone",ti.DuplicatesColumnsSelected="DuplicatesColumnsSelected",ti.InvalidHeaderGroupStartEnd="InvalidHeaderGroupStartEnd",ti.HeaderGroupAlreadyExists="HeaderGroupAlreadyExists",ti.UnknownHeaderGroup="UnknownHeaderGroup",ti.UnknownDataValidationRule="UnknownDataValidationRule",ti.UnknownDataValidationCriterionType="UnknownDataValidationCriterionType",ti.InvalidDataValidationCriterionValue="InvalidDataValidationCriterionValue",ti.InvalidNumberOfCriterionValues="InvalidNumberOfCriterionValues",ti.InvalidCopyPasteSelection="InvalidCopyPasteSelection",ti.NoChanges="NoChanges",ti.InvalidInputId="InvalidInputId",ti.SheetIsHidden="SheetIsHidden",ti.InvalidTableResize="InvalidTableResize",ti.PivotIdNotFound="PivotIdNotFound",ti.PivotInError="PivotInError",ti.EmptyName="EmptyName",ti.ValueCellIsInvalidFormula="ValueCellIsInvalidFormula",ti.InvalidDefinition="InvalidDefinition",ti.InvalidColor="InvalidColor";const oi=[{name:"English (US)",code:"en_US",thousandsSeparator:",",decimalSeparator:".",weekStart:7,dateFormat:"m/d/yyyy",timeFormat:"hh:mm:ss a",formulaArgSeparator:","},{name:"French",code:"fr_FR",thousandsSeparator:" ",decimalSeparator:",",weekStart:1,dateFormat:"dd/mm/yyyy",timeFormat:"hh:mm:ss",formulaArgSeparator:";"}],si=oi[0],ii=["thin","medium","thick","dashed","dotted"];function ni(e){return Array.isArray(e)&&Array.isArray(e[0])}var ri;!function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(ri||(ri={}));const ai={Background:0,Highlights:1,Clipboard:2,Chart:4,Autofill:5,Selection:6,Headers:100},li=bt((()=>Object.keys(ai).sort(((e,t)=>ai[e]-ai[t]))));const ci={NotAvailable:"#N/A",InvalidReference:"#REF",BadExpression:"#BAD_EXPR",CircularDependency:"#CYCLE",UnknownFunction:"#NAME?",DivisionByZero:"#DIV/0!",SpilledBlocked:"#SPILL!",GenericError:"#ERROR",NullError:"#NULL!"},hi=new Set(Object.values(ci));class di extends Error{value;constructor(e=vo("Error"),t=ci.GenericError){super(e),this.value=t}}class ui extends di{constructor(e=vo("Invalid expression")){super(e,ci.BadExpression)}}class gi extends di{constructor(e=vo("Invalid reference")){super(e,ci.InvalidReference)}}class pi extends di{constructor(e=vo("Data not available")){super(e,ci.NotAvailable)}}class mi extends di{constructor(e=vo("Unknown function")){super(e,ci.UnknownFunction)}}class fi extends di{constructor(e=vo("Spill range is not empty")){super(e,ci.SpilledBlocked)}}const vi=["number","string","boolean","undefined"];function bi(e,t,o){if(!e())throw new di(t,o)}function Si(e){if(void 0!==e)return ni(e)?e[0][0]?.format:e.format}function yi(e){return"string"==typeof e&&hi.has(e)}const Ci=e=>vo("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function wi(e,t){const o=Pi(e);switch(typeof o){case"number":return o;case"boolean":return o?1:0;case"string":if(Us(o,t)||""===o)return Bs(o,t);const e=xs(o,t);if(e)return e.value;throw new di(Ci(o));default:return 0}}function Ei(e,t){try{return wi(e,t)}catch(e){return}}function xi(e,t){return tn(e).map((e=>e.map((e=>{if("number"!=typeof e.value)throw new di(vo("Function [[FUNCTION_NAME]] expects number values for %s, but got a %s.",t,typeof e.value));return e.value}))))}function Ii(e,t){const o=Pi(e);if(""===o)throw new di(Ci(o));return wi(o,t)}function Ri(e,t){return Math.trunc(wi(e,t))}function Ti(e,t){return Math.trunc(Ii(e,t))}function Ai(e){bi((()=>e>=1),vo("The function [[FUNCTION_NAME]] expects a number value to be greater than or equal to 1, but receives %s.",e.toString()))}function _i(e){bi((()=>0!==e),vo("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."),ci.DivisionByZero)}function Di(e){const t=Pi(e);switch(typeof t){case"string":return t;case"number":return t.toString();case"boolean":return t?"TRUE":"FALSE";default:return""}}const Oi=bt((function(e){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")})),Fi=e=>vo("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a boolean.",e);function Mi(e){const t=Pi(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 di(Fi(t))}return!1;case"number":return!!t;default:return!1}}function Ni(e,t){return Is(wi(Pi(e),t))}function Pi(e){if("object"==typeof e&&null!==e&&"value"in e){if(yi(e.value))throw e;return e.value}if(yi(e))throw new di("",e);return e}function ki(e,t,o){for(let s of e)if(ni(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 Li(e,t){ki(e,(e=>{if(yi(e.value))throw e;t(e)}),(e=>{if(yi(e?.value))throw e;t(e)}))}function Vi(e,t,o){ki(e,(e=>{if("number"==typeof e?.value&&t(e),yi(e?.value))throw e}),(e=>{t({value:Ii(e,o),format:e?.format})}))}function Ui(e,t,o,s,i="rowFirst"){let n=s;for(let s of e)if(ni(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 Hi(e,t,o,s="rowFirst"){return Ui(e,t,t,o,s)}function Bi(e,t,o,s){return Ui(e,((e,o)=>{const s=o?.value;if("number"==typeof s)return t(e,s);if(yi(s))throw o;return e}),((e,o)=>t(e,Ii(o,s))),o)}function zi(e,t,o,s){return Ui(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,wi(i,s));if(yi(i))throw o;return t(e,0)}return e}),((e,o)=>t(e,wi(o,s))),o)}function $i(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 Gi(e,t){return 0===e.length?[]:$i(e.length,e[0].length,((o,s)=>t(e[o][s])))}function Wi(e){return e.length?$i(e[0].length,e.length,((t,o)=>e[o][t])):[]}function qi(e,t){return function(e,t,o){for(let s of e)if(ni(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(yi(o))throw e;return!0}),(e=>void 0===e||null===e.value||t(function(e){const t=Pi(e);if(""===t)throw new di(Fi(t));return Mi(t)}(e))))}function Zi(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)),Us(s,t)||ws(s,t)?s=wi(s,t):"TRUE"!==s&&"FALSE"!==s||(s=Mi(s)),{operator:o,operand:s}}const ji=bt((function(e){if("*"===e)return/.+/;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 Yi(e="",t,o){const{operator:s,operand:i}=t;if(void 0===i||null===e||null===i)return!1;if("number"==typeof i&&"="===s)return"string"==typeof e&&(Us(e,o)||ws(e,o))?wi(e,o)===i:e===i;if("<>"===s||"="===s){let t;return t=typeof e==typeof i&&("string"==typeof e&&"string"==typeof i?ji(i).test(e):e===i),"="===s?t:!t}if(typeof e==typeof i)switch(s){case"<":return e<i;case">":return e>i;case"<=":return e<=i;case">=":return e>=i}return!1}function Xi(e,t,o,s=!1){const i=e.length;if(i%2==1)throw new di(vo("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const n=tn(e[0]),r=n.length,a=n[0].length;let l=[];for(let t=0;t<i-1;t+=2){const i=tn(e[t]);if(i.length!==r||i[0].length!==a)throw new di(vo("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const n=Zi(Di(e[t+1]),o);s&&"string"==typeof n.operand&&(n.operand+="*"),l.push(n)}for(let s=0;s<r;s++)for(let n=0;n<a;n++){let r=!0;for(let t=0;t<i-1;t+=2){if(r=Yi(tn(e[t])[s][n].value??void 0,l[t/2],o),!r)break}r&&t(s,n)}}function Ki(e,t,o,s,i,n){if(void 0===t||null===t.value)return-1;if(yi(t.value))throw t;const r=Ji(t.value),a=typeof r;let l,c,h,d,u,g,p=0,m=i-1;const f="desc"===s?t=>Ji(n(e,i-t-1)):t=>Ji(n(e,t));for(;m-p>=0;){for(h=Math.floor((p+m)/2),d=h,u=f(d),g=typeof u;p<d&&a!==g;)d--,u=f(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&&c<d)&&(l=u,c=d):"nextGreater"===o&&u>=r&&(void 0===l||l>u||l===u&&c<d)&&(l=u,c=d),u>r||"strict"===o&&u===r?m=d-1:p=h+1):p=h+1}return void 0===c?-1:"desc"===s?i-c-1:c}function Qi(e,t,o,s,i,n,r=!1){if(void 0===t||null===t.value)return-1;if(yi(t.value))throw t;const a=Ji(t.value),l=r?(e,t)=>Ji(i(e,s-t-1)):(e,t)=>Ji(i(e,t)),c="wildcard"!==o||"string"!=typeof a||!(a.includes("*")||a.includes("?"));if(n&&c){const t=r?"reverseSearch":"forwardSearch";let i=n[t].get(e);if(void 0===i){i=new Map;for(let t=0;t<s;t++){const o=l(e,t)??null;i.has(o)||i.set(o,t)}n[t].set(e,i)}if(i.has(a)){const e=i.get(a);return r?s-e-1:e}if("strict"===o)return-1}const h=function(e,t,o,s,i){let n=o=>i(e,o)===t;if("wildcard"===o&&"string"==typeof t&&(t.includes("*")||t.includes("?"))){const o=ji(t);n=t=>{const s=i(e,t);return"string"==typeof s&&o.test(s)}}let r,a=-1;"nextSmaller"===o&&(n=o=>{const s=i(e,o);return(!r&&en(t,s)>=0||en(t,s)>=0&&en(s,r)>0)&&(r=s,a=o),s===t});"nextGreater"===o&&(n=o=>{const s=i(e,o);return(!r&&en(t,s)<=0||en(t,s)<=0&&en(s,r)<0)&&(r=s,a=o),s===t});for(let e=0;e<s;e++)if(n(e))return e;return a}(e,a,o,s,l);return r&&-1!==h?s-h-1:h}function Ji(e){return"string"==typeof e?Oi(e):e}function en(e,t){let o=vi.indexOf(typeof e)-vi.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 tn(e){return void 0===e?[[]]:ni(e)?e:[[e]]}function on(e,t){return Hi(e,((e,o)=>(e.push(t(o)),e)),[],"rowFirst")}function sn(e){if(void 0===e)return!1;const{value:t}=e;return null!==t&&""!==t}function nn(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}const rn=new n;function an(e,t){return{url:e=nn(e),label:t||e,isExternal:!0,isUrlEditable:!0}}rn.add("sheet_URL",{match:e=>Qe(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){const o=et(e);return t.tryGetSheetName(o)||vo("Invalid sheet")},open(e,t){const o=et(e);t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:o}).isCancelledBecause("SheetIsHidden")&&t.notifyUser({type:"warning",sticky:!1,text:vo("Cannot open the link because the linked sheet is hidden.")})},sequence:0});const ln={createLink:an,match:e=>je(e),open:e=>window.open(e,"_blank"),urlRepresentation:e=>e,sequence:0};function cn(e){return rn.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((t=>t.match(e)))||ln}function hn(e,t){return cn(e.url).urlRepresentation(e.url,t)}function dn(e,t){cn(e.url).open(e.url,t)}function un(e){if("string"==typeof e){if(Ze(e)){const{label:t,url:o}=Xe(e);return cn(o).createLink(o,t)}return je(e)?an(e):void 0}}function gn(e){let t;if('"'===e.current?(e.shift(),t='"'):e.currentStartsWith("[$")&&(e.advanceBy(2),t="]"),!t)return null;let o="";for(;e.current&&e.current!==t;)o+=e.shift();if(e.current!==t)throw new Error("Unterminated string in format");return e.shift(),{type:"STRING",value:o}}const pn=new Set("$+-/():!^&~{}<>= ");function mn(e){if("\\"===e.current){e.shift();const t=e.shift();if(!t)throw new Error("Unexpected end of format string");return{type:"CHAR",value:t}}return pn.has(e.current)?{type:"CHAR",value:e.shift()}:null}function fn(e){return","===e.current?(e.shift(),{type:"THOUSANDS_SEPARATOR",value:","}):null}function vn(e){return"@"===e.current?(e.shift(),{type:"TEXT_PLACEHOLDER",value:"@"}):null}function bn(e){return"."===e.current?(e.shift(),{type:"DECIMAL_POINT",value:"."}):null}function Sn(e){return"%"===e.current?(e.shift(),{type:"PERCENT",value:"%"}):null}function yn(e){if("0"===e.current||"#"===e.current){const t=e.current;return e.shift(),{type:"DIGIT",value:t}}return null}const Cn=new Set("dmqyhsa");function wn(e){if(!Cn.has(e.current))return null;const t=e.current;let o="";for(;e.current===t;)o+=e.shift();return{type:"DATE_PART",value:o}}function En(e){if("*"!==e.current)return null;e.shift();const t=e.shift();if(!t)throw new Error("Unexpected end of format string");return{type:"REPEATED_CHAR",value:t}}const xn=20,In={};function Rn(e){let t=In[e];return void 0===t&&(t=function(e){const t=function(e){const t=new Rt(e),o=[];let s=[];for(o.push(s);!t.isOver();){if(";"===t.current){s=[],o.push(s),t.shift();continue}let e=yn(t)||gn(t)||mn(t)||fn(t)||bn(t)||Sn(t)||wn(t)||vn(t)||En(t);if(!e)throw new Error("Unknown token at "+t.remaining());s.push(e)}return o}(e);for(const e of t){const t=e.filter((e=>"REPEATED_CHAR"===e.type));for(const e of t.slice(1))e.type="CHAR"}const o=An(t[0])||Tn(t[0])||_n(t[0]);if(!o)throw new Error("Invalid first format part of: "+e);if(t.length>1&&"text"===o.type)throw new Error("The first format in a multi-part format must be a number format: "+e);const s=An(t[1])||Tn(t[1]);if(t[1]?.length&&!s)throw new Error("Invalid second format part of: "+e);const i=An(t[2])||Tn(t[2]);if(t[2]?.length&&!i)throw new Error("Invalid third format part of: "+e);const n=_n(t[3]);if(t[3]?.length&&!n)throw new Error("Invalid fourth format part of: "+e);return{positive:o,negative:s,zero:i,text:n}}(e),In[e]=t),t}function Tn(e){if(!e||!function(e){return e.every((e=>"DIGIT"===e.type||"DECIMAL_POINT"===e.type||"THOUSANDS_SEPARATOR"===e.type||"PERCENT"===e.type||"STRING"===e.type||"CHAR"===e.type||"REPEATED_CHAR"===e.type))}(e))return;const t=[];let o,s=t,i=0,n=0,r=e.findLastIndex((e=>"DIGIT"===e.type)),a=!1,l=0;for(let c=0;c<e.length;c++){const h=e[c];switch(h.type){case"DIGIT":s===t?s.push(h):l<xn&&(s.push(h),l++);break;case"DECIMAL_POINT":if(s!==t)throw new Error("Multiple decimal points in a number format");o=[],s=o;break;case"REPEATED_CHAR":case"CHAR":case"STRING":s.push(h);break;case"PERCENT":i++,s.push(h);break;case"THOUSANDS_SEPARATOR":c-1===r?(n+=1,r++,s.push(h)):"DIGIT"===e[c+1]?.type&&"DIGIT"===e[c-1]?.type?(s===t&&(a=!0),s.push(h)):s.push({type:"CHAR",value:","})}}return{type:"number",integerPart:t,decimalPart:o,percentSymbols:i,thousandsSeparator:a,magnitude:n}}function An(e){const t=e&&function(e){return e.every((e=>"DATE_PART"===e.type||"DECIMAL_POINT"===e.type||"THOUSANDS_SEPARATOR"===e.type||"STRING"===e.type||"CHAR"===e.type||"REPEATED_CHAR"===e.type))}(e)?{type:"date",tokens:e}:void 0;if(!t)return;if(t.tokens.length&&t.tokens.every((e=>"DATE_PART"===e.type&&"a"===e.value)))throw new Error("Invalid date format");const o=function(e){const t=e.filter((e=>"DATE_PART"===e.type));for(let e=0;e<t.length;e++)!t[e].value.startsWith("m")||t[e].value.length>2||(t[e-1]?.value.startsWith("h")||t[e+1]?.value.startsWith("s"))&&(t[e].value=t[e].value.replaceAll("m","M"));return e}(t.tokens.map((e=>"THOUSANDS_SEPARATOR"===e.type||"DECIMAL_POINT"===e.type?{type:"CHAR",value:e.value}:e)));return{type:"date",tokens:o}}function _n(e){return e&&function(e){return e.every((e=>"STRING"===e.type||"TEXT_PLACEHOLDER"===e.type||"CHAR"===e.type||"REPEATED_CHAR"===e.type))}(e)?{type:"text",tokens:e}:void 0}function Dn(e){return[On(e.positive),On(e.negative),On(e.zero),On(e.text)].filter(tt).join(";")}function On(e){if(!e)return;let t="";const o="number"!==e.type?e.tokens:function(e){let t=[...e.integerPart];e.decimalPart&&(t.push({type:"DECIMAL_POINT",value:"."}),t.push(...e.decimalPart));return t}(e);for(let e of o)switch(e.type){case"STRING":t+=`[$${e.value}]`;break;case"CHAR":t+=(s=e.value,pn.has(s)?e.value:`\\${e.value}`);break;case"REPEATED_CHAR":t+="*"+e.value;break;default:t+=e.value}var s;return t}const Fn=11,Mn="REPEATED_CHAR_PLACEHOLDER_",Nn={0:vo("January"),1:vo("February"),2:vo("March"),3:vo("April"),4:vo("May"),5:vo("June"),6:vo("July"),7:vo("August"),8:vo("September"),9:vo("October"),10:vo("November"),11:vo("December")},Pn={0:vo("Sunday"),1:vo("Monday"),2:vo("Tuesday"),3:vo("Wednesday"),4:vo("Thursday"),5:vo("Friday"),6:vo("Saturday")};function kn(e,{format:t,locale:o,formatWidth:s}){switch("boolean"==typeof e&&(e=e?"TRUE":"FALSE"),typeof e){case"string":{if(e.includes('\\"')&&(e=e.replaceAll(/\\"/g,'"')),!t)return e;const o=Rn(t);let i=o.text||o.positive;return i&&"text"===i.type?Ln(e,i,s):e}case"number":t||(t=Zn(e));const i=Rn(t);if("text"===i.positive.type)return Ln(e.toString(),i.positive,s);let n=i.positive;if(e<0&&i.negative?(n=i.negative,e=-e):0===e&&i.zero&&(n=i.zero),"date"===n.type)return Vn(function(e,t){const o=Is(e),s=t.tokens.some((e=>"DATE_PART"===e.type&&"a"===e.value));let i="";for(const e of t.tokens)switch(e.type){case"DATE_PART":i+=Wn(o,e.value,s);break;case"REPEATED_CHAR":i+=Mn+e.value;break;default:i+=e.value}return i}(e,n),s);const r=e<0,a=Vn(function(e,t,o){if(e===1/0)return"∞"+(t.percentSymbols?"%":"");const s=2*t.percentSymbols-3*t.magnitude;e*=10**s;let i=0;void 0!==t.decimalPart&&(i=t.decimalPart.filter((e=>"DIGIT"===e.type)).length);const{integerDigits:n,decimalDigits:r}=Hn(Math.abs(e),i);let a=function(e,t,o){let s=t.integerPart;s.some((e=>"DIGIT"===e.type))||(s=[...s,{type:"DIGIT",value:"#"}]);"0"===e&&(e="");let i="";const n=s.findIndex((e=>"DIGIT"===e.type));let r=e.length-1;function a(t,s){if("0"===s&&(t=t||"0"),!t)return;const n=e.length-1-r;i=o&&n>0&&n%3==0?t+o+i:t+i}for(let t=s.length-1;t>=0;t--){const o=s[t];switch(o.type){case"DIGIT":if(a(e[r],o.value),r--,n===t)for(;r>=0;)a(e[r],"0"),r--;break;case"THOUSANDS_SEPARATOR":break;case"REPEATED_CHAR":i=Mn+o.value+i;break;default:i=o.value+i}}return i}(n,t,t.thousandsSeparator?o.thousandsSeparator:void 0);void 0!==t.decimalPart&&(a+=o.decimalSeparator+function(e,t){if(!t.decimalPart)return"";let o="",s=0;for(const i of t.decimalPart)switch(i.type){case"DIGIT":o+="#"===i.value?e[s]||"":e[s]||"0",s++;break;case"THOUSANDS_SEPARATOR":break;case"REPEATED_CHAR":o+=Mn+i.value;break;default:o+=i.value}return o}(r||"",t));return a}(Math.abs(e),n,o),s);return r?"-"+a:a;case"object":return""}}function Ln(e,t,o){let s="";for(const o of t.tokens)switch(o.type){case"TEXT_PLACEHOLDER":s+=e;break;case"CHAR":case"STRING":s+=o.value;break;case"REPEATED_CHAR":s+=Mn+o.value}return Vn(s,o)}function Vn(e,t){const o=e.indexOf(Mn);if(-1===o)return e;const s=e.slice(0,o),i=e.slice(o+Mn.length+1),n=e[o+Mn.length];const{timesToRepeat:r,padding:a}=function(){if(!t)return{timesToRepeat:0,padding:""};const e=t.measureText(s+i),o=t.measureText(n),r=t.availableWidth-e;if(r<=0)return{timesToRepeat:0,padding:""};const a=Math.floor(r/o),l=r-a*o,c=t.measureText(" ");return{timesToRepeat:a,padding:" ".repeat(Math.floor(l/c))}}();return s+n.repeat(r)+a+i}const Un=[];function Hn(e,t=xn){const o=e.toString();if(o.includes("e"))return function(e,t=xn){let o=Un[t];o||(o=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),Un[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(zn)?.[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:Bn(n||"")}}function Bn(e){let t=e.length-1;for(;t>=0&&"0"===e[t];)t--;return e.slice(0,t+1)||void 0}const zn=/^0+/;function $n(e,t){const{integerDigits:o,decimalDigits:s}=Hn(e,20);return s?o+t+s:o}const Gn=bt((function(e){if(!e)return!1;try{return"date"===Rn(e).positive.type}catch(e){return!1}}));function Wn(e,t,o){switch(t){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"ddd":return Pn[e.getDay()].slice(0,3);case"dddd":return Pn[e.getDay()].toString();case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"mmm":return Nn[e.getMonth()].slice(0,3);case"mmmm":return Nn[e.getMonth()].toString();case"mmmmm":return Nn[e.getMonth()].slice(0,1);case"qq":return vo("Q%(quarter)s",{quarter:e.getQuarter()}).toString();case"qqqq":return vo("Quarter %(quarter)s",{quarter:e.getQuarter()}).toString();case"yy":const s=String(e.getFullYear()).replace("-","").padStart(2,"0");return s.slice(s.length-2);case"yyyy":return e.getFullYear();case"hhhh":return Math.floor((e.getTime()-hs.getTime())/36e5).toString();case"hh":let i=e.getHours();return o&&(i=0===i?12:i>12?i-12:i),i.toString().padStart(2,"0");case"MM":return e.getMinutes().toString().padStart(2,"0");case"ss":return e.getSeconds().toString().padStart(2,"0");case"a":return e.getHours()>=12?"PM":"AM";default:throw new Error(`invalid date format token: ${t}`)}}const qn=bt((function(e){return new RegExp(`[0-9]+${Ne(e.decimalSeparator)}[0-9]`)}));function Zn(e){let{integerDigits:t,decimalDigits:o}=Hn(e);if(!o)return"0";const s=t.replace("-","").length;if(s+2>Fn)return"0";const i=Fn-s-1;return({decimalDigits:o}=Hn(e,Math.min(i,o.length))),o?"0."+"0".repeat(o.length):"0"}function jn(e,t){if(!ws(e,t))return;return xs(e,t).format}function Yn(e){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}if(e.includes("%"))return t+"%"}function Xn(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 Kn(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();"after"===o&&s&&(r=" "+r);return[Qn(r,o,` ${n} `),Qn(r,o,`(${n})`),Qn(r,o," - ")].join(";")}function Qn(e,t,o){const s=`[$${e}]`;return"before"===t?s+"* "+o:o+"* "+s}function Jn(e){const t=Rn(e);return Dn({positive:er(t.positive),negative:t.negative?er(t.negative):void 0,zero:t.zero?er(t.zero):void 0,text:t.text})}function er(e){if("number"!==e.type||!e.decimalPart)return e;const t=e.decimalPart.filter((e=>"DIGIT"!==e.type));return{...e,decimalPart:void 0,integerPart:[...e.integerPart,...t]}}function tr({value:e,format:t},o){return kn(e,{format:or({value:e,format:t},void 0,o),locale:o})}function or(e,t,o){let s=0;try{s=Math.abs(wi(e?.value,o))}catch(e){return""}const i=e?.format;if(void 0!==t){const e=t?.value;switch(e){case"k":return sr(i,1,"k");case"m":return sr(i,2,"m");case"b":return sr(i,3,"b");default:throw new di(vo("The formatting unit should be 'k', 'm' or 'b'."))}}return s<1e5?sr(i,0,""):s<1e8?sr(i,1,"k"):s<1e11?sr(i,2,"m"):sr(i,3,"b")}function sr(e,t,o,s){const i=Rn(e||"#,##0");return Dn({positive:ir(i.positive,t,o),negative:i.negative?ir(i.negative,t,o):void 0,zero:i.zero?ir(i.zero,t,o):void 0,text:i.text})}function ir(e,t,o){if("number"!==e.type)return e;const s={type:"STRING",value:o};let i=[...e.integerPart];const n=i.findLastIndex((e=>"DIGIT"===e.type));if(-1===n)throw new Error("Cannot create a large number format from a format with no digit.");for(;"THOUSANDS_SEPARATOR"===i[n+1]?.type;)i=St(i,[n+1]);const r=i[n+1];i="STRING"===r?.type&&["m","k","b"].includes(r.value)?function(e,t,o){const s=[...e];return s.splice(o,1,t),s}(i,s,n+1):yt(i,[s],n+1),t>0&&(i=yt(i,Array(t).fill({type:"THOUSANDS_SEPARATOR",value:","}),n+1));const a=e.percentSymbols-i.filter((e=>"PERCENT"===e.type)).length;return i.push(...new Array(a).fill({type:"PERCENT",value:"%"})),{...e,integerPart:i,decimalPart:void 0,magnitude:t}}function nr(e,t){const o=Rn(e);return Dn(Rn(Dn({positive:rr(o.positive,t),negative:o.negative?rr(o.negative,t):void 0,zero:o.zero?rr(o.zero,t):void 0,text:o.text})))}function rr(e,t){return"number"!==e.type?e:t>0?function(e,t){let o=e.integerPart,s=e.decimalPart;if(!s){const e=o.findLastIndex((e=>"DIGIT"===e.type));s=o.slice(e+1),o=o.slice(0,e+1)}const i=Be(0,t).map((()=>({type:"DIGIT",value:"0"}))),n=s.findLastIndex((e=>"DIGIT"===e.type));s=-1===n?[...i,...s]:yt(s,i,n+1);return{...e,decimalPart:s,integerPart:o}}(e,t):function(e,t){let o=e.decimalPart;if(!o)return e;const s=[];let i=0;for(let e=o.length-1;e>=0&&!(i>=Math.abs(t));e--)"DIGIT"===o[e].type&&(i++,s.push(e));if(o=St(o,s),o.some((e=>"DIGIT"===e.type)))return{...e,decimalPart:o};return{...e,decimalPart:void 0,integerPart:[...e.integerPart,...o]}}(e,Math.abs(t))}function ar(e){const t=Rn(e);for(const e of[t.positive,t.negative,t.zero])if(e&&"date"===e.type&&e.tokens.some((e=>"DATE_PART"===e.type&&e.value.includes("q"))))return!1;return!0}function lr(e){if(!e)return!1;try{return"text"===Rn(e).positive.type}catch{return!1}}function cr(e,t){return dr({value:lr(t.format)?e.content:e.parsedValue,format:t.format},t.locale)}function hr(e,t){if(e.startsWith("="))throw new Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);if(""===e)return null;if(Us(e,si))return Bs(e,si);const o=xs(e,t);return o?o.value:Ge(e)?"TRUE"===e.toUpperCase():e}function dr(e,t=si,o){const s=un(e.value);if(!s)return ur(e,t,o);const i=hr(s.label,t);return{...ur({value:i,format:e.format||("number"==typeof i?jn(s.label,t)||Yn(s.label):void 0)},t,o),link:s}}function ur(e,t,o){let{value:s,format:i,message:n}=e;i=o?.format||i;const r=kn(s,{format:i,locale:t});return yi(s)?function(e,t){return{value:e,formattedValue:e,message:t,type:$s.error,isAutoSummable:!1,defaultAlign:"center"}}(s,n):lr(i)?gr(Di(s),i,r):null===s?pr(i):"number"==typeof s?Gn(i||"")?function(e,t,o){return{value:e,format:t,formattedValue:o,type:$s.number,isAutoSummable:!1,defaultAlign:"right"}}(s,i,r):function(e,t,o){return{value:e||0,format:t,formattedValue:o,type:$s.number,isAutoSummable:!0,defaultAlign:"right"}}(s,i,r):"boolean"==typeof s?function(e,t,o){return{value:e,format:t,formattedValue:o,type:$s.boolean,isAutoSummable:!1,defaultAlign:"center"}}(s,i,r):gr(s,i,r)}function gr(e,t,o){return{value:e,format:t,formattedValue:o,type:$s.text,isAutoSummable:!0,defaultAlign:"left"}}const pr=bt((function(e){return{value:null,format:e,formattedValue:"",type:$s.empty,isAutoSummable:!0,defaultAlign:"left"}}));function mr(e){const t=cs.now();switch(e){case"today":return Ts(t);case"yesterday":return Ts(cs.fromTimestamp(t.setDate(t.getDate()-1)));case"tomorrow":return Ts(cs.fromTimestamp(t.setDate(t.getDate()+1)));case"lastWeek":return Ts(cs.fromTimestamp(t.setDate(t.getDate()-7)));case"lastMonth":return Ts(cs.fromTimestamp(t.setMonth(t.getMonth()-1)));case"lastYear":return Ts(cs.fromTimestamp(t.setFullYear(t.getFullYear()-1)))}}function fr(e,t){return"dateValue"in e&&"exactDate"!==e.dateValue?[mr(e.dateValue)]:e.values.map((e=>Cs(e,t)))}function vr(e,t){return e.values.map((e=>Ei(e,t)))}function br(e,t){return e.map((e=>{if(e.startsWith("="))return e;const o=hr(e,t);return"number"==typeof o?kn(o,{format:t.dateFormat,locale:t}):""}))}function Sr(e){return 20+120*Math.exp(-.035*(e-1))}class yr{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&&is(this.zone)>1?o.push({...e.parts[0]}):2===e.parts.length&&1===is(this.zone)&&o.pop(),this.parts=o}static fromRange(e,t){return e instanceof yr?e:new yr(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(vo("Bad zone format"))}static getRangeParts(e,t){const o=e.split(":").map((e=>{const t=To(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(ko(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 yr({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 Cr(e,t,o){const s=o.sheetId===e?t:o.sheetId;return o.clone({sheetId:s})}function wr(e,t,o){if(!o)return;const s=e.getRangeFromSheetXC(t,o);return s.invalidSheetName||s.invalidXc?void 0:s}function Er(e){const t=[];for(const o of e)for(const e of Ko(o.zone))t.push({...e,sheetId:o.sheetId});return t}function xr(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 Ir(e){const t=[];for(let o=0;o<e;o++){const e={cells:{}};t.push(e)}return t}function Rr(e,t,o){return o.map((o=>o>=e?o+t:o))}function Tr(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(tt)}function Ar(e,t=1){return t*(e+ee)-ee}function _r(e,t=!1,o=!1){return`${o?"italic":""} ${t?"bold":""} ${e}px ${de}`}const Dr={};function Or(e,t,o,s="pt"){const i=kr(o,s);e.save(),e.font=i;const n=Fr(e,t);return e.restore(),n}function Fr(e,t){const o=e.font;if(Dr[o]||(Dr[o]={}),void 0===Dr[o][t]){const s=e.measureText(t).width;Dr[o][t]=s}return Dr[o][t]}const Mr={};function Nr(e,t,o,s="pt"){const i=kr(o,s);e.save(),e.font=i;const n=function(e,t){const o=e.font;Mr[o]||(Mr[o]={});if(void 0===Mr[o][t]){const s=e.measureText(t),i=s.width,n=s.fontBoundingBoxAscent+s.fontBoundingBoxDescent;Mr[o][t]={width:i,height:n}}return Mr[o][t]}(e,t);return e.restore(),n}function Pr(e){return Math.round(96*e/72)}function kr(e,t="pt"){return`${e.italic?"italic ":""}${e.bold?"bold":ce} ${("pt"===t?Lr(e):e.fontSize)??he}px ${de}`}function Lr(e){return Pr(e?.fontSize||he)}function Vr(e,t,o,s){if(Or(e,t,s)<=o)return[t];const i=[];let n="";for(let r of t){Or(e,n+r,s)>o?(i.push(n),n=r):n+=r}return i.push(n),i}function Ur(e,t,o,s){o||(o={});const i=[],n=t.includes(Ae)?t.split(Ae):[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=Vr(e,t,s,o),l=n.pop(),c=Or(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=Or(e,t,o);n<=a?(r+=t,a-=n):(i.push(r),r=l,a=s-c)}}""!==r&&i.push(r)}return i}function Hr(e){return e?e.toLowerCase():""}const Br=/([0-9\.]*)px/;function zr(e,t,o){let s=Fr(e,t);if(s<=o)return t;const i=Fr(e,"…");if(s<=i)return t;let n=t.length;for(;s>=o-i&&n-- >0;)s=Fr(e,t=t.substring(0,n));return t+"…"}function $r(e,t,o,s=!1,i=!1,n=function(e){return Number(e.match(Br)?.[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 Gr{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 Wr(e,t){const o=new Set(t.map((e=>e.left))),s=new Set(t.map((e=>e.right))),i=new Set(t.map((e=>e.top))),n=new Set(t.map((e=>e.bottom))),r=1===i.size&&1===n.size||1===o.size&&1===s.size?function(e){return e.reduce(((e,t)=>{const o=e.length;for(let s=0;s<o;s++)if(Wo(e[s],t))return e[s]=zo(e[s],t),e;return e[o]=t,e}),[])}(t):[t[t.length-1]],a=r.map((e=>Ko(e))).flat();return{sheetId:e,zones:t,clippedZones:r,columnsIndexes:[...new Set(a.map((e=>e.col)))].sort(((e,t)=>e-t)),rowsIndexes:[...new Set(a.map((e=>e.row)))].sort(((e,t)=>e-t))}}function qr(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()}function Zr(e){if(!e[Gs.Html])return{text:e[Gs.PlainText]};const t=(new DOMParser).parseFromString(e[Gs.Html],"text/html"),o=t.querySelector("div")?.getAttribute("data-osheet-clipboard"),s=o&&JSON.parse(o);return{text:e[Gs.PlainText],data:s}}class jr{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,s){return{zones:[],sheetId:e}}convertTextToClipboardData(e){}}class Yr extends jr{copy(e){}pasteFromCopy(e,t,o,s){if(1===t.length)for(const i of qr(t,o))this.pasteZone(e,i.left,i.top,o,s);else for(const i of no(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){}}class Xr extends Yr{copy(e){const t=e.sheetId;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){const s=e.sheetId;if("asValue"===o.pasteOption)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})}}const Kr=["%"],Qr="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(Kr);function Jr(e,t=si){e=ft(e);const o=new Rt(e),s=[];for(;!o.isOver();){let e=ha(o)||sa(o,t)||oa(o)||ia(o)||aa(o)||ea(o)||da(o)||ra(o,t)||ca(o);e||(e={type:"UNKNOWN",value:o.shift()}),s.push(e)}return s}function ea(e){return"?"===e.current?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const ta={"(":{type:"LEFT_PAREN",value:"("},")":{type:"RIGHT_PAREN",value:")"}};function oa(e){if("("===e.current||")"===e.current){const t=e.shift();return ta[t]}return null}function sa(e,t){if(e.current===t.formulaArgSeparator){return{type:"ARG_SEPARATOR",value:e.shift()}}return null}function ia(e){for(let t of Qr)if(e.currentStartsWith(t))return e.advanceBy(t.length),{type:"OPERATOR",value:t};return null}const na=new Set("0123456789");function ra(e,t){if(!na.has(e.current)&&e.current!==t.decimalSeparator)return null;const o=e.remaining().match(Ls(t.decimalSeparator));return o?(e.advanceBy(o[0].length),{type:"NUMBER",value:o[0]}):null}function aa(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 la=new Set("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.!$");function ca(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&&la.has(e.current);)t+=e.shift();if(t.length){const e=t;return Io.test(e)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}function ha(e){let t=0;for(;e.current===Ae;)t++,e.shift();if(t)return{type:"SPACE",value:Ae.repeat(t)};let o="";for(;e.current&&e.current.match(pt);)o+=e.shift();return o?{type:"SPACE",value:o}:null}function da(e){return e.currentStartsWith(ci.InvalidReference)?(e.advanceBy(ci.InvalidReference.length),{type:"INVALID_REFERENCE",value:ci.InvalidReference}):null}function ua(e){if(!e||"object"!=typeof e||e.thousandsSeparator&&"string"!=typeof e.thousandsSeparator)return!1;for(const t of["code","name","decimalSeparator","dateFormat","timeFormat","formulaArgSeparator"])if(!e[t]||"string"!=typeof e[t])return!1;if(e.formulaArgSeparator===e.decimalSeparator)return!1;if(e.thousandsSeparator===e.decimalSeparator)return!1;try{kn(1,{locale:e,format:"#,##0.00"}),kn(1,{locale:e,format:e.dateFormat}),kn(1,{locale:e,format:e.timeFormat})}catch{return!1}return!0}function ga(e,t){return e.startsWith("=")?fa(e,t):Sa(e,t)}function pa(e,t){return e.startsWith("=")?fa(e,t):function(e,t){if(ws(e,t)){const o=wi(e,t);let s=si.dateFormat;return Number.isInteger(o)||(s+=" "+si.timeFormat),kn(o,{locale:si,format:s})}return Sa(e,t)}(e,t)}function ma(e,t){return e.startsWith("=")?va(e,t):function(e,t){if(ws(e,si)){const o=wi(e,si);let s=t.dateFormat;return Number.isInteger(o)||(s+=" "+t.timeFormat),kn(o,{locale:t,format:s})}return function(e,t){if("."===t.decimalSeparator||!Us(e,si))return e;const o=qn(si),s=e.replace(o,(e=>e.replace(".",t.decimalSeparator)));return s}(e,t)}(e,t)}function fa(e,t){return ba(e,t,si)}function va(e,t){return ba(e,si,t)}function ba(e,t,o){if(t.formulaArgSeparator===o.formulaArgSeparator&&t.decimalSeparator===o.decimalSeparator)return e;const s=Jr(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 Sa(e,t){return"."!==t.decimalSeparator&&Us(e,t)?(t.thousandsSeparator&&(e=e.replaceAll(t.thousandsSeparator,"")),e.replace(t.decimalSeparator,".")):e}function ya(e,t){return Ea(e,(e=>pa(e,t)))}function Ca(e,t){return Ea(e,(e=>ma(e,t)))}function wa(e,t){const o=Pe(e);return o.criterion.values=o.criterion.values.map((e=>ma(e,t))),o}function Ea(e,t){switch((e=Pe(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}case"DataBarRule":return e;case"ColorScaleRule":return e.minimum=xa(e.minimum,t),e.maximum=xa(e.maximum,t),e.midpoint&&(e.midpoint=xa(e.midpoint,t)),e;case"IconSetRule":return e.lowerInflectionPoint.value=t(e.lowerInflectionPoint.value),e.upperInflectionPoint.value=t(e.upperInflectionPoint.value),e}}function xa(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 Ia(e){return e.dateFormat+" "+e.timeFormat}function Ra(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=Jr(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,si)}(e,t):Sa(e,t)}function Ta(e){let t=!1,o=!0;return qi(e,(e=>(t=!0,o=o&&e,o))),{foundBoolean:t,result:o}}function Aa(e){let t=!1,o=!1;return qi(e,(e=>(t=!0,o=o||e,!o))),{foundBoolean:t,result:o}}function _a(e,t){return Bi(e,((e,t)=>e+t),0,t)}function Da(e){return Hi(e,((e,t)=>sn(t)?e.add(t?.value):e),new Set).size}function Oa(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 Fa(e){if(e.length!==e[0].length)throw new di(vo("Function [[FUNCTION_NAME]] invert matrix error, only square matrices are invertible"));let t=1;const o=e.length,s=Oa(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]){Ma(i,e,n),Ma(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 Ma(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 Na(e,t){if(e.length!==t[0].length)throw new di(vo("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 Pa(e){if(!ni(e))return e;if(1!==e.length||1!==e[0].length)throw new di(vo("The value should be a scalar or a 1x1 matrix"));return e[0][0]}function ka(...e){const t=e[0].length;e.forEach(((e,o)=>bi((()=>e.length===t),vo("[[FUNCTION_NAME]] has mismatched dimensions for argument %s (%s vs %s).",o.toString(),t.toString(),e.length.toString()))))}function La(e,t){let o=0;const s=Bi(e,((e,t)=>(o+=1,e+t)),0,t);return _i(o),s/o}function Va(e,t){let o=0;for(let s of e)if(ni(s))for(let e of s)for(let t of e)"number"==typeof t.value&&(o+=1);else{const e=s?.value;yi(e)||"string"==typeof e&&!Us(e,t)&&!xs(e,t)||(o+=1)}return o}function Ua(e){return Hi(e,((e,t)=>void 0!==t&&null!==t.value?e+1:e),0)}function Ha(e,t){let o={value:-1/0};return Vi(e,(e=>{e.value>=o.value&&(o=e)}),t),o.value===-1/0?{value:0}:o}function Ba(e,t){let o={value:1/0};return Vi(e,(e=>{e.value<=o.value&&(o=e)}),t),o.value===1/0?{value:0}:o}function za(e,t,o){const s=e[0].length?e:[Be(1,t.flat().length+1)],i=s.length;let n=o[0].length?o:s;return n=n.length===i?Wi(n):n,{_X:s,_newX:n}}function $a(e,t,o=!0,s=!1){const i=t.flat(),n=i.length;let{_X:r}=za(e,t,[[]]);r=r.length===n?Wi(r):r.slice(),ka(r[0],i);const a=r.length,l=n-a-(o?1:0),c=[i],h=Wi(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=Wa(h,c);if(o||p.push([0]),!s)return p;const m=Na(g,Wi(g)),{inverted:f}=Fa(m);if(void 0===f)throw new di(vo("Matrix is not invertible"));let v=0,b=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;v+=s*s,b+=o*o}const S=Math.sqrt(v/l),y=b/(b+v),C=b/a/(v/l),w=[];for(let e=0;e<a;e++)w.push(S*Math.sqrt(f[e][e]));if(o){const e=Na(f,[d]),t=Na(Wi([d]),e);w.push(S*Math.sqrt(t[0][0]+1/i.length))}const E=[[p[0][0],w[0],y,C,b],[p[1][0],w[1],S,l,v]];for(let e=2;e<a;e++)E.push([p[e][0],w[e],"","",""]);return o?E.push([p[a][0],w[a],"","",""]):E.push([0,"","","",""]),E}function Ga(e,t,o,s){ka(t,e),bi((()=>o>=1),vo("Function [[FUNCTION_NAME]] A regression of order less than 1 cannot be possible."));const i=[e],n=t.map((e=>Be(0,o).map((t=>Math.pow(e,o-t)))));s&&n.forEach((e=>e.push(1)));const r=Wa(n,i);return s||r.push([0]),r}function Wa(e,t){const o=Na(e,Wi(e)),{inverted:s}=Fa(o);if(void 0===s)throw new di(vo("Matrix is not invertible"));const i=Na(e,t);return Wi(Na(s,i))}function qa(e,t,o){return e.reduce(((e,s,i)=>e+s*Math.pow(t,o-i)),0)}function Za(e){return e.map((e=>e.map((e=>Math.exp(e)))))}function ja(e){return e.map((e=>e.map((e=>Math.log(e)))))}function Ya(e,t,o,s){const{_X:i,_newX:n}=za(t,e,o),r=$a(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:Wi(l)}const Xa="(previous)",Ka="(next)";function Qa(e,t){const o=e.definition.rows.map((e=>e.nameWithGranularity)),s=t.filter((e=>o.includes(e.field))),i=e.definition.columns.map((e=>e.nameWithGranularity));return{colDomain:t.filter((e=>i.includes(e.field))),rowDomain:s}}function Ja(e,t,o){return"column"===t?Qa(e,o).colDomain:Qa(e,o).rowDomain}function el(e,t){return void 0!==tl(e,t)}function tl(e,t,o){let s=t;for(const t of e){const e=s.find((e=>e.value===t.value));if(!e)return;if(e.field===o)return s;s=e.children}return s}function ol(e,t,o){const s=(e=Pe(e)).find((e=>e.field===t));return s?(s.value=o,e):e}function sl(e,t){return t.some((t=>t.field===e))}function il(e,t){if(e.definition.rows.map((e=>e.nameWithGranularity)).includes(t))return"row";if(e.definition.columns.map((e=>e.nameWithGranularity)).includes(t))return"column";throw new Error(`Field ${t} not found in pivot`)}function nl(e){return e?e.map(rl).join(", "):""}function rl(e){return e?`${e.field}=${e.value}`:""}function al(e,t){const o=e.findIndex((e=>e.field===t));if(-1===o)return"";const s=e.slice(0,o),i=e.at(-1);return nl(i.field===t?s:[...s,i])}function ll(e,t){const o=e.findIndex((e=>e.field===t));return-1===o?"":nl([...e.slice(0,o),...e.slice(o+1)])}const cl=new n;function hl(e){return cl.get(e)}const dl={normalizeFunctionValue:e=>wi(e,si),toValueAndFormat:(e,t)=>({value:wi(e,si),format:"dd mmm yyyy"}),toFunctionValue:e=>`"${kn(wi(e,si),{locale:si,format:"mm/dd/yyyy"})}"`},ul={normalizeFunctionValue(e){const t=wi(e,si);if(t<1||t>31)throw new di(vo("%s is not a valid day of month (it should be a number between 1 and 31)",t));return t},toValueAndFormat:e=>({value:wi(e,si),format:"0"}),toFunctionValue:e=>`${e}`},gl={normalizeFunctionValue(e){const t=wi(e,si);if(t<1||t>7)throw new di(vo("%s is not a valid day of week (it should be a number between 1 and 7)",t));return t},toValueAndFormat(e,t){const o=(e-1+(t||si).weekStart)%7;return{value:Pn[o].toString(),format:"@"}},toFunctionValue:e=>`${e}`},pl={normalizeFunctionValue(e){const t=wi(e,si);if(t<0||t>53)throw new di(vo("%s is not a valid week (it should be a number between 0 and 53)",t));return t},toValueAndFormat:e=>({value:wi(e,si),format:"0"}),toFunctionValue:e=>`${e}`},ml={normalizeFunctionValue(e){const t=wi(e,si);if(t<1||t>12)throw new di(vo("%s is not a valid month (it should be a number between 1 and 12)",t));return t},toValueAndFormat:e=>({value:Nn[wi(e,si)-1].toString(),format:"@"}),toFunctionValue:e=>`${e}`},fl={normalizeFunctionValue(e){const t=wi(e,si);if(t<1||t>4)throw new di(vo("%s is not a valid quarter (it should be a number between 1 and 4)",t));return t},toValueAndFormat:e=>({value:vo("Q%(quarter_number)s",{quarter_number:e}),format:"@"}),toFunctionValue:e=>`${e}`},vl={normalizeFunctionValue:e=>wi(e,si),toValueAndFormat:e=>({value:wi(e,si),format:"0"}),toFunctionValue:e=>`${e}`},bl={normalizeFunctionValue(e){const t=wi(e,si);if(t<0||t>23)throw new di(vo("%s is not a valid hour (it should be a number between 0 and 23)",t));return t},toValueAndFormat:e=>({value:vo("%(hour_number)sh",{hour_number:e}),format:"@"}),toFunctionValue:e=>`${e}`},Sl={normalizeFunctionValue(e){const t=wi(e,si);if(t<0||t>59)throw new di(vo("%s is not a valid minute (it should be a number between 0 and 59)",t));return t},toValueAndFormat:e=>({value:vo("%(minute_number)s'",{minute_number:e}),format:"@"}),toFunctionValue:e=>`${e}`},yl={normalizeFunctionValue(e){const t=wi(e,si);if(t<0||t>59)throw new di(vo("%s is not a valid second (it should be a number between 0 and 59)",t));return t},toValueAndFormat:e=>({value:vo("%(second_number)s''",{second_number:e}),format:"@"}),toFunctionValue:e=>`${e}`};function Cl(e){return{normalizeFunctionValue:t=>null===t?null:e.normalizeFunctionValue(t),toValueAndFormat:(t,o)=>null===t?{value:vo("(Undefined)")}:e.toValueAndFormat(t,o),toFunctionValue:t=>null===t?"false":e.toFunctionValue(t)}}cl.add("day",Cl(dl)).add("year",Cl(vl)).add("day_of_month",Cl(ul)).add("iso_week_number",Cl(pl)).add("month_number",Cl(ml)).add("quarter_number",Cl(fl)).add("day_of_week",Cl(gl)).add("hour_number",Cl(bl)).add("minute_number",Cl(Sl)).add("second_number",Cl(yl));const wl={count:vo("Count"),count_distinct:vo("Count Distinct"),bool_and:vo("Boolean And"),bool_or:vo("Boolean Or"),max:vo("Maximum"),min:vo("Minimum"),avg:vo("Average"),sum:vo("Sum")},El=["max","min","avg","sum","count_distinct","count"],xl={integer:El,char:El,boolean:["count_distinct","count","bool_and","bool_or"]},Il={};for(const e in xl){Il[e]={};for(const t of xl[e])Il[e][t]=wl[t]}const Rl={count:e=>({value:Ua([e]),format:"0"}),count_distinct:e=>({value:Da([e]),format:"0"}),bool_and:e=>({value:Ta([e]).result}),bool_or:e=>({value:Aa([e]).result}),max:(e,t)=>Ha([e],t),min:(e,t)=>Ba([e],t),avg:(e,t)=>({value:La([e],t),format:Si(e)}),sum:(e,t)=>({value:_a([e],t),format:Si(e)})};function Tl(e){const t=Object.keys(e);if(!t.length)return 0;const o=t.map((e=>parseInt(e,10)));return Math.max(...o)}const Al={year:vo("Year"),quarter:vo("Quarter & Year"),month:vo("Month & Year"),week:vo("Week & Year"),day:vo("Day"),quarter_number:vo("Quarter"),month_number:vo("Month"),iso_week_number:vo("Week"),day_of_month:vo("Day of Month"),day_of_week:vo("Day of Week"),hour_number:vo("Hour"),minute_number:vo("Minute"),second_number:vo("Second")},_l=["date","datetime"];function Dl(e){const[t,o]=e.split(":");return o?{fieldName:t,granularity:o}:{fieldName:t}}function Ol(e){return _l.includes(e.type)}function Fl(e,t,o){const s=[e];o&&s.push(`"${o}"`);for(const{field:e,value:o,type:i}of t){if("measure"===e){s.push('"measure"',`"${o}"`);continue}const{granularity:t}=Dl(e),n=Ll(o,{type:i,granularity:t});s.push(`"${e}"`,n)}return s}function Ml(e,t){let o=0,s=0;const i=t.columns.map((e=>e.nameWithGranularity)),n=t.rows.map((e=>e.nameWithGranularity));for(;void 0!==e[o]&&e[o]===n[s];)o++,s++;for(s=0;void 0!==e[o]&&e[o]===i[s];)o++,s++;return e.length===o}function Nl(e,t){switch(t.type){case"HEADER":return`=PIVOT.HEADER(${Fl(e,t.domain).join(",")})`;case"VALUE":return`=PIVOT.VALUE(${Fl(e,t.domain,t.measure).join(",")})`;case"MEASURE_HEADER":return`=PIVOT.HEADER(${Fl(e,[...t.domain,{field:"measure",value:t.measure,type:"char"}]).join(",")})`}return""}function Pl(e,t){if(null===t||"null"===t)return null;const o="boolean"==typeof t?Di(t).toLocaleLowerCase():Di(t);if("null"===o)return null;if(!Ul.contains(e.type))throw new di(vo("Field %(field)s is not supported because of its type (%(type)s)",{field:e.displayName,type:e.type}));if("false"===o.toLowerCase())return!1;return Ul.get(e.type)(o,e.granularity)}function kl(e,t){if(!t)throw new Error("Missing granularity");return hl(t).normalizeFunctionValue(e)}function Ll(e,t){return null===e?'"null"':Hl.contains(t.type)?Hl.get(t.type)(e,t.granularity):`"${e}"`}function Vl(e,t){if(!t)throw new Error("Missing granularity");return hl(t).toFunctionValue(e)}const Ul=new n;Ul.add("date",kl).add("datetime",kl).add("integer",(e=>wi(e,si))).add("boolean",(e=>Mi(e))).add("char",(e=>Di(e)));const Hl=new n;function Bl(e){return e.displayName+(e.granularity?` (${Al[e.granularity]})`:"")}function zl(e,t,o){const{rowDomain:s,colDomain:i}=Qa(e,t);if(0===s.length&&0===i.length)return o;if(0===s.length&&i.length>0)return{...o,format:(o.format||"@")+"* "};const n=s.length-1,r=o.format||"@";return{...o,format:`${" ".repeat(n)}${r}* `}}Hl.add("date",Vl).add("datetime",Vl).add("integer",(e=>`${wi(e,si)}`)).add("boolean",(e=>Mi(e)?"TRUE":"FALSE")).add("char",(e=>`"${Di(e).replace(/"/g,'\\"')}"`));class $l extends Yr{isCutAllowed(e){return 1!==e.zones.length?"WrongCutSelection":"Success"}copy(e){const t=e.sheetId,{clippedZones:o,rowsIndexes:s,columnsIndexes:i}=e,n=[],r=1==s.length&&1==i.length;for(let o of s){let a=[];for(let n of i){const l={col:n,row:o,sheetId:t};let c=this.getters.getCell(l);const h=this.getters.getEvaluatedCell(l),d=this.getters.getPivotIdFromPosition(l),u=this.getters.getArrayFormulaSpreadingOn(l);if(d&&u){const t=this.getters.getSpreadZone(u);if((!ct(u,l)||!r)&&t&&!e.zones.some((e=>Zo(t,e)))){const e=this.getters.getPivotCellFromPosition(l),t=Nl(this.getters.getPivotFormulaId(d),e);c={id:c?.id||"",style:c?.style,format:c?.format,content:t,isFormula:!1,parsedValue:h.value}}}else if(u&&!ct(u,l)){const e=s.includes(u.row)&&i.includes(u.col)?"":kn(h.value,{locale:this.getters.getLocale()});c={id:c?.id||"",style:c?.style,format:h.format,content:e,isFormula:!1,parsedValue:h.value}}a.push({content:c?.content??"",style:c?.style,format:c?.format,tokens:c?.isFormula?c.compiledFormula.tokens.map((({value:e,type:t})=>({value:e,type:t}))):[],border:this.getters.getCellBorder(l)||void 0,evaluatedCell:h,position:l})}n.push(a)}return{cells:n,zones:o,sheetId:e.sheetId}}isPasteAllowed(e,t,o,s){if(!o.cells)return"Success";if(s?.isCutOperation&&void 0!==s?.pasteOption)return"WrongPasteOption";if(t.length>1&&(o.cells.length>1||o.cells[0].length>1))return"WrongPasteSelection";const i=o.cells.length,n=o.cells[0].length;for(const s of qr(t,o.cells))if(this.getters.doesIntersectMerge(e,s)&&(t.length>1||!this.getters.isSingleCellOrMerge(e,t[0])||i*n!=1))return"WillRemoveExistingMerge";return"Success"}paste(e,t,o){const s=e.zones,i=e.sheetId;o.isCutOperation?this.pasteFromCut(i,s,t,o):this.pasteFromCopy(i,s,t.cells,o)}getPasteTarget(e,t,o,s){const i=o.cells[0].length,n=o.cells.length;return s?.isCutOperation?{sheetId:e,zones:[{left:t[0].left,top:t[0].top,right:t[0].left+i-1,bottom:t[0].top+n-1}]}:1===i&&1===n?{zones:[],sheetId:e}:{sheetId:e,zones:qr(t,o.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){this.dispatch("CLEAR_CELLS",{sheetId:e.sheetId,target:e.zones}),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?.format??e.evaluatedCell.format;if("asValue"===o?.pasteOption)return void this.dispatch("UPDATE_CELL",{...t,content:e.evaluatedCell.value?.toString()||"",format:a});if("onlyFormat"===o?.pasteOption)return void this.dispatch("UPDATE_CELL",{...t,style:e?.style??null,format:a??r.format});let l=e?.content;e?.tokens&&e.tokens.length>0&&!o?.isCutOperation?l=this.getters.getTranslatedCellFormula(s,i-e.position.col,n-e.position.row,e.tokens):e?.tokens&&e.tokens.length>0&&(l=this.getters.getFormulaMovedInSheet(e.position.sheetId,s,e.tokens)),""!==l||e?.format||e?.style?this.dispatch("UPDATE_CELL",{...t,content:l,style:e?.style||null,format:e?.format}):r&&this.dispatch("CLEAR_CELL",t)}convertTextToClipboardData(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=Ra(e[o]||"",t);s.push({content:i,evaluatedCell:{formattedValue:i}})}o.cells.push(s)}return o}}class Gl extends jr{copy(e){}}class Wl extends Yr{uuidGenerator=new Gr;queuedChanges={};copy(e){if(!e.zones.length)return;const{rowsIndexes:t,columnsIndexes:o}=e,s=e.sheetId,i=[];for(const e of t){const t=[];for(const i of o){const o=Array.from(this.getters.getRulesByCell(s,i,e));t.push({position:{col:i,row:e,sheetId:s},rules:o})}i.push(t)}return{cfRules:i}}paste(e,t,o){if(this.queuedChanges={},"asValue"===o.pasteOption)return;const s=e.zones,i=e.sheetId;o.isCutOperation?this.pasteFromCut(i,s,t):this.pasteFromCopy(i,s,t.cfRules,o),this.executeQueuedChanges()}pasteFromCut(e,t,o){const s=t[0];this.pasteZone(e,s.left,s.top,o.cfRules,{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){if(e?.rules&&e.rules.length>0){const s=ts(t);for(const i of e.rules){const n=[];if(o&&n.push(ts(e.position)),e.position.sheetId===t.sheetId)this.adaptCFRules(e.position.sheetId,i,[s],n);else{this.adaptCFRules(e.position.sheetId,i,[],n);const o=this.getCFToCopyTo(t.sheetId,i);this.adaptCFRules(t.sheetId,o,[s],[])}}}}adaptCFRules(e,t,o,s){this.queuedChanges[e]||(this.queuedChanges[e]=[]);const i=this.queuedChanges[e].find((e=>e.cf.id===t.id));i?(i.toAdd.push(...o),i.toRemove.push(...s)):this.queuedChanges[e].push({toAdd:o,toRemove:s,cf:t})}executeQueuedChanges(){for(const e in this.queuedChanges)for(const{toAdd:t,toRemove:o,cf:s}of this.queuedChanges[e]){const i=this.getters.getAdaptedCfRanges(e,s,t,o);i&&(0!==i.length?this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:s.id,rule:s.rule,stopIfTrue:s.stopIfTrue},ranges:i,sheetId:e}):this.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:s.id,sheetId:e}))}}getCFToCopyTo(e,t){let o=this.getters.getConditionalFormats(e).find((e=>e.stopIfTrue===t.stopIfTrue&&ct(e.rule,t.rule)));const s=this.queuedChanges[e];return!o&&s&&(o=s.find((e=>e.cf.stopIfTrue===t.stopIfTrue&&ct(e.cf.rule,t.rule)))?.cf),o||{...t,id:this.uuidGenerator.uuidv4(),ranges:[]}}}class ql extends Yr{copy(e){const t=e.sheetId,{rowsIndexes:o,columnsIndexes:s,zones:i}=e,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){o.push({});continue}const l=this.getters.getCoreTable(s),c=l?.range.zone;let h;if(!n.has(a.id)&&l&&c&&i.some((e=>Zo(c,e)))){n.add(a.id);const e=[];for(const o of Be(c.left,c.right+1))e.push(this.getters.getFilterHiddenValues({sheetId:t,col:o,row:c.top}));h={range:l.range.rangeData,config:l.config,type:l.type}}o.push({table:h,style:this.getTableStyleToCopy(s),isWholeTableCopied:n.has(a.id)})}}return{tableCells:r,sheetId:e.sheetId}}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,...ut(o)},border:{...s,...ut(i)}}}paste(e,t,o){const s=e.zones,i=e.sheetId;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:[this.getters.getRangeFromRangeData(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=jo(this.getters.getRangeFromRangeData(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)||"asValue"===s?.pasteOption||(s?.pasteOption||t.isWholeTableCopied)&&"onlyFormat"!==s?.pasteOption||(t.style?.style&&this.dispatch("UPDATE_CELL",{...o,style:t.style.style}),t.style?.border&&this.dispatch("SET_BORDER",{...o,border:t.style.border}))}}const Zl={figureHandlers:new n,cellHandlers:new n};function jl(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?Bo(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?Vo(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function Yl(e,t){const o="DELETE_SHEET"===t.type&&t.sheetId;if("sheetId"in t&&e._sheetId!==t.sheetId)return e;{const s=jl(e._zone,t);if(s&&o!==e._sheetId)return{...e,_zone:s}}}Zl.figureHandlers.add("chart",class extends Gl{copy(e){const t=e.sheetId,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,s){return{zones:[],figureId:(new Gr).uuidv4(),sheetId:e}}paste(e,t,o){if(!e.figureId)return;const{zones:s,figureId:i}=e,n=e.sheetId,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 Gl{copy(e){const t=e.sheetId,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=Pe(this.getters.getImage(e.figureId));return{figureId:e.figureId,copiedFigure:s,copiedImage:i,sheetId:t}}getPasteTarget(e,t,o,s){return{sheetId:e,zones:[],figureId:(new Gr).uuidv4()}}paste(e,t,o){if(!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=Pe(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"}}),Zl.cellHandlers.add("dataValidation",class extends Yr{uuidGenerator=new Gr;queuedChanges={};copy(e){const{rowsIndexes:t,columnsIndexes:o}=e,s=e.sheetId,i=[];for(const e of t){const t=[];for(const i of o){const o={sheetId:s,col:i,row:e},n=this.getters.getValidationRuleForCell(o);t.push({position:o,rule:n})}i.push(t)}return{dvRules:i}}paste(e,t,o){if(this.queuedChanges={},o.pasteOption)return;const s=e.zones,i=e.sheetId;o.isCutOperation?this.pasteFromCut(i,s,t):this.pasteFromCopy(i,s,t.dvRules),this.executeQueuedChanges()}pasteFromCut(e,t,o){const s=t[0];this.pasteZone(e,s.left,s.top,o.dvRules,{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){if(e){const s=ts(t),i=e.rule;if(!i){const e=this.getters.getValidationRuleForCell(t);return void(e&&this.adaptDataValidationRule(t.sheetId,e,[],[s]))}const n=[];if(o&&n.push(ts(e.position)),e.position.sheetId===t.sheetId){const o=this.getDataValidationRuleToCopyTo(t.sheetId,i,!1);this.adaptDataValidationRule(e.position.sheetId,o,[s],n)}else{const o=this.getters.getValidationRuleForCell(e.position);o&&this.adaptDataValidationRule(e.position.sheetId,o,[],n);const r=this.getDataValidationRuleToCopyTo(t.sheetId,i);this.adaptDataValidationRule(t.sheetId,r,[s],[])}}}getDataValidationRuleToCopyTo(e,t,o=!0){let s=this.getters.getDataValidationRules(e).find((e=>ct(t.criterion,e.criterion)&&t.isBlocking===e.isBlocking));const i=this.queuedChanges[e];return!s&&i&&(s=i.find((e=>ct(t.criterion,e.rule.criterion)&&t.isBlocking===e.rule.isBlocking))?.rule),s||{...t,id:o?this.uuidGenerator.uuidv4():t.id,ranges:[]}}adaptDataValidationRule(e,t,o,s){this.queuedChanges[e]||(this.queuedChanges[e]=[]);const i=this.queuedChanges[e].find((e=>e.rule.id===t.id));i?(i.toAdd.push(...o),i.toRemove.push(...s)):this.queuedChanges[e].push({toAdd:o,toRemove:s,rule:t})}executeQueuedChanges(){for(const e in this.queuedChanges)for(const{toAdd:t,toRemove:o,rule:s}of this.queuedChanges[e]){const i=s.ranges.map((e=>e.zone)),n=no(i,o),r=no([...n,...t],[]);0!==r.length?this.dispatch("ADD_DATA_VALIDATION_RULE",{rule:s,ranges:r.map((t=>this.getters.getRangeDataFromZone(e,t))),sheetId:e}):this.dispatch("REMOVE_DATA_VALIDATION_RULE",{sheetId:e,id:s.id})}}}).add("cell",$l).add("sheet",class extends Yr{isPasteAllowed(e,t,o,s){if(!("cells"in o))return"Success";const{xSplit:i,ySplit:n}=this.getters.getPaneDivisions(e);for(const e of qr(t,o.cells))if(e.left<i&&e.right>=i||e.top<n&&e.bottom>=n)return"FrozenPaneOverlap";return"Success"}}).add("merge",class extends Yr{copy(e){const t=this.getters.getActiveSheetId(),{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.getMerge(s))}i.push(o)}return{merges:i}}paste(e,t,o){o.isCutOperation||this.pasteFromCopy(e.sheetId,e.zones,t.merges,o)}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.pasteMerge(r,n)}}pasteMerge(e,t){if(!e)return;if(this.getters.isInMerge(t))return;const{sheetId:o,col:s,row:i}=t;this.dispatch("ADD_MERGE",{sheetId:o,force:!0,target:[{left:s,top:i,right:s+e.right-e.left,bottom:i+e.bottom-e.top}]})}}).add("border",Xr).add("table",ql).add("conditionalFormat",Wl);class Xl{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 Kl extends Xl{dependencies=new Map;factory=new Ql(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 Ql{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 Jl{get;disposeCallbacks=[];constructor(e){this.get=e}onDispose(e){this.disposeCallbacks.push(e)}dispose(){this.disposeCallbacks.forEach((e=>e()))}}function ec(){const e=t.useEnv();if(e.__spreadsheet_stores__ instanceof Kl)return e.__spreadsheet_stores__;const o=new Kl;return t.useSubEnv({__spreadsheet_stores__:o,getStore:e=>ic(o.get(e),(()=>o.trigger("store-updated")))}),o}function tc(e){const o=nc(t.useEnv()),s=o.get(e);return sc(o,s)}function oc(e,...o){const s=nc(t.useEnv()),i=s.instantiate(e,...o);return t.onWillUnmount((()=>i.dispose())),sc(s,i)}function sc(e,o){const s=t.useComponent();return ic(o,(()=>{"mounted"===t.status(s)&&e.trigger("store-updated")}))}function ic(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 nc(e){const t=e.__spreadsheet_stores__;if(!(t instanceof Kl))throw new Error("No store provider found. Did you forget to call useStoreProvider()?");return t}const rc=(ac="Model",class{constructor(e){throw new Error(`This is a abstract store for ${ac}, it cannot be instantiated.\nDid you forget to inject your store instance?\n\nconst stores = useStoreProvider();\nstores.inject(MyMetaStore, storeInstance);\n`)}});var ac;class lc{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 cc extends Jl{model=this.get(rc);getters=this.model.getters;renderer=this.get(lc);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){}}const hc={id:"void-composer",get editionMode(){return"inactive"},startEdition:()=>{throw new Error("No composer is registered")},stopEdition:()=>{throw new Error("No composer is registered")},setCurrentContent:()=>{throw new Error("No composer is registered")}};class dc extends cc{mutators=["focusComposer","focusActiveComposer"];activeComposer=hc;_focusMode="inactive";get focusMode(){return"inactive"===this.activeComposer.editionMode?"inactive":this._focusMode}focusComposer(e,t){this.activeComposer=e,this.getters.isReadonly()||(this._focusMode=t.focusMode||"contentFocus","inactive"!==this._focusMode&&this.setComposerContent(t))}focusActiveComposer(e){if(!this.getters.isReadonly()){if(!this.activeComposer)throw new Error("No composer is registered");this._focusMode=e.focusMode||"contentFocus","inactive"!==this._focusMode&&this.setComposerContent(e)}}setComposerContent({content:e,selection:t}){"inactive"===this.activeComposer.editionMode?this.activeComposer.startEdition(e,t):e&&this.activeComposer.setCurrentContent(e,t)}}const uc="x1";function gc(e,t,o,s){let i=!1;const n=[];for(let s in o){let r=o[s];if(r.labelCell){const e=fc(r.labelCell,t);r.labelCell!==e&&(i=!0,r={...r,labelCell:e})}const a=fc(r.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===ci.InvalidReference?(i=!0,r=void 0):a!==r.dataRange&&(i=!0,r={...r,dataRange:a}),n[s]=r}let r=s;const a=fc(r,t);a!==r&&(i=!0,r=a);return{isStale:i,dataSets:n.filter(tt),labelRange:r}}function pc(e,t,o){return o.map((o=>({dataRange:Cr(e,t,o.dataRange),labelCell:o.labelCell?Cr(e,t,o.labelCell):void 0})))}function mc(e,t,o){return o?Cr(e,t,o):void 0}function fc(e,t){if(!e)return;const o=t(e);switch(o.changeType){case"NONE":return e;case"REMOVE":return;default:return o.range}}function vc(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({...bc(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({...bc(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 bc(e,t,o,s){if(o.left!==o.right&&o.top!==o.bottom)throw new Error(`Zone should be a single column or row: ${Lo(o)}`);if(s){const i=Lo(o),n=Lo(s);return{labelCell:e.getRangeFromSheetXC(t,n),dataRange:e.getRangeFromSheetXC(t,i)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,Lo(o))}}function Sc(e,t){const o=t.labelCell?.zone;let s=t.dataRange.zone;if(o){const{numberOfRows:e,numberOfCols:t}=jo(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",{useBoundedReference:!0})}),{label:n,range:e.getRangeString(i,"forceSheetReference",{useBoundedReference:!0}),backgroundColor:t.backgroundColor,rightYAxis:t.rightYAxis}}function yc(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",{useBoundedReference:!0})}function Cc(e,t){let o;if(e.labelRange){const s=jl(Mo(e.labelRange),t);o=s?Lo(s):void 0}const s=e.dataSets.map((e=>Mo(e.dataRange))).map((e=>jl(e,t))).filter(tt).map((e=>({dataRange:Lo(e)})));return{...e,labelRange:o,dataSets:s}}function wc(e){return e&&Lt(e)<.3?"#FFFFFF":"#000000"}function Ec(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!Io.test(e.dataRange)));if(t)return"InvalidDataSet";if(e.dataSets.map((e=>Mo(e.dataRange))).some((e=>e.top!==e.bottom&&ss(e))))return"InvalidDataSet"}return"Success"}function xc(e){if(e.labelRange){if(!Io.test(e.labelRange||""))return"InvalidLabelRange"}return"Success"}function Ic(e,t,o){if(!o)return!1;if(!e)return!1;if(!t)return!0;const s=is(t.dataRange.zone);return!(is(e.zone)<s)}function Rc(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 Tc(e){let t=!1,o=!1;if("horizontal"in e&&e.horizontal)return{useLeftAxis:!0,useRightAxis:!1};for(const s of e.dataSets||[])"y1"===s.yAxisId?o=!0:t=!0;return t||=!o,{useLeftAxis:t,useRightAxis:o}}function Ac({displayTitle:e,displayLegend:t}){let o=25;return e?o=0:t&&(o=10),{left:20,right:20,top:o,bottom:10}}function _c(e,t){const o=[],s=[],i=[];for(let e=0;e<t.data.length;e++)"number"==typeof t.data[e]&&(o.push(t.data[e]),s.push(e+1)),i.push(e+1);const n=Be(.5,i.length+.55,.2),r=Oc(e,o,s,n);if(r.length)return Dc(t,e,r,n)}function Dc(e,t,o,s){const i=Ut(e.backgroundColor);i.a=1;const n=t.color||Wt(Vt(i),.5);return{type:"line",xAxisID:uc,yAxisID:e.yAxisID,label:e.label?vo("Trend line for %s",e.label):"",data:o.map(((e,t)=>({x:s[t],y:e}))),order:-1,showLine:!0,pointRadius:0,backgroundColor:n,borderColor:n,borderDash:[5,5],borderWidth:void 0,fill:!1,pointBackgroundColor:n}}function Oc(e,t,o,s){if(t.length<2||o.length<2||0===s.length)return[];const{normalizedLabels:i,normalizedNewLabels:n}=function(e,t,o){let s=[],i=[];if("logarithmic"===o.type){const o=Math.max(...e.map(Math.abs));s=e.map((e=>e/o)),i=t.map((e=>e/o))}else{const o=Math.max(...e),n=Math.min(...e),r=o-n;s=e.map((e=>(e-o)/r)),i=t.map((e=>(e-o)/r))}return{normalizedLabels:s,normalizedNewLabels:i}}(o,s,e);try{switch(e.type){case"polynomial":{const o=e.order;if(!o)return Array.from({length:s.length},(()=>NaN));if(1===o)return Ya([t],[i],[n],!0)[0];const r=Ga(t,i,o,!0).flat();return n.map((e=>qa(r,e,o)))}case"exponential":{const e=[],o=[];for(let s=0;s<t.length;s++)t[s]>0&&(e.push(Math.log(t[s])),o.push(i[s]));return o.length?Za(Ya([e],[o],[n],!0))[0]:Array.from({length:s.length},(()=>NaN))}case"logarithmic":return Ya([t],ja([i]),ja([n]),!0)[0];default:return[]}}catch(e){return Array.from({length:s.length},(()=>NaN))}}function Fc(e){return t=>{if(t=Number(t),isNaN(t))return t;const{locale:o,format:s}=e;return kn(t,{locale:o,format:!s&&Math.abs(t)>=1e3?"#,##":s})}}function Mc(e,t){return new Jt(t,e.dataSets.map((e=>e.backgroundColor)))}const Nc=[{value:"left",label:vo("Left")},{value:"right",label:vo("Right")}],Pc={id:"chartShowValuesPlugin",afterDatasetsDraw(e,t,o){if(!o.showValues)return;const s=e._metasets?.[0]?.data;if(!s)return;const i=e.ctx;switch(i.save(),i.textAlign="center",i.textBaseline="middle",i.miterLimit=1,e.config.type){case"pie":case"doughnut":!function(e,t,o){for(const s of e._metasets)for(let e=0;e<s._parsed.length;e++){const i=Number(s._parsed[e]);if(isNaN(i)||0===i)continue;const n=s.data[e],{startAngle:r,endAngle:a,innerRadius:l,outerRadius:c}=n,h=(r+a)/2,d=(l+c)/2,u=n.x+d*Math.cos(h),g=n.y+d*Math.sin(h)+7;o.fillStyle=wc(t.background),o.strokeStyle=t.background||"#ffffff";kc(t.callback(i),u,g,o)}}(e,o,i);break;case"bar":case"line":o.horizontal?function(e,t,o){const s=e.chartArea.right,i=e.chartArea.left,n={};for(const r of e._metasets){if(r.xAxisID===uc)return;for(let e=0;e<r._parsed.length;e++){const a=r._parsed[e].x,l=t.callback(a-0),c=r.data[e],h=c.y;let d=a<0?c.x+c.width/2:c.x-c.width/2;d=Math.min(d,s),d=Math.max(d,i),n[h]||(n[h]=[]);const u=Or(o,l,{fontSize:12},"px");for(const e of n[h])Math.abs(e-d)<u&&(d=e+u+3);n[h].push(d),o.fillStyle=c.options.backgroundColor,o.strokeStyle=t.background||"#ffffff",kc(l,d,h,o)}}}(e,o,i):function(e,t,o){const s=e.chartArea.bottom,i=e.chartArea.top,n={};for(const r of e._metasets){if(r.xAxisID===uc)return;for(let a=0;a<r._parsed.length;a++){const l=r._parsed[a].y,c=r.data[a],h=c.x;let d=0;d="line"===e.config.type?c.y-10:l<0?c.y-c.height/2:c.y+c.height/2,d=Math.min(d,s),d=Math.max(d,i),n[h]||(n[h]=[]);for(const e of n[h]||[])Math.abs(e-d)<13&&(d=e-13);n[h].push(d),o.fillStyle=c.options.backgroundColor,o.strokeStyle=t.background||"#ffffff",kc(t.callback(l-0),h,d,o)}}}(e,o,i)}i.restore()}};function kc(e,t,o,s){s.lineWidth=3,s.strokeText(e,t,o),s.lineWidth=1,s.fillText(e,t,o)}const Lc={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=Uc(s,e);if(!o)break;const n=Vc(t),r=Vc(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 Vc(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 Uc(e,t){return e.find(((e,o)=>o>t&&0!==e.height))}window.Chart?.register(Lc),window.Chart?.register(Pc);class Hc 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(Pe(e.chartJsConfig))})),t.onWillUnmount((()=>this.chart?.destroy())),t.useEffect((()=>{const e=this.chartRuntime;e!==this.currentRuntime&&(e.chartJsConfig.type!==this.currentRuntime.chartJsConfig.type?(this.chart?.destroy(),this.createChart(Pe(e.chartJsConfig))):this.updateChartJs(Pe(e)),this.currentRuntime=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 Bc{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 zc(e,t,o,s,i){if("text"===t||"progress"===t||e?.type!==$s.number||o?.type!==$s.number)return;const n=o.value-e.value;return n>0?s:n<0?i:void 0}function $c(e,t,o){if("text"===o||e?.type!==$s.number||t?.type!==$s.number)return"neutral";const s=t.value-e.value;return s>0?"up":s<0?"down":"neutral"}function Gc(e){return e.keyValue&&!Io.test(e.keyValue)?"InvalidScorecardKeyValue":"Success"}function Wc(e){return e.baseline&&!Io.test(e.baseline)?"InvalidScorecardBaseline":"Success"}const qc=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"),Zc=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 jc=class e extends Bc{keyValue;baseline;baselineMode;baselineDescr;progressBar=!1;background;baselineColorUp;baselineColorDown;fontColor;humanize;type="scorecard";constructor(e,t,o){super(e,t,o),this.keyValue=wr(o,t,e.keyValue),this.baseline=wr(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp??Se,this.baselineColorDown=e.baselineColorDown??ye,this.humanize=e.humanize??!1}static validateChartDefinition(e,t){return e.checkValidations(t,Gc,Wc)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0].dataRange:void 0,title:e.title||{text:""},baselineMode:be,baselineColorUp:Se,baselineColorDown:ye,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,s;return e.baseline&&(o=jl(Mo(e.baseline),t)),e.keyValue&&(s=jl(Mo(e.keyValue),t)),{...e,baseline:o?Lo(o):void 0,keyValue:s?Lo(s):void 0}}copyForSheetId(t){const o=mc(this.sheetId,t,this.baseline),s=mc(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=fc(this.baseline,t),s=fc(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 Yc(e,t){const o=t.getContext("2d");t.width=e.canvas.width;const s=t.width-q;if(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 t=o.textBaseline;o.textBaseline="middle",o.fillText(zr(o,e.title.text,s-e.title.position.x),e.title.position.x,e.title.position.y),o.textBaseline=t}if(e.baseline&&(o.font=e.baseline.style.font,o.fillStyle=e.baseline.style.color,$r(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(qc);break;case"up":o.fill(Zc)}o.restore()}if(e.baselineDescr){const t=e.baselineDescr[0];o.font=t.style.font,o.fillStyle=t.style.color;for(const t of e.baselineDescr)o.fillText(zr(o,t.text,s-t.position.x),t.position.x,t.position.y)}if(e.key&&(o.font=e.key.style.font,o.fillStyle=e.key.style.color,$r(o,zr(o,e.key.text,s-e.key.position.x),e.key.position,e.key.style.underline,e.key.style.strikethrough)),e.progressBar){if(o.fillStyle=e.progressBar.style.backgroundColor,o.beginPath(),o.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width,e.progressBar.dimension.height,e.progressBar.dimension.height/2),o.fill(),o.fillStyle=e.progressBar.style.color,o.beginPath(),e.progressBar.value>0)o.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width*Math.max(0,Math.min(1,e.progressBar.value)),e.progressBar.dimension.height,e.progressBar.dimension.height/2);else{const t=e.progressBar.dimension.width*Math.max(0,Math.min(1,-e.progressBar.value));o.roundRect(e.progressBar.position.x+e.progressBar.dimension.width-t,e.progressBar.position.y,t,e.progressBar.dimension.height,e.progressBar.dimension.height/2)}o.fill()}}const Xc=10,Kc=.05;function Qc({width:e,height:t},o){return new Jc({width:e,height:t},o).computeDesign()}class Jc{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-Xc;break;default:s=Xc}e.title={text:this.title,style:t.title,position:{x:s,y:Xc+o/2}}}const s=t.baselineArrow?.size??0;let{height:i,width:n}=this.getTextDimensions(this.baseline,t.baselineValue.font);this.baseline||(i=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).height);const r=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).width;e.baseline={text:this.baseline,style:t.baselineValue,position:{x:(this.width-n-r+s)/2,y:this.keyValue?this.height*(1-Kc*(this.runtime.progressBar?1:2)):this.height-(this.height-o-i)/2-Xc}};const a=s+q;if(e.baseline.position.x<a&&(e.baseline.position.x=a),t.baselineArrow&&!this.runtime.progressBar&&(e.baselineArrow={direction:this.baselineArrow,style:t.baselineArrow,position:{x:e.baseline.position.x-s,y:e.baseline.position.y-(i+s)/2}}),this.baselineDescr){const o={x:e.baseline.position.x+n,y:e.baseline.position.y};e.baselineDescr=[{text:this.baselineDescr,style:t.baselineDescr,position:o}]}let l=0;this.runtime.progressBar&&(l=.05*this.height,e.progressBar={position:{x:20,y:.9*this.height-i-l},dimension:{height:l,width:this.width-40},value:this.runtime.progressBar.value,style:{color:this.runtime.progressBar.color,backgroundColor:this.secondaryFontColor}});const{width:c,height:h}=this.getFullTextDimensions(this.keyValue,t.keyValue.font);return this.keyValue&&(e.key={text:this.keyValue,style:t.keyValue,position:{x:Math.max(Xc,(this.width-c)/2),y:.4*this.height+5+(o+h/2)/2}}),e}get title(){return this.runtime.title.text??""}get keyValue(){return this.runtime.keyValue}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){return function(e,t){const o=e||"";return t&&o?" "+o:o}(this.runtime.baselineDescr,this.baseline)}get baselineArrow(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get secondaryFontColor(){return Lt(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(){let e=16;const t=Math.floor(.9*e);return this.runtime.progressBar&&(e/=1.5),{title:{font:_r(14,this.runtime.title.bold,this.runtime.title.italic),color:this.runtime.title.color??this.secondaryFontColor},keyValue:{color:this.runtime.keyValueStyle?.textColor||this.runtime.fontColor,font:_r(32,this.runtime.keyValueStyle?.bold,this.runtime.keyValueStyle?.italic),strikethrough:this.runtime.keyValueStyle?.strikethrough,underline:this.runtime.keyValueStyle?.underline},baselineValue:{font:_r(e,this.runtime.baselineStyle?.bold,this.runtime.baselineStyle?.italic),strikethrough:this.runtime.baselineStyle?.strikethrough,underline:this.runtime.baselineStyle?.underline,color:this.runtime.baselineStyle?.textColor||this.runtime.baselineColor||this.secondaryFontColor},baselineDescr:{font:_r(t),color:this.secondaryFontColor},baselineArrow:"neutral"===this.baselineArrow||this.runtime.progressBar?void 0:{size:this.keyValue?.8*e:0,color:this.runtime.baselineColor||this.secondaryFontColor}}}}class eh extends t.Component{static template="o-spreadsheet-ScorecardChart";static props={figure:Object};canvas=t.useRef("chartContainer");get runtime(){return this.env.model.getters.getChartRuntime(this.props.figure.id)}get title(){const e=this.env.model.getters.getChartDefinition(this.props.figure.id).title.text??"";return vo(e)}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;Yc(Qc(e.getBoundingClientRect(),this.runtime),e)}}const th=new n;function oh(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))}th.add("dataValidation",{getProposals(e,t){if(t.startsWith("="))return[];if(!this.composer.currentEditedCell)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(ot).map((e=>e.toString())).filter((e=>""!==e))))}return i.map((e=>({text:e})))},selectProposal(e,t){this.composer.setCurrentContent(t),this.composer.stopEdition()}});const sh=/(.*?)\((.*?)\)(.*)/,ih=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function nh(e,t=""){return function(e,t){let o=e.match(sh),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=ih.find((e=>t===e));o?n.push(o):"RANGE<ANY>"===t?n.push("RANGE"):"OPTIONAL"===t?r=!0:"REPEATING"===t?a=!0:t.startsWith("DEFAULT=")&&(i=e.trim().slice(8))}const l={name:s,description:t,type:n};(n.includes("ANY")||n.includes("RANGE"))&&(l.acceptErrors=!0);r&&(l.optional=!0);a&&(l.repeating=!0);void 0!==i&&(l.default=!0,l.defaultValue=i);n.some((e=>e.startsWith("RANGE")))&&(l.acceptMatrix=!0);n.every((e=>e.startsWith("RANGE")))&&(l.acceptMatrixOnly=!0);return l}(e,t)}function rh(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 ah(e,t){bi((()=>1===t.length||1===t[0].length),e)}function lh(e,...t){if(t.every(ni)){const o=t[0].length,s=t[0][0].length;for(const i of t)bi((()=>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 di(e)}function ch(e,t){bi((()=>t>0),e)}function hh(e,t){bi((()=>t.length===t[0].length),e)}const dh={description:vo("Returns a result array constrained to a specific width and height."),args:[nh("input_range (any, range<any>)",vo("The range to constrain.")),nh("rows (number)",vo("The number of rows in the constrained array.")),nh("columns (number)",vo("The number of columns in the constrained array."))],compute:function(e,t,o){const s=tn(e),i=Ri(t?.value,this.locale),n=Ri(o?.value,this.locale);ch(vo("The rows argument (%s) must be strictly positive.",i.toString()),i),ch(vo("The columns argument (%s) must be strictly positive.",i.toString()),n);const r=Math.min(i,s[0].length);return $i(Math.min(n,s.length),r,((e,t)=>s[e][t]))},isExported:!1},uh={description:vo("Creates a new array from the selected columns in the existing range."),args:[nh("array (any, range<any>)",vo("The array that contains the columns to be returned.")),nh("col_num (number, range<number>)",vo("The first column index of the columns to be returned.")),nh("col_num2 (number, range<number>, repeating)",vo("The columns indexes of the columns to be returned."))],compute:function(e,...t){const o=tn(e),s=on(t,(e=>Ri(e?.value,this.locale))),i=s.filter((e=>0===e||o.length<Math.abs(e)));bi((()=>0===i.length),vo("The columns arguments must be between -%s and %s (got %s), excluding 0.",o.length.toString(),o.length.toString(),i.join(",")));const n=Array(s.length);for(let e=0;e<s.length;e++)s[e]>0?n[e]=o[s[e]-1]:n[e]=o[o.length+s[e]];return n},isExported:!0},gh={description:vo("Creates a new array from the selected rows in the existing range."),args:[nh("array (any, range<any>)",vo("The array that contains the rows to be returned.")),nh("row_num (number, range<number>)",vo("The first row index of the rows to be returned.")),nh("row_num2 (number, range<number>, repeating)",vo("The rows indexes of the rows to be returned."))],compute:function(e,...t){const o=tn(e),s=on(t,(e=>Ri(e?.value,this.locale))),i=o.length,n=s.filter((e=>0===e||o[0].length<Math.abs(e)));return bi((()=>0===n.length),vo("The rows arguments must be between -%s and %s (got %s), excluding 0.",o[0].length.toString(),o[0].length.toString(),n.join(","))),$i(i,s.length,((e,t)=>s[t]>0?o[e][s[t]-1]:o[e][o[e].length+s[t]]))},isExported:!0},ph={description:vo("Expands or pads an array to specified row and column dimensions."),args:[nh("array (any, range<any>)",vo("The array to expand.")),nh("rows (number)",vo("The number of rows in the expanded array. If missing, rows will not be expanded.")),nh("columns (number, optional)",vo("The number of columns in the expanded array. If missing, columns will not be expanded.")),nh("pad_with (any, default=0)",vo("The value with which to pad."))],compute:function(e,t,o,s={value:0}){const i=tn(e),n=Ri(t?.value,this.locale),r=void 0!==o?Ri(o.value,this.locale):i.length;return bi((()=>n>=i[0].length),vo("The rows arguments (%s) must be greater or equal than the number of rows of the array.",n.toString())),bi((()=>r>=i.length),vo("The columns arguments (%s) must be greater or equal than the number of columns of the array.",r.toString())),$i(r,n,((e,t)=>e>=i.length||t>=i[e].length?s:i[e][t]))},isExported:!0},mh={description:vo("Flattens all the values from one or more ranges into a single column."),args:[nh("range (any, range<any>)",vo("The first range to flatten.")),nh("range2 (any, range<any>, repeating)",vo("Additional ranges to flatten."))],compute:function(...e){return[on(e,(e=>void 0===e?{value:""}:e))]},isExported:!1},fh={description:vo("Calculates the frequency distribution of a range."),args:[nh("data (range<number>)",vo("The array of ranges containing the values to be counted.")),nh("classes (number, range<number>)",vo("The range containing the set of classes."))],compute:function(e,t){const o=on([e],(e=>e.value)).filter((e=>"number"==typeof e)),s=on([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},vh={description:vo("Appends ranges horizontally and in sequence to return a larger array."),args:[nh("range1 (any, range<any>)",vo("The first range to be appended.")),nh("range2 (any, range<any>, repeating)",vo("Additional ranges to add to range1."))],compute:function(...e){const t=Math.max(...e.map((e=>e?.[0]?.length??0))),o=[];for(const s of e){const e=tn(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},bh={description:vo("Returns the matrix determinant of a square matrix."),args:[nh("square_matrix (number, range<number>)",vo("An range with an equal number of rows and columns representing a matrix whose determinant will be calculated."))],compute:function(e){const t=xi(e,"square_matrix");return hh(vo("The argument square_matrix must have the same number of columns and rows."),t),Fa(t).determinant},isExported:!0},Sh={description:vo("Returns the multiplicative inverse of a square matrix."),args:[nh("square_matrix (number, range<number>)",vo("An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated."))],compute:function(e){const t=xi(e,"square_matrix");hh(vo("The argument square_matrix must have the same number of columns and rows."),t);const{inverted:o}=Fa(t);if(!o)throw new di(vo("The matrix is not invertible."));return o},isExported:!0},yh={description:vo("Calculates the matrix product of two matrices."),args:[nh("matrix1 (number, range<number>)",vo("The first matrix in the matrix multiplication operation.")),nh("matrix2 (number, range<number>)",vo("The second matrix in the matrix multiplication operation."))],compute:function(e,t){const o=xi(e,"matrix1"),s=xi(t,"matrix2");return bi((()=>o.length===s[0].length),vo("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())),Na(o,s)},isExported:!0},Ch={description:vo("Calculates the sum of the products of corresponding entries in equal-sized ranges."),args:[nh("range1 (number, range<number>)",vo("The first range whose entries will be multiplied with corresponding entries in the other ranges.")),nh("range2 (number, range<number>, repeating)",vo("The other range whose entries will be multiplied with corresponding entries in the other ranges."))],compute:function(...e){lh(vo("All the ranges must have the same dimensions."),...e);const t=e.map(tn);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*=wi(o[e][s],this.locale);o+=i}return o},isExported:!0};function wh(e,t,o){lh("The arguments array_x and array_y must have the same dimensions.",e,t);const s=tn(e),i=tn(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 di(vo("The arguments array_x and array_y must contain at least one pair of numbers."));return r}const Eh={description:vo("Calculates the sum of the difference of the squares of the values in two array."),args:[nh("array_x (number, range<number>)",vo("The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.")),nh("array_y (number, range<number>)",vo("The array or range of values whose squares will be subtracted from the squares of corresponding entries in array_x and added together."))],compute:function(e,t){return wh(e,t,((e,t)=>e**2-t**2))},isExported:!0},xh={description:vo("Calculates the sum of the sum of the squares of the values in two array."),args:[nh("array_x (number, range<number>)",vo("The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.")),nh("array_y (number, range<number>)",vo("The array or range of values whose squares will be added to the squares of corresponding entries in array_x and added together."))],compute:function(e,t){return wh(e,t,((e,t)=>e**2+t**2))},isExported:!0},Ih={description:vo("Calculates the sum of squares of the differences of values in two array."),args:[nh("array_x (number, range<number>)",vo("The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.")),nh("array_y (number, range<number>)",vo("The array or range of values that will be subtracted from corresponding entries in array_x, the result squared, and all such results added together."))],compute:function(e,t){return wh(e,t,((e,t)=>(e-t)**2))},isExported:!0},Rh=!1,Th=[nh("array (any, range<any>)",vo("The array which will be transformed.")),nh("ignore (number, default=0)",vo("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.")),nh("scan_by_column (number, default=false)",vo("Whether the array should be scanned by column. True scans the array by column and false (default) scans the array by row."))];function Ah(e){const t=Math.trunc(e);if(0===t)return()=>!0;if(1===t)return e=>null!==e.value;if(2===t)return e=>!yi(e.value);if(3===t)return e=>null!==e.value&&!yi(e.value);throw new di(vo("Argument ignore must be between 0 and 3"))}const _h={description:vo("Transforms a range of cells into a single column."),args:Th,compute:function(e,t={value:0},o={value:Rh}){const s=tn(e),i=wi(t.value,this.locale),n=(Mi(o.value)?s:Wi(s)).flat().filter(Ah(i));if(0===n.length)throw new pi(vo("No results for the given arguments of TOCOL."));return[n]},isExported:!0},Dh={description:vo("Transforms a range of cells into a single row."),args:Th,compute:function(e,t={value:0},o={value:Rh}){const s=tn(e),i=wi(t.value,this.locale),n=(Mi(o.value)?s:Wi(s)).flat().filter(Ah(i)).map((e=>[e]));if(0===n.length||0===n[0].length)throw new pi(vo("No results for the given arguments of TOROW."));return n},isExported:!0},Oh={description:vo("Transposes the rows and columns of a range."),args:[nh("range (any, range<any>)",vo("The range to be transposed."))],compute:function(e){const t=tn(e);return $i(t[0].length,t.length,((e,o)=>t[o][e]))},isExported:!0},Fh={description:vo("Appends ranges vertically and in sequence to return a larger array."),args:[nh("range1 (any, range<any>)",vo("The first range to be appended.")),nh("range2 (any, range<any>, repeating)",vo("Additional ranges to add to range1."))],compute:function(...e){const t=Math.max(...e.map((e=>tn(e).length))),o=e.reduce(((e,t)=>e+tn(t)[0].length),0),s=Array(t).fill([]).map((()=>Array(o).fill({value:0})));let i=0;for(const t of e){const e=tn(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},Mh={description:vo("Wraps the provided row or column of cells by columns after a specified number of elements to form a new array."),args:[nh("range (any, range<any>)",vo("The range to wrap.")),nh("wrap_count (number)",vo("The maximum number of cells for each column, rounded down to the nearest whole number.")),nh("pad_with (any, default=0)",vo("The value with which to fill the extra cells in the range."))],compute:function(e,t,o={value:0}){const s=tn(e),i=Ri(t?.value,this.locale);ah(vo("Argument range must be a single row or column."),s);const n=s.flat();return $i(Math.ceil(n.length/i),i,((e,t)=>{const s=e*i+t;return s<n.length?n[s]:o}))},isExported:!0},Nh={description:vo("Wraps the provided row or column of cells by rows after a specified number of elements to form a new array."),args:[nh("range (any, range<any>)",vo("The range to wrap.")),nh("wrap_count (number)",vo("The maximum number of cells for each row, rounded down to the nearest whole number.")),nh("pad_with (any, default=0)",vo("The value with which to fill the extra cells in the range."))],compute:function(e,t,o={value:0}){const s=tn(e),i=Ri(t?.value,this.locale);ah(vo("Argument range must be a single row or column."),s);const n=s.flat(),r=Math.ceil(n.length/i);return $i(i,r,((e,t)=>{const s=t*i+e;return s<n.length?n[s]:o}))},isExported:!0};var Ph=Object.freeze({__proto__:null,ARRAY_CONSTRAIN:dh,CHOOSECOLS:uh,CHOOSEROWS:gh,EXPAND:ph,FLATTEN:mh,FREQUENCY:fh,HSTACK:vh,MDETERM:bh,MINVERSE:Sh,MMULT:yh,SUMPRODUCT:Ch,SUMX2MY2:Eh,SUMX2PY2:xh,SUMXMY2:Ih,TOCOL:_h,TOROW:Dh,TRANSPOSE:Oh,VSTACK:Fh,WRAPCOLS:Mh,WRAPROWS:Nh});const kh={description:vo("Apply a large number format"),args:[nh("value (number)",vo("The number.")),nh("unit (string, optional)",vo("The formatting unit. Use 'k', 'm', or 'b' to force the unit"))],compute:function(e,t){return{value:wi(e,this.locale),format:or(e,t,this.locale)}}};var Lh=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:kh});const Vh=/^-?[a-z0-9]+$/i,Uh={description:vo("Absolute value of a number."),args:[nh("value (number)",vo("The number of which to return the absolute value."))],compute:function(e){return Math.abs(wi(e,this.locale))},isExported:!0},Hh={description:vo("Inverse cosine of a value, in radians."),args:[nh("value (number)",vo("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive."))],compute:function(e){const t=wi(e,this.locale);return bi((()=>Math.abs(t)<=1),vo("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},Bh={description:vo("Inverse hyperbolic cosine of a number."),args:[nh("value (number)",vo("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1."))],compute:function(e){const t=wi(e,this.locale);return bi((()=>t>=1),vo("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},zh={description:vo("Inverse cotangent of a value."),args:[nh("value (number)",vo("The value for which to calculate the inverse cotangent."))],compute:function(e){const t=wi(e,this.locale);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},$h={description:vo("Inverse hyperbolic cotangent of a value."),args:[nh("value (number)",vo("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive."))],compute:function(e){const t=wi(e,this.locale);return bi((()=>Math.abs(t)>1),vo("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},Gh={description:vo("Inverse sine of a value, in radians."),args:[nh("value (number)",vo("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive."))],compute:function(e){const t=wi(e,this.locale);return bi((()=>Math.abs(t)<=1),vo("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Wh={description:vo("Inverse hyperbolic sine of a number."),args:[nh("value (number)",vo("The value for which to calculate the inverse hyperbolic sine."))],compute:function(e){return Math.asinh(wi(e,this.locale))},isExported:!0},qh={description:vo("Inverse tangent of a value, in radians."),args:[nh("value (number)",vo("The value for which to calculate the inverse tangent."))],compute:function(e){return Math.atan(wi(e,this.locale))},isExported:!0},Zh={description:vo("Angle from the X axis to a point (x,y), in radians."),args:[nh("x (number)",vo("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),nh("y (number)",vo("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis."))],compute:function(e,t){const o=wi(e,this.locale),s=wi(t,this.locale);return bi((()=>0!==o||0!==s),vo("Function [[FUNCTION_NAME]] caused a divide by zero error."),ci.DivisionByZero),Math.atan2(s,o)},isExported:!0},jh={description:vo("Inverse hyperbolic tangent of a number."),args:[nh("value (number)",vo("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive."))],compute:function(e){const t=wi(e,this.locale);return bi((()=>Math.abs(t)<1),vo("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},Yh={description:vo("Rounds number up to nearest multiple of factor."),args:[nh("value (number)",vo("The value to round up to the nearest integer multiple of factor.")),nh("factor (number, default=1)",vo("The number to whose multiples value will be rounded."))],compute:function(e,t={value:1}){const o=wi(e,this.locale),s=wi(t,this.locale);return bi((()=>s>=0||o<=0),vo("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 Xh(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 Kh={description:vo("Rounds number up to nearest multiple of factor."),args:[nh("number (number)",vo("The value to round up to the nearest integer multiple of significance.")),nh("significance (number, default=1)",vo("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),nh("mode (number, default=0)",vo("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero."))],compute:function(e,t={value:1},o={value:0}){const s=wi(t,this.locale);return{value:Xh(wi(e,this.locale),s,wi(o,this.locale)),format:e?.format}},isExported:!0},Qh={description:vo("Rounds number up to nearest multiple of factor."),args:[nh("number (number)",vo("The value to round up to the nearest integer multiple of significance.")),nh("significance (number, default=1)",vo("The number to whose multiples number will be rounded."))],compute:function(e,t={value:1}){const o=wi(t,this.locale);return{value:Xh(wi(e,this.locale),o),format:e?.format}},isExported:!0},Jh={description:vo("Cosine of an angle provided in radians."),args:[nh("angle (number)",vo("The angle to find the cosine of, in radians."))],compute:function(e){return Math.cos(wi(e,this.locale))},isExported:!0},ed={description:vo("Hyperbolic cosine of any real number."),args:[nh("value (number)",vo("Any real value to calculate the hyperbolic cosine of."))],compute:function(e){return Math.cosh(wi(e,this.locale))},isExported:!0},td={description:vo("Cotangent of an angle provided in radians."),args:[nh("angle (number)",vo("The angle to find the cotangent of, in radians."))],compute:function(e){const t=wi(e,this.locale);return _i(t),1/Math.tan(t)},isExported:!0},od={description:vo("Hyperbolic cotangent of any real number."),args:[nh("value (number)",vo("Any real value to calculate the hyperbolic cotangent of."))],compute:function(e){const t=wi(e,this.locale);return _i(t),1/Math.tanh(t)},isExported:!0},sd={description:vo("Number of empty values."),args:[nh("value1 (any, range)",vo("The first value or range in which to count the number of blanks.")),nh("value2 (any, range, repeating)",vo("Additional values or ranges in which to count the number of blanks."))],compute:function(...e){return Hi(e,((e,t)=>void 0===t||null===t.value||""===t.value?e+1:e),0)},isExported:!0},id={description:vo("A conditional count across a range."),args:[nh("range (range)",vo("The range that is tested against criterion.")),nh("criterion (string)",vo("The pattern or test to apply to range."))],compute:function(...e){let t=0;return Xi(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0},nd={description:vo("Count values depending on multiple criteria."),args:[nh("criteria_range1 (range)",vo("The range to check against criterion1.")),nh("criterion1 (string)",vo("The pattern or test to apply to criteria_range1.")),nh("criteria_range2 (any, range, repeating)",vo("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.")),nh("criterion2 (string, repeating)",vo("Additional criteria to check."))],compute:function(...e){let t=0;return Xi(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0},rd={description:vo("Counts number of unique values in a range."),args:[nh("value1 (any, range)",vo("The first value or range to consider for uniqueness.")),nh("value2 (any, range, repeating)",vo("Additional values or ranges to consider for uniqueness."))],compute:function(...e){return Da(e)}},ad={description:vo("Counts number of unique values in a range, filtered by a set of criteria."),args:[nh("range (range)",vo("The range of cells from which the number of unique values will be counted.")),nh("criteria_range1 (range)",vo("The range of cells over which to evaluate criterion1.")),nh("criterion1 (string)",vo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),nh("criteria_range2 (any, range, repeating)",vo("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.")),nh("criterion2 (string, repeating)",vo("The pattern or test to apply to criteria_range2."))],compute:function(e,...t){let o=new Set;return Xi(t,((t,s)=>{const i=e[t]?.[s];sn(i)&&o.add(i.value)}),this.locale),o.size}},ld={description:vo("Cosecant of an angle provided in radians."),args:[nh("angle (number)",vo("The angle to find the cosecant of, in radians."))],compute:function(e){const t=wi(e,this.locale);return _i(t),1/Math.sin(t)},isExported:!0},cd={description:vo("Hyperbolic cosecant of any real number."),args:[nh("value (number)",vo("Any real value to calculate the hyperbolic cosecant of."))],compute:function(e){const t=wi(e,this.locale);return _i(t),1/Math.sinh(t)},isExported:!0},hd={description:vo("Converts from another base to decimal."),args:[nh("value (string)",vo("The number to convert.")),nh("base (number)",vo("The base to convert the value from."))],compute:function(e,t){let o=wi(t,this.locale);o=Math.floor(o),bi((()=>2<=o&&o<=36),vo("The base (%s) must be between 2 and 36 inclusive.",o.toString()));const s=Di(e);if(""===s)return 0;bi((()=>!!Vh.test(s)),vo("The value (%s) must be a valid base %s representation.",s,o.toString()));const i=parseInt(s,o);return bi((()=>!isNaN(i)),vo("The value (%s) must be a valid base %s representation.",s,o.toString())),i},isExported:!0},dd={description:vo("Converts an angle value in radians to degrees."),args:[nh("angle (number)",vo("The angle to convert from radians to degrees."))],compute:function(e){return 180*wi(e,this.locale)/Math.PI},isExported:!0},ud={description:vo("Euler's number, e (~2.718) raised to a power."),args:[nh("value (number)",vo("The exponent to raise e."))],compute:function(e){return Math.exp(wi(e,this.locale))},isExported:!0},gd={description:vo("Rounds number down to nearest multiple of factor."),args:[nh("value (number)",vo("The value to round down to the nearest integer multiple of factor.")),nh("factor (number, default=1)",vo("The number to whose multiples value will be rounded."))],compute:function(e,t={value:1}){const o=wi(e,this.locale),s=wi(t,this.locale);return bi((()=>s>=0||o<=0),vo("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 pd(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 md={description:vo("Rounds number down to nearest multiple of factor."),args:[nh("number (number)",vo("The value to round down to the nearest integer multiple of significance.")),nh("significance (number, default=1)",vo("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),nh("mode (number, default=0)",vo("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero."))],compute:function(e,t={value:1},o={value:0}){const s=wi(t,this.locale);return{value:pd(wi(e,this.locale),s,wi(o,this.locale)),format:e?.format}},isExported:!0},fd={description:vo("Rounds number down to nearest multiple of factor."),args:[nh("number (number)",vo("The value to round down to the nearest integer multiple of significance.")),nh("significance (number, default=1)",vo("The number to whose multiples number will be rounded."))],compute:function(e,t={value:1}){const o=wi(t,this.locale);return{value:pd(wi(e,this.locale),o),format:e?.format}},isExported:!0},vd={description:vo("Whether the provided value is even."),args:[nh("value (number)",vo("The value to be verified as even."))],compute:function(e){const t=Ii(e,this.locale);return!(1&Math.floor(Math.abs(t)))},isExported:!0},bd={description:vo("Rounds number up to nearest multiple of factor."),args:[nh("number (number)",vo("The value to round up to the nearest integer multiple of significance.")),nh("significance (number, default=1)",vo("The number to whose multiples number will be rounded."))],compute:function(e,t={value:1}){return{value:Xh(wi(e,this.locale),wi(t,this.locale)),format:e?.format}},isExported:!0},Sd={description:vo("Whether the provided value is even."),args:[nh("value (number)",vo("The value to be verified as even."))],compute:function(e){const t=Ii(e,this.locale);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},yd={description:vo("The logarithm of a number, base e (euler's number)."),args:[nh("value (number)",vo("The value for which to calculate the logarithm, base e."))],compute:function(e){const t=wi(e,this.locale);return bi((()=>t>0),vo("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0};function Cd(e,t){bi((()=>0!==t),vo("The divisor must be different from 0."),ci.DivisionByZero);const o=e%t;return o>0&&t<0||o<0&&t>0?o+t:o}const wd={description:vo("Modulo (remainder) operator."),args:[nh("dividend (number)",vo("The number to be divided to find the remainder.")),nh("divisor (number)",vo("The number to divide by."))],compute:function(e,t){const o=wi(t,this.locale);return{value:Cd(wi(e,this.locale),o),format:e?.format}},isExported:!0},Ed={description:vo("Returns a n x n unit matrix, where n is the input dimension."),args:[nh("dimension (number)",vo("An integer specifying the dimension size of the unit matrix. It must be positive."))],compute:function(e){const t=Ri(e,this.locale);return ch(vo("The argument dimension must be positive"),t),Oa(t)},isExported:!0},xd={description:vo("Rounds a number up to the nearest odd integer."),args:[nh("value (number)",vo("The value to round to the next greatest odd number."))],compute:function(e){const t=wi(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},Id={description:vo("The number pi."),args:[],compute:function(){return Math.PI},isExported:!0},Rd={description:vo("A number raised to a power."),args:[nh("base (number)",vo("The number to raise to the exponent power.")),nh("exponent (number)",vo("The exponent to raise base to."))],compute:function(e,t){const o=wi(e,this.locale),s=wi(t,this.locale);return bi((()=>o>=0||Number.isInteger(s)),vo("The exponent (%s) must be an integer when the base is negative.",s.toString())),{value:Math.pow(o,s),format:e?.format}},isExported:!0},Td={description:vo("Result of multiplying a series of numbers together."),args:[nh("factor1 (number, range<number>)",vo("The first number or range to calculate for the product.")),nh("factor2 (number, range<number>, repeating)",vo("More numbers or ranges to calculate for the product."))],compute:function(...e){let t=0,o=1;for(let s of e)if(ni(s))for(let e of s)for(let s of e){const e=s.value;if("number"==typeof e&&(o*=e,t+=1),yi(e))throw s}else void 0!==s&&null!==s.value&&(o*=Ii(s,this.locale),t+=1);return{value:0===t?0:o,format:Si(e[0])}},isExported:!0},Ad={description:vo("A random number between 0 inclusive and 1 exclusive."),args:[],compute:function(){return Math.random()},isExported:!0},_d={description:vo("Returns a grid of random numbers between 0 inclusive and 1 exclusive."),args:[nh("rows (number, default=1)",vo("The number of rows to be returned.")),nh("columns (number, default=1)",vo("The number of columns to be returned.")),nh("min (number, default=0)",vo("The minimum number you would like returned.")),nh("max (number, default=1)",vo("The maximum number you would like returned.")),nh("whole_number (number, default=FALSE)",vo("Return a whole number or a decimal value."))],compute:function(e={value:1},t={value:1},o={value:0},s={value:1},i={value:!1}){const n=Ri(t,this.locale),r=Ri(e,this.locale),a=wi(o,this.locale),l=wi(s,this.locale),c=Mi(i);ch(vo("The number of columns (%s) must be positive.",n.toString()),n),ch(vo("The number of rows (%s) must be positive.",r.toString()),r),bi((()=>a<=l),vo("The maximum (%s) must be greater than or equal to the minimum (%s).",l.toString(),a.toString())),c&&bi((()=>Number.isInteger(a)&&Number.isInteger(l)),vo("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},Dd={description:vo("Random integer between two values, inclusive."),args:[nh("low (number)",vo("The low end of the random range.")),nh("high (number)",vo("The high end of the random range."))],compute:function(e,t){let o=wi(e,this.locale);Number.isInteger(o)||(o=Math.ceil(o));let s=wi(t,this.locale);return Number.isInteger(s)||(s=Math.floor(s)),bi((()=>o<=s),vo("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},Od={description:vo("Rounds a number according to standard rules."),args:[nh("value (number)",vo("The value to round to places number of places.")),nh("places (number, default=0)",vo("The number of decimal places to which to round."))],compute:function(e,t={value:0}){const o=wi(e,this.locale);let s=wi(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},Fd={description:vo("Rounds down a number."),args:[nh("value (number)",vo("The value to round to places number of places, always rounding down.")),nh("places (number, default=0)",vo("The number of decimal places to which to round."))],compute:function(e,t={value:0}){const o=wi(e,this.locale);let s=wi(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},Md={description:vo("Rounds up a number."),args:[nh("value (number)",vo("The value to round to places number of places, always rounding up.")),nh("places (number, default=0)",vo("The number of decimal places to which to round."))],compute:function(e,t={value:0}){const o=wi(e,this.locale);let s=wi(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},Nd={description:vo("Secant of an angle provided in radians."),args:[nh("angle (number)",vo("The angle to find the secant of, in radians."))],compute:function(e){return 1/Math.cos(wi(e,this.locale))},isExported:!0},Pd={description:vo("Hyperbolic secant of any real number."),args:[nh("value (number)",vo("Any real value to calculate the hyperbolic secant of."))],compute:function(e){return 1/Math.cosh(wi(e,this.locale))},isExported:!0},kd={description:vo("Returns a sequence of numbers."),args:[nh("rows (number)",vo("The number of rows to return")),nh("columns (number, optional, default=1)",vo("The number of columns to return")),nh("start (number, optional, default=1)",vo("The first number in the sequence")),nh("step (number, optional, default=1)",vo("The amount to increment each value in the sequence"))],compute:function(e,t={value:1},o={value:1},s={value:1}){const i=wi(o,this.locale),n=wi(s,this.locale),r=Ri(e,this.locale),a=Ri(t,this.locale);return ch(vo("The number of columns (%s) must be positive.",a),a),ch(vo("The number of rows (%s) must be positive.",r),r),$i(a,r,((e,t)=>({value:i+t*a*n+e*n})))},isExported:!0},Ld={description:vo("Sine of an angle provided in radians."),args:[nh("angle (number)",vo("The angle to find the sine of, in radians."))],compute:function(e){return Math.sin(wi(e,this.locale))},isExported:!0},Vd={description:vo("Hyperbolic sine of any real number."),args:[nh("value (number)",vo("Any real value to calculate the hyperbolic sine of."))],compute:function(e){return Math.sinh(wi(e,this.locale))},isExported:!0},Ud={description:vo("Positive square root of a positive number."),args:[nh("value (number)",vo("The number for which to calculate the positive square root."))],compute:function(e){const t=wi(e,this.locale);return bi((()=>t>=0),vo("The value (%s) must be positive or null.",t.toString())),{value:Math.sqrt(t),format:e?.format}},isExported:!0},Hd={description:vo("Sum of a series of numbers and/or cells."),args:[nh("value1 (number, range<number>)",vo("The first number or range to add together.")),nh("value2 (number, range<number>, repeating)",vo("Additional numbers or ranges to add to value1."))],compute:function(...e){const t=e[0];return{value:_a(e,this.locale),format:Si(t)}},isExported:!0},Bd={description:vo("A conditional sum across a range."),args:[nh("criteria_range (range)",vo("The range which is tested against criterion.")),nh("criterion (string)",vo("The pattern or test to apply to range.")),nh("sum_range (range, default=criteria_range)",vo("The range to be summed, if different from range."))],compute:function(e,t,o){void 0===o&&(o=e);let s=0;return Xi([e,t],((e,t)=>{const i=o[e]?.[t]?.value;"number"==typeof i&&(s+=i)}),this.locale),s},isExported:!0},zd={description:vo("Sums a range depending on multiple criteria."),args:[nh("sum_range (range)",vo("The range to sum.")),nh("criteria_range1 (range)",vo("The range to check against criterion1.")),nh("criterion1 (string)",vo("The pattern or test to apply to criteria_range1.")),nh("criteria_range2 (any, range, repeating)",vo("Additional ranges to check.")),nh("criterion2 (string, repeating)",vo("Additional criteria to check."))],compute:function(e,...t){let o=0;return Xi(t,((t,s)=>{const i=e[t]?.[s]?.value;"number"==typeof i&&(o+=i)}),this.locale),o},isExported:!0},$d={description:vo("Tangent of an angle provided in radians."),args:[nh("angle (number)",vo("The angle to find the tangent of, in radians."))],compute:function(e){return Math.tan(wi(e,this.locale))},isExported:!0},Gd={description:vo("Hyperbolic tangent of any real number."),args:[nh("value (number)",vo("Any real value to calculate the hyperbolic tangent of."))],compute:function(e){return Math.tanh(wi(e,this.locale))},isExported:!0};function Wd(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 qd={description:vo("Truncates a number."),args:[nh("value (number)",vo("The value to be truncated.")),nh("places (number, default=0)",vo("The number of significant digits to the right of the decimal point to retain."))],compute:function(e,t={value:0}){return{value:Wd(wi(e,this.locale),wi(t,this.locale)),format:e?.format}},isExported:!0},Zd={description:vo("Rounds a number down to the nearest integer that is less than or equal to it."),args:[nh("value (number)",vo("The number to round down to the nearest integer."))],compute:function(e){return Math.floor(wi(e,this.locale))},isExported:!0};var jd=Object.freeze({__proto__:null,ABS:Uh,ACOS:Hh,ACOSH:Bh,ACOT:zh,ACOTH:$h,ASIN:Gh,ASINH:Wh,ATAN:qh,ATAN2:Zh,ATANH:jh,CEILING:Yh,CEILING_MATH:Kh,CEILING_PRECISE:Qh,COS:Jh,COSH:ed,COT:td,COTH:od,COUNTBLANK:sd,COUNTIF:id,COUNTIFS:nd,COUNTUNIQUE:rd,COUNTUNIQUEIFS:ad,CSC:ld,CSCH:cd,DECIMAL:hd,DEGREES:dd,EXP:ud,FLOOR:gd,FLOOR_MATH:md,FLOOR_PRECISE:fd,INT:Zd,ISEVEN:vd,ISODD:Sd,ISO_CEILING:bd,LN:yd,MOD:wd,MUNIT:Ed,ODD:xd,PI:Id,POWER:Rd,PRODUCT:Td,RAND:Ad,RANDARRAY:_d,RANDBETWEEN:Dd,ROUND:Od,ROUNDDOWN:Fd,ROUNDUP:Md,SEC:Nd,SECH:Pd,SEQUENCE:kd,SIN:Ld,SINH:Vd,SQRT:Ud,SUM:Hd,SUMIF:Bd,SUMIFS:zd,TAN:$d,TANH:Gd,TRUNC:qd});function Yd(e,t){const o=[],s=[];let i=0,n=0;Li([e],(e=>{o.push(e),i+=1})),Li([t],(e=>{s.push(e),n+=1})),bi((()=>i===n),vo("[[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 Xd(e,t,o){const{flatDataX:s,flatDataY:i}=Yd(e,t),n=i.length;bi((()=>0!==n&&(!o||1!==n)),vo("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."),ci.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 Kd(e,t,o,s){let i=0,n=0;const r=o?zi:Bi;n=r(e,((e,t)=>(i+=1,e+t)),0,s),bi((()=>0!==i&&(!t||1!==i)),vo("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."),ci.DivisionByZero);const a=n/i;return r(e,((e,t)=>e+Math.pow(t-a,2)),0,s)/(i-(t?1:0))}function Qd(e,t,o,s){const i=wi(t,s);bi((()=>o?0<=i&&i<=1:0<i&&i<1),vo("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let n,r=[],a=0;return Li(e,(e=>{const t=e?.value;"number"==typeof t&&(n=Ki(r,e,"nextSmaller","asc",r.length,((e,t)=>e[t])),r.splice(n+1,0,t),a++)})),bi((()=>0!==a),vo("[[FUNCTION_NAME]] has no valid input data.")),o||bi((()=>1/(a+1)<=i&&i<=a/(a+1)),vo("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),zs(r,i,o)}const Jd={description:vo("Average magnitude of deviations from mean."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the sample.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the sample."))],compute:function(...e){let t=0;const o=Bi(e,((e,o)=>(t+=1,e+o)),0,this.locale);_i(t);const s=o/t;return Bi(e,((e,t)=>e+Math.abs(s-t)),0,this.locale)/t},isExported:!0},eu={description:vo("Numerical average value in a dataset, ignoring text."),args:[nh("value1 (number, range<number>)",vo("The first value or range to consider when calculating the average value.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to consider when calculating the average value."))],compute:function(...e){return{value:La(e,this.locale),format:Si(e[0])}},isExported:!0},tu=vo("[[FUNCTION_NAME]] has mismatched range sizes."),ou=vo("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),su={description:vo("Weighted average."),args:[nh("values (number, range<number>)",vo("Values to average.")),nh("weights (number, range<number>)",vo("Weights for each corresponding value.")),nh("additional_values (number, range<number>, repeating)",vo("Additional values to average.")),nh("additional_weights (number, range<number>, repeating)",vo("Additional weights."))],compute:function(...e){let t=0,o=0;for(let s=0;s<e.length-1;s+=2){const i=e[s],n=e[s+1];if(lh(tu,i,n),ni(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=ni(n)?n?.[e][s].value:wi(n,this.locale),l="number"==typeof r,c="number"==typeof a;l&&c?(bi((()=>a>=0),ou),t+=r*a,o+=a):bi((()=>l===c),vo("[[FUNCTION_NAME]] expects number values."))}else{const e=wi(i,this.locale),s=ni(n)?n?.[0][0].value:wi(n,this.locale);"number"==typeof s&&(bi((()=>s>=0),ou),t+=e*s,o+=s)}}return _i(o),{value:t/o,format:Si(e[0])}}},iu={description:vo("Numerical average value in a dataset."),args:[nh("value1 (number, range<number>)",vo("The first value or range to consider when calculating the average value.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to consider when calculating the average value."))],compute:function(...e){let t=0;const o=zi(e,((e,o)=>(t+=1,e+o)),0,this.locale);return _i(t),{value:o/t,format:Si(e[0])}},isExported:!0},nu={description:vo("Average of values depending on criteria."),args:[nh("criteria_range (number, range<number>)",vo("The range to check against criterion.")),nh("criterion (string)",vo("The pattern or test to apply to criteria_range.")),nh("average_range (number, range<number>, default=criteria_range)",vo("The range to average. If not included, criteria_range is used for the average instead."))],compute:function(e,t,o){const s=tn(void 0===o?e:o);let i=0,n=0;return Xi([e,t],((e,t)=>{const o=s[e]?.[t]?.value;"number"==typeof o&&(i+=1,n+=o)}),this.locale),_i(i),n/i},isExported:!0},ru={description:vo("Average of values depending on multiple criteria."),args:[nh("average_range (range)",vo("The range to average.")),nh("criteria_range1 (range)",vo("The range to check against criterion1.")),nh("criterion1 (string)",vo("The pattern or test to apply to criteria_range1.")),nh("criteria_range2 (any, range, repeating)",vo("Additional criteria_range and criterion to check.")),nh("criterion2 (string, repeating)",vo("The pattern or test to apply to criteria_range2."))],compute:function(e,...t){const o=tn(e);let s=0,i=0;return Xi(t,((e,t)=>{const n=o[e]?.[t]?.value;"number"==typeof n&&(s+=1,i+=n)}),this.locale),_i(s),i/s},isExported:!0},au={description:vo("The number of numeric values in dataset."),args:[nh("value1 (number, any, range<number>)",vo("The first value or range to consider when counting.")),nh("value2 (number, any, range<number>, repeating)",vo("Additional values or ranges to consider when counting."))],compute:function(...e){return Va(e,this.locale)},isExported:!0},lu={description:vo("The number of values in a dataset."),args:[nh("value1 (any, range)",vo("The first value or range to consider when counting.")),nh("value2 (any, range, repeating)",vo("Additional values or ranges to consider when counting."))],compute:function(...e){return Ua(e)},isExported:!0},cu={description:vo("The covariance of a dataset."),args:[nh("data_y (any, range)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (any, range)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Xd(e,t,!1)},isExported:!0},hu={description:vo("The covariance of a dataset."),args:[nh("data_y (any, range)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (any, range)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Xd(e,t,!1)},isExported:!0},du={description:vo("The sample covariance of a dataset."),args:[nh("data_y (any, range)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (any, range)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Xd(e,t,!0)},isExported:!0},uu={description:vo("Calculates the expected y-value for a specified x based on a linear regression of a dataset."),args:[nh("x (number, range<number>)",vo("The value(s) on the x-axis to forecast.")),nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t,o){const{flatDataX:s,flatDataY:i}=Yd(t,o);return Ya([i],[s],Gi(tn(e),(e=>wi(e,this.locale))),!0)},isExported:!0},gu={description:vo("Fits points to exponential growth trend."),args:[nh("known_data_y (range<number>)",vo("The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.")),nh("known_data_x (range<number>, default={1;2;3;...})",vo("The values of the independent variable(s) corresponding with known_data_y.")),nh("new_data_x (any, range, default=known_data_x)",vo("The data points to return the y values for on the ideal curve fit.")),nh("b (boolean, default=TRUE)",vo("Given a general exponential form of y = b*m^x for a curve fit, calculates b if TRUE or forces b to be 1 and only calculates the m values if FALSE."))],compute:function(e,t=[[]],o=[[]],s={value:!0}){return Za(Ya(ja(xi(e,"the first argument (known_data_y)")),xi(t,"the second argument (known_data_x)"),xi(o,"the third argument (new_data_y)"),Mi(s)))}},pu={description:vo("Compute the intercept of the linear regression."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Yd(e,t),[[],[i]]=$a([o],[s]);return i},isExported:!0},mu={description:vo("Nth largest element from a data set."),args:[nh("data (any, range)",vo("Array or range containing the dataset to consider.")),nh("n (number)",vo("The rank from largest to smallest of the element to return."))],compute:function(e,t){const o=Math.trunc(wi(t?.value,this.locale));let s,i=[],n=0;Li([e],(e=>{"number"==typeof e?.value&&(s=Ki(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 bi((()=>void 0!==r),vo("[[FUNCTION_NAME]] has no valid input data.")),bi((()=>n>=o),vo("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o)),r},isExported:!0},fu={description:vo("Given partial data about a linear trend, calculates various parameters about the ideal linear trend using the least-squares method."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>, default={1;2;3;...})",vo("The range representing the array or matrix of independent data.")),nh("calculate_b (boolean, default=TRUE)",vo("A flag specifying wheter to compute the slope or not")),nh("verbose (boolean, default=FALSE)",vo("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept"))],compute:function(e,t=[[]],o={value:!0},s={value:!1}){return $a(xi(t,"the first argument (data_y)"),xi(e,"the second argument (data_x)"),Mi(o),Mi(s))},isExported:!0},vu={description:vo("Given partial data about an exponential growth curve, calculates various parameters about the best fit ideal exponential growth curve."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>, optional, default={1;2;3;...})",vo("The range representing the array or matrix of independent data.")),nh("calculate_b (boolean, default=TRUE)",vo("A flag specifying wheter to compute the slope or not")),nh("verbose (boolean, default=FALSE)",vo("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept"))],compute:function(e,t=[[]],o={value:!0},s={value:!1}){const i=$a(xi(t,"the second argument (data_x)"),ja(xi(e,"the first argument (data_y)")),Mi(o),Mi(s));for(let e=0;e<i.length;e++)i[e][0]=Math.exp(i[e][0]);return i},isExported:!0},bu={description:vo("Compute the Matthews correlation coefficient of a dataset."),args:[nh("data_x (range)",vo("The range representing the array or matrix of observed data.")),nh("data_y (range)",vo("The range representing the array or matrix of predicted data."))],compute:function(e,t){const o=e.flat(),s=t.flat();if(ka(o,s),0===o.length)throw new di(vo("[[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=Mi(o[e]);t===Mi(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},Su={description:vo("Maximum value in a numeric dataset."),args:[nh("value1 (number, range<number>)",vo("The first value or range to consider when calculating the maximum value.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to consider when calculating the maximum value."))],compute:function(...e){return Ha(e,this.locale)},isExported:!0},yu={description:vo("Maximum numeric value in a dataset."),args:[nh("value1 (any, range)",vo("The first value or range to consider when calculating the maximum value.")),nh("value2 (any, range, repeating)",vo("Additional values or ranges to consider when calculating the maximum value."))],compute:function(...e){const t=zi(e,((e,t)=>Math.max(t,e)),-1/0,this.locale);return{value:t===-1/0?0:t,format:Si(e[0])}},isExported:!0},Cu={description:vo("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:[nh("range (range)",vo("The range of cells from which the maximum will be determined.")),nh("criteria_range1 (range)",vo("The range of cells over which to evaluate criterion1.")),nh("criterion1 (string)",vo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),nh("criteria_range2 (any, range, repeating)",vo("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.")),nh("criterion2 (string, repeating)",vo("The pattern or test to apply to criteria_range2."))],compute:function(e,...t){let o=-1/0;return Xi(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},wu={description:vo("Median value in a numeric dataset."),args:[nh("value1 (any, range)",vo("The first value or range to consider when calculating the median value.")),nh("value2 (any, range, repeating)",vo("Additional values or ranges to consider when calculating the median value."))],compute:function(...e){let t=[];return Vi(e,(e=>{t.push(e)}),this.locale),{value:Qd(t,{value:.5},!0,this.locale),format:Si(t[0])}},isExported:!0},Eu={description:vo("Minimum value in a numeric dataset."),args:[nh("value1 (number, range<number>)",vo("The first value or range to consider when calculating the minimum value.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to consider when calculating the minimum value."))],compute:function(...e){return Ba(e,this.locale)},isExported:!0},xu={description:vo("Minimum numeric value in a dataset."),args:[nh("value1 (number, range<number>)",vo("The first value or range to consider when calculating the minimum value.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to consider when calculating the minimum value."))],compute:function(...e){const t=zi(e,((e,t)=>Math.min(t,e)),1/0,this.locale);return{value:t===1/0?0:t,format:Si(e[0])}},isExported:!0},Iu={description:vo("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:[nh("range (range)",vo("The range of cells from which the minimum will be determined.")),nh("criteria_range1 (range)",vo("The range of cells over which to evaluate criterion1.")),nh("criterion1 (string)",vo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),nh("criteria_range2 (any, range, repeating)",vo("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.")),nh("criterion2 (string, repeating)",vo("The pattern or test to apply to criteria_range2."))],compute:function(e,...t){let o=1/0;return Xi(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 Ru(e,t){const{flatDataX:o,flatDataY:s}=Yd(e,t);if(0===o.length)throw new di(vo("[[FUNCTION_NAME]] expects non-empty ranges for both parameters."));if(o.length<2)throw new di(vo("[[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 Tu={description:vo("Compute the Pearson product-moment correlation coefficient of a dataset."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Ru(e,t)},isExported:!0},Au=Tu,_u={description:vo("Value at a given percentile of a dataset."),args:[nh("data (any, range)",vo("The array or range containing the dataset to consider.")),nh("percentile (number)",vo("The percentile whose value within data will be calculated and returned."))],compute:function(e,t){return Ou.compute.bind(this)(e,t)},isExported:!0},Du={description:vo("Value at a given percentile of a dataset exclusive of 0 and 1."),args:[nh("data (any, range)",vo("The array or range containing the dataset to consider.")),nh("percentile (number)",vo("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned."))],compute:function(e,t){return{value:Qd([e],t,!1,this.locale),format:Si(e)}},isExported:!0},Ou={description:vo("Value at a given percentile of a dataset."),args:[nh("data (any, range)",vo("The array or range containing the dataset to consider.")),nh("percentile (number)",vo("The percentile whose value within data will be calculated and returned."))],compute:function(e,t){return{value:Qd([e],t,!0,this.locale),format:Si(e)}},isExported:!0},Fu={description:vo("Compute the coefficients of polynomial regression of the dataset."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data.")),nh("order (number)",vo("The order of the polynomial to fit the data, between 1 and 6.")),nh("intercept (boolean, default=TRUE)",vo("A flag specifying whether to compute the intercept or not."))],compute:function(e,t,o,s={value:!0}){const{flatDataX:i,flatDataY:n}=Yd(e,t);return Ga(n,i,wi(o,this.locale),Mi(s))},isExported:!1},Mu={description:vo("Predict value by computing a polynomial regression of the dataset."),args:[nh("x (number, range<number>)",vo("The value(s) on the x-axis to forecast.")),nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data.")),nh("order (number)",vo("The order of the polynomial to fit the data, between 1 and 6.")),nh("intercept (boolean, default=TRUE)",vo("A flag specifying whether to compute the intercept or not."))],compute:function(e,t,o,s,i={value:!0}){const n=wi(s,this.locale),{flatDataX:r,flatDataY:a}=Yd(t,o),l=Ga(a,r,n,Mi(i)).flat();return Gi(tn(e),(e=>qa(l,wi(e,this.locale),n)))},isExported:!1},Nu={description:vo("Value nearest to a specific quartile of a dataset."),args:[nh("data (any, range)",vo("The array or range containing the dataset to consider.")),nh("quartile_number (number)",vo("Which quartile value to return."))],compute:function(e,t){return ku.compute.bind(this)(e,t)},isExported:!0},Pu={description:vo("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:[nh("data (any, range)",vo("The array or range containing the dataset to consider.")),nh("quartile_number (number)",vo("Which quartile value, exclusive of 0 and 4, to return."))],compute:function(e,t){return{value:Qd([e],{value:.25*Math.trunc(wi(t,this.locale))},!1,this.locale),format:Si(e)}},isExported:!0},ku={description:vo("Value nearest to a specific quartile of a dataset."),args:[nh("data (any, range)",vo("The array or range containing the dataset to consider.")),nh("quartile_number (number)",vo("Which quartile value to return."))],compute:function(e,t){return{value:Qd([e],{value:.25*Math.trunc(wi(t,this.locale))},!0,this.locale),format:Si(e)}},isExported:!0},Lu={description:vo("Returns the rank of a specified value in a dataset."),args:[nh("value (number)",vo("The value whose rank will be determined.")),nh("data (range)",vo("The range containing the dataset to consider.")),nh("is_ascending (boolean, default=FALSE)",vo("Whether to consider the values in data in descending or ascending order."))],compute:function(e,t,o={value:!1}){const s=Mi(o),i=wi(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=wi(t,this.locale);e===i?r=!0:e>i!==s&&n++}if(!r)throw new pi(vo("Value not found in the given data."));return n},isExported:!0},Vu={description:vo("Compute the square of r, the Pearson product-moment correlation coefficient of a dataset."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Math.pow(Ru(t,e),2)},isExported:!0},Uu={description:vo("Compute the slope of the linear regression."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Yd(e,t),[[i]]=$a([o],[s]);return i},isExported:!0},Hu={description:vo("Nth smallest element in a data set."),args:[nh("data (any, range)",vo("The array or range containing the dataset to consider.")),nh("n (number)",vo("The rank from smallest to largest of the element to return."))],compute:function(e,t){const o=Math.trunc(wi(t?.value,this.locale));let s,i=[],n=0;Li([e],(e=>{"number"==typeof e?.value&&(s=Ki(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 bi((()=>void 0!==r),vo("[[FUNCTION_NAME]] has no valid input data.")),bi((()=>n>=o),vo("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o)),r},isExported:!0},Bu={description:vo("Compute the Spearman rank correlation coefficient of a dataset."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Yd(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},zu={description:vo("Standard deviation."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the sample.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the sample."))],compute:function(...e){return Math.sqrt(Xu.compute.bind(this)(...e))},isExported:!0},$u={description:vo("Standard deviation of entire population."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the population.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the population."))],compute:function(...e){return Math.sqrt(Ku.compute.bind(this)(...e))},isExported:!0},Gu={description:vo("Standard deviation."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the sample.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the sample."))],compute:function(...e){return Math.sqrt(Qu.compute.bind(this)(...e))},isExported:!0},Wu={description:vo("Standard deviation of sample (text as 0)."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the sample.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the sample."))],compute:function(...e){return Math.sqrt(Ju.compute.bind(this)(...e))},isExported:!0},qu={description:vo("Standard deviation of entire population."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the population.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the population."))],compute:function(...e){return Math.sqrt(eg.compute.bind(this)(...e))},isExported:!0},Zu={description:vo("Standard deviation of entire population (text as 0)."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the population.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the population."))],compute:function(...e){return Math.sqrt(tg.compute.bind(this)(...e))},isExported:!0},ju={description:vo("Calculates the standard error of the predicted y-value for each x in the regression of a dataset."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Yd(e,t);return $a([o],[s],!0,!0)[1][2]},isExported:!0},Yu={description:vo("Fits points to linear trend derived via least-squares."),args:[nh("known_data_y (number, range<number>)",vo("The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.")),nh("known_data_x (number, range<number>, optional, default={1;2;3;...})",vo("The values of the independent variable(s) corresponding with known_data_y.")),nh("new_data_x (number, range<number>, optional, default=known_data_x)",vo("The data points to return the y values for on the ideal curve fit.")),nh("b (boolean, optional, default=TRUE)",vo("Given a general linear form of y = m*x+b for a curve fit, calculates b if TRUE or forces b to be 0 and only calculates the m values if FALSE, i.e. forces the curve fit to pass through the origin."))],compute:function(e,t=[[]],o=[[]],s={value:!0}){return Ya(xi(e,"the first argument (known_data_y)"),xi(t,"the second argument (known_data_x)"),xi(o,"the third argument (new_data_y)"),Mi(s))}},Xu={description:vo("Variance."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the sample.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the sample."))],compute:function(...e){return Kd(e,!0,!1,this.locale)},isExported:!0},Ku={description:vo("Variance of entire population."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the population.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the population."))],compute:function(...e){return Kd(e,!1,!1,this.locale)},isExported:!0},Qu={description:vo("Variance."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the sample.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the sample."))],compute:function(...e){return Kd(e,!0,!1,this.locale)},isExported:!0},Ju={description:vo("Variance of sample (text as 0)."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the sample.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the sample."))],compute:function(...e){return Kd(e,!0,!0,this.locale)},isExported:!0},eg={description:vo("Variance of entire population."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the population.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the population."))],compute:function(...e){return Kd(e,!1,!1,this.locale)},isExported:!0},tg={description:vo("Variance of entire population (text as 0)."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the population.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the population."))],compute:function(...e){return Kd(e,!1,!0,this.locale)},isExported:!0};var og=Object.freeze({__proto__:null,AVEDEV:Jd,AVERAGE:eu,AVERAGEA:iu,AVERAGEIF:nu,AVERAGEIFS:ru,AVERAGE_WEIGHTED:su,CORREL:Au,COUNT:au,COUNTA:lu,COVAR:cu,COVARIANCE_P:hu,COVARIANCE_S:du,FORECAST:uu,GROWTH:gu,INTERCEPT:pu,LARGE:mu,LINEST:fu,LOGEST:vu,MATTHEWS:bu,MAX:Su,MAXA:yu,MAXIFS:Cu,MEDIAN:wu,MIN:Eu,MINA:xu,MINIFS:Iu,PEARSON:Tu,PERCENTILE:_u,PERCENTILE_EXC:Du,PERCENTILE_INC:Ou,POLYFIT_COEFFS:Fu,POLYFIT_FORECAST:Mu,QUARTILE:Nu,QUARTILE_EXC:Pu,QUARTILE_INC:ku,RANK:Lu,RSQ:Vu,SLOPE:Uu,SMALL:Hu,SPEARMAN:Bu,STDEV:zu,STDEVA:Wu,STDEVP:qu,STDEVPA:Zu,STDEV_P:$u,STDEV_S:Gu,STEYX:ju,TREND:Yu,VAR:Xu,VARA:Ju,VARP:eg,VARPA:tg,VAR_P:Ku,VAR_S:Qu});function sg(e,t,o,s){const i=new Map,n=e.length;for(let t=n-1;t>=0;t--)i.set(Di(e[t][0]).toUpperCase(),t);const r=t?.value;if("number"!=typeof r&&"string"!=typeof r)throw new di(vo("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 di(vo("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=Di(t).toUpperCase();if(a=i.get(e)??-1,-1===a)throw new di(vo("The field (%s) must be one of %s.",Di(t),[...i.keys()].toString()))}const l=o[0].length;if(l<2)throw new di(vo("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=Di(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}Xi(n,((e,t)=>{c.add(t)}),s,!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const ig=[nh("database (range)",vo("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.")),nh("field (number, string)",vo("Indicates which column in database contains the values to be extracted and operated on.")),nh("criteria (range)",vo("An array or range containing zero or more criteria to filter the database values by before operating."))],ng={description:vo("Average of a set of values from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return eu.compute.bind(this)([s])},isExported:!0},rg={description:vo("Counts values from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return au.compute.bind(this)([s])},isExported:!0},ag={description:vo("Counts values and text from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return lu.compute.bind(this)([s])},isExported:!0},lg={description:vo("Single value from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return bi((()=>1===s.length),vo("More than one match found in DGET evaluation.")),s[0]},isExported:!0},cg={description:vo("Maximum of values from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return Su.compute.bind(this)([s])},isExported:!0},hg={description:vo("Minimum of values from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return Eu.compute.bind(this)([s])},isExported:!0},dg={description:vo("Product of values from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return Td.compute.bind(this)([s])},isExported:!0},ug={description:vo("Standard deviation of population sample from table."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return zu.compute.bind(this)([s])},isExported:!0},gg={description:vo("Standard deviation of entire population from table."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return qu.compute.bind(this)([s])},isExported:!0},pg={description:vo("Sum of values from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return Hd.compute.bind(this)([s])},isExported:!0},mg={description:vo("Variance of population sample from table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return Xu.compute.bind(this)([s])},isExported:!0},fg={description:vo("Variance of a population from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return eg.compute.bind(this)([s])},isExported:!0};var vg=Object.freeze({__proto__:null,DAVERAGE:ng,DCOUNT:rg,DCOUNTA:ag,DGET:lg,DMAX:cg,DMIN:hg,DPRODUCT:dg,DSTDEV:ug,DSTDEVP:gg,DSUM:pg,DVAR:mg,DVARP:fg});var bg;!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"}(bg||(bg={}));const Sg={description:vo("Converts year/month/day into a date."),args:[nh("year (number)",vo("The year component of the date.")),nh("month (number)",vo("The month component of the date.")),nh("day (number)",vo("The day component of the date."))],compute:function(e,t,o){let s=Math.trunc(wi(e,this.locale));const i=Math.trunc(wi(t,this.locale)),n=Math.trunc(wi(o,this.locale));bi((()=>0<=s&&s<=9999),vo("The year (%s) must be between 0 and 9999 inclusive.",s.toString())),s<1900&&(s+=1900);const r=Rs(new cs(s,i-1,n));return bi((()=>r>=0),vo("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),{value:r,format:this.locale.dateFormat}},isExported:!0},yg={description:vo("Calculates the number of days, months, or years between two dates."),args:[nh("start_date (date)",vo("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.")),nh("end_date (date)",vo("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.")),nh("unit (string)",vo('A text abbreviation for unit of time. Accepted values are "Y" (the number of whole years between start_date and end_date), "M" (the number of whole months between start_date and end_date), "D" (the number of days between start_date and end_date), "MD" (the number of days between start_date and end_date after subtracting whole months), "YM" (the number of whole months between start_date and end_date after subtracting whole years), "YD" (the number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart).'))],compute:function(e,t,o){const s=Di(o).toUpperCase();bi((()=>Object.values(bg).includes(s)),((e,t)=>{const o=e.map((e=>`'${e}'`)).join(", ");return vo("The function [[FUNCTION_NAME]] has an argument with value '%s'. It should be one of: %s.",t,o)})(Object.values(bg),Di(o)));const i=Math.trunc(wi(e,this.locale)),n=Math.trunc(wi(t,this.locale)),r=Is(i),a=Is(n);switch(bi((()=>n>=i),vo("start_date (%s) should be on or before end_date (%s).",r.toLocaleDateString(),a.toLocaleDateString())),s){case bg.WHOLE_YEARS:return Ps(r,a);case bg.WHOLE_MONTHS:return Ms(r,a);case bg.WHOLE_DAYS:return Ns(r,a);case bg.MONTH_WITHOUT_WHOLE_YEARS:return Ms(r,a)-12*Ps(r,a);case bg.DAYS_WITHOUT_WHOLE_MONTHS:let e=a.getDate()-r.getDate();if(e<0){e=As(new cs(a.getFullYear(),a.getMonth()-1,1))-Math.abs(e)}return e;case bg.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR:{if(function(e,t){return Fs(e,t,1)<1}(i,n))return Ns(r,a);const e=new cs(r.getFullYear(),a.getMonth(),a.getDate());let t=Ns(r,e);return t<0&&(e.setFullYear(r.getFullYear()+1),t=Ns(r,e)),t}}},isExported:!0},Cg={description:vo("Converts a date string to a date value."),args:[nh("date_string (string)",vo("The string representing the date."))],compute:function(e){const t=Di(e),o=xs(t,this.locale);return bi((()=>null!==o),vo("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(o.value)},isExported:!0},wg={description:vo("Day of the month that a specific date falls on."),args:[nh("date (string)",vo("The date from which to extract the day."))],compute:function(e){return Ni(e,this.locale).getDate()},isExported:!0},Eg={description:vo("Number of days between two dates."),args:[nh("end_date (date)",vo("The end of the date range.")),nh("start_date (date)",vo("The start of the date range."))],compute:function(e,t){const o=Ni(e,this.locale),s=Ni(t,this.locale),i=o.getTime()-s.getTime();return Math.round(i/ds)},isExported:!0},xg={description:vo("Number of days between two dates on a 360-day year (months of 30 days)."),args:[nh("start_date (date)",vo("The start date to consider in the calculation.")),nh("end_date (date)",vo("The end date to consider in the calculation.")),nh("method (number, default=0)",vo("An indicator of what day count method to use. (0) US NASD method (1) European method"))],compute:function(e,t,o={value:0}){const s=Math.trunc(wi(e,this.locale)),i=Math.trunc(wi(t,this.locale)),n=Fs(s,i,Mi(o)?4:0);return Math.sign(i-s)*Math.round(360*n)},isExported:!0},Ig={description:vo("Date a number of months before/after another date."),args:[nh("start_date (date)",vo("The date from which to calculate the result.")),nh("months (number)",vo("The number of months before (negative) or after (positive) 'start_date' to calculate."))],compute:function(e,t){return{value:Rs(Ds(Ni(e,this.locale),Math.trunc(wi(t,this.locale)),!1)),format:this.locale.dateFormat}},isExported:!0},Rg={description:vo("Last day of a month before or after a date."),args:[nh("start_date (date)",vo("The date from which to calculate the result.")),nh("months (number)",vo("The number of months before (negative) or after (positive) 'start_date' to consider."))],compute:function(e,t){const o=Ni(e,this.locale),s=Math.trunc(wi(t,this.locale)),i=o.getFullYear(),n=o.getMonth();return{value:Rs(new cs(i,n+s+1,0)),format:this.locale.dateFormat}},isExported:!0},Tg={description:vo("Hour component of a specific time."),args:[nh("time (date)",vo("The time from which to calculate the hour component."))],compute:function(e){return Ni(e,this.locale).getHours()},isExported:!0},Ag={description:vo("ISO week number of the year."),args:[nh("date (date)",vo("The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number."))],compute:function(e){const t=Ni(e,this.locale),o=t.getFullYear();let s=1;for(;4!==new cs(o,0,s).getDay();)s+=1;const i=new cs(o,0,s-3);let n=31;for(;4!==new cs(o,11,n).getDay();)n-=1;const r=new cs(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 cs(o,11,n+3+1);break;case-1:let e=1;for(;4!==new cs(o-1,0,e).getDay();)e+=1;l=new cs(o-1,0,e-3)}const c=(t.getTime()-l.getTime())/ds;return Math.floor(c/7)+1},isExported:!0},_g={description:vo("Minute component of a specific time."),args:[nh("time (date)",vo("The time from which to calculate the minute component."))],compute:function(e){return Ni(e,this.locale).getMinutes()},isExported:!0},Dg={description:vo("Month of the year a specific date falls in"),args:[nh("date (date)",vo("The date from which to extract the month."))],compute:function(e){return Ni(e,this.locale).getMonth()+1},isExported:!0},Og={description:vo("Net working days between two provided days."),args:[nh("start_date (date)",vo("The start date of the period from which to calculate the number of net working days.")),nh("end_date (date)",vo("The end date of the period from which to calculate the number of net working days.")),nh("holidays (date, range<date>, optional)",vo("A range or array constant containing the date serial numbers to consider holidays."))],compute:function(e,t,o){return Mg.compute.bind(this)(e,t,{value:1},o)},isExported:!0};function Fg(e){const t=e?.value;if("string"==typeof t){bi((()=>{if(7!==t.length)return!1;for(let e of t)if("0"!==e&&"1"!==e)return!1;return!0}),vo('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 bi((()=>1<=t&&t<=7||11<=t&&t<=17),vo("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 di(vo("The weekend must be a number or a string."))}const Mg={description:vo("Net working days between two dates (specifying weekends)."),args:[nh("start_date (date)",vo("The start date of the period from which to calculate the number of net working days.")),nh("end_date (date)",vo("The end date of the period from which to calculate the number of net working days.")),nh("weekend (any, default=1)",vo("A number or string representing which days of the week are considered weekends.")),nh("holidays (date, range<date>, optional)",vo("A range or array constant containing the dates to consider as holidays."))],compute:function(e,t,o={value:1},s){const i=Ni(e,this.locale),n=Ni(t,this.locale),r=Fg(o);let a=new Set;void 0!==s&&Li([s],(e=>{const t=Ni(e,this.locale);a.add(t.getTime())}));const l=i.getTime()>n.getTime(),c=cs.fromTimestamp((l?i:n).getTime());let h=cs.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},Ng={description:vo("Current date and time as a date value."),args:[],compute:function(){const e=cs.now(),t=e.getTime()-hs.getTime(),o=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return{value:Math.floor(t/ds)+o,format:Ia(this.locale)}},isExported:!0},Pg={description:vo("Minute component of a specific time."),args:[nh("time (date)",vo("The time from which to calculate the second component."))],compute:function(e){return Ni(e,this.locale).getSeconds()},isExported:!0},kg={description:vo("Converts hour/minute/second into a time."),args:[nh("hour (number)",vo("The hour component of the time.")),nh("minute (number)",vo("The minute component of the time.")),nh("second (number)",vo("The second component of the time."))],compute:function(e,t,o){let s=Math.trunc(wi(e,this.locale)),i=Math.trunc(wi(t,this.locale)),n=Math.trunc(wi(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,bi((()=>s>=0),vo("The function [[FUNCTION_NAME]] result cannot be negative")),{value:s/24+i/1440+n/86400,format:this.locale.timeFormat}},isExported:!0},Lg={description:vo("Converts a time string into its serial number representation."),args:[nh("time_string (string)",vo("The string that holds the time representation."))],compute:function(e){const t=Di(e),o=xs(t,this.locale);bi((()=>null!==o),vo("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},Vg={description:vo("Current date as a date value."),args:[],compute:function(){const e=cs.now();return{value:Rs(new cs(e.getFullYear(),e.getMonth(),e.getDate())),format:this.locale.dateFormat}},isExported:!0},Ug={description:vo("Day of the week of the date provided (as number)."),args:[nh("date (date)",vo("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.")),nh("type (number, default=1)",vo("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1."))],compute:function(e,t={value:1}){const o=Ni(e,this.locale),s=Math.round(wi(t,this.locale)),i=o.getDay();return bi((()=>[1,2,3].includes(s)),vo("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},Hg={description:vo("Week number of the year."),args:[nh("date (date)",vo("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.")),nh("type (number, default=1)",vo("A number representing the day that a week starts on. Sunday = 1."))],compute:function(e,t={value:1}){const o=Ni(e,this.locale),s=Math.round(wi(t,this.locale));if(bi((()=>1===s||2===s||11<=s&&s<=17||21===s),vo("The type (%s) is out of range.",s.toString())),21===s)return Ag.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 cs(n,0,r);for(;a.getDay()!==i;)r+=1,a=new cs(n,0,r);const l=(o.getTime()-a.getTime())/ds;return l<0?1:Math.floor(l/7)+(1===r?1:2)},isExported:!0},Bg={description:vo("Date after a number of workdays."),args:[nh("start_date (date)",vo("The date from which to begin counting.")),nh("num_days (number)",vo("The number of working days to advance from start_date. If negative, counts backwards.")),nh("holidays (date, range<date>, optional)",vo("A range or array constant containing the dates to consider holidays."))],compute:function(e,t,o={value:null}){return zg.compute.bind(this)(e,t,{value:1},o)},isExported:!0},zg={description:vo("Date after a number of workdays (specifying weekends)."),args:[nh("start_date (date)",vo("The date from which to begin counting.")),nh("num_days (number)",vo("The number of working days to advance from start_date. If negative, counts backwards.")),nh("weekend (any, default=1)",vo("A number or string representing which days of the week are considered weekends.")),nh("holidays (date, range<date>, optional)",vo("A range or array constant containing the dates to consider holidays."))],compute:function(e,t,o={value:1},s){let i=Ni(e,this.locale),n=Math.trunc(wi(t,this.locale));"string"==typeof o.value&&bi((()=>"1111111"!==o.value),vo("The weekend must be different from '1111111'."));const r=Fg(o);let a=new Set;void 0!==s&&Li([s],(e=>{const t=Ni(e,this.locale);a.add(t.getTime())}));let l=cs.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-hs.getTime();return{value:Math.round(u/ds),format:this.locale.dateFormat}},isExported:!0},$g={description:vo("Year specified by a given date."),args:[nh("date (date)",vo("The date from which to extract the year."))],compute:function(e){return Ni(e,this.locale).getFullYear()},isExported:!0},Gg={description:vo("Exact number of years between two dates."),args:[nh("start_date (date)",vo("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.")),nh("end_date (date)",vo("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.")),nh("day_count_convention (number, default=0)",vo("An indicator of what day count method to use."))],compute:function(e,t,o={value:0}){let s=Math.trunc(wi(e,this.locale)),i=Math.trunc(wi(t,this.locale));const n=Math.trunc(wi(o,this.locale));return bi((()=>s>=0),vo("The start_date (%s) must be positive or null.",s.toString())),bi((()=>i>=0),vo("The end_date (%s) must be positive or null.",i.toString())),bi((()=>0<=n&&n<=4),vo("The day_count_convention (%s) must be between 0 and 4 inclusive.",n.toString())),Fs(s,i,n)}},Wg={description:vo("First day of the month preceding a date."),args:[nh("date (date)",vo("The date from which to calculate the result."))],compute:function(e){const t=Ni(e,this.locale),o=t.getFullYear(),s=t.getMonth();return{value:Rs(new cs(o,s,1)),format:this.locale.dateFormat}}},qg={description:vo("Last day of the month following a date."),args:[nh("date (date)",vo("The date from which to calculate the result."))],compute:function(e){return Rg.compute.bind(this)(e,{value:0})}},Zg={description:vo("Quarter of the year a specific date falls in"),args:[nh("date (date)",vo("The date from which to extract the quarter."))],compute:function(e){return Math.ceil((Ni(e,this.locale).getMonth()+1)/3)}},jg={description:vo("First day of the quarter of the year a specific date falls in."),args:[nh("date (date)",vo("The date from which to calculate the start of quarter."))],compute:function(e){const t=Zg.compute.bind(this)(e),o=$g.compute.bind(this)(e);return{value:Rs(new cs(o,3*(t-1),1)),format:this.locale.dateFormat}}},Yg={description:vo("Last day of the quarter of the year a specific date falls in."),args:[nh("date (date)",vo("The date from which to calculate the end of quarter."))],compute:function(e){const t=Zg.compute.bind(this)(e),o=$g.compute.bind(this)(e);return{value:Rs(new cs(o,3*t,0)),format:this.locale.dateFormat}}},Xg={description:vo("First day of the year a specific date falls in."),args:[nh("date (date)",vo("The date from which to calculate the start of the year."))],compute:function(e){const t=$g.compute.bind(this)(e);return{value:Rs(new cs(t,0,1)),format:this.locale.dateFormat}}},Kg={description:vo("Last day of the year a specific date falls in."),args:[nh("date (date)",vo("The date from which to calculate the end of the year."))],compute:function(e){const t=$g.compute.bind(this)(e);return{value:Rs(new cs(t+1,0,0)),format:this.locale.dateFormat}}};var Qg=Object.freeze({__proto__:null,DATE:Sg,DATEDIF:yg,DATEVALUE:Cg,DAY:wg,DAYS:Eg,DAYS360:xg,EDATE:Ig,EOMONTH:Rg,HOUR:Tg,ISOWEEKNUM:Ag,MINUTE:_g,MONTH:Dg,MONTH_END:qg,MONTH_START:Wg,NETWORKDAYS:Og,NETWORKDAYS_INTL:Mg,NOW:Ng,QUARTER:Zg,QUARTER_END:Yg,QUARTER_START:jg,SECOND:Pg,TIME:kg,TIMEVALUE:Lg,TODAY:Vg,WEEKDAY:Ug,WEEKNUM:Hg,WORKDAY:Bg,WORKDAY_INTL:zg,YEAR:$g,YEARFRAC:Gg,YEAR_END:Kg,YEAR_START:Xg});const Jg={description:vo("Compare two numeric values, returning 1 if they're equal."),args:[nh("number1 (number)",vo("The first number to compare.")),nh("number2 (number, default=0)",vo("The second number to compare."))],compute:function(e,t={value:0}){return wi(e,this.locale)===wi(t,this.locale)?1:0},isExported:!0};var ep=Object.freeze({__proto__:null,DELTA:Jg});const tp=[$s.number,$s.error,$s.text,$s.boolean];function op(e){const t="ascending"===e?1:-1;return(e,o)=>{if(e.type===$s.empty)return o.type===$s.empty?0:1;if(o.type===$s.empty)return-1;let s=tp.indexOf(e.type)-tp.indexOf(o.type);return 0===s&&(s=e.type===$s.text||e.type===$s.error?e.value.localeCompare(o.value):e.value-o.value),t*s}}function sp(e,t,o,s,i){let n=Js.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);Go(o,s)?n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:a,row:l,zone:s,sortDirection:i}):e.askConfirmation(vo("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(vo("Cannot sort. To sort, select only cells or only merges that have the same size."))}}function ip(e,t,...o){for(const[e,t]of o.entries())bi((()=>void 0!==t),vo("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(Mi(Pa(o[r+1])?.value)?"ascending":"descending");const a=o[r];if(ni(a)&&(a.length>1||a[0].length>1))bi((()=>1===a.length&&a[0].length===n),vo("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=wi(Pa(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:op("descending"),ascending:op("ascending")},a=Be(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?$s.empty:"string"==typeof i?$s.text:typeof i},c={value:a,type:null===a?$s.empty:"string"==typeof a?$s.text:typeof a},h=r[s[o]](l,c);if(0!==h)return h}return 0})),a.map((t=>e[t]))}const np={description:vo("Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions."),args:[nh("range (any, range<any>)",vo("The data to be filtered.")),nh("condition1 (boolean, range<boolean>)",vo("A column or row containing true or false values corresponding to the first column or row of range.")),nh("condition2 (boolean, range<boolean>, repeating)",vo("Additional column or row containing true or false values."))],compute:function(e,...t){let o=tn(e);const s=t.map((e=>Gi(tn(e),(e=>e.value))));s.map((e=>ah(vo("The arguments condition must be a single column or row."),e))),lh(vo("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?Wi(o):o,bi((()=>i.every((e=>e.length===o.length))),vo("FILTER has mismatched sizes on the range and conditions."));const r=[];for(let e=0;e<o.length;e++){const t=o[e];i.every((t=>("boolean"==typeof t[e]||"number"==typeof t[e])&&t[e]))&&r.push(t)}if(!r.length)throw new pi(vo("No match found in FILTER evaluation"));return"row"===n?Wi(r):r},isExported:!0},rp={description:vo("Sorts the rows of a given array or range by the values in one or more columns."),args:[nh("range (range)",vo("The data to be sorted.")),nh("sort_column (any, range<number>, repeating)",vo("The index of the column in range or a range outside of range containing the values by which to sort.")),nh("is_ascending (boolean, repeating)",vo("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order."))],compute:function(e,...t){const o=Wi(e);return Wi(ip(o,this.locale,...t))},isExported:!0},ap={description:vo("Returns the first n items in a data set after performing a sort."),args:[nh("range (range)",vo("The data to be sorted.")),nh("n (number, default=1)",vo("The number of items to return.")),nh("display_ties_mode (number, default=0)",vo("A number representing the way to display ties.")),nh("sort_column (number, range<number>, repeating)",vo("The index of the column in range or a range outside of range containing the values by which to sort.")),nh("is_ascending (boolean, repeating)",vo("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order."))],compute:function(e,t,o,...s){const i=wi(t?.value??1,this.locale);bi((()=>i>=0),vo("Wrong value of 'n'. Expected a positive number. Got %s.",i));const n=wi(o?.value??0,this.locale);bi((()=>n>=0&&n<=3),vo("Wrong value of 'display_ties_mode'. Expected a positive number between 0 and 3. Got %s.",n));const r=ip(Wi(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 Wi(r.slice(0,i));case 1:for(let e=i;e<r.length;e++)if(!a(e,i-1))return Wi(r.slice(0,e));return Wi(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 Wi(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 Wi(e)}}},isExported:!0},lp={description:vo("Unique rows in the provided source range."),args:[nh("range (any, range<any>)",vo("The data to filter by unique entries.")),nh("by_column (boolean, default=FALSE)",vo("Whether to filter the data by columns or by rows.")),nh("exactly_once (boolean, default=FALSE)",vo("Whether to return only entries with no duplicates."))],compute:function(e={value:""},t,o){if(!ni(e))return[[e]];const s=Mi(t?.value)||!1,i=Mi(o?.value)||!1;s||(e=Wi(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 di(vo("No unique values found"));return s?r:Wi(r)},isExported:!0};var cp=Object.freeze({__proto__:null,FILTER:np,SORT:rp,SORTN:ap,UNIQUE:lp});function hp(e,t){bi((()=>e<t),vo("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function dp(e,t){bi((()=>t<e),vo("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function up(e){bi((()=>[1,2,4].includes(e)),vo("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function gp(e){bi((()=>0<=e&&e<=4),vo("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function pp(e){bi((()=>e>0),vo("The redemption (%s) must be strictly positive.",e.toString()))}function mp(e){bi((()=>e>0),vo("The price (%s) must be strictly positive.",e.toString()))}function fp(e){bi((()=>e>0),vo("The number_of_periods (%s) must be greater than 0.",e.toString()))}function vp(e){bi((()=>e>0),vo("The rate (%s) must be strictly positive.",e.toString()))}function bp(e){bi((()=>e>0),vo("The life (%s) must be strictly positive.",e.toString()))}function Sp(e){bi((()=>e>=0),vo("The cost (%s) must be positive or null.",e.toString()))}function yp(e){bi((()=>e>0),vo("The period (%s) must be strictly positive.",e.toString()))}function Cp(e){bi((()=>e>=0),vo("The salvage (%s) must be positive or null.",e.toString()))}function wp(e){bi((()=>e>0),vo("The present value (%s) must be strictly positive.",e.toString()))}function Ep(e,t){bi((()=>e<=t),vo("The period (%s) must be less than or equal life (%s).",e.toString(),t.toString()))}function xp(e){bi((()=>e>0),vo("The investment (%s) must be strictly positive.",e.toString()))}function Ip(e){bi((()=>e>0),vo("The discount (%s) must be strictly positive.",e.toString()))}function Rp(e){bi((()=>e<1),vo("The discount (%s) must be smaller than 1.",e.toString()))}function Tp(e){bi((()=>e>0),vo("The depreciation factor (%s) must be strictly positive.",e.toString()))}function Ap(e,t,o){const s=Ni(e,o),i=Ni(t,o),n=Ni(e,o);n.setFullYear(s.getFullYear()+1),bi((()=>i.getTime()<=n.getTime()),vo("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function _p(e,t,o){fp(o),bi((()=>e>0),vo("The first_period (%s) must be strictly positive.",e.toString())),bi((()=>t>0),vo("The last_period (%s) must be strictly positive.",t.toString())),bi((()=>e<=t),vo("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),bi((()=>t<=o),vo("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),o.toString()))}function Dp(e){bi((()=>e>-1),vo("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function Op(e,t){bi((()=>e.length===t.length&&e[0].length===t[0].length),vo("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function Fp(e){bi((()=>e.every((t=>t>=e[0]))),vo("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const Mp=[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("frequency (number)",vo("The number of interest or coupon payments per year (1, 2, or 4).")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))];function Np(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)?(bi((()=>u<s&&void 0!==n),vo("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,bi((()=>u<s),vo("Function [[FUNCTION_NAME]] didn't find any result.")),u++)}while(!d);return h}const Pp={description:vo("Accrued interest of security paying at maturity."),args:[nh("issue (date)",vo("The date the security was initially issued.")),nh("maturity (date)",vo("The maturity date of the security.")),nh("rate (number)",vo("The annualized rate of interest.")),nh("redemption (number)",vo("The redemption amount per 100 face value, or par.")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){const n=Math.trunc(wi(e,this.locale)),r=Math.trunc(wi(t,this.locale)),a=wi(s,this.locale),l=wi(o,this.locale),c=Math.trunc(wi(i,this.locale));!function(e){bi((()=>e>=0),vo("The issue (%s) must be positive or null.",e.toString()))}(n),dp(r,n),gp(c),pp(a),vp(l);return a*l*Fs(n,r,c)},isExported:!0},kp={description:vo("Depreciation for an accounting period."),args:[nh("cost (number)",vo("The initial cost of the asset.")),nh("purchase_date (date)",vo("The date the asset was purchased.")),nh("first_period_end (date)",vo("The date the first period ended.")),nh("salvage (number)",vo("The value of the asset at the end of depreciation.")),nh("period (number)",vo("The single period within life for which to calculate depreciation.")),nh("rate (number)",vo("The deprecation rate.")),nh("day_count_convention (number, optional)",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=wi(e,this.locale),l=Math.trunc(wi(t,this.locale)),c=Math.trunc(wi(o,this.locale)),h=wi(s,this.locale),d=wi(i,this.locale),u=wi(n,this.locale),g=Math.trunc(wi(r,this.locale));!function(e){bi((()=>e>0),vo("The cost (%s) must be strictly positive.",e.toString()))}(a),function(e){bi((()=>e>=0),vo("The purchase_date (%s) must be positive or null.",e.toString()))}(l),Cp(h),function(e,t){bi((()=>e<=t),vo("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(h,a),function(e){bi((()=>e>=0),vo("The period (%s) must be positive or null.",e.toString()))}(d),vp(u),gp(g),bi((()=>l<=c),vo("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=Fs(l,c,g),v=l===c?m:m*f,b=a-v-m*p;return b>=h?0===p?v:m:h-b<m?m-(h-b):0},isExported:!0},Lp={description:vo("Days in coupon period containing settlement date."),args:Mp,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(wi(e,this.locale)),n=Math.trunc(wi(t,this.locale)),r=Math.trunc(wi(o,this.locale)),a=Math.trunc(wi(s,this.locale));if(hp(i,n),up(r),gp(a),1===a){const i=zp.compute.bind(this)(e,t,o,s).value;return Hp.compute.bind(this)(e,t,o,s).value-i}return(3===a?365:360)/r},isExported:!0},Vp={description:vo("Days from settlement until next coupon."),args:Mp,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(wi(e,this.locale)),n=Math.trunc(wi(t,this.locale)),r=Math.trunc(wi(o,this.locale)),a=Math.trunc(wi(s,this.locale));hp(i,n),up(r),gp(a);const l=zp.compute.bind(this)(e,t,o,s).value;if([1,2,3].includes(a))return i-l;if(4===a){const e=Fs(l,i,a);return Math.round(360*e)}const c=Ni(i,this.locale),h=Ni(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&&_s(h)&&_s(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&_s(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Up={description:vo("Days from settlement until next coupon."),args:Mp,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(wi(e,this.locale)),n=Math.trunc(wi(t,this.locale)),r=Math.trunc(wi(o,this.locale)),a=Math.trunc(wi(s,this.locale));hp(i,n),up(r),gp(a);const l=Hp.compute.bind(this)(e,t,o,s).value;if([1,2,3].includes(a))return l-i;if(4===a){const e=Fs(i,l,a);return Math.round(360*e)}const c=Vp.compute.bind(this)(e,t,o,s);return Lp.compute.bind(this)(e,t,o,s)-c},isExported:!0},Hp={description:vo("Next coupon date after the settlement date."),args:Mp,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(wi(e,this.locale)),n=Math.trunc(wi(t,this.locale)),r=Math.trunc(wi(o,this.locale)),a=Math.trunc(wi(s,this.locale));hp(i,n),up(r),gp(a);const l=12/r,c=Bp.compute.bind(this)(e,t,o,s);return{value:Rs(Ds(Ni(n,this.locale),-(c-1)*l,!0)),format:this.locale.dateFormat}},isExported:!0},Bp={description:vo("Number of coupons between settlement and maturity."),args:Mp,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(wi(e,this.locale)),n=Math.trunc(wi(t,this.locale)),r=Math.trunc(wi(o,this.locale)),a=Math.trunc(wi(s,this.locale));hp(i,n),up(r),gp(a);let l=1,c=n;const h=12/r;for(;c>i;)c=Rs(Ds(Ni(c,this.locale),-h,!1)),l++;return l-1},isExported:!0},zp={description:vo("Last coupon date prior to or on the settlement date."),args:Mp,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(wi(e,this.locale)),n=Math.trunc(wi(t,this.locale)),r=Math.trunc(wi(o,this.locale)),a=Math.trunc(wi(s,this.locale));hp(i,n),up(r),gp(a);const l=12/r,c=Bp.compute.bind(this)(e,t,o,s);return{value:Rs(Ds(Ni(n,this.locale),-c*l,!0)),format:this.locale.dateFormat}},isExported:!0},$p={description:vo("Cumulative interest paid over a set of periods."),args:[nh("rate (number)",vo("The interest rate.")),nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("present_value (number)",vo("The current value of the annuity.")),nh("first_period (number)",vo("The number of the payment period to begin the cumulative calculation.")),nh("last_period (number)",vo("The number of the payment period to end the cumulative calculation.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s,i,n={value:0}){const r=wi(s,this.locale),a=wi(i,this.locale),l=wi(e,this.locale),c=wi(o,this.locale),h=wi(t,this.locale),d=Mi(n)?1:0;_p(r,a,h),vp(l),wp(c);let u=0;for(let e=r;e<=a;e++)u+=sm(l,e,h,c,0,d);return u},isExported:!0},Gp={description:vo("Cumulative principal paid over a set of periods."),args:[nh("rate (number)",vo("The interest rate.")),nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("present_value (number)",vo("The current value of the annuity.")),nh("first_period (number)",vo("The number of the payment period to begin the cumulative calculation.")),nh("last_period (number)",vo("The number of the payment period to end the cumulative calculation.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s,i,n={value:0}){const r=wi(s,this.locale),a=wi(i,this.locale),l=wi(e,this.locale),c=wi(o,this.locale),h=wi(t,this.locale),d=Mi(n)?1:0;_p(r,a,h),vp(l),wp(c);let u=0;for(let e=r;e<=a;e++)u+=fm(l,e,h,c,0,d);return u},isExported:!0},Wp={description:vo("Depreciation via declining balance method."),args:[nh("cost (number)",vo("The initial cost of the asset.")),nh("salvage (number)",vo("The value of the asset at the end of depreciation.")),nh("life (number)",vo("The number of periods over which the asset is depreciated.")),nh("period (number)",vo("The single period within life for which to calculate depreciation.")),nh("month (number, optional)",vo("The number of months in the first year of depreciation."))],compute:function(e,t,o,s,...i){const n=wi(e,this.locale),r=wi(t,this.locale),a=wi(o,this.locale),l=Math.trunc(wi(s,this.locale)),c=i.length?Math.trunc(wi(i[0],this.locale)):12,h=a+(12===c?0:1);Sp(n),Cp(r),yp(l),bp(a),bi((()=>1<=c&&c<=12),vo("The month (%s) must be between 1 and 12 inclusive.",c.toString())),bi((()=>l<=h),vo("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 qp(e,t,o,s,i){if(Sp(e),Cp(t),yp(s),bp(o),Ep(s,o),Tp(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 Zp={description:vo("Depreciation via double-declining balance method."),args:[nh("cost (number)",vo("The initial cost of the asset.")),nh("salvage (number)",vo("The value of the asset at the end of depreciation.")),nh("life (number)",vo("The number of periods over which the asset is depreciated.")),nh("period (number)",vo("The single period within life for which to calculate depreciation.")),nh("factor (number, default=2)",vo("The factor by which depreciation decreases."))],compute:function(e,t,o,s,i={value:2}){return{value:qp(wi(e,this.locale),wi(t,this.locale),wi(o,this.locale),wi(s,this.locale),wi(i,this.locale)),format:"#,##0.00"}},isExported:!0},jp={description:vo("Discount rate of a security based on price."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("price (number)",vo("The price at which the security is bought per 100 face value.")),nh("redemption (number)",vo("The redemption amount per 100 face value, or par.")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(wi(e,this.locale)),r=Math.trunc(wi(t,this.locale)),a=wi(o,this.locale),l=wi(s,this.locale),c=Math.trunc(wi(i,this.locale));hp(n,r),gp(c),mp(a),pp(l);return(l-a)/l/Fs(n,r,c)},isExported:!0},Yp={description:vo("Convert a decimal fraction to decimal value."),args:[nh("fractional_price (number)",vo("The price quotation given using fractional decimal conventions.")),nh("unit (number)",vo("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],compute:function(e,t){const o=wi(e,this.locale),s=Math.trunc(wi(t,this.locale));bi((()=>s>0),vo("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},Xp={description:vo("Convert a decimal value to decimal fraction."),args:[nh("decimal_price (number)",vo("The price quotation given as a decimal value.")),nh("unit (number)",vo("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],compute:function(e,t){const o=wi(e,this.locale),s=Math.trunc(wi(t,this.locale));bi((()=>s>0),vo("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},Kp={description:vo("Number of periods for an investment to reach a value."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("rate (number)",vo("The annualized rate of interest.")),nh("yield (number)",vo("The expected annual yield of the security.")),nh("frequency (number)",vo("The number of interest or coupon payments per year (1, 2, or 4).")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n={value:0}){const r=Math.trunc(wi(e,this.locale)),a=Math.trunc(wi(t,this.locale)),l=wi(o,this.locale),c=wi(s,this.locale),h=Math.trunc(wi(i,this.locale)),d=Math.trunc(wi(n,this.locale));hp(r,a),up(h),gp(d),bi((()=>l>=0),vo("The rate (%s) must be positive or null.",l.toString())),bi((()=>c>=0),vo("The yield (%s) must be positive or null.",c.toString()));const u=Fs(r,a,d),g=u-Math.trunc(u)||1/h,p=Math.ceil(u*h),m=l/h,f=c/h;let v=0,b=0;for(let e=1;e<=p;e++){const t=(m+(e===p?1:0))/(1+f)**e;b+=(g+(e-1)/h)*t,v+=t}return 0===v?0:b/v},isExported:!0},Qp={description:vo("Annual effective interest rate."),args:[nh("nominal_rate (number)",vo("The nominal interest rate per year.")),nh("periods_per_year (number)",vo("The number of compounding periods per year."))],compute:function(e,t){const o=wi(e,this.locale),s=Math.trunc(wi(t,this.locale));return bi((()=>o>0),vo("The nominal rate (%s) must be strictly greater than 0.",o.toString())),bi((()=>s>0),vo("The number of periods by year (%s) must strictly greater than 0.",s.toString())),Math.pow(1+o/s,s)-1},isExported:!0};function Jp(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 em={description:vo("Future value of an annuity investment."),args:[nh("rate (number)",vo("The interest rate.")),nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("payment_amount (number)",vo("The amount per period to be paid.")),nh("present_value (number, default=0)",vo("The current value of the annuity.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;return{value:Jp(wi(e,this.locale),wi(t,this.locale),wi(o,this.locale),wi(s,this.locale),Mi(i)?1:0),format:"#,##0.00"}},isExported:!0},tm={description:vo("Future value of principal from series of rates."),args:[nh("principal (number)",vo("The amount of initial capital or value to compound against.")),nh("rate_schedule (number, range<number>)",vo("A series of interest rates to compound against the principal."))],compute:function(e,t){return Hi([t],((e,t)=>e*(1+wi(t,this.locale))),wi(e,this.locale))},isExported:!0},om={description:vo("Calculates effective interest rate."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("investment (number)",vo("The amount invested in the security.")),nh("redemption (number)",vo("The amount to be received at maturity.")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){const n=Math.trunc(wi(e,this.locale)),r=Math.trunc(wi(t,this.locale)),a=wi(s,this.locale),l=wi(o,this.locale),c=Math.trunc(wi(i,this.locale));hp(n,r),xp(l),pp(a),gp(c);return(a-l)/l/Fs(n,r,c)},isExported:!0};function sm(e,t,o,s,i,n){return pm(e,o,s,i,n)-fm(e,t,o,s,i,n)}const im={description:vo("Payment on the principal of an investment."),args:[nh("rate (number)",vo("The annualized rate of interest.")),nh("period (number)",vo("The amortization period, in terms of number of periods.")),nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("present_value (number)",vo("The current value of the annuity.")),nh("future_value (number, default=0)",vo("The future value remaining after the final payment has been made.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s,i={value:0},n={value:0}){return{value:sm(wi(e,this.locale),wi(t,this.locale),wi(o,this.locale),wi(s,this.locale),wi(i,this.locale),Mi(n)?1:0),format:"#,##0.00"}},isExported:!0},nm={description:vo("Internal rate of return given periodic cashflows."),args:[nh("cashflow_amounts (number, range<number>)",vo("An array or range containing the income or payments associated with the investment.")),nh("rate_guess (number, default=0.1)",vo("An estimate for what the internal rate of return will be."))],compute:function(e,t={value:.1}){const o=wi(t,this.locale);Dp(o);let s=!1,i=!1,n=[];Vi([e],(({value:e})=>{e>0&&(s=!0),e<0&&(i=!0),n.push(e)}),this.locale),bi((()=>s&&i),vo("The cashflow_amounts must include negative and positive values."));const r=n.shift();return{value:Np((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},rm={description:vo("Returns the interest paid at a particular period of an investment."),args:[nh("rate (number)",vo("The interest rate.")),nh("period (number)",vo("The period for which you want to view the interest payment.")),nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("present_value (number)",vo("The current value of the annuity."))],compute:function(e,t,o,s){const i=wi(e,this.locale),n=wi(t,this.locale),r=wi(o,this.locale),a=wi(s,this.locale);bi((()=>0!==r),vo("The number of periods must be different than 0.",r.toString()));return-1*(a-a*(n/r))*i},isExported:!0},am={description:vo("Modified Macaulay duration."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("rate (number)",vo("The annualized rate of interest.")),nh("yield (number)",vo("The expected annual yield of the security.")),nh("frequency (number)",vo("The number of interest or coupon payments per year (1, 2, or 4).")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n={value:0}){return Kp.compute.bind(this)(e,t,o,s,i,n)/(1+wi(s,this.locale)/Math.trunc(wi(i,this.locale)))},isExported:!0},lm={description:vo("Modified internal rate of return."),args:[nh("cashflow_amounts (range<number>)",vo("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")),nh("financing_rate (number)",vo("The interest rate paid on funds invested.")),nh("reinvestment_return_rate (number)",vo("The return (as a percentage) earned on reinvestment of income received from the investment."))],compute:function(e,t,o){const s=wi(t,this.locale),i=wi(o,this.locale),n=Wi(e).flat().filter((e=>null!==e.value)).map((e=>wi(e,this.locale))),r=n.length;let a=0,l=0;for(const e of Be(0,r)){const t=n[e];t>=0?a+=t*(i+1)**(r-e-1):l+=t/(s+1)**e}bi((()=>0!==l&&0!==a),vo("There must be both positive and negative values in cashflow_amounts."));return(-a/l)**(1/(r-1))-1},isExported:!0},cm={description:vo("Annual nominal interest rate."),args:[nh("effective_rate (number)",vo("The effective interest rate per year.")),nh("periods_per_year (number)",vo("The number of compounding periods per year."))],compute:function(e,t){const o=wi(e,this.locale),s=Math.trunc(wi(t,this.locale));return bi((()=>o>0),vo("The effective rate (%s) must must strictly greater than 0.",o.toString())),bi((()=>s>0),vo("The number of periods by year (%s) must strictly greater than 0.",s.toString())),(Math.pow(o+1,1/s)-1)*s},isExported:!0},hm={description:vo("Number of payment periods for an investment."),args:[nh("rate (number)",vo("The interest rate.")),nh("payment_amount (number)",vo("The amount of each payment made.")),nh("present_value (number)",vo("The current value of the annuity.")),nh("future_value (number, default=0)",vo("The future value remaining after the final payment has been made.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;const n=wi(e,this.locale),r=wi(t,this.locale),a=wi(o,this.locale),l=wi(s,this.locale),c=Mi(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 dm(e,t,o,s){let i=0;return Bi(o,((t,o)=>(i++,t+o/(1+e)**i)),t,s)}const um={description:vo("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:[nh("discount (number)",vo("The discount rate of the investment over one period.")),nh("cashflow1 (number, range<number>)",vo("The first future cash flow.")),nh("cashflow2 (number, range<number>, repeating)",vo("Additional future cash flows."))],compute:function(e,...t){const o=wi(e,this.locale);return bi((()=>-1!==o),vo("The discount (%s) must be different from -1.",o.toString())),{value:dm(o,0,t,this.locale),format:"#,##0.00"}},isExported:!0},gm={description:vo("Computes the number of periods needed for an investment to reach a value."),args:[nh("rate (number)",vo("The rate at which the investment grows each period.")),nh("present_value (number)",vo("The investment's current value.")),nh("future_value (number)",vo("The investment's desired future value."))],compute:function(e,t,o){const s=wi(e,this.locale),i=wi(t,this.locale),n=wi(o,this.locale);return vp(s),bi((()=>i>0),vo("The present_value (%s) must be strictly positive.",i.toString())),bi((()=>n>0),vo("The future_value (%s) must be strictly positive.",n.toString())),(Math.log(n)-Math.log(i))/Math.log(1+s)},isExported:!0};function pm(e,t,o,s,i){if(fp(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 mm={description:vo("Periodic payment for an annuity investment."),args:[nh("rate (number)",vo("The annualized rate of interest.")),nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("present_value (number)",vo("The current value of the annuity.")),nh("future_value (number, default=0)",vo("The future value remaining after the final payment has been made.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s={value:0},i={value:0}){const n=wi(t,this.locale),r=wi(e,this.locale),a=Mi(i)?1:0,l=wi(s,this.locale);return{value:pm(r,n,wi(o,this.locale),l,a),format:"#,##0.00"}},isExported:!0};function fm(e,t,o,s,i,n){fp(o),bi((()=>t>0&&t<=o),vo("The period must be between 1 and number_of_periods (%s)",o));const r=pm(e,o,s,i,n);if(1===n&&1===t)return r;return r+-Jp(e,0===n?t-1:t-2,r,s+r*n,0)*e}const vm={description:vo("Payment on the principal of an investment."),args:[nh("rate (number)",vo("The annualized rate of interest.")),nh("period (number)",vo("The amortization period, in terms of number of periods.")),nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("present_value (number)",vo("The current value of the annuity.")),nh("future_value (number, default=0)",vo("The future value remaining after the final payment has been made.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s,i={value:0},n={value:0}){const r=wi(o,this.locale),a=wi(e,this.locale),l=wi(t,this.locale),c=Mi(n)?1:0,h=wi(i,this.locale);return{value:fm(a,l,r,wi(s,this.locale),h,c),format:"#,##0.00"}},isExported:!0},bm={description:vo("Present value of an annuity investment."),args:[nh("rate (number)",vo("The interest rate.")),nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("payment_amount (number)",vo("The amount per period to be paid.")),nh("future_value (number, default=0)",vo("The future value remaining after the final payment has been made.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;const n=wi(e,this.locale),r=wi(t,this.locale),a=wi(o,this.locale),l=wi(s,this.locale),c=Mi(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},Sm={description:vo("Price of a security paying periodic interest."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("rate (number)",vo("The annualized rate of interest.")),nh("yield (number)",vo("The expected annual yield of the security.")),nh("redemption (number)",vo("The redemption amount per 100 face value, or par.")),nh("frequency (number)",vo("The number of interest or coupon payments per year (1, 2, or 4).")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=Math.trunc(wi(e,this.locale)),l=Math.trunc(wi(t,this.locale)),c=wi(o,this.locale),h=wi(s,this.locale),d=wi(i,this.locale),u=Math.trunc(wi(n,this.locale)),g=Math.trunc(wi(r,this.locale));hp(a,l),up(u),gp(g),bi((()=>c>=0),vo("The rate (%s) must be positive or null.",c.toString())),bi((()=>h>=0),vo("The yield (%s) must be positive or null.",h.toString())),pp(d);const p=Fs(a,l,g)*u,m=Math.ceil(p),f=p-Math.floor(p)||1,v=1+h/u,b=100*c/u;if(1===m)return(b+d)/(f*h/u+1)-b*(1-f);let S=0;for(let e=1;e<=m;e++)S+=b/v**(e-1+f);return d/v**(m-1+f)+S-b*(1-f)},isExported:!0},ym={description:vo("Price of a discount security."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("discount (number)",vo("The discount rate of the security at time of purchase.")),nh("redemption (number)",vo("The redemption amount per 100 face value, or par.")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(wi(e,this.locale)),r=Math.trunc(wi(t,this.locale)),a=wi(o,this.locale),l=wi(s,this.locale),c=Math.trunc(wi(i,this.locale));hp(n,r),gp(c),Ip(a),pp(l);return l-a*l*Fs(n,r,c)},isExported:!0},Cm={description:vo("Calculates the price of a security paying interest at maturity, based on expected yield."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("issue (date)",vo("The date the security was initially issued.")),nh("rate (number)",vo("The annualized rate of interest.")),nh("yield (number)",vo("The expected annual yield of the security.")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n={value:0}){n=n||0;const r=Math.trunc(wi(e,this.locale)),a=Math.trunc(wi(t,this.locale)),l=Math.trunc(wi(o,this.locale)),c=wi(s,this.locale),h=wi(i,this.locale),d=Math.trunc(wi(n,this.locale));dp(r,l),hp(r,a),gp(d),bi((()=>c>=0),vo("The rate (%s) must be positive or null.",c.toString())),bi((()=>h>=0),vo("The yield (%s) must be positive or null.",h.toString()));const u=Fs(r,a,d),g=Fs(r,l,d);return(100+Fs(l,a,d)*c*100)/(1+u*h)-g*c*100},isExported:!0},wm=.1,Em={description:vo("Interest rate of an annuity investment."),args:[nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("payment_per_period (number)",vo("The amount per period to be paid.")),nh("present_value (number)",vo("The current value of the annuity.")),nh("future_value (number, default=0)",vo("The future value remaining after the final payment has been made.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period.")),nh("rate_guess (number, default=0.1)",vo("An estimate for what the interest rate will be."))],compute:function(e,t,o,s={value:0},i={value:0},n={value:wm}){const r=wi(e,this.locale),a=wi(t,this.locale),l=Mi(i)?1:0,c=wi(n,this.locale)||wm;let h=wi(s,this.locale),d=wi(o,this.locale);fp(r),bi((()=>[a,d,h].some((e=>e>0))&&[a,d,h].some((e=>e<0))),vo("There must be both positive and negative values in [payment_amount, present_value, future_value].",r.toString())),Dp(c),h-=a*l,d+=a*l;return{value:Np((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},xm={description:vo("Amount received at maturity for a security."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("investment (number)",vo("The amount invested (irrespective of face value of each security).")),nh("discount (number)",vo("The discount rate of the security invested in.")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(wi(e,this.locale)),r=Math.trunc(wi(t,this.locale)),a=wi(o,this.locale),l=wi(s,this.locale),c=Math.trunc(wi(i,this.locale));hp(n,r),gp(c),xp(a),Ip(l);return a/(1-l*Fs(n,r,c))},isExported:!0},Im={description:vo("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:[nh("number_of_periods (number)",vo("The number of periods.")),nh("present_value (number)",vo("The present value of the investment.")),nh("future_value (number)",vo("The future value of the investment."))],compute:function(e,t,o){const s=wi(e,this.locale),i=wi(t,this.locale),n=wi(o,this.locale);return fp(s),(n/i)**(1/s)-1},isExported:!0},Rm={description:vo("Depreciation of an asset using the straight-line method."),args:[nh("cost (number)",vo("The initial cost of the asset.")),nh("salvage (number)",vo("The value of the asset at the end of depreciation.")),nh("life (number)",vo("The number of periods over which the asset is depreciated."))],compute:function(e,t,o){return{value:(wi(e,this.locale)-wi(t,this.locale))/wi(o,this.locale),format:"#,##0.00"}},isExported:!0},Tm={description:vo("Depreciation via sum of years digit method."),args:[nh("cost (number)",vo("The initial cost of the asset.")),nh("salvage (number)",vo("The value of the asset at the end of depreciation.")),nh("life (number)",vo("The number of periods over which the asset is depreciated.")),nh("period (number)",vo("The single period within life for which to calculate depreciation."))],compute:function(e,t,o,s){const i=wi(e,this.locale),n=wi(t,this.locale),r=wi(o,this.locale),a=wi(s,this.locale);yp(a),bp(r),Ep(a,r);return{value:(r-a+1)/(r*(r+1)/2)*(i-n),format:"#,##0.00"}},isExported:!0};function Am(e,t,o){return 100*(1-o*Fs(e,t,2))}const _m={description:vo("Price of a US Treasury bill."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("discount (number)",vo("The discount rate of the bill at time of purchase."))],compute:function(e,t,o){const s=Math.trunc(wi(e,this.locale)),i=Math.trunc(wi(t,this.locale)),n=wi(o,this.locale);return hp(s,i),Ap(s,i,this.locale),Ip(n),Rp(n),Am(s,i,n)},isExported:!0},Dm={description:vo("Equivalent rate of return for a US Treasury bill."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("discount (number)",vo("The discount rate of the bill at time of purchase."))],compute:function(e,t,o){const s=Math.trunc(wi(e,this.locale)),i=Math.trunc(wi(t,this.locale)),n=wi(o,this.locale);hp(s,i),Ap(s,i,this.locale),Ip(n),Rp(n);const r=Eg.compute.bind(this)({value:i},{value:s});if(r<=182)return 365*n/(360-n*r);const a=Am(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},Om={description:vo("The yield of a US Treasury bill based on price."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("price (number)",vo("The price at which the security is bought per 100 face value."))],compute:function(e,t,o){const s=Math.trunc(wi(e,this.locale)),i=Math.trunc(wi(t,this.locale)),n=wi(o,this.locale);hp(s,i),Ap(s,i,this.locale),mp(n);return(100-n)/n*(1/Fs(s,i,2))},isExported:!0},Fm={description:vo("Variable declining balance. WARNING : does not handle decimal periods."),args:[nh("cost (number)",vo("The initial cost of the asset.")),nh("salvage (number)",vo("The value of the asset at the end of depreciation.")),nh("life (number)",vo("The number of periods over which the asset is depreciated.")),nh("start (number)",vo("Starting period to calculate depreciation.")),nh("end (number)",vo("Ending period to calculate depreciation.")),nh("factor (number, default=2)",vo("The number of months in the first year of depreciation.")),nh("no_switch (number, default=false)",vo("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation."))],compute:function(e,t,o,s,i,n={value:2},r={value:false}){n=n||0;const a=wi(e,this.locale),l=wi(t,this.locale),c=wi(o,this.locale),h=Math.trunc(wi(s,this.locale)),d=Math.trunc(wi(i,this.locale)),u=wi(n,this.locale),g=Mi(r);if(Sp(a),Cp(l),function(e,t,o){bp(o),bi((()=>e>=0),vo("The start_period (%s) must be greater or equal than 0.",e.toString())),bi((()=>t>=0),vo("The end_period (%s) must be greater or equal than 0.",t.toString())),bi((()=>e<=t),vo("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),bi((()=>t<=o),vo("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),o.toString()))}(h,d,c),Tp(u),0===a)return 0;if(l>=a)return h<1?a-l:0;const p=u/c;if(p>=1)return h<1?a-l:0;let m=a,f=0,v=0,b=!1;for(let e=0;e<d;e++){if(!b||g){const t=m*p,o=(m-l)/(c-e);!g&&o>t?(b=!0,f=o):f=t}const t=Math.max(m-f,l);e>=h&&(v+=m-t),m=t}return v},isExported:!0},Mm={description:vo("Internal rate of return given non-periodic cash flows."),args:[nh("cashflow_amounts (range<number>)",vo("An range containing the income or payments associated with the investment.")),nh("cashflow_dates (range<number>)",vo("An range with dates corresponding to the cash flows in cashflow_amounts.")),nh("rate_guess (number, default=0.1)",vo("An estimate for what the internal rate of return will be."))],compute:function(e,t,o={value:wm}){const s=wi(o,this.locale),i=e.flat().map((e=>wi(e,this.locale))),n=t.flat().map((e=>wi(e,this.locale)));var r;Op(e,t),r=i,bi((()=>r.some((e=>e>0))&&r.some((e=>e<0))),vo("There must be both positive and negative values in cashflow_amounts.")),Fp(n),Dp(s);const a=new Map;for(const e of Be(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 Np((e=>{let t=c[0];for(const o of Be(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 Be(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},Nm={description:vo("Net present value given to non-periodic cash flows.."),args:[nh("discount (number)",vo("The discount rate of the investment over one period.")),nh("cashflow_amounts (number, range<number>)",vo("An range containing the income or payments associated with the investment.")),nh("cashflow_dates (number, range<number>)",vo("An range with dates corresponding to the cash flows in cashflow_amounts."))],compute:function(e,t,o){const s=wi(e,this.locale),i=ni(t)?t.flat().map((e=>Ii(e,this.locale))):[Ii(t,this.locale)],n=ni(o)?o.flat().map((e=>Ii(e,this.locale))):[Ii(o,this.locale)];if(ni(o)&&ni(t)?Op(t,o):bi((()=>i.length===n.length),vo("There must be the same number of values in cashflow_amounts and cashflow_dates.")),Fp(n),vp(s),1===i.length)return i[0];const r=new Map;for(const e of Be(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 Be(1,l.length)){const t=(a[0]-a[e])/365;c+=l[e]*(1+s)**t}return c},isExported:!0},Pm={description:vo("Annual yield of a security paying periodic interest."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("rate (number)",vo("The annualized rate of interest.")),nh("price (number)",vo("The price at which the security is bought per 100 face value.")),nh("redemption (number)",vo("The redemption amount per 100 face value, or par.")),nh("frequency (number)",vo("The number of interest or coupon payments per year (1, 2, or 4).")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=Math.trunc(wi(e,this.locale)),l=Math.trunc(wi(t,this.locale)),c=wi(o,this.locale),h=wi(s,this.locale),d=wi(i,this.locale),u=Math.trunc(wi(n,this.locale)),g=Math.trunc(wi(r,this.locale));hp(a,l),up(u),gp(g),bi((()=>c>=0),vo("The rate (%s) must be positive or null.",c.toString())),mp(h),pp(d);const p=Fs(a,l,g)*u,m=Math.ceil(p),f=p-Math.floor(p)||1,v=100*c/u;if(1===m){const e=h+v*(1-f);return(d+v-e)*u*(1/f)/e}const b=Np((function(e){return function(e,t,o,s,i,n){let r=n-(e+i*(1-t))*s**(o-1+t);for(let e=1;e<=o;e++)r+=i*s**(e-1);return r}(h,f,m,e,v,d)}),(function(e){return function(e,t,o,s,i){let n=-(e+i*(1-t))*(o-1+t)*s**(o-2+t);for(let e=1;e<=o;e++)n+=i*(e-1)*s**(e-2);return n}(h,f,m,e,v)}),1+(c+1)/u,100,1e-5);return(b-1)*u},isExported:!0},km={description:vo("Annual yield of a discount security."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("price (number)",vo("The price at which the security is bought per 100 face value.")),nh("redemption (number)",vo("The redemption amount per 100 face value, or par.")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(wi(e,this.locale)),r=Math.trunc(wi(t,this.locale)),a=wi(o,this.locale),l=wi(s,this.locale),c=Math.trunc(wi(i,this.locale));hp(n,r),gp(c),mp(a),pp(l);return(l/a-1)/Fs(n,r,c)},isExported:!0},Lm={description:vo("Annual yield of a security paying interest at maturity."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("issue (date)",vo("The date the security was initially issued.")),nh("rate (number)",vo("The annualized rate of interest.")),nh("price (number)",vo("The price at which the security is bought.")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n={value:0}){n=n||0;const r=Math.trunc(wi(e,this.locale)),a=Math.trunc(wi(t,this.locale)),l=Math.trunc(wi(o,this.locale)),c=wi(s,this.locale),h=wi(i,this.locale),d=Math.trunc(wi(n,this.locale));hp(r,a),gp(d),bi((()=>r>=l),vo("The settlement (%s) must be greater than or equal to the issue (%s).",r.toString(),l.toString())),bi((()=>c>=0),vo("The rate (%s) must be positive or null.",c.toString())),mp(h);const u=Fs(l,a,d),g=Fs(l,r,d),p=Fs(r,a,d);return(100*(1+c*u)/(h+100*c*g)-1)/p},isExported:!0};var Vm,Um=Object.freeze({__proto__:null,ACCRINTM:Pp,AMORLINC:kp,COUPDAYBS:Vp,COUPDAYS:Lp,COUPDAYSNC:Up,COUPNCD:Hp,COUPNUM:Bp,COUPPCD:zp,CUMIPMT:$p,CUMPRINC:Gp,DB:Wp,DDB:Zp,DISC:jp,DOLLARDE:Yp,DOLLARFR:Xp,DURATION:Kp,EFFECT:Qp,FV:em,FVSCHEDULE:tm,INTRATE:om,IPMT:im,IRR:nm,ISPMT:rm,MDURATION:am,MIRR:lm,NOMINAL:cm,NPER:hm,NPV:um,PDURATION:gm,PMT:mm,PPMT:vm,PRICE:Sm,PRICEDISC:ym,PRICEMAT:Cm,PV:bm,RATE:Em,RECEIVED:xm,RRI:Im,SLN:Rm,SYD:Tm,TBILLEQ:Dm,TBILLPRICE:_m,TBILLYIELD:Om,VDB:Fm,XIRR:Mm,XNPV:Nm,YIELD:Pm,YIELDDISC:km,YIELDMAT:Lm});!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"}(Vm||(Vm={}));const Hm=(e,t=(()=>!0))=>[{goTo:e,guard:t}],Bm=(e,t=(()=>!0))=>({goTo:e,guard:t}),zm={[Vm.LeftRef]:{REFERENCE:Hm(Vm.Separator),NUMBER:Hm(Vm.FullRowSeparator),SYMBOL:[Bm(Vm.FullColumnSeparator,(e=>Ro(e.value))),Bm(Vm.FullRowSeparator,(e=>To(e.value)))]},[Vm.FullColumnSeparator]:{SPACE:Hm(Vm.FullColumnSeparator),OPERATOR:Hm(Vm.RightColumnRef,(e=>":"===e.value))},[Vm.FullRowSeparator]:{SPACE:Hm(Vm.FullRowSeparator),OPERATOR:Hm(Vm.RightRowRef,(e=>":"===e.value))},[Vm.Separator]:{SPACE:Hm(Vm.Separator),OPERATOR:Hm(Vm.RightRef,(e=>":"===e.value))},[Vm.RightRef]:{SPACE:Hm(Vm.RightRef),NUMBER:Hm(Vm.Found),REFERENCE:Hm(Vm.Found,(e=>Do(e.value))),SYMBOL:Hm(Vm.Found,(e=>Ao(e.value)||_o(e.value)))},[Vm.RightColumnRef]:{SPACE:Hm(Vm.RightColumnRef),SYMBOL:Hm(Vm.Found,(e=>Ao(e.value))),REFERENCE:Hm(Vm.Found,(e=>Do(e.value)))},[Vm.RightRowRef]:{SPACE:Hm(Vm.RightRowRef),NUMBER:Hm(Vm.Found),REFERENCE:Hm(Vm.Found,(e=>Do(e.value))),SYMBOL:Hm(Vm.Found,(e=>_o(e.value)))},[Vm.Found]:{}};function $m(e){let t=0,o=zm[Vm.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 Vm.Found:return s+=i.value,e.splice(0,t),{type:"REFERENCE",value:s};default:o=zm[r],s+=i.value}}return null}function Gm(e,t=si){const o=Jr(e,t),s=[];for(;o.length;)s.push($m(o)||o.shift());return s}const Wm=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,qm=["-","+"],Zm=["%"],jm=["*","+","&"],Ym={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10};function Xm(e){const t=e.shift();if(!t)throw new ui;switch(t.type){case"DEBUGGER":const o=Jm(e,1e3);return o.debug=!0,o;case"NUMBER":return{type:"NUMBER",value:Bs(t.value,si)};case"STRING":return{type:"STRING",value:Me(t.value)};case"INVALID_REFERENCE":return{type:"REFERENCE",value:ci.InvalidReference};case"REFERENCE":if(":"===e[0]?.value&&"REFERENCE"===e[1]?.type){e.shift();const o=e.shift();return{type:"REFERENCE",value:`${t.value}:${o?.value}`}}return{type:"REFERENCE",value:t.value};case"SYMBOL":const s=t.value,i=e[0];if("LEFT_PAREN"===i?.type&&Wm.test(t.value)&&s===Le(s,"'")){const t=function(e){Qm(e,"LEFT_PAREN",vo("Missing opening parenthesis"));const t=e[0];if("RIGHT_PAREN"===t?.type)return Qm(e,"RIGHT_PAREN"),[];const o=[];o.push(Km(e));for(;"RIGHT_PAREN"!==e[0]?.type;)Qm(e,"ARG_SEPARATOR",vo("Wrong function call")),o.push(Km(e));return Qm(e,"RIGHT_PAREN"),o}(e);return{type:"FUNCALL",value:s,args:t}}const n=s.toUpperCase();return"TRUE"===n||"FALSE"===n?{type:"BOOLEAN",value:"TRUE"===n}:{type:"SYMBOL",value:Le(t.value,"'")};case"LEFT_PAREN":const r=Jm(e);return Qm(e,"RIGHT_PAREN",vo("Missing closing parenthesis")),r;case"OPERATOR":const a=t.value;if(qm.includes(a))return{type:"UNARY_OPERATION",value:a,operand:Jm(e,Ym[a])};throw new ui(vo("Unexpected token: %s",t.value));default:throw new ui(vo("Unexpected token: %s",t.value))}}function Km(e){const t=e[0];return"ARG_SEPARATOR"===t?.type||"RIGHT_PAREN"===t?.type?{type:"EMPTY",value:""}:Jm(e)}function Qm(e,t,o){const s=e.shift();if(!s||s.type!==t)throw new ui(o)}function Jm(e,t=0){if(0===e.length)throw new ui;let o=Xm(e);for(;"OPERATOR"===e[0]?.type&&Ym[e[0].value]>t;){const t=e.shift().value;if(Zm.includes(t))o={type:"UNARY_OPERATION",value:t,operand:o,postfix:!0};else{o={type:"BIN_OPERATION",value:t,left:o,right:Jm(e,Ym[t])}}}return o}function ef(e){return tf(Gm(e))}function tf(e){e=e.filter((e=>"SPACE"!==e.type)),"="===e[0]?.value&&e.splice(0,1);const t=Jm(e);if(e.length)throw new ui;return t}function of(e,t,o){return rf(e,(e=>e.type===t?o(e):e))}function sf(e){return Array.from(nf(e))}function*nf(e){switch(yield e,e.type){case"FUNCALL":for(const t of e.args)yield*nf(t);break;case"UNARY_OPERATION":yield*nf(e.operand);break;case"BIN_OPERATION":yield*nf(e.left),yield*nf(e.right)}}function rf(e,t){switch((e=t(e)).type){case"FUNCALL":return{...e,args:e.args.map((e=>rf(e,t)))};case"UNARY_OPERATION":return{...e,operand:rf(e.operand,t)};case"BIN_OPERATION":return{...e,right:rf(e.right,t),left:rf(e.left,t)};default:return e}}function af(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>af(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?lf(e)+e.value:e.value+cf(e);case"BIN_OPERATION":return lf(e)+e.value+cf(e)}}function lf(e){const t=e.value,o="left"in e?e.left:e.operand,s=o.value;return"BIN_OPERATION"===o.type&&Ym[s]<Ym[t]?`(${af(o)})`:af(o)}function cf(e){const t=e.value,o="right"in e?e.right:e.operand,s=Ym[o.value],i=Ym[t];let n=!1;return"BIN_OPERATION"!==o.type?n=!1:s<i?n=!0:s!==i||jm.includes(t)||(n=!0),n?`(${af(o)})`:af(o)}function hf(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(tf(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}))}(Gm(e,t)))))}function df(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:o}=Oo(e.value),[s,i]=t.split(":"),n=uf(s),r=i?`:${uf(i)}`:"";return{...e,value:Fo(o,n+r)}}function uf(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=gf(e,"colrow");break;case"colrow":e=gf(e,"row");break;case"row":e=gf(e,"col");break;case"col":e=gf(e,"none")}return e}function gf(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 pf(e,t,o){const s=(t.startsWith("=")?hf(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(df).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 mf=["address","col","contents","format","row","type"],ff={description:vo("Gets information about a cell."),args:[nh("info_type (string)",vo("The type of information requested. Can be one of %s",mf.join(", "))),nh("reference (meta)",vo("The reference to the cell."))],compute:function(e,t){const o=Di(e).toLowerCase();bi((()=>mf.includes(o)),vo("The info_type should be one of %s.",mf.join(", ")));const s=this.__originSheetId,i=Di(t),n=i.includes(":")?i.split(":")[0]:i;let{sheetName:r,xc:a}=Oo(n);r=r===this.getters.getSheetName(s)?void 0:r;const l=Fo(r,gf(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===$s.empty?"b":t===$s.text?"l":"v"}}return""},isExported:!0},vf={description:vo("Whether a value is an error other than #N/A."),args:[nh("value (any)",vo("The value to be verified as an error type."))],compute:function(e){const t=e?.value;return yi(t)&&t!==ci.NotAvailable},isExported:!0},bf={description:vo("Whether a value is an error."),args:[nh("value (any)",vo("The value to be verified as an error type."))],compute:function(e){const t=e?.value;return yi(t)},isExported:!0},Sf={description:vo("Whether a value is `true` or `false`."),args:[nh("value (any)",vo("The value to be verified as a logical TRUE or FALSE."))],compute:function(e){return"boolean"==typeof e?.value},isExported:!0},yf={description:vo("Whether a value is the error #N/A."),args:[nh("value (any)",vo("The value to be verified as an error type."))],compute:function(e){return e?.value===ci.NotAvailable},isExported:!0},Cf={description:vo("Whether a value is non-textual."),args:[nh("value (any)",vo("The value to be checked."))],compute:function(e){return!Ef.compute.bind(this)(e)},isExported:!0},wf={description:vo("Whether a value is a number."),args:[nh("value (any)",vo("The value to be verified as a number."))],compute:function(e){return"number"==typeof e?.value},isExported:!0},Ef={description:vo("Whether a value is text."),args:[nh("value (any)",vo("The value to be verified as text."))],compute:function(e){return"string"==typeof e?.value&&!1===yi(e?.value)},isExported:!0},xf={description:vo("Whether the referenced cell is empty"),args:[nh("value (any)",vo("Reference to the cell that will be checked for emptiness."))],compute:function(e){return null===e?.value},isExported:!0},If={description:vo("Returns the error value #N/A."),args:[],compute:function(){return{value:ci.NotAvailable}},isExported:!0};var Rf=Object.freeze({__proto__:null,CELL:ff,ISBLANK:xf,ISERR:vf,ISERROR:bf,ISLOGICAL:Sf,ISNA:yf,ISNONTEXT:Cf,ISNUMBER:wf,ISTEXT:Ef,NA:If});const Tf={description:vo("Logical `and` operator."),args:[nh("logical_expression1 (boolean, range<boolean>)",vo("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.")),nh("logical_expression2 (boolean, range<boolean>, repeating)",vo("More expressions that represent logical values."))],compute:function(...e){const{result:t,foundBoolean:o}=Ta(e);return bi((()=>o),vo("[[FUNCTION_NAME]] has no valid input data.")),t},isExported:!0},Af={description:vo("Logical value `false`."),args:[],compute:function(){return!1},isExported:!0},_f={description:vo("Returns value depending on logical expression."),args:[nh("logical_expression (boolean)",vo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")),nh("value_if_true (any)",vo("The value the function returns if logical_expression is TRUE.")),nh("value_if_false (any, default=FALSE)",vo("The value the function returns if logical_expression is FALSE."))],compute:function(e,t,o){const s=Mi(e?.value)?t:o;return void 0===s?{value:""}:(null===s.value&&(s.value=""),s)},isExported:!0},Df={description:vo("Value if it is not an error, otherwise 2nd argument."),args:[nh("value (any)",vo("The value to return if value itself is not an error.")),nh('value_if_error (any, default="empty")',vo("The value the function returns if value is an error."))],compute:function(e,t={value:""}){const o=yi(e?.value)?t:e;return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)},isExported:!0},Of={description:vo("Value if it is not an #N/A error, otherwise 2nd argument."),args:[nh("value (any)",vo("The value to return if value itself is not #N/A an error.")),nh('value_if_error (any, default="empty")',vo("The value the function returns if value is an #N/A error."))],compute:function(e,t={value:""}){const o=e?.value===ci.NotAvailable?t:e;return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)},isExported:!0},Ff={description:vo("Returns a value depending on multiple logical expressions."),args:[nh("condition1 (boolean)",vo("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")),nh("value1 (any)",vo("The returned value if condition1 is TRUE.")),nh("condition2 (boolean, any, repeating)",vo("Additional conditions to be evaluated if the previous ones are FALSE.")),nh("value2 (any, repeating)",vo("Additional values to be returned if their corresponding conditions are TRUE."))],compute:function(...e){bi((()=>e.length%2==0),vo("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(Mi(e[t]?.value)){const o=e[t+1];return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)}throw new di(vo("No match."))},isExported:!0},Mf={description:vo("Returns opposite of provided logical value."),args:[nh("logical_expression (boolean)",vo("An expression or reference to a cell holding an expression that represents some logical value."))],compute:function(e){return!Mi(e)},isExported:!0},Nf={description:vo("Logical `or` operator."),args:[nh("logical_expression1 (boolean, range<boolean>)",vo("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.")),nh("logical_expression2 (boolean, range<boolean>, repeating)",vo("More expressions that evaluate to logical values."))],compute:function(...e){const{result:t,foundBoolean:o}=Aa(e);return bi((()=>o),vo("[[FUNCTION_NAME]] has no valid input data.")),t},isExported:!0},Pf={description:vo("Logical value `true`."),args:[],compute:function(){return!0},isExported:!0},kf={description:vo("Logical `xor` operator."),args:[nh("logical_expression1 (boolean, range<boolean>)",vo("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.")),nh("logical_expression2 (boolean, range<boolean>, repeating)",vo("More expressions that evaluate to logical values."))],compute:function(...e){let t=!1,o=!1;return qi(e,(e=>(t=!0,o=o?!e:e,!0))),bi((()=>t),vo("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0};var Lf=Object.freeze({__proto__:null,AND:Tf,FALSE:Af,IF:_f,IFERROR:Df,IFNA:Of,IFS:Ff,NOT:Mf,OR:Nf,TRUE:Pf,XOR:kf});function Vf(e,t){const o=t.getPivotId(e);if(!o)throw new di(vo('There is no pivot with id "%s"',e));return o}function Uf(e){if(e.length%2!=0)throw new di(vo("Function PIVOT takes an even number of arguments."))}function Hf(e,t,o){const s=[];if("SPREADSHEET"===t.type&&t.dataSet){const{sheetId:o,zone:i}=t.dataSet,n=Lo(i),r=e.getters.getRangeFromSheetXC(o,n);if(void 0===r||r.invalidXc||r.invalidSheetName)throw new gi;s.push(r)}for(const t of o)if(t.computedBy){const o=e.getters.getMeasureCompiledFormula(t);s.push(...o.dependencies.filter((e=>!e.invalidXc)))}const i=e.__originCellPosition;i&&s.length&&(e.updateDependencies?.(i),e.addDependencies?.(i,s))}const Bf=!0;function zf(e){return{value:ci.NotAvailable,message:vo("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Di(e))}}const $f={description:vo("Returns a cell reference as a string. "),args:[nh("row (number)",vo("The row number of the cell reference. ")),nh("column (number)",vo("The column number (not name) of the cell reference. A is column number 1. ")),nh("absolute_relative_mode (number, default=1)",vo("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).")),nh("use_a1_notation (boolean, default=TRUE)",vo("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).")),nh("sheet (string, optional)",vo("A string indicating the name of the sheet into which the address points."))],compute:function(e,t,o={value:1},s={value:!0},i){const n=Ti(e,this.locale),r=Ti(t,this.locale);Ai(n),Ai(r);const a=Ti(o,this.locale);var l,c;bi((()=>[1,2,3,4].includes(a)),(l=4,c=a,vo("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(Mi(s)){h=io(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?Fo(Di(i),h):h},isExported:!0},Gf={description:vo("Column number of a specified cell."),args:[nh("cell_reference (meta, default='this cell')",vo("The cell whose column number will be returned. Column A corresponds to 1. By default, the function use the cell in which the formula is entered."))],compute:function(e){if(yi(e?.value))throw e;const t=void 0===e?this.__originCellPosition?.col:No(e.value).left;return bi((()=>void 0!==t),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter."),t+1},isExported:!0},Wf={description:vo("Number of columns in a specified array or range."),args:[nh("range (meta)",vo("The range whose column count will be returned."))],compute:function(e){if(yi(e?.value))throw e;const t=No(e.value);return t.right-t.left+1},isExported:!0},qf={description:vo("Horizontal lookup"),args:[nh("search_key (string, number, boolean)",vo("The value to search for. For example, 42, 'Cats', or I24.")),nh("range (any, range)",vo("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")),nh("index (number)",vo("The row index of the value to be returned, where the first row in range is numbered 1.")),nh("is_sorted (boolean, default=true)",vo("Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned."))],compute:function(e,t,o,s={value:Bf}){const i=Math.trunc(wi(o?.value,this.locale)),n=tn(t);bi((()=>1<=i&&i<=n[0].length),vo("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const r=(e,t)=>e[t][0].value,a=Mi(s.value)?Ki(n,e,"nextSmaller","asc",n.length,r):Qi(t,e,"wildcard",n.length,r,this.lookupCaches),l=n[a];return void 0===l?zf(e):l[i-1]},isExported:!0},Zf={description:vo("Returns the content of a cell, specified by row and column offset."),args:[nh("reference (any, range)",vo("The range of cells from which the values are returned.")),nh("row (number, default=0)",vo("The index of the row to be returned from within the reference range of cells.")),nh("column (number, default=0)",vo("The index of the column to be returned from within the reference range of cells."))],compute:function(e,t={value:0},o={value:0}){const s=tn(e),i=wi(t.value,this.locale),n=wi(o.value,this.locale);return bi((()=>n>=0&&n-1<s.length&&i>=0&&i-1<s[0].length),vo("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},jf={description:vo("Returns the content of a cell, specified by a string."),args:[nh("reference (string)",vo("The range of cells from which the values are returned.")),nh("use_a1_notation (boolean, default=TRUE)",vo("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE)."))],compute:function(e,t={value:!0}){let o=e?.value?.toString();if(!o)throw new gi(vo("Reference should be defined."));if(!Mi(t))throw new di(vo("R1C1 notation is not supported."));const s=this.__originSheetId,i=this.__originCellPosition;i&&this.updateDependencies?.(i);const n=this.getters.getRangeFromSheetXC(s,o);if(void 0===n||n.invalidXc||n.invalidSheetName)throw new gi;i&&this.addDependencies?.(i,[n]);const r=[];for(let e=n.zone.left;e<=n.zone.right;e++){const t=[];for(let o=n.zone.top;o<=n.zone.bottom;o++){const s={sheetId:n.sheetId,col:e,row:o};t.push(this.getters.getEvaluatedCell(s))}r.push(t)}return 1===r.length&&1===r[0].length?r[0][0]:r},isExported:!0},Yf={description:vo("Look up a value."),args:[nh("search_key (string, number, boolean)",vo("The value to search for. For example, 42, 'Cats', or I24.")),nh("search_array (any, range)",vo("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.")),nh("result_range (any, range, optional)",vo("The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method."))],compute:function(e,t,o){const s=tn(t),i=tn(o);let n=s.length,r=s[0].length;const a=r>=n,l=a?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,c=Ki(s,e,"nextSmaller","asc",a?r:n,l);return-1===c||a&&void 0===s[0][c]||!a&&void 0===s[c][r-1]?zf(e):0===i[0].length?a?s[n-1][c]:s[c][r-1]:(n=i.length,r=i[0].length,bi((()=>1===n||1===r),vo("The result_range must be a single row or a single column.")),n>1?(bi((()=>c<=n-1),vo("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(c+1).toString())),i[c][0]):(bi((()=>c<=r-1),vo("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(c+1).toString())),i[0][c]))},isExported:!0},Xf={description:vo("Position of item in range that matches value."),args:[nh("search_key (string, number, boolean)",vo("The value to search for. For example, 42, 'Cats', or I24.")),nh("range (any, range)",vo("The one-dimensional array to be searched.")),nh("search_type (number, default=1)",vo("The search method. 1 (default) finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order."))],compute:function(e,t,o={value:1}){let s=wi(o,this.locale);const i=tn(t),n=i.length,r=i[0].length;bi((()=>1===n||1===r),vo("The range must be a single row or a single column."));let a=-1;const l=1===n?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,c=1===n?i[0].length:i.length;switch(s=Math.sign(s),s){case 1:a=Ki(i,e,"nextSmaller","asc",c,l);break;case 0:a=Qi(i,e,"wildcard",c,l,this.lookupCaches);break;case-1:a=Ki(i,e,"nextGreater","desc",c,l)}return 1===n&&void 0===i[0][a]||1!==n&&void 0===i[a]?zf(e):a+1},isExported:!0},Kf={description:vo("Row number of a specified cell."),args:[nh("cell_reference (meta, default='this cell')",vo("The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered."))],compute:function(e){if(yi(e?.value))throw e;const t=void 0===e?this.__originCellPosition?.row:No(e.value).top;return bi((()=>void 0!==t),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter."),t+1},isExported:!0},Qf={description:vo("Number of rows in a specified array or range."),args:[nh("range (meta)",vo("The range whose row count will be returned."))],compute:function(e){if(yi(e?.value))throw e;const t=No(e.value);return t.bottom-t.top+1},isExported:!0},Jf={description:vo("Vertical lookup."),args:[nh("search_key (string, number, boolean)",vo("The value to search for. For example, 42, 'Cats', or I24.")),nh("range (any, range)",vo("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")),nh("index (number)",vo("The column index of the value to be returned, where the first column in range is numbered 1.")),nh("is_sorted (boolean, default=true)",vo("Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned."))],compute:function(e,t,o,s={value:Bf}){const i=Math.trunc(wi(o?.value,this.locale)),n=tn(t);bi((()=>1<=i&&i<=n.length),vo("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const r=(e,t)=>e[0][t].value,a=Mi(s.value)?Ki(n,e,"nextSmaller","asc",n[0].length,r):Qi(n,e,"wildcard",n[0].length,r,this.lookupCaches),l=n[i-1][a];return void 0===l?zf(e):l},isExported:!0},ev={0:"strict",1:"nextGreater","-1":"nextSmaller",2:"wildcard"},tv={description:vo("Search a range for a match and return the corresponding item from a second range."),args:[nh("search_key (string,number,boolean)",vo("The value to search for.")),nh("lookup_range (any, range)",vo("The range to consider for the search. Should be a single column or a single row.")),nh("return_range (any, range)",vo("The range containing the return value. Should have the same dimensions as lookup_range.")),nh("if_not_found (any, optional)",vo("If a valid match is not found, return this value.")),nh("match_mode (any, default=0)",vo("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match. (2) Wildcard match.")),nh("search_mode (any, default=1)",vo("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. "))],compute:function(e,t,o,s,i={value:0},n={value:1}){const r=Math.trunc(wi(i.value,this.locale)),a=Math.trunc(wi(n.value,this.locale)),l=tn(t),c=tn(o);bi((()=>1===l.length||1===l[0].length),vo("lookup_range should be either a single row or single column.")),bi((()=>[-1,1,-2,2].includes(a)),vo("search_mode should be a value in [-1, 1, -2, 2].")),bi((()=>[-1,0,1,2].includes(r)),vo("match_mode should be a value in [-1, 0, 1, 2]."));const h=1===l.length?"col":"row";bi((()=>!(2===r&&[-2,2].includes(a))),vo("the search and match mode combination is not supported for XLOOKUP evaluation.")),bi((()=>"col"===h?c[0].length===l[0].length:c.length===l.length),vo("return_range should have the same dimensions as lookup_range."));const d="col"===h?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,u="col"===h?l[0].length:l.length,g=ev[r],p=-1===a,m=2===a||-2===a?Ki(l,e,g,2===a?"asc":"desc",u,d):Qi(l,e,g,u,d,this.lookupCaches,p);return-1!==m?"col"===h?c.map((e=>[e[m]])):[c[m]]:void 0===s?zf(e):[[s]]},isExported:!0},ov={description:vo("Get the value from a pivot."),args:[nh("pivot_id (number,string)",vo("ID of the pivot.")),nh("measure_name (string)",vo("Name of the measure.")),nh("domain_field_name (string,optional,repeating)",vo("Field name.")),nh("domain_value (number,string,boolean,optional,repeating)",vo("Value."))],compute:function(e,t,...o){const s=Di(e),i=Di(t),n=Vf(s,this.getters);!function(e,t,o){const{measures:s}=o.getPivotCoreDefinition(e);if(!s.find((e=>e.id===t))){const e=`(${s.map((e=>e.id)).join(", ")})`;throw new di(vo("The argument %s is not a valid measure. Here are the measures: %s",t,e))}}(n,i,this.getters),Uf(o);const r=this.getters.getPivot(n),a=this.getters.getPivotCoreDefinition(n);Hf(this,a,a.measures.filter((e=>e.id===i))),r.init({reload:r.needsReevaluation});const l=r.assertIsValid({throwOnError:!1});if(l)return l;if(!r.areDomainArgsFieldsValid(o)){const e=vo("Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.",`=PIVOT(${s})`);return{value:ci.GenericError,message:vo("Dimensions don't match the pivot definition")+". "+e}}const c=r.parseArgsToPivotDomain(o);return r.getPivotCellValueAndFormat(i,c)}},sv={description:vo("Get the header of a pivot."),args:[nh("pivot_id (number,string)",vo("ID of the pivot.")),nh("domain_field_name (string,optional,repeating)",vo("Field name.")),nh("domain_value (number,string,value,optional,repeating)",vo("Value."))],compute:function(e,...t){const o=Di(e),s=Vf(o,this.getters);Uf(t);const i=this.getters.getPivot(s);Hf(this,this.getters.getPivotCoreDefinition(s),[]),i.init({reload:i.needsReevaluation});const n=i.assertIsValid({throwOnError:!1});if(n)return n;if(!i.areDomainArgsFieldsValid(t)){const e=vo("Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.",`=PIVOT(${o})`);return{value:ci.GenericError,message:vo("Dimensions don't match the pivot definition")+". "+e}}const r=i.parseArgsToPivotDomain(t),a=r.at(-1);if("measure"===a?.field)return i.getPivotMeasureValue(Di(a.value),r);const{value:l,format:c}=i.getPivotHeaderValueAndFormat(r);return{value:l,format:a&&"measure"!==a.field&&"false"!==a.value?c:void 0}}},iv={description:vo("Get a pivot table."),args:[nh("pivot_id (string)",vo("ID of the pivot.")),nh("row_count (number, optional)",vo("number of rows")),nh("include_total (boolean, default=TRUE)",vo("Whether to include total/sub-totals or not.")),nh("include_column_titles (boolean, default=TRUE)",vo("Whether to include the column titles or not.")),nh("column_count (number, optional)",vo("number of columns"))],compute:function(e,t={value:1e4},o={value:!0},s={value:!0},i={value:Number.MAX_VALUE}){const n=Di(e),r=wi(t,this.locale);if(r<0)throw new di(vo("The number of rows must be positive."));const a=wi(i,this.locale);if(a<0)throw new di(vo("The number of columns must be positive."));const l=Mi(s),c=Mi(o),h=Vf(n,this.getters),d=this.getters.getPivot(h),u=this.getters.getPivotCoreDefinition(h);Hf(this,u,u.measures),d.init({reload:d.needsReevaluation});const g=d.assertIsValid({throwOnError:!1});if(g)return g;const p=d.getTableStructure(),m=p.getPivotCells(c,l),f=l?p.columns.length:0,v=this.getters.getPivotDisplayName(h),b=Math.min(f+r,m[0].length);if(0===b)return[[{value:v}]];const S=Math.min(1+a,m.length),y=[];for(const e of Be(0,S)){y[e]=[];for(const t of Be(0,b)){const o=m[e][t];switch(o.type){case"EMPTY":y[e].push({value:""});break;case"HEADER":const t=d.getPivotHeaderValueAndFormat(o.domain);y[e].push(zl(d,o.domain,t));break;case"MEASURE_HEADER":y[e].push(d.getPivotMeasureValue(o.measure,o.domain));break;case"VALUE":y[e].push(d.getPivotCellValueAndFormat(o.measure,o.domain))}}}return l&&(y[0][0]={value:v}),y}},nv={description:vo("Returns a range reference shifted by a specified number of rows and columns from a starting cell reference."),args:[nh("cell_reference (meta)",vo("The starting point from which to count the offset rows and columns.")),nh("offset_rows (number)",vo("The number of rows to offset by.")),nh("offset_columns (number)",vo("The number of columns to offset by.")),nh("height (number, default='height of cell_reference')",vo("The number of rows of the range to return starting at the offset target.")),nh("width (number, default='width of cell_reference')",vo("The number of columns of the range to return starting at the offset target."))],compute:function(e,t,o,s,i){if(yi(e?.value))return e;const n=e?.value;if(!n)throw new Error("In this context, the function OFFSET needs to have a cell or range in parameter.");const r=No(n);let a=r.bottom-r.top+1,l=r.right-r.left+1;if(s){const e=wi(s,this.locale);ch(vo("Height value is %(_height)s. It should be greater than or equal to 1.",{_height:e}),e),a=e}if(i){const e=wi(i,this.locale);ch(vo("Width value is %(_width)s. It should be greater than or equal to 1.",{_width:e}),e),l=e}const{sheetName:c}=Oo(n),h=c&&this.getters.getSheetIdByName(c)||this.getters.getActiveSheetId(),d=wi(t,this.locale),u=wi(o,this.locale),g=this.__originCellPosition;g&&this.updateDependencies?.(g);const p=r.left+u,m=r.top+d;if(p<0||m<0)return new gi(vo("OFFSET evaluates to an out of bounds range."));const f={left:p,top:m,right:p+l-1,bottom:m+a-1},v=this.getters.getRangeFromZone(this.__originSheetId,f);return v.invalidXc||v.invalidSheetName?new gi:(g&&this.addDependencies?.(g,[v]),$i(l,a,((e,t)=>this.getters.getEvaluatedCell({sheetId:h,col:p+e,row:m+t}))))}};var rv=Object.freeze({__proto__:null,ADDRESS:$f,COLUMN:Gf,COLUMNS:Wf,HLOOKUP:qf,INDEX:Zf,INDIRECT:jf,LOOKUP:Yf,MATCH:Xf,OFFSET:nv,PIVOT:iv,PIVOT_HEADER:sv,PIVOT_VALUE:ov,ROW:Kf,ROWS:Qf,VLOOKUP:Jf,XLOOKUP:tv});const av={description:vo("Sum of two numbers."),args:[nh("value1 (number)",vo("The first addend.")),nh("value2 (number)",vo("The second addend."))],compute:function(e,t){return{value:wi(e,this.locale)+wi(t,this.locale),format:e?.format||t?.format}}},lv={description:vo("Concatenation of two values."),args:[nh("value1 (string)",vo("The value to which value2 will be appended.")),nh("value2 (string)",vo("The value to append to value1."))],compute:function(e,t){return Di(e)+Di(t)},isExported:!0},cv={description:vo("One number divided by another."),args:[nh("dividend (number)",vo("The number to be divided.")),nh("divisor (number)",vo("The number to divide by."))],compute:function(e,t){const o=wi(t,this.locale);return bi((()=>0!==o),vo("The divisor must be different from zero."),ci.DivisionByZero),{value:wi(e,this.locale)/o,format:e?.format||t?.format}}};function hv(e){return void 0===e||null===e.value}const dv={number:0,string:"",boolean:!1},uv={description:vo("Equal."),args:[nh("value1 (string, number, boolean)",vo("The first value.")),nh("value2 (string, number, boolean)",vo("The value to test against value1 for equality."))],compute:function(e,t){let o=hv(e)?dv[typeof t?.value]:e?.value,s=hv(t)?dv[typeof e?.value]:t?.value;return"string"==typeof o&&(o=o.toUpperCase()),"string"==typeof s&&(s=s.toUpperCase()),o===s}};function gv(e,t,o){let s=hv(e)?dv[typeof t?.value]:e?.value,i=hv(t)?dv[typeof e?.value]:t?.value;if(yi(s))throw e;if(yi(i))throw t;"number"!=typeof s&&(s=Di(s).toUpperCase()),"number"!=typeof i&&(i=Di(i).toUpperCase());const n=typeof s,r=typeof i;return"string"===n&&"number"===r||("string"!==r||"number"!==n)&&o(s,i)}const pv={description:vo("Strictly greater than."),args:[nh("value1 (number, string, boolean)",vo("The value to test as being greater than value2.")),nh("value2 (number, string, boolean)",vo("The second value."))],compute:function(e,t){return gv(e,t,((e,t)=>e>t))}},mv={description:vo("Greater than or equal to."),args:[nh("value1 (number, string, boolean)",vo("The value to test as being greater than or equal to value2.")),nh("value2 (number, string, boolean)",vo("The second value."))],compute:function(e,t){return gv(e,t,((e,t)=>e>=t))}},fv={description:vo("Less than."),args:[nh("value1 (number, string, boolean)",vo("The value to test as being less than value2.")),nh("value2 (number, string, boolean)",vo("The second value."))],compute:function(e,t){return!mv.compute.bind(this)(e,t)}},vv={description:vo("Less than or equal to."),args:[nh("value1 (number, string, boolean)",vo("The value to test as being less than or equal to value2.")),nh("value2 (number, string, boolean)",vo("The second value."))],compute:function(e,t){return!pv.compute.bind(this)(e,t)}},bv={description:vo("Difference of two numbers."),args:[nh("value1 (number)",vo("The minuend, or number to be subtracted from.")),nh("value2 (number)",vo("The subtrahend, or number to subtract from value1."))],compute:function(e,t){return{value:wi(e,this.locale)-wi(t,this.locale),format:e?.format||t?.format}}},Sv={description:vo("Product of two numbers"),args:[nh("factor1 (number)",vo("The first multiplicand.")),nh("factor2 (number)",vo("The second multiplicand."))],compute:function(e,t){return{value:wi(e,this.locale)*wi(t,this.locale),format:e?.format||t?.format}}},yv={description:vo("Not equal."),args:[nh("value1 (string, number, boolean)",vo("The first value.")),nh("value2 (string, number, boolean)",vo("The value to test against value1 for inequality."))],compute:function(e,t){return!uv.compute.bind(this)(e,t)}},Cv={description:vo("A number raised to a power."),args:[nh("base (number)",vo("The number to raise to the exponent power.")),nh("exponent (number)",vo("The exponent to raise base to."))],compute:function(e,t){return Rd.compute.bind(this)(e,t)}},wv={description:vo("A number with the sign reversed."),args:[nh("value (number)",vo("The number to have its sign reversed. Equivalently, the number to multiply by -1."))],compute:function(e){return{value:-wi(e,this.locale),format:e?.format}}},Ev={description:vo("Value interpreted as a percentage."),args:[nh("percentage (number)",vo("The value to interpret as a percentage."))],compute:function(e){return wi(e,this.locale)/100}},xv={description:vo("A specified number, unchanged."),args:[nh("value (any)",vo("The number to return."))],compute:function(e={value:null}){return e}};var Iv=Object.freeze({__proto__:null,ADD:av,CONCAT:lv,DIVIDE:cv,EQ:uv,GT:pv,GTE:mv,LT:fv,LTE:vv,MINUS:bv,MULTIPLY:Sv,NE:yv,POW:Cv,UMINUS:wv,UNARY_PERCENT:Ev,UPLUS:xv});const Rv=e=>({transform:t=>t*e,inverseTransform:t=>t/e}),Tv={transform:e=>e,inverseTransform:e=>e},Av=1e-10,_v=.0254,Dv=_v/72,Ov=.3048,Fv=.9144,Mv=1609.34,Nv=1852,Pv=946073047258e4,kv={g:{...Tv,category:"weight"},u:{...Rv(166053e-29),category:"weight"},grain:{...Rv(.0647989),category:"weight"},ozm:{...Rv(28.3495),category:"weight"},lbm:{...Rv(453.592),category:"weight"},stone:{...Rv(6350.29),category:"weight"},sg:{...Rv(14593.90294),category:"weight"},cwt:{...Rv(45359.237),category:"weight"},uk_cwt:{...Rv(50802.3),category:"weight"},ton:{...Rv(907184.74),category:"weight"},uk_ton:{...Rv(1016046.9),category:"weight"},m:{...Tv,category:"distance"},km:{...Rv(1e3),category:"distance"},ang:{...Rv(Av),category:"distance"},Picapt:{...Rv(Dv),category:"distance"},pica:{...Rv(_v/6),category:"distance"},in:{...Rv(_v),category:"distance"},ft:{...Rv(Ov),category:"distance"},yd:{...Rv(Fv),category:"distance"},ell:{...Rv(1.143),category:"distance"},mi:{...Rv(Mv),category:"distance"},survey_mi:{...Rv(1609.34),category:"distance"},Nmi:{...Rv(Nv),category:"distance"},ly:{...Rv(Pv),category:"distance"},parsec:{...Rv(0x6da012f95c9fd0),category:"distance"},sec:{...Tv,category:"time"},min:{...Rv(60),category:"time"},hr:{...Rv(3600),category:"time"},day:{...Rv(86400),category:"time"},yr:{...Rv(31556952),category:"time"},Pa:{...Tv,category:"pressure"},bar:{...Rv(1e5),category:"pressure"},mmHg:{...Rv(133.322),category:"pressure"},Torr:{...Rv(133.322),category:"pressure"},psi:{...Rv(6894.76),category:"pressure"},atm:{...Rv(101325),category:"pressure"},N:{...Tv,category:"force"},dyn:{...Rv(1e-5),category:"force"},pond:{...Rv(.00980665),category:"force"},lbf:{...Rv(4.44822),category:"force"},J:{...Tv,category:"energy"},eV:{...Rv(160218e-24),category:"energy"},e:{...Rv(1e-7),category:"energy"},flb:{...Rv(1.3558179483),category:"energy"},c:{...Rv(4.184),category:"energy"},cal:{...Rv(4.1868),category:"energy"},BTU:{...Rv(1055.06),category:"energy"},Wh:{...Rv(3600),category:"energy"},HPh:{...Rv(2684520),category:"energy"},W:{...Tv,category:"power"},PS:{...Rv(735.499),category:"power"},HP:{...Rv(745.7),category:"power"},T:{...Tv,category:"magnetism"},ga:{...Rv(1e-4),category:"magnetism"},K:{...Tv,category:"temperature"},C:{transform:e=>e+273.15,inverseTransform:e=>e-273.15,category:"temperature"},F:{transform:e=>5*(e-32)/9+273.15,inverseTransform:e=>9*(e-273.15)/5+32,category:"temperature"},Rank:{...Rv(5/9),category:"temperature"},Reau:{transform:e=>1.25*e+273.15,inverseTransform:e=>(e-273.15)/1.25,category:"temperature"},"m^3":{...Tv,category:"volume",order:3},"ang^3":{...Rv(Math.pow(Av,3)),category:"volume",order:3},"Picapt^3":{...Rv(Math.pow(Dv,3)),category:"volume",order:3},tsp:{...Rv(492892e-11),category:"volume"},tspm:{...Rv(5e-6),category:"volume"},tbs:{...Rv(14786764825785619e-21),category:"volume"},"in^3":{...Rv(Math.pow(_v,3)),category:"volume",order:3},oz:{...Rv(295735295625e-16),category:"volume"},cup:{...Rv(237e-6),category:"volume"},pt:{...Rv(.0004731765),category:"volume"},uk_pt:{...Rv(568261e-9),category:"volume"},qt:{...Rv(.0009463529),category:"volume"},l:{...Rv(.001),category:"volume"},uk_qt:{...Rv(.0011365225),category:"volume"},gal:{...Rv(.0037854118),category:"volume"},uk_gal:{...Rv(.00454609),category:"volume"},"ft^3":{...Rv(Math.pow(Ov,3)),category:"volume",order:3},bushel:{...Rv(.0352390704),category:"volume"},barrel:{...Rv(.158987295),category:"volume"},"yd^3":{...Rv(Math.pow(Fv,3)),category:"volume",order:3},MTON:{...Rv(1.13267386368),category:"volume"},GRT:{...Rv(2.83168),category:"volume"},"mi^3":{...Rv(Math.pow(Mv,3)),category:"volume",order:3},"Nmi^3":{...Rv(Math.pow(Nv,3)),category:"volume",order:3},"ly^3":{...Rv(Math.pow(Pv,3)),category:"volume",order:3},"m^2":{...Tv,category:"area",order:2},"ang^2":{...Rv(Math.pow(Av,2)),category:"area",order:2},"Picapt^2":{...Rv(Math.pow(Dv,2)),category:"area",order:2},"in^2":{...Rv(Math.pow(_v,2)),category:"area",order:2},"ft^2":{...Rv(Math.pow(Ov,2)),category:"area",order:2},"yd^2":{...Rv(Math.pow(Fv,2)),category:"area",order:2},ar:{...Rv(100),category:"area"},Morgen:{...Rv(2500),category:"area"},uk_acre:{...Rv(4046.8564224),category:"area"},us_acre:{...Rv(4046.8726098743),category:"area"},ha:{...Rv(1e4),category:"area"},"mi^2":{...Rv(Math.pow(Mv,2)),category:"area",order:2},"Nmi^2":{...Rv(Math.pow(Nv,2)),category:"area",order:2},"ly^2":{...Rv(Math.pow(Pv,2)),category:"area",order:2},bit:{...Tv,category:"information"},byte:{...Rv(8),category:"information"},"m/s":{...Tv,category:"speed"},"m/hr":{...Rv(1/3600),category:"speed"},"km/hr":{...Rv(1/3.6),category:"speed"},mph:{...Rv(.44704),category:"speed"},kn:{...Rv(.5144444444),category:"speed"},admkn:{...Rv(.5147733333),category:"speed"}},Lv={shweight:"cwt",lcwt:"uk_cwt",hweight:"uk_cwt",LTON:"uk_ton",brton:"uk_ton",pc:"parsec",Pica:"Picapt",d:"day",mn:"min",s:"sec",p:"Pa",at:"atm",dy:"dyn",ev:"eV",hh:"HPh",wh:"Wh",btu:"BTU",h:"HP",cel:"C",fah:"F",kel:"K",us_pt:"pt",L:"l",lt:"l",ang3:"ang^3",ft3:"ft^3",in3:"in^3",ly3:"ly^3",m3:"m^3",mi3:"mi^3",yd3:"yd^3",Nmi3:"Nmi^3",Picapt3:"Picapt^3","Pica^3":"Picapt^3",Pica3:"Picapt^3",regton:"GRT",ang2:"ang^2",ft2:"ft^2",in2:"in^2",ly2:"ly^2",m2:"m^2",mi2:"mi^2",Nmi2:"Nmi^2",Picapt2:"Picapt^2","Pica^2":"Picapt^2",Pica2:"Picapt^2",yd2:"yd^2","m/h":"m/hr","m/sec":"m/s"},Vv={"":1,Y:1e24,Z:1e21,E:1e18,P:1e15,T:1e12,G:1e9,M:1e6,k:1e3,h:100,da:10,e:10,d:.1,c:.01,m:.001,u:1e-6,n:1e-9,p:1e-12,f:1e-15,a:1e-18,z:1e-21,y:1e-21,Yi:Math.pow(2,80),Zi:Math.pow(2,70),Ei:Math.pow(2,60),Pi:Math.pow(2,50),Ti:Math.pow(2,40),Gi:Math.pow(2,30),Mi:Math.pow(2,20),ki:Math.pow(2,10)},Uv={weight:vo("Weight"),distance:vo("Distance"),time:vo("Time"),pressure:vo("Pressure"),force:vo("Force"),energy:vo("Energy"),power:vo("Power"),magnetism:vo("Magnetism"),temperature:vo("Temperature"),volume:vo("Volume"),area:vo("Area"),information:vo("Information"),speed:vo("Speed")};function Hv(e){return Uv[e]??""}function Bv(e){for(const[t,o]of Object.entries(Vv)){if(t&&!e.startsWith(t))continue;const s=e.slice(t.length);let i=kv[s];if(!i&&Lv[s]&&(i=kv[Lv[s]]),i)return{...i,factor:i.order?Math.pow(o,i.order):o}}}const zv={description:vo("Converts a numeric value to a different unit of measure."),args:[nh("value (number)",vo("the numeric value in start_unit to convert to end_unit")),nh("start_unit (string)",vo("The starting unit, the unit currently assigned to value")),nh("end_unit (string)",vo("The unit of measure into which to convert value"))],compute:function(e,t,o){const s=wi(e,this.locale),i=Di(t),n=Di(o),r=Bv(i),a=Bv(n);return r?a?r.category!==a.category?{value:ci.GenericError,message:vo("Incompatible units of measure ('%s' vs '%s')",Hv(r.category),Hv(a.category))}:{value:a.inverseTransform(r.factor*r.transform(s))/a.factor,format:e?.format}:{value:ci.GenericError,message:vo("Invalid units of measure ('%s')",n)}:{value:ci.GenericError,message:vo("Invalid units of measure ('%s')",i)}},isExported:!0};var $v=Object.freeze({__proto__:null,CONVERT:zv});const Gv=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,Wv={description:vo("Gets character associated with number."),args:[nh("table_number (number)",vo("The number of the character to look up from the current Unicode table in decimal format."))],compute:function(e){const t=Math.trunc(wi(e,this.locale));return bi((()=>t>=1),vo("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},qv={description:vo("Remove non-printable characters from a piece of text."),args:[nh("text (string)",vo("The text whose non-printable characters are to be removed."))],compute:function(e){const t=Di(e);let o="";for(const e of t)e&&e.charCodeAt(0)>31&&(o+=e);return o},isExported:!0},Zv={description:vo("Appends strings to one another."),args:[nh("string1 (string, range<string>)",vo("The initial string.")),nh("string2 (string, range<string>, repeating)",vo("More strings to append in sequence."))],compute:function(...e){return Hi(e,((e,t)=>e+Di(t)),"")},isExported:!0},jv={description:vo("Tests whether two strings are identical."),args:[nh("string1 (string)",vo("The first string to compare.")),nh("string2 (string)",vo("The second string to compare."))],compute:function(e,t){return Di(e)===Di(t)},isExported:!0},Yv={description:vo("First position of string found in text, case-sensitive."),args:[nh("search_for (string)",vo("The string to look for within text_to_search.")),nh("text_to_search (string)",vo("The text to search for the first occurrence of search_for.")),nh("starting_at (number, default=1)",vo("The character within text_to_search at which to start the search."))],compute:function(e,t,o={value:1}){const s=Di(e),i=Di(t),n=wi(o,this.locale);bi((()=>""!==i),vo("The text_to_search must be non-empty.")),bi((()=>n>=1),vo("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const r=i.indexOf(s,n-1);return bi((()=>r>=0),vo("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",s.toString(),i)),r+1},isExported:!0},Xv={description:vo("Concatenates elements of arrays with delimiter."),args:[nh("delimiter (string)",vo("The character or string to place between each concatenated value.")),nh("value_or_array1 (string, range<string>)",vo("The value or values to be appended using delimiter.")),nh("value_or_array2 (string, range<string>, repeating)",vo("More values to be appended using delimiter."))],compute:function(e,...t){const o=Di(e);return Hi(t,((e,t)=>(e?e+o:"")+Di(t)),"")}},Kv={description:vo("Substring from beginning of specified string."),args:[nh("text (string)",vo("The string from which the left portion will be returned.")),nh("number_of_characters (number, optional)",vo("The number of characters to return from the left side of string."))],compute:function(e,...t){const o=t.length?wi(t[0],this.locale):1;return bi((()=>o>=0),vo("The number_of_characters (%s) must be positive or null.",o.toString())),Di(e).substring(0,o)},isExported:!0},Qv={description:vo("Length of a string."),args:[nh("text (string)",vo("The string whose length will be returned."))],compute:function(e){return Di(e).length},isExported:!0},Jv={description:vo("Converts a specified string to lowercase."),args:[nh("text (string)",vo("The string to convert to lowercase."))],compute:function(e){return Di(e).toLowerCase()},isExported:!0},eb={description:vo("A segment of a string."),args:[nh("text (string)",vo("The string to extract a segment from.")),nh("starting_at (number)",vo("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),nh("extract_length (number)",vo("The length of the segment to extract."))],compute:function(e,t,o){const s=Di(e),i=wi(t,this.locale),n=wi(o,this.locale);return bi((()=>i>=1),vo("The starting_at argument (%s) must be positive greater than one.",i.toString())),bi((()=>n>=0),vo("The extract_length argument (%s) must be positive or null.",n.toString())),s.slice(i-1,i+n-1)},isExported:!0},tb={description:vo("Capitalizes each word in a specified string."),args:[nh("text_to_capitalize (string)",vo("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase."))],compute:function(e){return Di(e).replace(Gv,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},ob={description:vo("Replaces part of a text string with different text."),args:[nh("text (string)",vo("The text, a part of which will be replaced.")),nh("position (number)",vo("The position where the replacement will begin (starting from 1).")),nh("length (number)",vo("The number of characters in the text to be replaced.")),nh("new_text (string)",vo("The text which will be inserted into the original text."))],compute:function(e,t,o,s){const i=wi(t,this.locale);bi((()=>i>=1),vo("The position (%s) must be greater than or equal to 1.",i.toString()));const n=Di(e),r=wi(o,this.locale),a=Di(s);return n.substring(0,i-1)+a+n.substring(i-1+r)},isExported:!0},sb={description:vo("A substring from the end of a specified string."),args:[nh("text (string)",vo("The string from which the right portion will be returned.")),nh("number_of_characters (number, optional)",vo("The number of characters to return from the right side of string."))],compute:function(e,...t){const o=t.length?wi(t[0],this.locale):1;bi((()=>o>=0),vo("The number_of_characters (%s) must be positive or null.",o.toString()));const s=Di(e),i=s.length;return s.substring(i-o,i)},isExported:!0},ib={description:vo("First position of string found in text, ignoring case."),args:[nh("search_for (string)",vo("The string to look for within text_to_search.")),nh("text_to_search (string)",vo("The text to search for the first occurrence of search_for.")),nh("starting_at (number, default=1)",vo("The character within text_to_search at which to start the search."))],compute:function(e,t,o={value:1}){const s=Di(e).toLowerCase(),i=Di(t).toLowerCase(),n=wi(o,this.locale);bi((()=>""!==i),vo("The text_to_search must be non-empty.")),bi((()=>n>=1),vo("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const r=i.indexOf(s,n-1);return bi((()=>r>=0),vo("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",s,i)),r+1},isExported:!0},nb={description:vo("Split text by specific character delimiter(s)."),args:[nh("text (string)",vo("The text to divide.")),nh("delimiter (string)",vo("The character or characters to use to split text.")),nh("split_by_each (boolean, default=true})",vo("Whether or not to divide text around each character contained in delimiter.")),nh("remove_empty_text (boolean, default=true)",vo("Whether or not to remove empty text messages from the split results. The default behavior is to treat consecutive delimiters as one (if TRUE). If FALSE, empty cells values are added between consecutive delimiters."))],compute:function(e,t,o={value:true},s={value:true}){const i=Di(e),n=Ne(Di(t)),r=Mi(o),a=Mi(s);bi((()=>n.length>0),vo("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))),Wi([c])},isExported:!0},rb={description:vo("Replaces existing text with new text in a string."),args:[nh("text_to_search (string)",vo("The text within which to search and replace.")),nh("search_for (string)",vo("The string to search for within text_to_search.")),nh("replace_with (string)",vo("The string that will replace search_for.")),nh("occurrence_number (number, optional)",vo("The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced."))],compute:function(e,t,o,s){const i=wi(s,this.locale);bi((()=>i>=0),vo("The occurrenceNumber (%s) must be positive or null.",i.toString()));const n=Di(e),r=Di(t);if(""===r)return n;const a=Di(o),l=new RegExp(Ne(r),"g");if(0===i)return n.replace(l,a);let c=0;return n.replace(l,(e=>++c===i?a:e))},isExported:!0},ab={description:vo("Combines text from multiple strings and/or arrays."),args:[nh("delimiter (string)",vo(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")),nh("ignore_empty (boolean)",vo("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")),nh("text1 (string, range<string>)",vo("Any text item. This could be a string, or an array of strings in a range.")),nh("text2 (string, range<string>, repeating)",vo("Additional text item(s)."))],compute:function(e,t,...o){const s=Di(e),i=Mi(t);let n=0;return Hi(o,((e,t)=>i&&""===Di(t)?e:(n++?e+s:"")+Di(t)),"")},isExported:!0},lb={description:vo("Removes space characters."),args:[nh("text (string)",vo("The text or reference to a cell containing text to be trimmed."))],compute:function(e){return Ct(Di(e))},isExported:!0},cb={description:vo("Converts a specified string to uppercase."),args:[nh("text (string)",vo("The string to convert to uppercase."))],compute:function(e){return Di(e).toUpperCase()},isExported:!0},hb={description:vo("Converts a number to text according to a specified format."),args:[nh("number (number)",vo("The number, date or time to format.")),nh("format (string)",vo("The pattern by which to format the number, enclosed in quotation marks."))],compute:function(e,t){return kn(wi(e,this.locale),{format:Di(t),locale:this.locale})},isExported:!0},db={description:vo("Converts a string to a numeric value."),args:[nh("value (number)",vo("the string to be converted"))],compute:function(e){return wi(e,this.locale)},isExported:!0};var ub=Object.freeze({__proto__:null,CHAR:Wv,CLEAN:qv,CONCATENATE:Zv,EXACT:jv,FIND:Yv,JOIN:Xv,LEFT:Kv,LEN:Qv,LOWER:Jv,MID:eb,PROPER:tb,REPLACE:ob,RIGHT:sb,SEARCH:ib,SPLIT:nb,SUBSTITUTE:rb,TEXT:hb,TEXTJOIN:ab,TRIM:lb,UPPER:cb,VALUE:db});const gb={description:vo("Creates a hyperlink in a cell."),args:[nh("url (string)",vo("The full URL of the link enclosed in quotation marks.")),nh("link_label (string, optional)",vo("The text to display in the cell, enclosed in quotation marks."))],compute:function(e,t){const o=Di(e).trim(),s=Di(t)||o;return""===o?s:Ye(s,o)},isExported:!0};var pb=Object.freeze({__proto__:null,HYPERLINK:gb});const mb=[{name:vo("Array"),functions:Ph},{name:vo("Database"),functions:vg},{name:vo("Date"),functions:Qg},{name:vo("Filter"),functions:cp},{name:vo("Financial"),functions:Um},{name:vo("Info"),functions:Rf},{name:vo("Lookup"),functions:rv},{name:vo("Logical"),functions:Lf},{name:vo("Math"),functions:jd},{name:vo("Misc"),functions:Lh},{name:vo("Operator"),functions:Iv},{name:vo("Statistical"),functions:og},{name:vo("Text"),functions:ub},{name:vo("Engineering"),functions:ep},{name:vo("Web"),functions:pb},{name:vo("Parser"),functions:$v}],fb=/^[A-Z0-9\_\.]+$/;const vb=new class extends n{mapping={};add(e,t){if(e=e.toUpperCase(),!fb.test(e))throw new Error(vo("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const o=rh(t);return function(e){let t=!1,o=!1,s=!1;for(let i of e){if(i.type.includes("META")&&i.type.length>1)throw new Error(vo("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(vo("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(vo("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=i.repeating,o=i.optional,s=i.default}}(o.args),this.mapping[e]=function(e,t){function o(...o){let i,n=1,r=1,a=1/0,l=1/0;for(let s=0;s<o.length;s++){const c=e.args[e.getArgToFocus(s+1)-1],h=o[s];if(ni(h)&&!c.acceptMatrix){const e=h.length,t=h[0].length;1!==e||1!==t?(i??=new Array(o.length),1!==e&&1!==t?(i[s]="matrix",n=Math.max(n,e),r=Math.max(r,t),a=Math.min(a,e),l=Math.min(l,t)):1!==e?(i[s]="horizontal",n=Math.max(n,e),a=Math.min(a,e)):1!==t&&(i[s]="vertical",r=Math.max(r,t),l=Math.min(l,t))):o[s]=h[0][0]}if(!ni(h)&&c.acceptMatrixOnly)throw new ui(vo("Function %s expects the parameter '%s' to be reference to a cell or range.",t,(s+1).toString()))}if(1===n&&1===r)return s.apply(this,o);const c=(e,t)=>o.map(((o,s)=>{switch(i?.[s]){case"matrix":return o[e][t];case"horizontal":return o[e][0];case"vertical":return o[0][t];case void 0:return o}}));return $i(n,r,((e,t)=>{if(e>a-1||t>l-1)return bb;const o=s.apply(this,c(e,t));return ni(o)?o[0][0]:o}))}function s(...o){for(let t=0;t<o.length;t++){const s=o[t];if(!e.args[e.getArgToFocus(t+1)-1].acceptErrors&&!ni(s)&&yi(s?.value))return s}try{return i.apply(this,o)}catch(e){return Sb(e,t)}}function i(...o){const s=e.compute.apply(this,o);return ni(s)?"object"==typeof s[0][0]&&null!==s[0][0]&&"value"in s[0][0]?(function(e,t){const o=e.length,s=e[0]?.length??0;for(let i=0;i<o;i++)for(let o=0;o<s;o++)t(e[i][o])}(s,(e=>yb(e,t))),s):Gi(s,(e=>({value:e}))):"object"==typeof s&&null!==s&&"value"in s?(yb(s,t),s):{value:s}}return o}(o,e),super.add(e,o),this}};for(let e of mb){const t=e.functions;for(let o in t){const s=t[o];s.category=s.category||e.name,o=o.replace(/_/g,"."),vb.add(o,{isExported:!1,...s})}}const bb=new pi(vo("Array arguments to [[FUNCTION_NAME]] are of different size."));function Sb(e,t){return o=e,void 0!==o?.value&&"string"==typeof o.value&&yi(e.value)?(wb(e)&&yb(e,t),e):(console.error(e),new di(Cb+(wb(e)?" "+e.message:"")));var o}function yb(e,t){e.message?.includes("[[FUNCTION_NAME]]")&&(e.message=e.message.replace("[[FUNCTION_NAME]]",t))}const Cb=vo("An unexpected error occurred. Submit a support ticket at odoo.com/help.");function wb(e){return void 0!==e?.message&&"string"==typeof e.message}th.add("functions",{sequence:100,autoSelectFirstProposal:!0,maxDisplayedProposals:10,getProposals(e){if("SYMBOL"!==e.type)return[];const t=e.value;if(!this.composer.currentContent.startsWith("="))return[];const o=Object.entries(vb.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:o}])=>({text:e,description:o,htmlContent:oh(t,e,I,"o-semi-bold")}))).sort(((e,t)=>e.text.length-t.text.length||e.text.localeCompare(t.text)));return o},selectProposal(e,t){let o=e.end,s=e.end;["SYMBOL","FUNCTION"].includes(e.type)&&(o=e.start);const i=this.composer.currentTokens;t+="(";const n=i.map((e=>e.start)).indexOf(e.start);if(n+1<i.length){const e=i[n+1];"LEFT_PAREN"===e?.type&&s++}this.composer.changeComposerCursorSelection(o,s),this.composer.replaceComposerCursorSelection(t)}});class Eb{mutators=["setFocusableElement"];focusableElement=void 0;setFocusableElement(e){this.focusableElement=e}}const xb={};let Ib=0;function Rb(e,...t){const o="__sheet__"+Ib++;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),xb[e]=o}(o,String.raw(e,...t)),function(e){const t=xb[e];t.setAttribute("component",e),document.head.appendChild(t)}(o),o}function Tb({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function Ab(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 _b(e){let t="";for(const o in e)e[o]&&(t+=`${o}:${e[o]}; `);return t}const Db=/Mac/i,Ob=["Shift","Control","Alt","Meta"];function Fb(e,t){return!!e&&(!!t.target&&e.contains(t.target))}function Mb(){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 Nb(e){const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}function*Pb(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*Pb(t)}const kb=/^[a-zA-Z]$/;function Lb(e,t="key"){let o="";Ob.includes(e.key)||(Ub(e)&&(o+="Ctrl+"),e.altKey&&(o+="Alt+"),e.shiftKey&&(o+="Shift+"));const s="key"===t?e.key:e.code;return o+=kb.test(s)?s.toUpperCase():s,o}function Vb(){return Boolean(Db.test(navigator.userAgent))}function Ub(e){return Vb()?e.metaKey:e.ctrlKey}function Hb(){const e=t.useState({x:0,y:0,width:0,height:0});let o=null;function s(){if(o||(o=document.querySelector(".o-spreadsheet")),o){const{top:t,left:s,width:i,height:n}=o.getBoundingClientRect();e.x=s,e.y=t,e.width=i,e.height=n}}return t.onMounted(s),t.onPatched(s),e}function Bb(e){const o=t.useState({x:0,y:0,width:0,height:0});function s(){const t=e.el;if(null===t)return;const{top:s,left:i,width:n,height:r}=t.getBoundingClientRect();o.x=i,o.y=s,o.width=n,o.height=r}return t.onMounted(s),t.onPatched(s),o}const zb={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"};function $b(e,t){const o=zb[e.key];e.shiftKey?t.resizeAnchorZone(o,Ub(e)?"end":1):t.moveAnchorCell(o,Ub(e)?"end":1)}Rb`
1
+ !function(e,t){"use strict";function o(e){return e.map(i).sort(((e,t)=>e.sequence-t.sequence))}let s=1;function i(e){const t=e.name,o=e.children,n=e.description,r=e.icon,a=e.secondaryIcon;return{id:(e.id||s++).toString(),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(i):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:"function"==typeof r?r:()=>r||"",iconColor:e.iconColor,secondaryIcon:"function"==typeof a?a:()=>a||"",description:"function"==typeof n?n:()=>n||"",textColor:e.textColor,sequence:e.sequence||0,onStartHover:e.onStartHover,onStopHover:e.onStopHover}}class n{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]}}const r=.5,a="#37A850",l="#f5f5f5",c="#F8F9FA",h="#E8EAED",d="#595959",u="#666666",g="#c9ccd2",p="#3266ca",m="#FFFFFF",f="#CACACA",v=11982760,b="#017E84",S="#188038",y="#E0E2E4",C="#4A4F59",w="#999",E="#E2E3E3",x="#BCBCBC",I="#9B359B",R="#4EA7F2",T="#EA6175",A="#AAAAAA",_="#111827",D="#D8DADD",O="#E7E9ED",F="#F9FAFB",M="#374151",N=M+"C2",P="#111827",k="#714B67",L=O,V=D,U="#111827",H="#e6f2f3",B="#111827",z="#017E84",$="#D44C591A",G="#C34A41",W="#E6F2F3",q=20,Z=22,j=["#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"],Y=26,X=48,K=96,Q=23,J=15,ee=4,te=ee,oe=21,se=17,ie=2*Q,ne=250,re={align:"left",verticalAlign:"bottom",wrapping:"overflow",bold:!1,italic:!1,strikethrough:!1,underline:!1,fontSize:10,fillColor:"",textColor:""},ae=re.verticalAlign,le=re.wrapping,ce="400",he=re.fontSize,de="'Roboto', arial",ue="thin",ge="#000000",pe="START_REVISION",me=1,fe=20,ve="??",be="difference",Se="#43C5B1",ye="#EA6175",Ce=.4,we=["'","*","?","/","\\","[","]"],Ee=/'|\*|\?|\/|\\|\[|\]/,xe="|";var Ie;!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"}(Ie||(Ie={}));let Re=0;function Te(){return Re}const Ae="\n",_e=[6,7,8,9,10,11,12,14,18,24,36],De={hasFilters:!1,totalRow:!1,firstColumn:!0,lastColumn:!1,numberOfHeaders:1,bandedRows:!0,bandedColumns:!1,styleId:"TableStyleMedium5",automaticAutofill:!1},Oe={symbol:"$",position:"before",decimalPlaces:2,code:"",name:"Dollar"},Fe=new RegExp(Ee,"g");function Me(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function Ne(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pe(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&&null!==e&&(e?.constructor===Object||void 0===e?.constructor)}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");for(const o in e)t[o]=Pe(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 ke(e){return Le(e,"'")}function Le(e,t='"'){return e.startsWith(t)&&(e=e.slice(1)),e.endsWith(t)&&(e=e.slice(0,-1)),e}function Ve(e){return e.match(/\w/g)?.length!==e.length&&(e=`'${e}'`),e}function Ue(e,t=" "){return e.replace(Fe,t)}function He(e,t,o){return e<t?t:e>o?o:e}function Be(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 ze(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*$e(e,t){t.next();for(const o of e){const e=t.next();yield{...o,next:e.done?void 0:e.value}}}function Ge(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}const We=/^\[(.+)\]\((.+)\)$/,qe=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function Ze(e){return We.test(e)}function je(e){return qe.test(e)}function Ye(e,t){return`[${e}](${t})`}function Xe(e){const t=e.match(We)||[],o=t[1],s=t[2];if(!o||!s)throw new Error(`Could not parse markdown link ${e}.`);return{label:o,url:s}}const Ke="o-spreadsheet://";function Qe(e){return e.startsWith(Ke)}function Je(e){return`${Ke}${e}`}function et(e){if(e.startsWith(Ke))return e.substr(Ke.length);throw new Error(`${e} is not a valid sheet link`)}function tt(e){return void 0!==e}function ot(e){return null!==e}function st(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?st(e):!e))}function it(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 nt(e){let t="";for(let o=0,s=e.length;o<s;o++)t+=e[o];return t}function rt(e){let t,o=!1;const s=()=>(o||(t=e instanceof Function?e():e,o=!0),t);return s.map=e=>rt((()=>e(s()))),s}function at(e,t){let o=e.slice(t).find((e=>e));return o||(o=e.slice(0,t).reverse().find((e=>e))),o||""}function lt(e,t){return"after"===e?t+1:t}function ct(e,t){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 o in e){if(typeof e[o]!=typeof t[o])return!1;if("object"==typeof e[o]){if(!ct(e[o],t[o]))return!1}else if(e[o]!==t[o])return!1}return!0}function ht(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(!ct(e[o],t[o]))return!1;return!0}function dt(e,t){if(e.length<t.length)return!1;const o=new Set(e);return t.every((e=>o.has(e)))}function ut(e){if(!e)return e;const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}const gt=[" ","\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))],pt=new RegExp(gt.join("|"),"g"),mt=/(\r\n|\r)/g;function ft(e){return e?e.replace(mt,Ae):""}function vt(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 bt(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 St(e,t){return e.filter(((e,o)=>!t.includes(o)))}function yt(e,t,o){const s=[...e];return s.splice(o,0,...t),s}function Ct(e){return e.split("\n").map((e=>e.replace(/\s+/g," ").trim())).join("\n")}function wt(e,t,o){return t>o?wt(e,o,t):e>=t&&e<=o}function Et(e,t){let o=Ne(e);const s=t.matchCase?"":"i";return t.exactMatch&&(o=`^${o}$`),RegExp(o,s)}function xt(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 It(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}class Rt{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 Tt(e,t=(e=>e)){const o=new Set;return e.filter((e=>{const s=t(e);return!o.has(s)&&(o.add(s),!0)}))}function At(e){const t={};for(const o in e)for(const s in e[o])t[s]||(t[s]={}),t[s][o]=e[o][s];return t}const _t=/rgba?\(|\s+|\)/gi,Dt=/^#([A-F\d]{2}){3,4}$/,Ot=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function Ft(e){return Mt(e.toString(16).padStart(6,"0"))}function Mt(e){let t=e;if(e.startsWith("rgb")?t=function(e){const t=e.replace(_t,"").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"#"+nt(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}`),!Dt.test(t))throw new Error(`invalid color input: ${e}`);return t}function Nt(e){try{return Mt(e),!0}catch(e){return!1}}const Pt=e=>e>=0&&e<=255;function kt(e,t,o,s=1){if(!Pt(e)||!Pt(t)||!Pt(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 Lt(e){let{r:t,g:o,b:s}=Ut(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 Vt(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 Ut(e){let t,o,s,i;if(7===(e=Mt(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 Ht(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 Bt(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 zt(e){return Vt(Ht(e))}function $t(e){return Bt(Ut(e))}function Gt(e,t){return 1===t?Mt(e).slice(0,7):Vt({...Ut(e),a:t})}function Wt(e,t){const o=$t(e);return 1===t?"#fff":(o.l=t*(100-o.l)+o.l,zt(o))}function qt(e,t){const o=$t(e);return 1===t?"#000":(o.l=o.l-t*o.l,zt(o))}const Zt=["#4EA7F2","#EA6175","#43C5B1","#F4A261","#8481DD","#FFD86D"],jt=["#4EA7F2","#3188E6","#43C5B1","#00A78D","#EA6175","#CE4257","#F4A261","#F48935","#8481DD","#5752D1","#FFD86D","#FFBC2C"],Yt=["#4EA7F2","#3188E6","#056BD9","#A76DBC","#7F4295","#6D2387","#EA6175","#CE4257","#982738","#43C5B1","#00A78D","#0E8270","#F4A261","#F48935","#BE5D10","#8481DD","#5752D1","#3A3580","#A4A8B6","#7E8290","#545B70","#FFD86D","#FFBC2C","#C08A16"],Xt=["#4EA7F2","#3188E6","#056BD9","#155193","#A76DBC","#7F4295","#6D2387","#4F1565","#EA6175","#CE4257","#982738","#791B29","#43C5B1","#00A78D","#0E8270","#105F53","#F4A261","#F48935","#BE5D10","#7D380D","#8481DD","#5752D1","#3A3580","#26235F","#A4A8B6","#7E8290","#545B70","#3F4250","#FFD86D","#FFBC2C","#C08A16","#936A12"];function Kt(e,t){return t[e%t.length]}function Qt(e){return e<=6?Zt:e<=12?jt:e<=24?Yt:Xt}class Jt{preferredColors;currentColorIndex=0;palette;constructor(e,t=[]){this.preferredColors=t,this.palette=Qt(e).filter((e=>!t.includes(e)))}next(){return this.preferredColors?.[this.currentColorIndex]?this.preferredColors[this.currentColorIndex++]:Kt(this.currentColorIndex++,this.palette)}}function eo(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):eo(Math.floor(e/26)-1)+eo(e%26)}function to(e){let t=0;const o=e.length;for(let s=0;s<o;s++){const o=e.charCodeAt(s);t=26*t+(o>=65&&o<=90?o-64:o-96)}return t-1}function oo(e){return e>="0"&&e<="9"}function so(e){let t="",o="",s=0;for("$"===(e=e.trim())[s]&&s++;s<e.length&&((i=e[s])>="A"&&i<="Z"||i>="a"&&i<="z");)t+=e[s++];var i;if(0===t.length||t.length>3)throw new Error(`Invalid cell description: ${e}`);for("$"===e[s]&&s++;s<e.length&&oo(e[s]);)o+=e[s++];if(s!==e.length||0===o.length||o.length>7)throw new Error(`Invalid cell description: ${e}`);const n=to(t),r=Number(o)-1;if(isNaN(r))throw new Error(`Invalid cell description: ${e}`);return{col:n,row:r}}function io(e,t,o={colFixed:!1,rowFixed:!1}){return(o.colFixed?"$":"")+eo(e)+(o.rowFixed?"$":"")+String(t+1)}function no(e,t=[]){if(e.length<=1&&0===t.length)return e;const o=[0],s=new Map([[0,[]]]);return ro(o,s,e,!1),ro(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 ro(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=ao(e,t,o,!0,0),a=ao(e,t,n,!1,r);for(let o=r;o<=a;o++){lo(t.get(e[o]),i,s)}co(e,t,r,a)}}function ao(e,t,o,s,i){if(void 0===o)return e.length-1;const n=ho(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 lo(e,t,o=!1){const s=t.top,i=void 0===t.bottom?void 0:t.bottom+1,n=[],r=ho(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 co(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--)ht(t.get(e[o]),t.get(e[o-1]))&&(t.delete(e[o]),e.splice(o,1))}function ho(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}const uo=e=>e,go=()=>!1;let po=uo,mo=go;function fo(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 vo=function(e,...t){return mo()?fo(po(e),...t):new bo(e,t)};class bo extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return mo()?fo(po(e),...this.values):fo(e,...this.values)}toString(){return this.valueOf()}}const So=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),yo=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),Co=new RegExp(/^\$?([A-Z]{1,3})+$/,"i"),wo=new RegExp(/^\$?([0-9]{1,7})+$/,"i"),Eo=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),xo=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),Io=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[So.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 Ro(e){return Eo.test(e)}function To(e){return xo.test(e)}function Ao(e){return Co.test(e)}function _o(e){return wo.test(e)}function Do(e){return yo.test(e)}function Oo(e){if(!e.includes("!"))return{xc:e};const t=e.split("!"),o=t.pop();return{sheetName:ke(t.join("!"))||void 0,xc:o}}function Fo(e,t){return void 0!==e?`${Ve(e)}!${t}`:t}function Mo(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(Ro(r))i=n=to(r),o=s=0,a=!0;else if(To(r))o=s=parseInt(r,10)-1,i=n=0,l=!0;else{const e=so(r);i=n=e.col,o=s=e.row,c=!0}if(t)if(Ro(t))n=to(t),a=!0;else if(To(t))s=parseInt(t,10)-1,l=!0;else{const e=so(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 No(e){const t=Mo(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function Po(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))&&(ko(e)&&e.top>=0&&e.left>=0)}function ko(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 Lo(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?`${io(s,t)}:${eo(i)}`:`${eo(s)}:${eo(i)}`;if(void 0===i&&void 0!==o)return 0!==s||n?`${io(s,t)}:${o+1}`:`${t+1}:${o+1}`;if(void 0!==o&&void 0!==i)return r?io(s,t):`${io(s,t)}:${io(i,o)}`;throw new Error(vo("Bad zone format"))}function Vo(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?Jo(e,n,"RESIZE",i):r<e[t]?Jo(e,n,"MOVE",i):{...e}}function Uo(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?Jo(e,n,"RESIZE",i):r<e[t]?Jo(e,n,"MOVE",i):{...e}}function Ho(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 Bo(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 zo(...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 $o(e,t){if(Wo(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 Go(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function Wo(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function qo(e,t,o){const{left:s,right:i,top:n,bottom:r}=o;return e>=s&&e<=i&&t>=n&&t<=r}function Zo(e,t){return Go(zo(t,e),t)}function jo(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function Yo(e){const{numberOfCols:t,numberOfRows:o}=jo(e);return 1===t||1===o}function Xo(e){const t={};for(const o of e)t[o.sheetId]??=[],t[o.sheetId].push(ts(o));for(const e in t)t[e]=no(t[e]);return t}function Ko(e){const t=[],{left:o,right:s,top:i,bottom:n}=Qo(e);for(const e of Be(o,s+1))for(const o of Be(i,n+1))t.push({col:e,row:o});return t}function Qo(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 Jo(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?!(ss(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 es(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 ts(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function os(e){return{...e,right:e.left,bottom:e.top}}function ss(e){return void 0===e.right}function is(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function ns(e){return e.length<2||1===no(e).length}function rs(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)=>{return e!==o&&(n=s,((i=t).right+1===n.left||i.left===n.right+1?i.top<=n.bottom&&i.top>=n.top||n.top<=i.bottom&&n.top>=i.top:(i.bottom+1===n.top||i.top===n.bottom+1)&&(i.left<=n.right&&i.left>=n.left||n.left<=i.right&&n.left>=i.left))||Wo(t,s));var i,n}));if(-1!==i){t[e]=zo(t[i],s),t.splice(i,1),o=!0;break}}}return t}function as(e,t){for(const o in t)if(ct(t[o],e))return parseInt(o,10);const o=Object.keys(t),s=0===o.length?0:xt(o.map((e=>parseInt(e,10))));return t[s+1]=e,s+1}function ls(e){const t={};for(const o in e){const s=no(e[o].map(ts));for(const e of s)t[Lo(e)]=Number(o)}return t}class cs{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 cs(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds())}static now(){const e=new Date;return new cs(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 hs=new cs(1899,11,30),ds=864e5,us=2e3,gs=cs.now().getFullYear(),ps=cs.now().getMonth(),ms=cs.fromTimestamp(0).getTime()-hs.getTime(),fs=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,vs=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,bs=/\/|-|\s/,Ss=/^(\d{1,4})[\/-\s](\d{1,4})([\/-\s](\d{1,4}))?$/,ys=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function Cs(e,t){switch(typeof e){case"number":return e;case"string":return ws(e,t)?xs(e,t)?.value:!e||isNaN(Number(e))?void 0:Number(e);default:return}}function ws(e,t){return null!==xs(e,t)}const Es=new Map;function xs(e,t){return Es.has(t)||Es.set(t,new Map),Es.get(t).has(e)||Es.get(t).set(e,function(e,t){e=e.trim();let o=null;const s=e.match(ys);if(s){if(o=function(e){if(e=e.trim(),ys.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 cs(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(Ss);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(bs)[0];if(i=function(e,t){let{year:o,month:s,day:i}=e;const n=function(e){if(!e)return ps;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 gs;const t=Number(e);switch(e.length){case 1:return us+t;case 2:return us+(us+t>gs+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 cs(a,n,r);if(h.getMonth()!==n||h.getDate()!==r)return null;const d=h.getTime()-hs.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(tt).join(t);case"ymd":return[i,n,r].filter(tt).join(t);case"dmy":return[r,n,i].filter(tt).join(t)}}(e,t,l,c);return{value:Math.round(d/ds),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 cs(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)),Es.get(t).get(e)}function Is(e){const t=Math.trunc(e);let o=cs.fromTimestamp(t*ds-ms),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 Rs(e){return Math.round(Ts(e))}function Ts(e){return(e.getTime()-hs.getTime())/ds}function As(e){return new cs(e.getFullYear(),e.getMonth()+1,0).getDate()}function _s(e){return As(e)===e.getDate()}function Ds(e,t,o){const s=e.getFullYear(),i=e.getMonth(),n=e.getDate(),r=new cs(s,i+t,1);return o&&n===As(e)||n>As(r)?r.setDate(As(r)):r.setDate(n),r}function Os(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function Fs(e,t,o){if(e===t)return 0;if(e>t){const o=t;t=e,e=o}const s=Is(e),i=Is(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===(Os(c)?29:28)&&(n=30,1===l&&r===(Os(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+=Os(o)?366:365;o=t/e}else s?Os(c)&&(o=366):(Os(c)&&a<2&&(o=366),Os(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 Ms(e,t){const o=12*(t.getFullYear()-e.getFullYear())+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?o-1:o}function Ns(e,t){const o=e.getTime(),s=t.getTime();return Math.floor((s-o)/ds)}function Ps(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 ks(e,t,o){return t>o?ks(e,o,t):(e=Math.trunc(e),t=Math.trunc(t),o=Math.trunc(o),e>=t&&e<=o)}const Ls=bt((function(e){return e=Ne(e),new RegExp(`(?:^-?\\d+(?:${e}?\\d*(?:e\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)})),Vs=bt((function(e){const t=Ne(e.decimalSeparator),o="(?:\\s*"+`(?:\\d+(?:${Ne(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 Us(e,t){return!!e&&Vs(t).test(e.trim())}const Hs=bt((function(e){return new RegExp(`[$€${Ne(e.thousandsSeparator||"")}]`,"g")}));function Bs(e,t){e=e.replace(Hs(t),""),"."!==t.decimalSeparator&&(e=e.replace(t.decimalSeparator,"."));let o=Number(e);return isNaN(o)&&e.includes("%")&&(o=Number(e.split("%")[0]),!isNaN(o))?o/100:o}function zs(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)}var $s,Gs;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}($s||($s={})),function(e){e.PlainText="text/plain",e.Html="text/html"}(Gs||(Gs={}));const Ws=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"]),qs=new Set(["EVALUATE_CELLS","UPDATE_CELL","UNHIDE_COLUMNS_ROWS","HIDE_COLUMNS_ROWS","GROUP_HEADERS","UNGROUP_HEADERS","FOLD_ALL_HEADER_GROUPS","FOLD_HEADER_GROUP","FOLD_HEADER_GROUPS_IN_ZONE","UNFOLD_ALL_HEADER_GROUPS","UNFOLD_HEADER_GROUP","UNFOLD_HEADER_GROUPS_IN_ZONE","UPDATE_TABLE","UPDATE_FILTER","UNDO","REDO"]),Zs=new Set(["MOVE_RANGES"]),js=new Set(["DUPLICATE_SHEET","EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","CHANGE_CONDITIONAL_FORMAT_PRIORITY"]),Ys=new Set(["AUTOFILL_CELL","SET_BORDER","SET_ZONE_BORDERS"]),Xs=new Set(["START","ACTIVATE_SHEET","COPY","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","EVALUATE_CELLS","SET_FORMULA_VISIBILITY","UPDATE_FILTER"]),Ks=new Set(["UPDATE_CELL","UPDATE_CELL_POSITION","CLEAR_CELL","CLEAR_CELLS","DELETE_CONTENT","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","RESIZE_COLUMNS_ROWS","HIDE_COLUMNS_ROWS","UNHIDE_COLUMNS_ROWS","SET_GRID_LINES_VISIBILITY","UNFREEZE_COLUMNS","UNFREEZE_ROWS","FREEZE_COLUMNS","FREEZE_ROWS","UNFREEZE_COLUMNS_ROWS","ADD_MERGE","REMOVE_MERGE","CREATE_SHEET","DELETE_SHEET","DUPLICATE_SHEET","MOVE_SHEET","RENAME_SHEET","COLOR_SHEET","HIDE_SHEET","SHOW_SHEET","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 Qs(e){return Ks.has(e.type)}class Js{reasons;constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>"Success"!==e))}static get Success(){return ei}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}const ei=new Js;var ti;e.CommandResult=void 0,(ti=e.CommandResult||(e.CommandResult={})).Success="Success",ti.CancelledForUnknownReason="CancelledForUnknownReason",ti.WillRemoveExistingMerge="WillRemoveExistingMerge",ti.MergeIsDestructive="MergeIsDestructive",ti.CellIsMerged="CellIsMerged",ti.InvalidTarget="InvalidTarget",ti.EmptyUndoStack="EmptyUndoStack",ti.EmptyRedoStack="EmptyRedoStack",ti.NotEnoughElements="NotEnoughElements",ti.NotEnoughSheets="NotEnoughSheets",ti.MissingSheetName="MissingSheetName",ti.UnchangedSheetName="UnchangedSheetName",ti.DuplicatedSheetName="DuplicatedSheetName",ti.DuplicatedSheetId="DuplicatedSheetId",ti.ForbiddenCharactersInSheetName="ForbiddenCharactersInSheetName",ti.WrongSheetMove="WrongSheetMove",ti.WrongSheetPosition="WrongSheetPosition",ti.InvalidAnchorZone="InvalidAnchorZone",ti.SelectionOutOfBound="SelectionOutOfBound",ti.TargetOutOfSheet="TargetOutOfSheet",ti.WrongCutSelection="WrongCutSelection",ti.WrongPasteSelection="WrongPasteSelection",ti.WrongPasteOption="WrongPasteOption",ti.WrongFigurePasteOption="WrongFigurePasteOption",ti.EmptyClipboard="EmptyClipboard",ti.EmptyRange="EmptyRange",ti.InvalidRange="InvalidRange",ti.InvalidZones="InvalidZones",ti.InvalidSheetId="InvalidSheetId",ti.InvalidFigureId="InvalidFigureId",ti.InputAlreadyFocused="InputAlreadyFocused",ti.MaximumRangesReached="MaximumRangesReached",ti.MinimumRangesReached="MinimumRangesReached",ti.InvalidChartDefinition="InvalidChartDefinition",ti.InvalidDataSet="InvalidDataSet",ti.InvalidLabelRange="InvalidLabelRange",ti.InvalidScorecardKeyValue="InvalidScorecardKeyValue",ti.InvalidScorecardBaseline="InvalidScorecardBaseline",ti.InvalidGaugeDataRange="InvalidGaugeDataRange",ti.EmptyGaugeRangeMin="EmptyGaugeRangeMin",ti.GaugeRangeMinNaN="GaugeRangeMinNaN",ti.EmptyGaugeRangeMax="EmptyGaugeRangeMax",ti.GaugeRangeMaxNaN="GaugeRangeMaxNaN",ti.GaugeRangeMinBiggerThanRangeMax="GaugeRangeMinBiggerThanRangeMax",ti.GaugeLowerInflectionPointNaN="GaugeLowerInflectionPointNaN",ti.GaugeUpperInflectionPointNaN="GaugeUpperInflectionPointNaN",ti.GaugeLowerBiggerThanUpper="GaugeLowerBiggerThanUpper",ti.InvalidAutofillSelection="InvalidAutofillSelection",ti.MinBiggerThanMax="MinBiggerThanMax",ti.LowerBiggerThanUpper="LowerBiggerThanUpper",ti.MidBiggerThanMax="MidBiggerThanMax",ti.MinBiggerThanMid="MinBiggerThanMid",ti.FirstArgMissing="FirstArgMissing",ti.SecondArgMissing="SecondArgMissing",ti.MinNaN="MinNaN",ti.MidNaN="MidNaN",ti.MaxNaN="MaxNaN",ti.ValueUpperInflectionNaN="ValueUpperInflectionNaN",ti.ValueLowerInflectionNaN="ValueLowerInflectionNaN",ti.MinInvalidFormula="MinInvalidFormula",ti.MidInvalidFormula="MidInvalidFormula",ti.MaxInvalidFormula="MaxInvalidFormula",ti.ValueUpperInvalidFormula="ValueUpperInvalidFormula",ti.ValueLowerInvalidFormula="ValueLowerInvalidFormula",ti.InvalidSortZone="InvalidSortZone",ti.WaitingSessionConfirmation="WaitingSessionConfirmation",ti.MergeOverlap="MergeOverlap",ti.TooManyHiddenElements="TooManyHiddenElements",ti.Readonly="Readonly",ti.InvalidViewportSize="InvalidViewportSize",ti.InvalidScrollingDirection="InvalidScrollingDirection",ti.ViewportScrollLimitsReached="ViewportScrollLimitsReached",ti.FigureDoesNotExist="FigureDoesNotExist",ti.InvalidConditionalFormatId="InvalidConditionalFormatId",ti.InvalidCellPopover="InvalidCellPopover",ti.EmptyTarget="EmptyTarget",ti.InvalidFreezeQuantity="InvalidFreezeQuantity",ti.FrozenPaneOverlap="FrozenPaneOverlap",ti.ValuesNotChanged="ValuesNotChanged",ti.InvalidFilterZone="InvalidFilterZone",ti.TableNotFound="TableNotFound",ti.TableOverlap="TableOverlap",ti.InvalidTableConfig="InvalidTableConfig",ti.InvalidTableStyle="InvalidTableStyle",ti.FilterNotFound="FilterNotFound",ti.MergeInTable="MergeInTable",ti.NonContinuousTargets="NonContinuousTargets",ti.DuplicatedFigureId="DuplicatedFigureId",ti.InvalidSelectionStep="InvalidSelectionStep",ti.DuplicatedChartId="DuplicatedChartId",ti.ChartDoesNotExist="ChartDoesNotExist",ti.InvalidHeaderIndex="InvalidHeaderIndex",ti.InvalidQuantity="InvalidQuantity",ti.MoreThanOneColumnSelected="MoreThanOneColumnSelected",ti.EmptySplitSeparator="EmptySplitSeparator",ti.SplitWillOverwriteContent="SplitWillOverwriteContent",ti.NoSplitSeparatorInSelection="NoSplitSeparatorInSelection",ti.NoActiveSheet="NoActiveSheet",ti.InvalidLocale="InvalidLocale",ti.MoreThanOneRangeSelected="MoreThanOneRangeSelected",ti.NoColumnsProvided="NoColumnsProvided",ti.ColumnsNotIncludedInZone="ColumnsNotIncludedInZone",ti.DuplicatesColumnsSelected="DuplicatesColumnsSelected",ti.InvalidHeaderGroupStartEnd="InvalidHeaderGroupStartEnd",ti.HeaderGroupAlreadyExists="HeaderGroupAlreadyExists",ti.UnknownHeaderGroup="UnknownHeaderGroup",ti.UnknownDataValidationRule="UnknownDataValidationRule",ti.UnknownDataValidationCriterionType="UnknownDataValidationCriterionType",ti.InvalidDataValidationCriterionValue="InvalidDataValidationCriterionValue",ti.InvalidNumberOfCriterionValues="InvalidNumberOfCriterionValues",ti.InvalidCopyPasteSelection="InvalidCopyPasteSelection",ti.NoChanges="NoChanges",ti.InvalidInputId="InvalidInputId",ti.SheetIsHidden="SheetIsHidden",ti.InvalidTableResize="InvalidTableResize",ti.PivotIdNotFound="PivotIdNotFound",ti.PivotInError="PivotInError",ti.EmptyName="EmptyName",ti.ValueCellIsInvalidFormula="ValueCellIsInvalidFormula",ti.InvalidDefinition="InvalidDefinition",ti.InvalidColor="InvalidColor";const oi=[{name:"English (US)",code:"en_US",thousandsSeparator:",",decimalSeparator:".",weekStart:7,dateFormat:"m/d/yyyy",timeFormat:"hh:mm:ss a",formulaArgSeparator:","},{name:"French",code:"fr_FR",thousandsSeparator:" ",decimalSeparator:",",weekStart:1,dateFormat:"dd/mm/yyyy",timeFormat:"hh:mm:ss",formulaArgSeparator:";"}],si=oi[0],ii=["thin","medium","thick","dashed","dotted"];function ni(e){return Array.isArray(e)&&Array.isArray(e[0])}var ri;!function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(ri||(ri={}));const ai={Background:0,Highlights:1,Clipboard:2,Chart:4,Autofill:5,Selection:6,Headers:100},li=bt((()=>Object.keys(ai).sort(((e,t)=>ai[e]-ai[t]))));const ci={NotAvailable:"#N/A",InvalidReference:"#REF",BadExpression:"#BAD_EXPR",CircularDependency:"#CYCLE",UnknownFunction:"#NAME?",DivisionByZero:"#DIV/0!",SpilledBlocked:"#SPILL!",GenericError:"#ERROR",NullError:"#NULL!"},hi=new Set(Object.values(ci));class di extends Error{value;constructor(e=vo("Error"),t=ci.GenericError){super(e),this.value=t}}class ui extends di{constructor(e=vo("Invalid expression")){super(e,ci.BadExpression)}}class gi extends di{constructor(e=vo("Invalid reference")){super(e,ci.InvalidReference)}}class pi extends di{constructor(e=vo("Data not available")){super(e,ci.NotAvailable)}}class mi extends di{constructor(e=vo("Unknown function")){super(e,ci.UnknownFunction)}}class fi extends di{constructor(e=vo("Spill range is not empty")){super(e,ci.SpilledBlocked)}}const vi=["number","string","boolean","undefined"];function bi(e,t,o){if(!e())throw new di(t,o)}function Si(e){if(void 0!==e)return ni(e)?e[0][0]?.format:e.format}function yi(e){return"string"==typeof e&&hi.has(e)}const Ci=e=>vo("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function wi(e,t){const o=Pi(e);switch(typeof o){case"number":return o;case"boolean":return o?1:0;case"string":if(Us(o,t)||""===o)return Bs(o,t);const e=xs(o,t);if(e)return e.value;throw new di(Ci(o));default:return 0}}function Ei(e,t){try{return wi(e,t)}catch(e){return}}function xi(e,t){return tn(e).map((e=>e.map((e=>{if("number"!=typeof e.value)throw new di(vo("Function [[FUNCTION_NAME]] expects number values for %s, but got a %s.",t,typeof e.value));return e.value}))))}function Ii(e,t){const o=Pi(e);if(""===o)throw new di(Ci(o));return wi(o,t)}function Ri(e,t){return Math.trunc(wi(e,t))}function Ti(e,t){return Math.trunc(Ii(e,t))}function Ai(e){bi((()=>e>=1),vo("The function [[FUNCTION_NAME]] expects a number value to be greater than or equal to 1, but receives %s.",e.toString()))}function _i(e){bi((()=>0!==e),vo("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."),ci.DivisionByZero)}function Di(e){const t=Pi(e);switch(typeof t){case"string":return t;case"number":return t.toString();case"boolean":return t?"TRUE":"FALSE";default:return""}}const Oi=bt((function(e){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")})),Fi=e=>vo("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a boolean.",e);function Mi(e){const t=Pi(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 di(Fi(t))}return!1;case"number":return!!t;default:return!1}}function Ni(e,t){return Is(wi(Pi(e),t))}function Pi(e){if("object"==typeof e&&null!==e&&"value"in e){if(yi(e.value))throw e;return e.value}if(yi(e))throw new di("",e);return e}function ki(e,t,o){for(let s of e)if(ni(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 Li(e,t){ki(e,(e=>{if(yi(e.value))throw e;t(e)}),(e=>{if(yi(e?.value))throw e;t(e)}))}function Vi(e,t,o){ki(e,(e=>{if("number"==typeof e?.value&&t(e),yi(e?.value))throw e}),(e=>{t({value:Ii(e,o),format:e?.format})}))}function Ui(e,t,o,s,i="rowFirst"){let n=s;for(let s of e)if(ni(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 Hi(e,t,o,s="rowFirst"){return Ui(e,t,t,o,s)}function Bi(e,t,o,s){return Ui(e,((e,o)=>{const s=o?.value;if("number"==typeof s)return t(e,s);if(yi(s))throw o;return e}),((e,o)=>t(e,Ii(o,s))),o)}function zi(e,t,o,s){return Ui(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,wi(i,s));if(yi(i))throw o;return t(e,0)}return e}),((e,o)=>t(e,wi(o,s))),o)}function $i(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 Gi(e,t){return 0===e.length?[]:$i(e.length,e[0].length,((o,s)=>t(e[o][s])))}function Wi(e){return e.length?$i(e[0].length,e.length,((t,o)=>e[o][t])):[]}function qi(e,t){return function(e,t,o){for(let s of e)if(ni(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(yi(o))throw e;return!0}),(e=>void 0===e||null===e.value||t(function(e){const t=Pi(e);if(""===t)throw new di(Fi(t));return Mi(t)}(e))))}function Zi(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)),Us(s,t)||ws(s,t)?s=wi(s,t):"TRUE"!==s&&"FALSE"!==s||(s=Mi(s)),{operator:o,operand:s}}const ji=bt((function(e){if("*"===e)return/.+/;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 Yi(e="",t,o){const{operator:s,operand:i}=t;if(void 0===i||null===e||null===i)return!1;if("number"==typeof i&&"="===s)return"string"==typeof e&&(Us(e,o)||ws(e,o))?wi(e,o)===i:e===i;if("<>"===s||"="===s){let t;return t=typeof e==typeof i&&("string"==typeof e&&"string"==typeof i?ji(i).test(e):e===i),"="===s?t:!t}if(typeof e==typeof i)switch(s){case"<":return e<i;case">":return e>i;case"<=":return e<=i;case">=":return e>=i}return!1}function Xi(e,t,o,s=!1){const i=e.length;if(i%2==1)throw new di(vo("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const n=tn(e[0]),r=n.length,a=n[0].length;let l=[];for(let t=0;t<i-1;t+=2){const i=tn(e[t]);if(i.length!==r||i[0].length!==a)throw new di(vo("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const n=Zi(Di(e[t+1]),o);s&&"string"==typeof n.operand&&(n.operand+="*"),l.push(n)}for(let s=0;s<r;s++)for(let n=0;n<a;n++){let r=!0;for(let t=0;t<i-1;t+=2){if(r=Yi(tn(e[t])[s][n].value??void 0,l[t/2],o),!r)break}r&&t(s,n)}}function Ki(e,t,o,s,i,n){if(void 0===t||null===t.value)return-1;if(yi(t.value))throw t;const r=Ji(t.value),a=typeof r;let l,c,h,d,u,g,p=0,m=i-1;const f="desc"===s?t=>Ji(n(e,i-t-1)):t=>Ji(n(e,t));for(;m-p>=0;){for(h=Math.floor((p+m)/2),d=h,u=f(d),g=typeof u;p<d&&a!==g;)d--,u=f(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&&c<d)&&(l=u,c=d):"nextGreater"===o&&u>=r&&(void 0===l||l>u||l===u&&c<d)&&(l=u,c=d),u>r||"strict"===o&&u===r?m=d-1:p=h+1):p=h+1}return void 0===c?-1:"desc"===s?i-c-1:c}function Qi(e,t,o,s,i,n,r=!1){if(void 0===t||null===t.value)return-1;if(yi(t.value))throw t;const a=Ji(t.value),l=r?(e,t)=>Ji(i(e,s-t-1)):(e,t)=>Ji(i(e,t)),c="wildcard"!==o||"string"!=typeof a||!(a.includes("*")||a.includes("?"));if(n&&c){const t=r?"reverseSearch":"forwardSearch";let i=n[t].get(e);if(void 0===i){i=new Map;for(let t=0;t<s;t++){const o=l(e,t)??null;i.has(o)||i.set(o,t)}n[t].set(e,i)}if(i.has(a)){const e=i.get(a);return r?s-e-1:e}if("strict"===o)return-1}const h=function(e,t,o,s,i){let n=o=>i(e,o)===t;if("wildcard"===o&&"string"==typeof t&&(t.includes("*")||t.includes("?"))){const o=ji(t);n=t=>{const s=i(e,t);return"string"==typeof s&&o.test(s)}}let r,a=-1;"nextSmaller"===o&&(n=o=>{const s=i(e,o);return(!r&&en(t,s)>=0||en(t,s)>=0&&en(s,r)>0)&&(r=s,a=o),s===t});"nextGreater"===o&&(n=o=>{const s=i(e,o);return(!r&&en(t,s)<=0||en(t,s)<=0&&en(s,r)<0)&&(r=s,a=o),s===t});for(let e=0;e<s;e++)if(n(e))return e;return a}(e,a,o,s,l);return r&&-1!==h?s-h-1:h}function Ji(e){return"string"==typeof e?Oi(e):e}function en(e,t){let o=vi.indexOf(typeof e)-vi.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 tn(e){return void 0===e?[[]]:ni(e)?e:[[e]]}function on(e,t){return Hi(e,((e,o)=>(e.push(t(o)),e)),[],"rowFirst")}function sn(e){if(void 0===e)return!1;const{value:t}=e;return null!==t&&""!==t}function nn(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}const rn=new n;function an(e,t){return{url:e=nn(e),label:t||e,isExternal:!0,isUrlEditable:!0}}rn.add("sheet_URL",{match:e=>Qe(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){const o=et(e);return t.tryGetSheetName(o)||vo("Invalid sheet")},open(e,t){const o=et(e);t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:o}).isCancelledBecause("SheetIsHidden")&&t.notifyUser({type:"warning",sticky:!1,text:vo("Cannot open the link because the linked sheet is hidden.")})},sequence:0});const ln={createLink:an,match:e=>je(e),open:e=>window.open(e,"_blank"),urlRepresentation:e=>e,sequence:0};function cn(e){return rn.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((t=>t.match(e)))||ln}function hn(e,t){return cn(e.url).urlRepresentation(e.url,t)}function dn(e,t){cn(e.url).open(e.url,t)}function un(e){if("string"==typeof e){if(Ze(e)){const{label:t,url:o}=Xe(e);return cn(o).createLink(o,t)}return je(e)?an(e):void 0}}function gn(e){let t;if('"'===e.current?(e.shift(),t='"'):e.currentStartsWith("[$")&&(e.advanceBy(2),t="]"),!t)return null;let o="";for(;e.current&&e.current!==t;)o+=e.shift();if(e.current!==t)throw new Error("Unterminated string in format");return e.shift(),{type:"STRING",value:o}}const pn=new Set("$+-/():!^&~{}<>= ");function mn(e){if("\\"===e.current){e.shift();const t=e.shift();if(!t)throw new Error("Unexpected end of format string");return{type:"CHAR",value:t}}return pn.has(e.current)?{type:"CHAR",value:e.shift()}:null}function fn(e){return","===e.current?(e.shift(),{type:"THOUSANDS_SEPARATOR",value:","}):null}function vn(e){return"@"===e.current?(e.shift(),{type:"TEXT_PLACEHOLDER",value:"@"}):null}function bn(e){return"."===e.current?(e.shift(),{type:"DECIMAL_POINT",value:"."}):null}function Sn(e){return"%"===e.current?(e.shift(),{type:"PERCENT",value:"%"}):null}function yn(e){if("0"===e.current||"#"===e.current){const t=e.current;return e.shift(),{type:"DIGIT",value:t}}return null}const Cn=new Set("dmqyhsa");function wn(e){if(!Cn.has(e.current))return null;const t=e.current;let o="";for(;e.current===t;)o+=e.shift();return{type:"DATE_PART",value:o}}function En(e){if("*"!==e.current)return null;e.shift();const t=e.shift();if(!t)throw new Error("Unexpected end of format string");return{type:"REPEATED_CHAR",value:t}}const xn=20,In={};function Rn(e){let t=In[e];return void 0===t&&(t=function(e){const t=function(e){const t=new Rt(e),o=[];let s=[];for(o.push(s);!t.isOver();){if(";"===t.current){s=[],o.push(s),t.shift();continue}let e=yn(t)||gn(t)||mn(t)||fn(t)||bn(t)||Sn(t)||wn(t)||vn(t)||En(t);if(!e)throw new Error("Unknown token at "+t.remaining());s.push(e)}return o}(e);for(const e of t){const t=e.filter((e=>"REPEATED_CHAR"===e.type));for(const e of t.slice(1))e.type="CHAR"}const o=An(t[0])||Tn(t[0])||_n(t[0]);if(!o)throw new Error("Invalid first format part of: "+e);if(t.length>1&&"text"===o.type)throw new Error("The first format in a multi-part format must be a number format: "+e);const s=An(t[1])||Tn(t[1]);if(t[1]?.length&&!s)throw new Error("Invalid second format part of: "+e);const i=An(t[2])||Tn(t[2]);if(t[2]?.length&&!i)throw new Error("Invalid third format part of: "+e);const n=_n(t[3]);if(t[3]?.length&&!n)throw new Error("Invalid fourth format part of: "+e);return{positive:o,negative:s,zero:i,text:n}}(e),In[e]=t),t}function Tn(e){if(!e||!function(e){return e.every((e=>"DIGIT"===e.type||"DECIMAL_POINT"===e.type||"THOUSANDS_SEPARATOR"===e.type||"PERCENT"===e.type||"STRING"===e.type||"CHAR"===e.type||"REPEATED_CHAR"===e.type))}(e))return;const t=[];let o,s=t,i=0,n=0,r=e.findLastIndex((e=>"DIGIT"===e.type)),a=!1,l=0;for(let c=0;c<e.length;c++){const h=e[c];switch(h.type){case"DIGIT":s===t?s.push(h):l<xn&&(s.push(h),l++);break;case"DECIMAL_POINT":if(s!==t)throw new Error("Multiple decimal points in a number format");o=[],s=o;break;case"REPEATED_CHAR":case"CHAR":case"STRING":s.push(h);break;case"PERCENT":i++,s.push(h);break;case"THOUSANDS_SEPARATOR":c-1===r?(n+=1,r++,s.push(h)):"DIGIT"===e[c+1]?.type&&"DIGIT"===e[c-1]?.type?(s===t&&(a=!0),s.push(h)):s.push({type:"CHAR",value:","})}}return{type:"number",integerPart:t,decimalPart:o,percentSymbols:i,thousandsSeparator:a,magnitude:n}}function An(e){const t=e&&function(e){return e.every((e=>"DATE_PART"===e.type||"DECIMAL_POINT"===e.type||"THOUSANDS_SEPARATOR"===e.type||"STRING"===e.type||"CHAR"===e.type||"REPEATED_CHAR"===e.type))}(e)?{type:"date",tokens:e}:void 0;if(!t)return;if(t.tokens.length&&t.tokens.every((e=>"DATE_PART"===e.type&&"a"===e.value)))throw new Error("Invalid date format");const o=function(e){const t=e.filter((e=>"DATE_PART"===e.type));for(let e=0;e<t.length;e++)!t[e].value.startsWith("m")||t[e].value.length>2||(t[e-1]?.value.startsWith("h")||t[e+1]?.value.startsWith("s"))&&(t[e].value=t[e].value.replaceAll("m","M"));return e}(t.tokens.map((e=>"THOUSANDS_SEPARATOR"===e.type||"DECIMAL_POINT"===e.type?{type:"CHAR",value:e.value}:e)));return{type:"date",tokens:o}}function _n(e){return e&&function(e){return e.every((e=>"STRING"===e.type||"TEXT_PLACEHOLDER"===e.type||"CHAR"===e.type||"REPEATED_CHAR"===e.type))}(e)?{type:"text",tokens:e}:void 0}function Dn(e){return[On(e.positive),On(e.negative),On(e.zero),On(e.text)].filter(tt).join(";")}function On(e){if(!e)return;let t="";const o="number"!==e.type?e.tokens:function(e){let t=[...e.integerPart];e.decimalPart&&(t.push({type:"DECIMAL_POINT",value:"."}),t.push(...e.decimalPart));return t}(e);for(let e of o)switch(e.type){case"STRING":t+=`[$${e.value}]`;break;case"CHAR":t+=(s=e.value,pn.has(s)?e.value:`\\${e.value}`);break;case"REPEATED_CHAR":t+="*"+e.value;break;default:t+=e.value}var s;return t}const Fn=11,Mn="REPEATED_CHAR_PLACEHOLDER_",Nn={0:vo("January"),1:vo("February"),2:vo("March"),3:vo("April"),4:vo("May"),5:vo("June"),6:vo("July"),7:vo("August"),8:vo("September"),9:vo("October"),10:vo("November"),11:vo("December")},Pn={0:vo("Sunday"),1:vo("Monday"),2:vo("Tuesday"),3:vo("Wednesday"),4:vo("Thursday"),5:vo("Friday"),6:vo("Saturday")};function kn(e,{format:t,locale:o,formatWidth:s}){switch("boolean"==typeof e&&(e=e?"TRUE":"FALSE"),typeof e){case"string":{if(e.includes('\\"')&&(e=e.replaceAll(/\\"/g,'"')),!t)return e;const o=Rn(t);let i=o.text||o.positive;return i&&"text"===i.type?Ln(e,i,s):e}case"number":t||(t=Zn(e));const i=Rn(t);if("text"===i.positive.type)return Ln(e.toString(),i.positive,s);let n=i.positive;if(e<0&&i.negative?(n=i.negative,e=-e):0===e&&i.zero&&(n=i.zero),"date"===n.type)return Vn(function(e,t){const o=Is(e),s=t.tokens.some((e=>"DATE_PART"===e.type&&"a"===e.value));let i="";for(const e of t.tokens)switch(e.type){case"DATE_PART":i+=Wn(o,e.value,s);break;case"REPEATED_CHAR":i+=Mn+e.value;break;default:i+=e.value}return i}(e,n),s);const r=e<0,a=Vn(function(e,t,o){if(e===1/0)return"∞"+(t.percentSymbols?"%":"");const s=2*t.percentSymbols-3*t.magnitude;e*=10**s;let i=0;void 0!==t.decimalPart&&(i=t.decimalPart.filter((e=>"DIGIT"===e.type)).length);const{integerDigits:n,decimalDigits:r}=Hn(Math.abs(e),i);let a=function(e,t,o){let s=t.integerPart;s.some((e=>"DIGIT"===e.type))||(s=[...s,{type:"DIGIT",value:"#"}]);"0"===e&&(e="");let i="";const n=s.findIndex((e=>"DIGIT"===e.type));let r=e.length-1;function a(t,s){if("0"===s&&(t=t||"0"),!t)return;const n=e.length-1-r;i=o&&n>0&&n%3==0?t+o+i:t+i}for(let t=s.length-1;t>=0;t--){const o=s[t];switch(o.type){case"DIGIT":if(a(e[r],o.value),r--,n===t)for(;r>=0;)a(e[r],"0"),r--;break;case"THOUSANDS_SEPARATOR":break;case"REPEATED_CHAR":i=Mn+o.value+i;break;default:i=o.value+i}}return i}(n,t,t.thousandsSeparator?o.thousandsSeparator:void 0);void 0!==t.decimalPart&&(a+=o.decimalSeparator+function(e,t){if(!t.decimalPart)return"";let o="",s=0;for(const i of t.decimalPart)switch(i.type){case"DIGIT":o+="#"===i.value?e[s]||"":e[s]||"0",s++;break;case"THOUSANDS_SEPARATOR":break;case"REPEATED_CHAR":o+=Mn+i.value;break;default:o+=i.value}return o}(r||"",t));return a}(Math.abs(e),n,o),s);return r?"-"+a:a;case"object":return""}}function Ln(e,t,o){let s="";for(const o of t.tokens)switch(o.type){case"TEXT_PLACEHOLDER":s+=e;break;case"CHAR":case"STRING":s+=o.value;break;case"REPEATED_CHAR":s+=Mn+o.value}return Vn(s,o)}function Vn(e,t){const o=e.indexOf(Mn);if(-1===o)return e;const s=e.slice(0,o),i=e.slice(o+Mn.length+1),n=e[o+Mn.length];const{timesToRepeat:r,padding:a}=function(){if(!t)return{timesToRepeat:0,padding:""};const e=t.measureText(s+i),o=t.measureText(n),r=t.availableWidth-e;if(r<=0)return{timesToRepeat:0,padding:""};const a=Math.floor(r/o),l=r-a*o,c=t.measureText(" ");return{timesToRepeat:a,padding:" ".repeat(Math.floor(l/c))}}();return s+n.repeat(r)+a+i}const Un=[];function Hn(e,t=xn){const o=e.toString();if(o.includes("e"))return function(e,t=xn){let o=Un[t];o||(o=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),Un[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(zn)?.[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:Bn(n||"")}}function Bn(e){let t=e.length-1;for(;t>=0&&"0"===e[t];)t--;return e.slice(0,t+1)||void 0}const zn=/^0+/;function $n(e,t){const{integerDigits:o,decimalDigits:s}=Hn(e,20);return s?o+t+s:o}const Gn=bt((function(e){if(!e)return!1;try{return"date"===Rn(e).positive.type}catch(e){return!1}}));function Wn(e,t,o){switch(t){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"ddd":return Pn[e.getDay()].slice(0,3);case"dddd":return Pn[e.getDay()].toString();case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"mmm":return Nn[e.getMonth()].slice(0,3);case"mmmm":return Nn[e.getMonth()].toString();case"mmmmm":return Nn[e.getMonth()].slice(0,1);case"qq":return vo("Q%(quarter)s",{quarter:e.getQuarter()}).toString();case"qqqq":return vo("Quarter %(quarter)s",{quarter:e.getQuarter()}).toString();case"yy":const s=String(e.getFullYear()).replace("-","").padStart(2,"0");return s.slice(s.length-2);case"yyyy":return e.getFullYear();case"hhhh":return Math.floor((e.getTime()-hs.getTime())/36e5).toString();case"hh":let i=e.getHours();return o&&(i=0===i?12:i>12?i-12:i),i.toString().padStart(2,"0");case"MM":return e.getMinutes().toString().padStart(2,"0");case"ss":return e.getSeconds().toString().padStart(2,"0");case"a":return e.getHours()>=12?"PM":"AM";default:throw new Error(`invalid date format token: ${t}`)}}const qn=bt((function(e){return new RegExp(`[0-9]+${Ne(e.decimalSeparator)}[0-9]`)}));function Zn(e){let{integerDigits:t,decimalDigits:o}=Hn(e);if(!o)return"0";const s=t.replace("-","").length;if(s+2>Fn)return"0";const i=Fn-s-1;return({decimalDigits:o}=Hn(e,Math.min(i,o.length))),o?"0."+"0".repeat(o.length):"0"}function jn(e,t){if(!ws(e,t))return;return xs(e,t).format}function Yn(e){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}if(e.includes("%"))return t+"%"}function Xn(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 Kn(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();"after"===o&&s&&(r=" "+r);return[Qn(r,o,` ${n} `),Qn(r,o,`(${n})`),Qn(r,o," - ")].join(";")}function Qn(e,t,o){const s=`[$${e}]`;return"before"===t?s+"* "+o:o+"* "+s}function Jn(e){const t=Rn(e);return Dn({positive:er(t.positive),negative:t.negative?er(t.negative):void 0,zero:t.zero?er(t.zero):void 0,text:t.text})}function er(e){if("number"!==e.type||!e.decimalPart)return e;const t=e.decimalPart.filter((e=>"DIGIT"!==e.type));return{...e,decimalPart:void 0,integerPart:[...e.integerPart,...t]}}function tr({value:e,format:t},o){return kn(e,{format:or({value:e,format:t},void 0,o),locale:o})}function or(e,t,o){let s=0;try{s=Math.abs(wi(e?.value,o))}catch(e){return""}const i=e?.format;if(void 0!==t){const e=t?.value;switch(e){case"k":return sr(i,1,"k");case"m":return sr(i,2,"m");case"b":return sr(i,3,"b");default:throw new di(vo("The formatting unit should be 'k', 'm' or 'b'."))}}return s<1e5?sr(i,0,""):s<1e8?sr(i,1,"k"):s<1e11?sr(i,2,"m"):sr(i,3,"b")}function sr(e,t,o,s){const i=Rn(e||"#,##0");return Dn({positive:ir(i.positive,t,o),negative:i.negative?ir(i.negative,t,o):void 0,zero:i.zero?ir(i.zero,t,o):void 0,text:i.text})}function ir(e,t,o){if("number"!==e.type)return e;const s={type:"STRING",value:o};let i=[...e.integerPart];const n=i.findLastIndex((e=>"DIGIT"===e.type));if(-1===n)throw new Error("Cannot create a large number format from a format with no digit.");for(;"THOUSANDS_SEPARATOR"===i[n+1]?.type;)i=St(i,[n+1]);const r=i[n+1];i="STRING"===r?.type&&["m","k","b"].includes(r.value)?function(e,t,o){const s=[...e];return s.splice(o,1,t),s}(i,s,n+1):yt(i,[s],n+1),t>0&&(i=yt(i,Array(t).fill({type:"THOUSANDS_SEPARATOR",value:","}),n+1));const a=e.percentSymbols-i.filter((e=>"PERCENT"===e.type)).length;return i.push(...new Array(a).fill({type:"PERCENT",value:"%"})),{...e,integerPart:i,decimalPart:void 0,magnitude:t}}function nr(e,t){const o=Rn(e);return Dn(Rn(Dn({positive:rr(o.positive,t),negative:o.negative?rr(o.negative,t):void 0,zero:o.zero?rr(o.zero,t):void 0,text:o.text})))}function rr(e,t){return"number"!==e.type?e:t>0?function(e,t){let o=e.integerPart,s=e.decimalPart;if(!s){const e=o.findLastIndex((e=>"DIGIT"===e.type));s=o.slice(e+1),o=o.slice(0,e+1)}const i=Be(0,t).map((()=>({type:"DIGIT",value:"0"}))),n=s.findLastIndex((e=>"DIGIT"===e.type));s=-1===n?[...i,...s]:yt(s,i,n+1);return{...e,decimalPart:s,integerPart:o}}(e,t):function(e,t){let o=e.decimalPart;if(!o)return e;const s=[];let i=0;for(let e=o.length-1;e>=0&&!(i>=Math.abs(t));e--)"DIGIT"===o[e].type&&(i++,s.push(e));if(o=St(o,s),o.some((e=>"DIGIT"===e.type)))return{...e,decimalPart:o};return{...e,decimalPart:void 0,integerPart:[...e.integerPart,...o]}}(e,Math.abs(t))}function ar(e){const t=Rn(e);for(const e of[t.positive,t.negative,t.zero])if(e&&"date"===e.type&&e.tokens.some((e=>"DATE_PART"===e.type&&e.value.includes("q"))))return!1;return!0}function lr(e){if(!e)return!1;try{return"text"===Rn(e).positive.type}catch{return!1}}function cr(e,t){return dr({value:lr(t.format)?e.content:e.parsedValue,format:t.format},t.locale)}function hr(e,t){if(e.startsWith("="))throw new Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);if(""===e)return null;if(Us(e,si))return Bs(e,si);const o=xs(e,t);return o?o.value:Ge(e)?"TRUE"===e.toUpperCase():e}function dr(e,t=si,o){const s=un(e.value);if(!s)return ur(e,t,o);const i=hr(s.label,t);return{...ur({value:i,format:e.format||("number"==typeof i?jn(s.label,t)||Yn(s.label):void 0)},t,o),link:s}}function ur(e,t,o){let{value:s,format:i,message:n}=e;i=o?.format||i;const r=kn(s,{format:i,locale:t});return yi(s)?function(e,t){return{value:e,formattedValue:e,message:t,type:$s.error,isAutoSummable:!1,defaultAlign:"center"}}(s,n):lr(i)?gr(Di(s),i,r):null===s?pr(i):"number"==typeof s?Gn(i||"")?function(e,t,o){return{value:e,format:t,formattedValue:o,type:$s.number,isAutoSummable:!1,defaultAlign:"right"}}(s,i,r):function(e,t,o){return{value:e||0,format:t,formattedValue:o,type:$s.number,isAutoSummable:!0,defaultAlign:"right"}}(s,i,r):"boolean"==typeof s?function(e,t,o){return{value:e,format:t,formattedValue:o,type:$s.boolean,isAutoSummable:!1,defaultAlign:"center"}}(s,i,r):gr(s,i,r)}function gr(e,t,o){return{value:e,format:t,formattedValue:o,type:$s.text,isAutoSummable:!0,defaultAlign:"left"}}const pr=bt((function(e){return{value:null,format:e,formattedValue:"",type:$s.empty,isAutoSummable:!0,defaultAlign:"left"}}));function mr(e){const t=cs.now();switch(e){case"today":return Ts(t);case"yesterday":return Ts(cs.fromTimestamp(t.setDate(t.getDate()-1)));case"tomorrow":return Ts(cs.fromTimestamp(t.setDate(t.getDate()+1)));case"lastWeek":return Ts(cs.fromTimestamp(t.setDate(t.getDate()-7)));case"lastMonth":return Ts(cs.fromTimestamp(t.setMonth(t.getMonth()-1)));case"lastYear":return Ts(cs.fromTimestamp(t.setFullYear(t.getFullYear()-1)))}}function fr(e,t){return"dateValue"in e&&"exactDate"!==e.dateValue?[mr(e.dateValue)]:e.values.map((e=>Cs(e,t)))}function vr(e,t){return e.values.map((e=>Ei(e,t)))}function br(e,t){return e.map((e=>{if(e.startsWith("="))return e;const o=hr(e,t);return"number"==typeof o?kn(o,{format:t.dateFormat,locale:t}):""}))}function Sr(e){return 20+120*Math.exp(-.035*(e-1))}class yr{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&&is(this.zone)>1?o.push({...e.parts[0]}):2===e.parts.length&&1===is(this.zone)&&o.pop(),this.parts=o}static fromRange(e,t){return e instanceof yr?e:new yr(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(vo("Bad zone format"))}static getRangeParts(e,t){const o=e.split(":").map((e=>{const t=To(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(ko(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 yr({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 Cr(e,t,o){const s=o.sheetId===e?t:o.sheetId;return o.clone({sheetId:s})}function wr(e,t,o){if(!o)return;const s=e.getRangeFromSheetXC(t,o);return s.invalidSheetName||s.invalidXc?void 0:s}function Er(e){const t=[];for(const o of e)for(const e of Ko(o.zone))t.push({...e,sheetId:o.sheetId});return t}function xr(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 Ir(e){const t=[];for(let o=0;o<e;o++){const e={cells:{}};t.push(e)}return t}function Rr(e,t,o){return o.map((o=>o>=e?o+t:o))}function Tr(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(tt)}function Ar(e,t=1){return t*(e+ee)-ee}function _r(e,t=!1,o=!1){return`${o?"italic":""} ${t?"bold":""} ${e}px ${de}`}const Dr={};function Or(e,t,o,s="pt"){const i=kr(o,s);e.save(),e.font=i;const n=Fr(e,t);return e.restore(),n}function Fr(e,t){const o=e.font;if(Dr[o]||(Dr[o]={}),void 0===Dr[o][t]){const s=e.measureText(t).width;Dr[o][t]=s}return Dr[o][t]}const Mr={};function Nr(e,t,o,s="pt"){const i=kr(o,s);e.save(),e.font=i;const n=function(e,t){const o=e.font;Mr[o]||(Mr[o]={});if(void 0===Mr[o][t]){const s=e.measureText(t),i=s.width,n=s.fontBoundingBoxAscent+s.fontBoundingBoxDescent;Mr[o][t]={width:i,height:n}}return Mr[o][t]}(e,t);return e.restore(),n}function Pr(e){return Math.round(96*e/72)}function kr(e,t="pt"){return`${e.italic?"italic ":""}${e.bold?"bold":ce} ${("pt"===t?Lr(e):e.fontSize)??he}px ${de}`}function Lr(e){return Pr(e?.fontSize||he)}function Vr(e,t,o,s){if(Or(e,t,s)<=o)return[t];const i=[];let n="";for(let r of t){Or(e,n+r,s)>o?(i.push(n),n=r):n+=r}return i.push(n),i}function Ur(e,t,o,s){o||(o={});const i=[],n=t.includes(Ae)?t.split(Ae):[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=Vr(e,t,s,o),l=n.pop(),c=Or(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=Or(e,t,o);n<=a?(r+=t,a-=n):(i.push(r),r=l,a=s-c)}}""!==r&&i.push(r)}return i}function Hr(e){return e?e.toLowerCase():""}const Br=/([0-9\.]*)px/;function zr(e,t,o){let s=Fr(e,t);if(s<=o)return t;const i=Fr(e,"…");if(s<=i)return t;let n=t.length;for(;s>=o-i&&n-- >0;)s=Fr(e,t=t.substring(0,n));return t+"…"}function $r(e,t,o,s=!1,i=!1,n=function(e){return Number(e.match(Br)?.[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 Gr{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 Wr(e,t){const o=new Set(t.map((e=>e.left))),s=new Set(t.map((e=>e.right))),i=new Set(t.map((e=>e.top))),n=new Set(t.map((e=>e.bottom))),r=1===i.size&&1===n.size||1===o.size&&1===s.size?function(e){return e.reduce(((e,t)=>{const o=e.length;for(let s=0;s<o;s++)if(Wo(e[s],t))return e[s]=zo(e[s],t),e;return e[o]=t,e}),[])}(t):[t[t.length-1]],a=r.map((e=>Ko(e))).flat();return{sheetId:e,zones:t,clippedZones:r,columnsIndexes:[...new Set(a.map((e=>e.col)))].sort(((e,t)=>e-t)),rowsIndexes:[...new Set(a.map((e=>e.row)))].sort(((e,t)=>e-t))}}function qr(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()}function Zr(e){if(!e[Gs.Html])return{text:e[Gs.PlainText]};const t=(new DOMParser).parseFromString(e[Gs.Html],"text/html"),o=t.querySelector("div")?.getAttribute("data-osheet-clipboard"),s=o&&JSON.parse(o);return{text:e[Gs.PlainText],data:s}}class jr{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,s){return{zones:[],sheetId:e}}convertTextToClipboardData(e){}}class Yr extends jr{copy(e){}pasteFromCopy(e,t,o,s){if(1===t.length)for(const i of qr(t,o))this.pasteZone(e,i.left,i.top,o,s);else for(const i of no(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){}}class Xr extends Yr{copy(e){const t=e.sheetId;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){const s=e.sheetId;if("asValue"===o.pasteOption)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})}}const Kr=["%"],Qr="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(Kr);function Jr(e,t=si){e=ft(e);const o=new Rt(e),s=[];for(;!o.isOver();){let e=ha(o)||sa(o,t)||oa(o)||ia(o)||aa(o)||ea(o)||da(o)||ra(o,t)||ca(o);e||(e={type:"UNKNOWN",value:o.shift()}),s.push(e)}return s}function ea(e){return"?"===e.current?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const ta={"(":{type:"LEFT_PAREN",value:"("},")":{type:"RIGHT_PAREN",value:")"}};function oa(e){if("("===e.current||")"===e.current){const t=e.shift();return ta[t]}return null}function sa(e,t){if(e.current===t.formulaArgSeparator){return{type:"ARG_SEPARATOR",value:e.shift()}}return null}function ia(e){for(let t of Qr)if(e.currentStartsWith(t))return e.advanceBy(t.length),{type:"OPERATOR",value:t};return null}const na=new Set("0123456789");function ra(e,t){if(!na.has(e.current)&&e.current!==t.decimalSeparator)return null;const o=e.remaining().match(Ls(t.decimalSeparator));return o?(e.advanceBy(o[0].length),{type:"NUMBER",value:o[0]}):null}function aa(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 la=new Set("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.!$");function ca(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&&la.has(e.current);)t+=e.shift();if(t.length){const e=t;return Io.test(e)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}function ha(e){let t=0;for(;e.current===Ae;)t++,e.shift();if(t)return{type:"SPACE",value:Ae.repeat(t)};let o="";for(;e.current&&e.current.match(pt);)o+=e.shift();return o?{type:"SPACE",value:o}:null}function da(e){return e.currentStartsWith(ci.InvalidReference)?(e.advanceBy(ci.InvalidReference.length),{type:"INVALID_REFERENCE",value:ci.InvalidReference}):null}function ua(e){if(!e||"object"!=typeof e||e.thousandsSeparator&&"string"!=typeof e.thousandsSeparator)return!1;for(const t of["code","name","decimalSeparator","dateFormat","timeFormat","formulaArgSeparator"])if(!e[t]||"string"!=typeof e[t])return!1;if(e.formulaArgSeparator===e.decimalSeparator)return!1;if(e.thousandsSeparator===e.decimalSeparator)return!1;try{kn(1,{locale:e,format:"#,##0.00"}),kn(1,{locale:e,format:e.dateFormat}),kn(1,{locale:e,format:e.timeFormat})}catch{return!1}return!0}function ga(e,t){return e.startsWith("=")?fa(e,t):Sa(e,t)}function pa(e,t){return e.startsWith("=")?fa(e,t):function(e,t){if(ws(e,t)){const o=wi(e,t);let s=si.dateFormat;return Number.isInteger(o)||(s+=" "+si.timeFormat),kn(o,{locale:si,format:s})}return Sa(e,t)}(e,t)}function ma(e,t){return e.startsWith("=")?va(e,t):function(e,t){if(ws(e,si)){const o=wi(e,si);let s=t.dateFormat;return Number.isInteger(o)||(s+=" "+t.timeFormat),kn(o,{locale:t,format:s})}return function(e,t){if("."===t.decimalSeparator||!Us(e,si))return e;const o=qn(si),s=e.replace(o,(e=>e.replace(".",t.decimalSeparator)));return s}(e,t)}(e,t)}function fa(e,t){return ba(e,t,si)}function va(e,t){return ba(e,si,t)}function ba(e,t,o){if(t.formulaArgSeparator===o.formulaArgSeparator&&t.decimalSeparator===o.decimalSeparator)return e;const s=Jr(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 Sa(e,t){return"."!==t.decimalSeparator&&Us(e,t)?(t.thousandsSeparator&&(e=e.replaceAll(t.thousandsSeparator,"")),e.replace(t.decimalSeparator,".")):e}function ya(e,t){return Ea(e,(e=>pa(e,t)))}function Ca(e,t){return Ea(e,(e=>ma(e,t)))}function wa(e,t){const o=Pe(e);return o.criterion.values=o.criterion.values.map((e=>ma(e,t))),o}function Ea(e,t){switch((e=Pe(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}case"DataBarRule":return e;case"ColorScaleRule":return e.minimum=xa(e.minimum,t),e.maximum=xa(e.maximum,t),e.midpoint&&(e.midpoint=xa(e.midpoint,t)),e;case"IconSetRule":return e.lowerInflectionPoint.value=t(e.lowerInflectionPoint.value),e.upperInflectionPoint.value=t(e.upperInflectionPoint.value),e}}function xa(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 Ia(e){return e.dateFormat+" "+e.timeFormat}function Ra(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=Jr(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,si)}(e,t):Sa(e,t)}function Ta(e){let t=!1,o=!0;return qi(e,(e=>(t=!0,o=o&&e,o))),{foundBoolean:t,result:o}}function Aa(e){let t=!1,o=!1;return qi(e,(e=>(t=!0,o=o||e,!o))),{foundBoolean:t,result:o}}function _a(e,t){return Bi(e,((e,t)=>e+t),0,t)}function Da(e){return Hi(e,((e,t)=>sn(t)?e.add(t?.value):e),new Set).size}function Oa(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 Fa(e){if(e.length!==e[0].length)throw new di(vo("Function [[FUNCTION_NAME]] invert matrix error, only square matrices are invertible"));let t=1;const o=e.length,s=Oa(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]){Ma(i,e,n),Ma(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 Ma(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 Na(e,t){if(e.length!==t[0].length)throw new di(vo("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 Pa(e){if(!ni(e))return e;if(1!==e.length||1!==e[0].length)throw new di(vo("The value should be a scalar or a 1x1 matrix"));return e[0][0]}function ka(...e){const t=e[0].length;e.forEach(((e,o)=>bi((()=>e.length===t),vo("[[FUNCTION_NAME]] has mismatched dimensions for argument %s (%s vs %s).",o.toString(),t.toString(),e.length.toString()))))}function La(e,t){let o=0;const s=Bi(e,((e,t)=>(o+=1,e+t)),0,t);return _i(o),s/o}function Va(e,t){let o=0;for(let s of e)if(ni(s))for(let e of s)for(let t of e)"number"==typeof t.value&&(o+=1);else{const e=s?.value;yi(e)||"string"==typeof e&&!Us(e,t)&&!xs(e,t)||(o+=1)}return o}function Ua(e){return Hi(e,((e,t)=>void 0!==t&&null!==t.value?e+1:e),0)}function Ha(e,t){let o={value:-1/0};return Vi(e,(e=>{e.value>=o.value&&(o=e)}),t),o.value===-1/0?{value:0}:o}function Ba(e,t){let o={value:1/0};return Vi(e,(e=>{e.value<=o.value&&(o=e)}),t),o.value===1/0?{value:0}:o}function za(e,t,o){const s=e[0].length?e:[Be(1,t.flat().length+1)],i=s.length;let n=o[0].length?o:s;return n=n.length===i?Wi(n):n,{_X:s,_newX:n}}function $a(e,t,o=!0,s=!1){const i=t.flat(),n=i.length;let{_X:r}=za(e,t,[[]]);r=r.length===n?Wi(r):r.slice(),ka(r[0],i);const a=r.length,l=n-a-(o?1:0),c=[i],h=Wi(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=Wa(h,c);if(o||p.push([0]),!s)return p;const m=Na(g,Wi(g)),{inverted:f}=Fa(m);if(void 0===f)throw new di(vo("Matrix is not invertible"));let v=0,b=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;v+=s*s,b+=o*o}const S=Math.sqrt(v/l),y=b/(b+v),C=b/a/(v/l),w=[];for(let e=0;e<a;e++)w.push(S*Math.sqrt(f[e][e]));if(o){const e=Na(f,[d]),t=Na(Wi([d]),e);w.push(S*Math.sqrt(t[0][0]+1/i.length))}const E=[[p[0][0],w[0],y,C,b],[p[1][0],w[1],S,l,v]];for(let e=2;e<a;e++)E.push([p[e][0],w[e],"","",""]);return o?E.push([p[a][0],w[a],"","",""]):E.push([0,"","","",""]),E}function Ga(e,t,o,s){ka(t,e),bi((()=>o>=1),vo("Function [[FUNCTION_NAME]] A regression of order less than 1 cannot be possible."));const i=[e],n=t.map((e=>Be(0,o).map((t=>Math.pow(e,o-t)))));s&&n.forEach((e=>e.push(1)));const r=Wa(n,i);return s||r.push([0]),r}function Wa(e,t){const o=Na(e,Wi(e)),{inverted:s}=Fa(o);if(void 0===s)throw new di(vo("Matrix is not invertible"));const i=Na(e,t);return Wi(Na(s,i))}function qa(e,t,o){return e.reduce(((e,s,i)=>e+s*Math.pow(t,o-i)),0)}function Za(e){return e.map((e=>e.map((e=>Math.exp(e)))))}function ja(e){return e.map((e=>e.map((e=>Math.log(e)))))}function Ya(e,t,o,s){const{_X:i,_newX:n}=za(t,e,o),r=$a(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:Wi(l)}const Xa="(previous)",Ka="(next)";function Qa(e,t){const o=e.definition.rows.map((e=>e.nameWithGranularity)),s=t.filter((e=>o.includes(e.field))),i=e.definition.columns.map((e=>e.nameWithGranularity));return{colDomain:t.filter((e=>i.includes(e.field))),rowDomain:s}}function Ja(e,t,o){return"column"===t?Qa(e,o).colDomain:Qa(e,o).rowDomain}function el(e,t){return void 0!==tl(e,t)}function tl(e,t,o){let s=t;for(const t of e){const e=s.find((e=>e.value===t.value));if(!e)return;if(e.field===o)return s;s=e.children}return s}function ol(e,t,o){const s=(e=Pe(e)).find((e=>e.field===t));return s?(s.value=o,e):e}function sl(e,t){return t.some((t=>t.field===e))}function il(e,t){if(e.definition.rows.map((e=>e.nameWithGranularity)).includes(t))return"row";if(e.definition.columns.map((e=>e.nameWithGranularity)).includes(t))return"column";throw new Error(`Field ${t} not found in pivot`)}function nl(e){return e?e.map(rl).join(", "):""}function rl(e){return e?`${e.field}=${e.value}`:""}function al(e,t){const o=e.findIndex((e=>e.field===t));if(-1===o)return"";const s=e.slice(0,o),i=e.at(-1);return nl(i.field===t?s:[...s,i])}function ll(e,t){const o=e.findIndex((e=>e.field===t));return-1===o?"":nl([...e.slice(0,o),...e.slice(o+1)])}const cl=new n;function hl(e){return cl.get(e)}const dl={normalizeFunctionValue:e=>wi(e,si),toValueAndFormat:(e,t)=>({value:wi(e,si),format:"dd mmm yyyy"}),toFunctionValue:e=>`"${kn(wi(e,si),{locale:si,format:"mm/dd/yyyy"})}"`},ul={normalizeFunctionValue(e){const t=wi(e,si);if(t<1||t>31)throw new di(vo("%s is not a valid day of month (it should be a number between 1 and 31)",t));return t},toValueAndFormat:e=>({value:wi(e,si),format:"0"}),toFunctionValue:e=>`${e}`},gl={normalizeFunctionValue(e){const t=wi(e,si);if(t<1||t>7)throw new di(vo("%s is not a valid day of week (it should be a number between 1 and 7)",t));return t},toValueAndFormat(e,t){const o=(e-1+(t||si).weekStart)%7;return{value:Pn[o].toString(),format:"@"}},toFunctionValue:e=>`${e}`},pl={normalizeFunctionValue(e){const t=wi(e,si);if(t<0||t>53)throw new di(vo("%s is not a valid week (it should be a number between 0 and 53)",t));return t},toValueAndFormat:e=>({value:wi(e,si),format:"0"}),toFunctionValue:e=>`${e}`},ml={normalizeFunctionValue(e){const t=wi(e,si);if(t<1||t>12)throw new di(vo("%s is not a valid month (it should be a number between 1 and 12)",t));return t},toValueAndFormat:e=>({value:Nn[wi(e,si)-1].toString(),format:"@"}),toFunctionValue:e=>`${e}`},fl={normalizeFunctionValue(e){const t=wi(e,si);if(t<1||t>4)throw new di(vo("%s is not a valid quarter (it should be a number between 1 and 4)",t));return t},toValueAndFormat:e=>({value:vo("Q%(quarter_number)s",{quarter_number:e}),format:"@"}),toFunctionValue:e=>`${e}`},vl={normalizeFunctionValue:e=>wi(e,si),toValueAndFormat:e=>({value:wi(e,si),format:"0"}),toFunctionValue:e=>`${e}`},bl={normalizeFunctionValue(e){const t=wi(e,si);if(t<0||t>23)throw new di(vo("%s is not a valid hour (it should be a number between 0 and 23)",t));return t},toValueAndFormat:e=>({value:vo("%(hour_number)sh",{hour_number:e}),format:"@"}),toFunctionValue:e=>`${e}`},Sl={normalizeFunctionValue(e){const t=wi(e,si);if(t<0||t>59)throw new di(vo("%s is not a valid minute (it should be a number between 0 and 59)",t));return t},toValueAndFormat:e=>({value:vo("%(minute_number)s'",{minute_number:e}),format:"@"}),toFunctionValue:e=>`${e}`},yl={normalizeFunctionValue(e){const t=wi(e,si);if(t<0||t>59)throw new di(vo("%s is not a valid second (it should be a number between 0 and 59)",t));return t},toValueAndFormat:e=>({value:vo("%(second_number)s''",{second_number:e}),format:"@"}),toFunctionValue:e=>`${e}`};function Cl(e){return{normalizeFunctionValue:t=>null===t?null:e.normalizeFunctionValue(t),toValueAndFormat:(t,o)=>null===t?{value:vo("(Undefined)")}:e.toValueAndFormat(t,o),toFunctionValue:t=>null===t?"false":e.toFunctionValue(t)}}cl.add("day",Cl(dl)).add("year",Cl(vl)).add("day_of_month",Cl(ul)).add("iso_week_number",Cl(pl)).add("month_number",Cl(ml)).add("quarter_number",Cl(fl)).add("day_of_week",Cl(gl)).add("hour_number",Cl(bl)).add("minute_number",Cl(Sl)).add("second_number",Cl(yl));const wl={count:vo("Count"),count_distinct:vo("Count Distinct"),bool_and:vo("Boolean And"),bool_or:vo("Boolean Or"),max:vo("Maximum"),min:vo("Minimum"),avg:vo("Average"),sum:vo("Sum")},El=["max","min","avg","sum","count_distinct","count"],xl={integer:El,char:El,boolean:["count_distinct","count","bool_and","bool_or"]},Il={};for(const e in xl){Il[e]={};for(const t of xl[e])Il[e][t]=wl[t]}const Rl={count:e=>({value:Ua([e]),format:"0"}),count_distinct:e=>({value:Da([e]),format:"0"}),bool_and:e=>({value:Ta([e]).result}),bool_or:e=>({value:Aa([e]).result}),max:(e,t)=>Ha([e],t),min:(e,t)=>Ba([e],t),avg:(e,t)=>({value:La([e],t),format:Si(e)}),sum:(e,t)=>({value:_a([e],t),format:Si(e)})};function Tl(e){const t=Object.keys(e);if(!t.length)return 0;const o=t.map((e=>parseInt(e,10)));return Math.max(...o)}const Al={year:vo("Year"),quarter:vo("Quarter & Year"),month:vo("Month & Year"),week:vo("Week & Year"),day:vo("Day"),quarter_number:vo("Quarter"),month_number:vo("Month"),iso_week_number:vo("Week"),day_of_month:vo("Day of Month"),day_of_week:vo("Day of Week"),hour_number:vo("Hour"),minute_number:vo("Minute"),second_number:vo("Second")},_l=["date","datetime"];function Dl(e){const[t,o]=e.split(":");return o?{fieldName:t,granularity:o}:{fieldName:t}}function Ol(e){return _l.includes(e.type)}function Fl(e,t,o){const s=[e];o&&s.push(`"${o}"`);for(const{field:e,value:o,type:i}of t){if("measure"===e){s.push('"measure"',`"${o}"`);continue}const{granularity:t}=Dl(e),n=Ll(o,{type:i,granularity:t});s.push(`"${e}"`,n)}return s}function Ml(e,t){let o=0,s=0;const i=t.columns.map((e=>e.nameWithGranularity)),n=t.rows.map((e=>e.nameWithGranularity));for(;void 0!==e[o]&&e[o]===n[s];)o++,s++;for(s=0;void 0!==e[o]&&e[o]===i[s];)o++,s++;return e.length===o}function Nl(e,t){switch(t.type){case"HEADER":return`=PIVOT.HEADER(${Fl(e,t.domain).join(",")})`;case"VALUE":return`=PIVOT.VALUE(${Fl(e,t.domain,t.measure).join(",")})`;case"MEASURE_HEADER":return`=PIVOT.HEADER(${Fl(e,[...t.domain,{field:"measure",value:t.measure,type:"char"}]).join(",")})`}return""}function Pl(e,t){if(null===t||"null"===t)return null;const o="boolean"==typeof t?Di(t).toLocaleLowerCase():Di(t);if("null"===o)return null;if(!Ul.contains(e.type))throw new di(vo("Field %(field)s is not supported because of its type (%(type)s)",{field:e.displayName,type:e.type}));if("false"===o.toLowerCase())return!1;return Ul.get(e.type)(o,e.granularity)}function kl(e,t){if(!t)throw new Error("Missing granularity");return hl(t).normalizeFunctionValue(e)}function Ll(e,t){return null===e?'"null"':Hl.contains(t.type)?Hl.get(t.type)(e,t.granularity):`"${e}"`}function Vl(e,t){if(!t)throw new Error("Missing granularity");return hl(t).toFunctionValue(e)}const Ul=new n;Ul.add("date",kl).add("datetime",kl).add("integer",(e=>wi(e,si))).add("boolean",(e=>Mi(e))).add("char",(e=>Di(e)));const Hl=new n;function Bl(e){return e.displayName+(e.granularity?` (${Al[e.granularity]})`:"")}function zl(e,t,o){const{rowDomain:s,colDomain:i}=Qa(e,t);if(0===s.length&&0===i.length)return o;if(0===s.length&&i.length>0)return{...o,format:(o.format||"@")+"* "};const n=s.length-1,r=o.format||"@";return{...o,format:`${" ".repeat(n)}${r}* `}}Hl.add("date",Vl).add("datetime",Vl).add("integer",(e=>`${wi(e,si)}`)).add("boolean",(e=>Mi(e)?"TRUE":"FALSE")).add("char",(e=>`"${Di(e).replace(/"/g,'\\"')}"`));class $l extends Yr{isCutAllowed(e){return 1!==e.zones.length?"WrongCutSelection":"Success"}copy(e){const t=e.sheetId,{clippedZones:o,rowsIndexes:s,columnsIndexes:i}=e,n=[],r=1==s.length&&1==i.length;for(let o of s){let a=[];for(let n of i){const l={col:n,row:o,sheetId:t};let c=this.getters.getCell(l);const h=this.getters.getEvaluatedCell(l),d=this.getters.getPivotIdFromPosition(l),u=this.getters.getArrayFormulaSpreadingOn(l);if(d&&u){const t=this.getters.getSpreadZone(u);if((!ct(u,l)||!r)&&t&&!e.zones.some((e=>Zo(t,e)))){const e=this.getters.getPivotCellFromPosition(l),t=Nl(this.getters.getPivotFormulaId(d),e);c={id:c?.id||"",style:c?.style,format:c?.format,content:t,isFormula:!1,parsedValue:h.value}}}else if(u&&!ct(u,l)){const e=s.includes(u.row)&&i.includes(u.col)?"":kn(h.value,{locale:this.getters.getLocale()});c={id:c?.id||"",style:c?.style,format:h.format,content:e,isFormula:!1,parsedValue:h.value}}a.push({content:c?.content??"",style:c?.style,format:c?.format,tokens:c?.isFormula?c.compiledFormula.tokens.map((({value:e,type:t})=>({value:e,type:t}))):[],border:this.getters.getCellBorder(l)||void 0,evaluatedCell:h,position:l})}n.push(a)}return{cells:n,zones:o,sheetId:e.sheetId}}isPasteAllowed(e,t,o,s){if(!o.cells)return"Success";if(s?.isCutOperation&&void 0!==s?.pasteOption)return"WrongPasteOption";if(t.length>1&&(o.cells.length>1||o.cells[0].length>1))return"WrongPasteSelection";const i=o.cells.length,n=o.cells[0].length;for(const s of qr(t,o.cells))if(this.getters.doesIntersectMerge(e,s)&&(t.length>1||!this.getters.isSingleCellOrMerge(e,t[0])||i*n!=1))return"WillRemoveExistingMerge";return"Success"}paste(e,t,o){const s=e.zones,i=e.sheetId;o.isCutOperation?this.pasteFromCut(i,s,t,o):this.pasteFromCopy(i,s,t.cells,o)}getPasteTarget(e,t,o,s){const i=o.cells[0].length,n=o.cells.length;return s?.isCutOperation?{sheetId:e,zones:[{left:t[0].left,top:t[0].top,right:t[0].left+i-1,bottom:t[0].top+n-1}]}:1===i&&1===n?{zones:[],sheetId:e}:{sheetId:e,zones:qr(t,o.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){this.dispatch("CLEAR_CELLS",{sheetId:e.sheetId,target:e.zones}),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?.format??e.evaluatedCell.format;if("asValue"===o?.pasteOption)return void this.dispatch("UPDATE_CELL",{...t,content:e.evaluatedCell.value?.toString()||"",format:a});if("onlyFormat"===o?.pasteOption)return void this.dispatch("UPDATE_CELL",{...t,style:e?.style??null,format:a??r.format});let l=e?.content;e?.tokens&&e.tokens.length>0&&!o?.isCutOperation?l=this.getters.getTranslatedCellFormula(s,i-e.position.col,n-e.position.row,e.tokens):e?.tokens&&e.tokens.length>0&&(l=this.getters.getFormulaMovedInSheet(e.position.sheetId,s,e.tokens)),""!==l||e?.format||e?.style?this.dispatch("UPDATE_CELL",{...t,content:l,style:e?.style||null,format:e?.format}):r&&this.dispatch("CLEAR_CELL",t)}convertTextToClipboardData(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=Ra(e[o]||"",t);s.push({content:i,evaluatedCell:{formattedValue:i}})}o.cells.push(s)}return o}}class Gl extends jr{copy(e){}}class Wl extends Yr{uuidGenerator=new Gr;queuedChanges={};copy(e){if(!e.zones.length)return;const{rowsIndexes:t,columnsIndexes:o}=e,s=e.sheetId,i=[];for(const e of t){const t=[];for(const i of o){const o=Array.from(this.getters.getRulesByCell(s,i,e));t.push({position:{col:i,row:e,sheetId:s},rules:o})}i.push(t)}return{cfRules:i}}paste(e,t,o){if(this.queuedChanges={},"asValue"===o.pasteOption)return;const s=e.zones,i=e.sheetId;o.isCutOperation?this.pasteFromCut(i,s,t):this.pasteFromCopy(i,s,t.cfRules,o),this.executeQueuedChanges()}pasteFromCut(e,t,o){const s=t[0];this.pasteZone(e,s.left,s.top,o.cfRules,{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){if(e?.rules&&e.rules.length>0){const s=ts(t);for(const i of e.rules){const n=[];if(o&&n.push(ts(e.position)),e.position.sheetId===t.sheetId)this.adaptCFRules(e.position.sheetId,i,[s],n);else{this.adaptCFRules(e.position.sheetId,i,[],n);const o=this.getCFToCopyTo(t.sheetId,i);this.adaptCFRules(t.sheetId,o,[s],[])}}}}adaptCFRules(e,t,o,s){this.queuedChanges[e]||(this.queuedChanges[e]=[]);const i=this.queuedChanges[e].find((e=>e.cf.id===t.id));i?(i.toAdd.push(...o),i.toRemove.push(...s)):this.queuedChanges[e].push({toAdd:o,toRemove:s,cf:t})}executeQueuedChanges(){for(const e in this.queuedChanges)for(const{toAdd:t,toRemove:o,cf:s}of this.queuedChanges[e]){const i=this.getters.getAdaptedCfRanges(e,s,t,o);i&&(0!==i.length?this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:s.id,rule:s.rule,stopIfTrue:s.stopIfTrue},ranges:i,sheetId:e}):this.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:s.id,sheetId:e}))}}getCFToCopyTo(e,t){let o=this.getters.getConditionalFormats(e).find((e=>e.stopIfTrue===t.stopIfTrue&&ct(e.rule,t.rule)));const s=this.queuedChanges[e];return!o&&s&&(o=s.find((e=>e.cf.stopIfTrue===t.stopIfTrue&&ct(e.cf.rule,t.rule)))?.cf),o||{...t,id:this.uuidGenerator.uuidv4(),ranges:[]}}}class ql extends Yr{copy(e){const t=e.sheetId,{rowsIndexes:o,columnsIndexes:s,zones:i}=e,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){o.push({});continue}const l=this.getters.getCoreTable(s),c=l?.range.zone;let h;if(!n.has(a.id)&&l&&c&&i.some((e=>Zo(c,e)))){n.add(a.id);const e=[];for(const o of Be(c.left,c.right+1))e.push(this.getters.getFilterHiddenValues({sheetId:t,col:o,row:c.top}));h={range:l.range.rangeData,config:l.config,type:l.type}}o.push({table:h,style:this.getTableStyleToCopy(s),isWholeTableCopied:n.has(a.id)})}}return{tableCells:r,sheetId:e.sheetId}}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,...ut(o)},border:{...s,...ut(i)}}}paste(e,t,o){const s=e.zones,i=e.sheetId;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:[this.getters.getRangeFromRangeData(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=jo(this.getters.getRangeFromRangeData(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)||"asValue"===s?.pasteOption||(s?.pasteOption||t.isWholeTableCopied)&&"onlyFormat"!==s?.pasteOption||(t.style?.style&&this.dispatch("UPDATE_CELL",{...o,style:t.style.style}),t.style?.border&&this.dispatch("SET_BORDER",{...o,border:t.style.border}))}}const Zl={figureHandlers:new n,cellHandlers:new n};function jl(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?Bo(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?Vo(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function Yl(e,t){const o="DELETE_SHEET"===t.type&&t.sheetId;if("sheetId"in t&&e._sheetId!==t.sheetId)return e;{const s=jl(e._zone,t);if(s&&o!==e._sheetId)return{...e,_zone:s}}}Zl.figureHandlers.add("chart",class extends Gl{copy(e){const t=e.sheetId,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,s){return{zones:[],figureId:(new Gr).uuidv4(),sheetId:e}}paste(e,t,o){if(!e.figureId)return;const{zones:s,figureId:i}=e,n=e.sheetId,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 Gl{copy(e){const t=e.sheetId,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=Pe(this.getters.getImage(e.figureId));return{figureId:e.figureId,copiedFigure:s,copiedImage:i,sheetId:t}}getPasteTarget(e,t,o,s){return{sheetId:e,zones:[],figureId:(new Gr).uuidv4()}}paste(e,t,o){if(!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=Pe(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"}}),Zl.cellHandlers.add("dataValidation",class extends Yr{uuidGenerator=new Gr;queuedChanges={};copy(e){const{rowsIndexes:t,columnsIndexes:o}=e,s=e.sheetId,i=[];for(const e of t){const t=[];for(const i of o){const o={sheetId:s,col:i,row:e},n=this.getters.getValidationRuleForCell(o);t.push({position:o,rule:n})}i.push(t)}return{dvRules:i}}paste(e,t,o){if(this.queuedChanges={},o.pasteOption)return;const s=e.zones,i=e.sheetId;o.isCutOperation?this.pasteFromCut(i,s,t):this.pasteFromCopy(i,s,t.dvRules),this.executeQueuedChanges()}pasteFromCut(e,t,o){const s=t[0];this.pasteZone(e,s.left,s.top,o.dvRules,{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){if(e){const s=ts(t),i=e.rule;if(!i){const e=this.getters.getValidationRuleForCell(t);return void(e&&this.adaptDataValidationRule(t.sheetId,e,[],[s]))}const n=[];if(o&&n.push(ts(e.position)),e.position.sheetId===t.sheetId){const o=this.getDataValidationRuleToCopyTo(t.sheetId,i,!1);this.adaptDataValidationRule(e.position.sheetId,o,[s],n)}else{const o=this.getters.getValidationRuleForCell(e.position);o&&this.adaptDataValidationRule(e.position.sheetId,o,[],n);const r=this.getDataValidationRuleToCopyTo(t.sheetId,i);this.adaptDataValidationRule(t.sheetId,r,[s],[])}}}getDataValidationRuleToCopyTo(e,t,o=!0){let s=this.getters.getDataValidationRules(e).find((e=>ct(t.criterion,e.criterion)&&t.isBlocking===e.isBlocking));const i=this.queuedChanges[e];return!s&&i&&(s=i.find((e=>ct(t.criterion,e.rule.criterion)&&t.isBlocking===e.rule.isBlocking))?.rule),s||{...t,id:o?this.uuidGenerator.uuidv4():t.id,ranges:[]}}adaptDataValidationRule(e,t,o,s){this.queuedChanges[e]||(this.queuedChanges[e]=[]);const i=this.queuedChanges[e].find((e=>e.rule.id===t.id));i?(i.toAdd.push(...o),i.toRemove.push(...s)):this.queuedChanges[e].push({toAdd:o,toRemove:s,rule:t})}executeQueuedChanges(){for(const e in this.queuedChanges)for(const{toAdd:t,toRemove:o,rule:s}of this.queuedChanges[e]){const i=s.ranges.map((e=>e.zone)),n=no(i,o),r=no([...n,...t],[]);0!==r.length?this.dispatch("ADD_DATA_VALIDATION_RULE",{rule:s,ranges:r.map((t=>this.getters.getRangeDataFromZone(e,t))),sheetId:e}):this.dispatch("REMOVE_DATA_VALIDATION_RULE",{sheetId:e,id:s.id})}}}).add("cell",$l).add("sheet",class extends Yr{isPasteAllowed(e,t,o,s){if(!("cells"in o))return"Success";const{xSplit:i,ySplit:n}=this.getters.getPaneDivisions(e);for(const e of qr(t,o.cells))if(e.left<i&&e.right>=i||e.top<n&&e.bottom>=n)return"FrozenPaneOverlap";return"Success"}}).add("merge",class extends Yr{copy(e){const t=this.getters.getActiveSheetId(),{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.getMerge(s))}i.push(o)}return{merges:i}}paste(e,t,o){o.isCutOperation||this.pasteFromCopy(e.sheetId,e.zones,t.merges,o)}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.pasteMerge(r,n)}}pasteMerge(e,t){if(!e)return;if(this.getters.isInMerge(t))return;const{sheetId:o,col:s,row:i}=t;this.dispatch("ADD_MERGE",{sheetId:o,force:!0,target:[{left:s,top:i,right:s+e.right-e.left,bottom:i+e.bottom-e.top}]})}}).add("border",Xr).add("table",ql).add("conditionalFormat",Wl);class Xl{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 Kl extends Xl{dependencies=new Map;factory=new Ql(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 Ql{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 Jl{get;disposeCallbacks=[];constructor(e){this.get=e}onDispose(e){this.disposeCallbacks.push(e)}dispose(){this.disposeCallbacks.forEach((e=>e()))}}function ec(){const e=t.useEnv();if(e.__spreadsheet_stores__ instanceof Kl)return e.__spreadsheet_stores__;const o=new Kl;return t.useSubEnv({__spreadsheet_stores__:o,getStore:e=>ic(o.get(e),(()=>o.trigger("store-updated")))}),o}function tc(e){const o=nc(t.useEnv()),s=o.get(e);return sc(o,s)}function oc(e,...o){const s=nc(t.useEnv()),i=s.instantiate(e,...o);return t.onWillUnmount((()=>i.dispose())),sc(s,i)}function sc(e,o){const s=t.useComponent();return ic(o,(()=>{"mounted"===t.status(s)&&e.trigger("store-updated")}))}function ic(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 nc(e){const t=e.__spreadsheet_stores__;if(!(t instanceof Kl))throw new Error("No store provider found. Did you forget to call useStoreProvider()?");return t}const rc=(ac="Model",class{constructor(e){throw new Error(`This is a abstract store for ${ac}, it cannot be instantiated.\nDid you forget to inject your store instance?\n\nconst stores = useStoreProvider();\nstores.inject(MyMetaStore, storeInstance);\n`)}});var ac;class lc{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 cc extends Jl{model=this.get(rc);getters=this.model.getters;renderer=this.get(lc);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){}}const hc={id:"void-composer",get editionMode(){return"inactive"},startEdition:()=>{throw new Error("No composer is registered")},stopEdition:()=>{throw new Error("No composer is registered")},setCurrentContent:()=>{throw new Error("No composer is registered")}};class dc extends cc{mutators=["focusComposer","focusActiveComposer"];activeComposer=hc;_focusMode="inactive";get focusMode(){return"inactive"===this.activeComposer.editionMode?"inactive":this._focusMode}focusComposer(e,t){this.activeComposer=e,this.getters.isReadonly()||(this._focusMode=t.focusMode||"contentFocus","inactive"!==this._focusMode&&this.setComposerContent(t))}focusActiveComposer(e){if(!this.getters.isReadonly()){if(!this.activeComposer)throw new Error("No composer is registered");this._focusMode=e.focusMode||"contentFocus","inactive"!==this._focusMode&&this.setComposerContent(e)}}setComposerContent({content:e,selection:t}){"inactive"===this.activeComposer.editionMode?this.activeComposer.startEdition(e,t):e&&this.activeComposer.setCurrentContent(e,t)}}const uc="x1";function gc(e,t,o,s){let i=!1;const n=[];for(let s in o){let r=o[s];if(r.labelCell){const e=fc(r.labelCell,t);r.labelCell!==e&&(i=!0,r={...r,labelCell:e})}const a=fc(r.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===ci.InvalidReference?(i=!0,r=void 0):a!==r.dataRange&&(i=!0,r={...r,dataRange:a}),n[s]=r}let r=s;const a=fc(r,t);a!==r&&(i=!0,r=a);return{isStale:i,dataSets:n.filter(tt),labelRange:r}}function pc(e,t,o){return o.map((o=>({dataRange:Cr(e,t,o.dataRange),labelCell:o.labelCell?Cr(e,t,o.labelCell):void 0})))}function mc(e,t,o){return o?Cr(e,t,o):void 0}function fc(e,t){if(!e)return;const o=t(e);switch(o.changeType){case"NONE":return e;case"REMOVE":return;default:return o.range}}function vc(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({...bc(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({...bc(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 bc(e,t,o,s){if(o.left!==o.right&&o.top!==o.bottom)throw new Error(`Zone should be a single column or row: ${Lo(o)}`);if(s){const i=Lo(o),n=Lo(s);return{labelCell:e.getRangeFromSheetXC(t,n),dataRange:e.getRangeFromSheetXC(t,i)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,Lo(o))}}function Sc(e,t){const o=t.labelCell?.zone;let s=t.dataRange.zone;if(o){const{numberOfRows:e,numberOfCols:t}=jo(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",{useBoundedReference:!0})}),{label:n,range:e.getRangeString(i,"forceSheetReference",{useBoundedReference:!0}),backgroundColor:t.backgroundColor,rightYAxis:t.rightYAxis}}function yc(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",{useBoundedReference:!0})}function Cc(e,t){let o;if(e.labelRange){const s=jl(Mo(e.labelRange),t);o=s?Lo(s):void 0}const s=e.dataSets.map((e=>Mo(e.dataRange))).map((e=>jl(e,t))).filter(tt).map((e=>({dataRange:Lo(e)})));return{...e,labelRange:o,dataSets:s}}function wc(e){return e&&Lt(e)<.3?"#FFFFFF":"#000000"}function Ec(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!Io.test(e.dataRange)));if(t)return"InvalidDataSet";if(e.dataSets.map((e=>Mo(e.dataRange))).some((e=>e.top!==e.bottom&&ss(e))))return"InvalidDataSet"}return"Success"}function xc(e){if(e.labelRange){if(!Io.test(e.labelRange||""))return"InvalidLabelRange"}return"Success"}function Ic(e,t,o){if(!o)return!1;if(!e)return!1;if(!t)return!0;const s=is(t.dataRange.zone);return!(is(e.zone)<s)}function Rc(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 Tc(e){let t=!1,o=!1;if("horizontal"in e&&e.horizontal)return{useLeftAxis:!0,useRightAxis:!1};for(const s of e.dataSets||[])"y1"===s.yAxisId?o=!0:t=!0;return t||=!o,{useLeftAxis:t,useRightAxis:o}}function Ac({displayTitle:e,displayLegend:t}){let o=25;return e?o=0:t&&(o=10),{left:20,right:20,top:o,bottom:10}}function _c(e,t){const o=[],s=[],i=[];for(let e=0;e<t.data.length;e++)"number"==typeof t.data[e]&&(o.push(t.data[e]),s.push(e+1)),i.push(e+1);const n=Be(.5,i.length+.55,.2),r=Oc(e,o,s,n);if(r.length)return Dc(t,e,r,n)}function Dc(e,t,o,s){const i=Ut(e.backgroundColor);i.a=1;const n=t.color||Wt(Vt(i),.5);return{type:"line",xAxisID:uc,yAxisID:e.yAxisID,label:e.label?vo("Trend line for %s",e.label):"",data:o.map(((e,t)=>({x:s[t],y:e}))),order:-1,showLine:!0,pointRadius:0,backgroundColor:n,borderColor:n,borderDash:[5,5],borderWidth:void 0,fill:!1,pointBackgroundColor:n}}function Oc(e,t,o,s){if(t.length<2||o.length<2||0===s.length)return[];const{normalizedLabels:i,normalizedNewLabels:n}=function(e,t,o){let s=[],i=[];if("logarithmic"===o.type){const o=Math.max(...e.map(Math.abs));s=e.map((e=>e/o)),i=t.map((e=>e/o))}else{const o=Math.max(...e),n=Math.min(...e),r=o-n;s=e.map((e=>(e-o)/r)),i=t.map((e=>(e-o)/r))}return{normalizedLabels:s,normalizedNewLabels:i}}(o,s,e);try{switch(e.type){case"polynomial":{const o=e.order;if(!o)return Array.from({length:s.length},(()=>NaN));if(1===o)return Ya([t],[i],[n],!0)[0];const r=Ga(t,i,o,!0).flat();return n.map((e=>qa(r,e,o)))}case"exponential":{const e=[],o=[];for(let s=0;s<t.length;s++)t[s]>0&&(e.push(Math.log(t[s])),o.push(i[s]));return o.length?Za(Ya([e],[o],[n],!0))[0]:Array.from({length:s.length},(()=>NaN))}case"logarithmic":return Ya([t],ja([i]),ja([n]),!0)[0];default:return[]}}catch(e){return Array.from({length:s.length},(()=>NaN))}}function Fc(e){return t=>{if(t=Number(t),isNaN(t))return t;const{locale:o,format:s}=e;return kn(t,{locale:o,format:!s&&Math.abs(t)>=1e3?"#,##":s})}}function Mc(e,t){return new Jt(t,e.dataSets.map((e=>e.backgroundColor)))}const Nc=[{value:"left",label:vo("Left")},{value:"right",label:vo("Right")}],Pc={id:"chartShowValuesPlugin",afterDatasetsDraw(e,t,o){if(!o.showValues)return;const s=e._metasets?.[0]?.data;if(!s)return;const i=e.ctx;switch(i.save(),i.textAlign="center",i.textBaseline="middle",i.miterLimit=1,e.config.type){case"pie":case"doughnut":!function(e,t,o){for(const s of e._metasets)for(let e=0;e<s._parsed.length;e++){const i=Number(s._parsed[e]);if(isNaN(i)||0===i)continue;const n=s.data[e],{startAngle:r,endAngle:a,innerRadius:l,outerRadius:c}=n,h=(r+a)/2,d=(l+c)/2,u=n.x+d*Math.cos(h),g=n.y+d*Math.sin(h)+7;o.fillStyle=wc(t.background),o.strokeStyle=t.background||"#ffffff";kc(t.callback(i),u,g,o)}}(e,o,i);break;case"bar":case"line":o.horizontal?function(e,t,o){const s=e.chartArea.right,i=e.chartArea.left,n={};for(const r of e._metasets){if(r.xAxisID===uc)return;for(let e=0;e<r._parsed.length;e++){const a=r._parsed[e].x,l=t.callback(a-0),c=r.data[e],h=c.y;let d=a<0?c.x+c.width/2:c.x-c.width/2;d=Math.min(d,s),d=Math.max(d,i),n[h]||(n[h]=[]);const u=Or(o,l,{fontSize:12},"px");for(const e of n[h])Math.abs(e-d)<u&&(d=e+u+3);n[h].push(d),o.fillStyle=c.options.backgroundColor,o.strokeStyle=t.background||"#ffffff",kc(l,d,h,o)}}}(e,o,i):function(e,t,o){const s=e.chartArea.bottom,i=e.chartArea.top,n={};for(const r of e._metasets){if(r.xAxisID===uc)return;for(let a=0;a<r._parsed.length;a++){const l=r._parsed[a].y,c=r.data[a],h=c.x;let d=0;d="line"===e.config.type?c.y-10:l<0?c.y-c.height/2:c.y+c.height/2,d=Math.min(d,s),d=Math.max(d,i),n[h]||(n[h]=[]);for(const e of n[h]||[])Math.abs(e-d)<13&&(d=e-13);n[h].push(d),o.fillStyle=c.options.backgroundColor,o.strokeStyle=t.background||"#ffffff",kc(t.callback(l-0),h,d,o)}}}(e,o,i)}i.restore()}};function kc(e,t,o,s){s.lineWidth=3,s.strokeText(e,t,o),s.lineWidth=1,s.fillText(e,t,o)}const Lc={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=Uc(s,e);if(!o)break;const n=Vc(t),r=Vc(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 Vc(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 Uc(e,t){return e.find(((e,o)=>o>t&&0!==e.height))}window.Chart?.register(Lc),window.Chart?.register(Pc);class Hc 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(Pe(e.chartJsConfig))})),t.onWillUnmount((()=>this.chart?.destroy())),t.useEffect((()=>{const e=this.chartRuntime;e!==this.currentRuntime&&(e.chartJsConfig.type!==this.currentRuntime.chartJsConfig.type?(this.chart?.destroy(),this.createChart(Pe(e.chartJsConfig))):this.updateChartJs(Pe(e)),this.currentRuntime=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 Bc{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 zc(e,t,o,s,i){if("text"===t||"progress"===t||e?.type!==$s.number||o?.type!==$s.number)return;const n=o.value-e.value;return n>0?s:n<0?i:void 0}function $c(e,t,o){if("text"===o||e?.type!==$s.number||t?.type!==$s.number)return"neutral";const s=t.value-e.value;return s>0?"up":s<0?"down":"neutral"}function Gc(e){return e.keyValue&&!Io.test(e.keyValue)?"InvalidScorecardKeyValue":"Success"}function Wc(e){return e.baseline&&!Io.test(e.baseline)?"InvalidScorecardBaseline":"Success"}const qc=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"),Zc=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 jc=class e extends Bc{keyValue;baseline;baselineMode;baselineDescr;progressBar=!1;background;baselineColorUp;baselineColorDown;fontColor;humanize;type="scorecard";constructor(e,t,o){super(e,t,o),this.keyValue=wr(o,t,e.keyValue),this.baseline=wr(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp??Se,this.baselineColorDown=e.baselineColorDown??ye,this.humanize=e.humanize??!1}static validateChartDefinition(e,t){return e.checkValidations(t,Gc,Wc)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0].dataRange:void 0,title:e.title||{text:""},baselineMode:be,baselineColorUp:Se,baselineColorDown:ye,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,s;return e.baseline&&(o=jl(Mo(e.baseline),t)),e.keyValue&&(s=jl(Mo(e.keyValue),t)),{...e,baseline:o?Lo(o):void 0,keyValue:s?Lo(s):void 0}}copyForSheetId(t){const o=mc(this.sheetId,t,this.baseline),s=mc(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=fc(this.baseline,t),s=fc(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 Yc(e,t){const o=t.getContext("2d");t.width=e.canvas.width;const s=t.width-q;if(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 t=o.textBaseline;o.textBaseline="middle",o.fillText(zr(o,e.title.text,s-e.title.position.x),e.title.position.x,e.title.position.y),o.textBaseline=t}if(e.baseline&&(o.font=e.baseline.style.font,o.fillStyle=e.baseline.style.color,$r(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(qc);break;case"up":o.fill(Zc)}o.restore()}if(e.baselineDescr){const t=e.baselineDescr[0];o.font=t.style.font,o.fillStyle=t.style.color;for(const t of e.baselineDescr)o.fillText(zr(o,t.text,s-t.position.x),t.position.x,t.position.y)}if(e.key&&(o.font=e.key.style.font,o.fillStyle=e.key.style.color,$r(o,zr(o,e.key.text,s-e.key.position.x),e.key.position,e.key.style.underline,e.key.style.strikethrough)),e.progressBar){if(o.fillStyle=e.progressBar.style.backgroundColor,o.beginPath(),o.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width,e.progressBar.dimension.height,e.progressBar.dimension.height/2),o.fill(),o.fillStyle=e.progressBar.style.color,o.beginPath(),e.progressBar.value>0)o.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width*Math.max(0,Math.min(1,e.progressBar.value)),e.progressBar.dimension.height,e.progressBar.dimension.height/2);else{const t=e.progressBar.dimension.width*Math.max(0,Math.min(1,-e.progressBar.value));o.roundRect(e.progressBar.position.x+e.progressBar.dimension.width-t,e.progressBar.position.y,t,e.progressBar.dimension.height,e.progressBar.dimension.height/2)}o.fill()}}const Xc=10,Kc=.05;function Qc({width:e,height:t},o){return new Jc({width:e,height:t},o).computeDesign()}class Jc{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-Xc;break;default:s=Xc}e.title={text:this.title,style:t.title,position:{x:s,y:Xc+o/2}}}const s=t.baselineArrow?.size??0;let{height:i,width:n}=this.getTextDimensions(this.baseline,t.baselineValue.font);this.baseline||(i=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).height);const r=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).width;e.baseline={text:this.baseline,style:t.baselineValue,position:{x:(this.width-n-r+s)/2,y:this.keyValue?this.height*(1-Kc*(this.runtime.progressBar?1:2)):this.height-(this.height-o-i)/2-Xc}};const a=s+q;if(e.baseline.position.x<a&&(e.baseline.position.x=a),t.baselineArrow&&!this.runtime.progressBar&&(e.baselineArrow={direction:this.baselineArrow,style:t.baselineArrow,position:{x:e.baseline.position.x-s,y:e.baseline.position.y-(i+s)/2}}),this.baselineDescr){const o={x:e.baseline.position.x+n,y:e.baseline.position.y};e.baselineDescr=[{text:this.baselineDescr,style:t.baselineDescr,position:o}]}let l=0;this.runtime.progressBar&&(l=.05*this.height,e.progressBar={position:{x:20,y:.9*this.height-i-l},dimension:{height:l,width:this.width-40},value:this.runtime.progressBar.value,style:{color:this.runtime.progressBar.color,backgroundColor:this.secondaryFontColor}});const{width:c,height:h}=this.getFullTextDimensions(this.keyValue,t.keyValue.font);return this.keyValue&&(e.key={text:this.keyValue,style:t.keyValue,position:{x:Math.max(Xc,(this.width-c)/2),y:.4*this.height+5+(o+h/2)/2}}),e}get title(){return this.runtime.title.text??""}get keyValue(){return this.runtime.keyValue}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){return function(e,t){const o=e||"";return t&&o?" "+o:o}(this.runtime.baselineDescr,this.baseline)}get baselineArrow(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get secondaryFontColor(){return Lt(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(){let e=16;const t=Math.floor(.9*e);return this.runtime.progressBar&&(e/=1.5),{title:{font:_r(14,this.runtime.title.bold,this.runtime.title.italic),color:this.runtime.title.color??this.secondaryFontColor},keyValue:{color:this.runtime.keyValueStyle?.textColor||this.runtime.fontColor,font:_r(32,this.runtime.keyValueStyle?.bold,this.runtime.keyValueStyle?.italic),strikethrough:this.runtime.keyValueStyle?.strikethrough,underline:this.runtime.keyValueStyle?.underline},baselineValue:{font:_r(e,this.runtime.baselineStyle?.bold,this.runtime.baselineStyle?.italic),strikethrough:this.runtime.baselineStyle?.strikethrough,underline:this.runtime.baselineStyle?.underline,color:this.runtime.baselineStyle?.textColor||this.runtime.baselineColor||this.secondaryFontColor},baselineDescr:{font:_r(t),color:this.secondaryFontColor},baselineArrow:"neutral"===this.baselineArrow||this.runtime.progressBar?void 0:{size:this.keyValue?.8*e:0,color:this.runtime.baselineColor||this.secondaryFontColor}}}}class eh extends t.Component{static template="o-spreadsheet-ScorecardChart";static props={figure:Object};canvas=t.useRef("chartContainer");get runtime(){return this.env.model.getters.getChartRuntime(this.props.figure.id)}get title(){const e=this.env.model.getters.getChartDefinition(this.props.figure.id).title.text??"";return vo(e)}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;Yc(Qc(e.getBoundingClientRect(),this.runtime),e)}}const th=new n;function oh(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))}th.add("dataValidation",{getProposals(e,t){if(t.startsWith("="))return[];if(!this.composer.currentEditedCell)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(ot).map((e=>e.toString())).filter((e=>""!==e))))}return i.map((e=>({text:e})))},selectProposal(e,t){this.composer.setCurrentContent(t),this.composer.stopEdition()}});const sh=/(.*?)\((.*?)\)(.*)/,ih=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function nh(e,t=""){return function(e,t){let o=e.match(sh),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=ih.find((e=>t===e));o?n.push(o):"RANGE<ANY>"===t?n.push("RANGE"):"OPTIONAL"===t?r=!0:"REPEATING"===t?a=!0:t.startsWith("DEFAULT=")&&(i=e.trim().slice(8))}const l={name:s,description:t,type:n};(n.includes("ANY")||n.includes("RANGE"))&&(l.acceptErrors=!0);r&&(l.optional=!0);a&&(l.repeating=!0);void 0!==i&&(l.default=!0,l.defaultValue=i);n.some((e=>e.startsWith("RANGE")))&&(l.acceptMatrix=!0);n.every((e=>e.startsWith("RANGE")))&&(l.acceptMatrixOnly=!0);return l}(e,t)}function rh(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 ah(e,t){bi((()=>1===t.length||1===t[0].length),e)}function lh(e,...t){if(t.every(ni)){const o=t[0].length,s=t[0][0].length;for(const i of t)bi((()=>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 di(e)}function ch(e,t){bi((()=>t>0),e)}function hh(e,t){bi((()=>t.length===t[0].length),e)}const dh={description:vo("Returns a result array constrained to a specific width and height."),args:[nh("input_range (any, range<any>)",vo("The range to constrain.")),nh("rows (number)",vo("The number of rows in the constrained array.")),nh("columns (number)",vo("The number of columns in the constrained array."))],compute:function(e,t,o){const s=tn(e),i=Ri(t?.value,this.locale),n=Ri(o?.value,this.locale);ch(vo("The rows argument (%s) must be strictly positive.",i.toString()),i),ch(vo("The columns argument (%s) must be strictly positive.",i.toString()),n);const r=Math.min(i,s[0].length);return $i(Math.min(n,s.length),r,((e,t)=>s[e][t]))},isExported:!1},uh={description:vo("Creates a new array from the selected columns in the existing range."),args:[nh("array (any, range<any>)",vo("The array that contains the columns to be returned.")),nh("col_num (number, range<number>)",vo("The first column index of the columns to be returned.")),nh("col_num2 (number, range<number>, repeating)",vo("The columns indexes of the columns to be returned."))],compute:function(e,...t){const o=tn(e),s=on(t,(e=>Ri(e?.value,this.locale))),i=s.filter((e=>0===e||o.length<Math.abs(e)));bi((()=>0===i.length),vo("The columns arguments must be between -%s and %s (got %s), excluding 0.",o.length.toString(),o.length.toString(),i.join(",")));const n=Array(s.length);for(let e=0;e<s.length;e++)s[e]>0?n[e]=o[s[e]-1]:n[e]=o[o.length+s[e]];return n},isExported:!0},gh={description:vo("Creates a new array from the selected rows in the existing range."),args:[nh("array (any, range<any>)",vo("The array that contains the rows to be returned.")),nh("row_num (number, range<number>)",vo("The first row index of the rows to be returned.")),nh("row_num2 (number, range<number>, repeating)",vo("The rows indexes of the rows to be returned."))],compute:function(e,...t){const o=tn(e),s=on(t,(e=>Ri(e?.value,this.locale))),i=o.length,n=s.filter((e=>0===e||o[0].length<Math.abs(e)));return bi((()=>0===n.length),vo("The rows arguments must be between -%s and %s (got %s), excluding 0.",o[0].length.toString(),o[0].length.toString(),n.join(","))),$i(i,s.length,((e,t)=>s[t]>0?o[e][s[t]-1]:o[e][o[e].length+s[t]]))},isExported:!0},ph={description:vo("Expands or pads an array to specified row and column dimensions."),args:[nh("array (any, range<any>)",vo("The array to expand.")),nh("rows (number)",vo("The number of rows in the expanded array. If missing, rows will not be expanded.")),nh("columns (number, optional)",vo("The number of columns in the expanded array. If missing, columns will not be expanded.")),nh("pad_with (any, default=0)",vo("The value with which to pad."))],compute:function(e,t,o,s={value:0}){const i=tn(e),n=Ri(t?.value,this.locale),r=void 0!==o?Ri(o.value,this.locale):i.length;return bi((()=>n>=i[0].length),vo("The rows arguments (%s) must be greater or equal than the number of rows of the array.",n.toString())),bi((()=>r>=i.length),vo("The columns arguments (%s) must be greater or equal than the number of columns of the array.",r.toString())),$i(r,n,((e,t)=>e>=i.length||t>=i[e].length?s:i[e][t]))},isExported:!0},mh={description:vo("Flattens all the values from one or more ranges into a single column."),args:[nh("range (any, range<any>)",vo("The first range to flatten.")),nh("range2 (any, range<any>, repeating)",vo("Additional ranges to flatten."))],compute:function(...e){return[on(e,(e=>void 0===e?{value:""}:e))]},isExported:!1},fh={description:vo("Calculates the frequency distribution of a range."),args:[nh("data (range<number>)",vo("The array of ranges containing the values to be counted.")),nh("classes (number, range<number>)",vo("The range containing the set of classes."))],compute:function(e,t){const o=on([e],(e=>e.value)).filter((e=>"number"==typeof e)),s=on([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},vh={description:vo("Appends ranges horizontally and in sequence to return a larger array."),args:[nh("range1 (any, range<any>)",vo("The first range to be appended.")),nh("range2 (any, range<any>, repeating)",vo("Additional ranges to add to range1."))],compute:function(...e){const t=Math.max(...e.map((e=>e?.[0]?.length??0))),o=[];for(const s of e){const e=tn(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},bh={description:vo("Returns the matrix determinant of a square matrix."),args:[nh("square_matrix (number, range<number>)",vo("An range with an equal number of rows and columns representing a matrix whose determinant will be calculated."))],compute:function(e){const t=xi(e,"square_matrix");return hh(vo("The argument square_matrix must have the same number of columns and rows."),t),Fa(t).determinant},isExported:!0},Sh={description:vo("Returns the multiplicative inverse of a square matrix."),args:[nh("square_matrix (number, range<number>)",vo("An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated."))],compute:function(e){const t=xi(e,"square_matrix");hh(vo("The argument square_matrix must have the same number of columns and rows."),t);const{inverted:o}=Fa(t);if(!o)throw new di(vo("The matrix is not invertible."));return o},isExported:!0},yh={description:vo("Calculates the matrix product of two matrices."),args:[nh("matrix1 (number, range<number>)",vo("The first matrix in the matrix multiplication operation.")),nh("matrix2 (number, range<number>)",vo("The second matrix in the matrix multiplication operation."))],compute:function(e,t){const o=xi(e,"matrix1"),s=xi(t,"matrix2");return bi((()=>o.length===s[0].length),vo("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())),Na(o,s)},isExported:!0},Ch={description:vo("Calculates the sum of the products of corresponding entries in equal-sized ranges."),args:[nh("range1 (number, range<number>)",vo("The first range whose entries will be multiplied with corresponding entries in the other ranges.")),nh("range2 (number, range<number>, repeating)",vo("The other range whose entries will be multiplied with corresponding entries in the other ranges."))],compute:function(...e){lh(vo("All the ranges must have the same dimensions."),...e);const t=e.map(tn);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*=wi(o[e][s],this.locale);o+=i}return o},isExported:!0};function wh(e,t,o){lh("The arguments array_x and array_y must have the same dimensions.",e,t);const s=tn(e),i=tn(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 di(vo("The arguments array_x and array_y must contain at least one pair of numbers."));return r}const Eh={description:vo("Calculates the sum of the difference of the squares of the values in two array."),args:[nh("array_x (number, range<number>)",vo("The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.")),nh("array_y (number, range<number>)",vo("The array or range of values whose squares will be subtracted from the squares of corresponding entries in array_x and added together."))],compute:function(e,t){return wh(e,t,((e,t)=>e**2-t**2))},isExported:!0},xh={description:vo("Calculates the sum of the sum of the squares of the values in two array."),args:[nh("array_x (number, range<number>)",vo("The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.")),nh("array_y (number, range<number>)",vo("The array or range of values whose squares will be added to the squares of corresponding entries in array_x and added together."))],compute:function(e,t){return wh(e,t,((e,t)=>e**2+t**2))},isExported:!0},Ih={description:vo("Calculates the sum of squares of the differences of values in two array."),args:[nh("array_x (number, range<number>)",vo("The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.")),nh("array_y (number, range<number>)",vo("The array or range of values that will be subtracted from corresponding entries in array_x, the result squared, and all such results added together."))],compute:function(e,t){return wh(e,t,((e,t)=>(e-t)**2))},isExported:!0},Rh=!1,Th=[nh("array (any, range<any>)",vo("The array which will be transformed.")),nh("ignore (number, default=0)",vo("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.")),nh("scan_by_column (number, default=false)",vo("Whether the array should be scanned by column. True scans the array by column and false (default) scans the array by row."))];function Ah(e){const t=Math.trunc(e);if(0===t)return()=>!0;if(1===t)return e=>null!==e.value;if(2===t)return e=>!yi(e.value);if(3===t)return e=>null!==e.value&&!yi(e.value);throw new di(vo("Argument ignore must be between 0 and 3"))}const _h={description:vo("Transforms a range of cells into a single column."),args:Th,compute:function(e,t={value:0},o={value:Rh}){const s=tn(e),i=wi(t.value,this.locale),n=(Mi(o.value)?s:Wi(s)).flat().filter(Ah(i));if(0===n.length)throw new pi(vo("No results for the given arguments of TOCOL."));return[n]},isExported:!0},Dh={description:vo("Transforms a range of cells into a single row."),args:Th,compute:function(e,t={value:0},o={value:Rh}){const s=tn(e),i=wi(t.value,this.locale),n=(Mi(o.value)?s:Wi(s)).flat().filter(Ah(i)).map((e=>[e]));if(0===n.length||0===n[0].length)throw new pi(vo("No results for the given arguments of TOROW."));return n},isExported:!0},Oh={description:vo("Transposes the rows and columns of a range."),args:[nh("range (any, range<any>)",vo("The range to be transposed."))],compute:function(e){const t=tn(e);return $i(t[0].length,t.length,((e,o)=>t[o][e]))},isExported:!0},Fh={description:vo("Appends ranges vertically and in sequence to return a larger array."),args:[nh("range1 (any, range<any>)",vo("The first range to be appended.")),nh("range2 (any, range<any>, repeating)",vo("Additional ranges to add to range1."))],compute:function(...e){const t=Math.max(...e.map((e=>tn(e).length))),o=e.reduce(((e,t)=>e+tn(t)[0].length),0),s=Array(t).fill([]).map((()=>Array(o).fill({value:0})));let i=0;for(const t of e){const e=tn(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},Mh={description:vo("Wraps the provided row or column of cells by columns after a specified number of elements to form a new array."),args:[nh("range (any, range<any>)",vo("The range to wrap.")),nh("wrap_count (number)",vo("The maximum number of cells for each column, rounded down to the nearest whole number.")),nh("pad_with (any, default=0)",vo("The value with which to fill the extra cells in the range."))],compute:function(e,t,o={value:0}){const s=tn(e),i=Ri(t?.value,this.locale);ah(vo("Argument range must be a single row or column."),s);const n=s.flat();return $i(Math.ceil(n.length/i),i,((e,t)=>{const s=e*i+t;return s<n.length?n[s]:o}))},isExported:!0},Nh={description:vo("Wraps the provided row or column of cells by rows after a specified number of elements to form a new array."),args:[nh("range (any, range<any>)",vo("The range to wrap.")),nh("wrap_count (number)",vo("The maximum number of cells for each row, rounded down to the nearest whole number.")),nh("pad_with (any, default=0)",vo("The value with which to fill the extra cells in the range."))],compute:function(e,t,o={value:0}){const s=tn(e),i=Ri(t?.value,this.locale);ah(vo("Argument range must be a single row or column."),s);const n=s.flat(),r=Math.ceil(n.length/i);return $i(i,r,((e,t)=>{const s=t*i+e;return s<n.length?n[s]:o}))},isExported:!0};var Ph=Object.freeze({__proto__:null,ARRAY_CONSTRAIN:dh,CHOOSECOLS:uh,CHOOSEROWS:gh,EXPAND:ph,FLATTEN:mh,FREQUENCY:fh,HSTACK:vh,MDETERM:bh,MINVERSE:Sh,MMULT:yh,SUMPRODUCT:Ch,SUMX2MY2:Eh,SUMX2PY2:xh,SUMXMY2:Ih,TOCOL:_h,TOROW:Dh,TRANSPOSE:Oh,VSTACK:Fh,WRAPCOLS:Mh,WRAPROWS:Nh});const kh={description:vo("Apply a large number format"),args:[nh("value (number)",vo("The number.")),nh("unit (string, optional)",vo("The formatting unit. Use 'k', 'm', or 'b' to force the unit"))],compute:function(e,t){return{value:wi(e,this.locale),format:or(e,t,this.locale)}}};var Lh=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:kh});const Vh=/^-?[a-z0-9]+$/i,Uh={description:vo("Absolute value of a number."),args:[nh("value (number)",vo("The number of which to return the absolute value."))],compute:function(e){return Math.abs(wi(e,this.locale))},isExported:!0},Hh={description:vo("Inverse cosine of a value, in radians."),args:[nh("value (number)",vo("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive."))],compute:function(e){const t=wi(e,this.locale);return bi((()=>Math.abs(t)<=1),vo("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},Bh={description:vo("Inverse hyperbolic cosine of a number."),args:[nh("value (number)",vo("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1."))],compute:function(e){const t=wi(e,this.locale);return bi((()=>t>=1),vo("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},zh={description:vo("Inverse cotangent of a value."),args:[nh("value (number)",vo("The value for which to calculate the inverse cotangent."))],compute:function(e){const t=wi(e,this.locale);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},$h={description:vo("Inverse hyperbolic cotangent of a value."),args:[nh("value (number)",vo("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive."))],compute:function(e){const t=wi(e,this.locale);return bi((()=>Math.abs(t)>1),vo("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},Gh={description:vo("Inverse sine of a value, in radians."),args:[nh("value (number)",vo("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive."))],compute:function(e){const t=wi(e,this.locale);return bi((()=>Math.abs(t)<=1),vo("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Wh={description:vo("Inverse hyperbolic sine of a number."),args:[nh("value (number)",vo("The value for which to calculate the inverse hyperbolic sine."))],compute:function(e){return Math.asinh(wi(e,this.locale))},isExported:!0},qh={description:vo("Inverse tangent of a value, in radians."),args:[nh("value (number)",vo("The value for which to calculate the inverse tangent."))],compute:function(e){return Math.atan(wi(e,this.locale))},isExported:!0},Zh={description:vo("Angle from the X axis to a point (x,y), in radians."),args:[nh("x (number)",vo("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),nh("y (number)",vo("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis."))],compute:function(e,t){const o=wi(e,this.locale),s=wi(t,this.locale);return bi((()=>0!==o||0!==s),vo("Function [[FUNCTION_NAME]] caused a divide by zero error."),ci.DivisionByZero),Math.atan2(s,o)},isExported:!0},jh={description:vo("Inverse hyperbolic tangent of a number."),args:[nh("value (number)",vo("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive."))],compute:function(e){const t=wi(e,this.locale);return bi((()=>Math.abs(t)<1),vo("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},Yh={description:vo("Rounds number up to nearest multiple of factor."),args:[nh("value (number)",vo("The value to round up to the nearest integer multiple of factor.")),nh("factor (number, default=1)",vo("The number to whose multiples value will be rounded."))],compute:function(e,t={value:1}){const o=wi(e,this.locale),s=wi(t,this.locale);return bi((()=>s>=0||o<=0),vo("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 Xh(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 Kh={description:vo("Rounds number up to nearest multiple of factor."),args:[nh("number (number)",vo("The value to round up to the nearest integer multiple of significance.")),nh("significance (number, default=1)",vo("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),nh("mode (number, default=0)",vo("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero."))],compute:function(e,t={value:1},o={value:0}){const s=wi(t,this.locale);return{value:Xh(wi(e,this.locale),s,wi(o,this.locale)),format:e?.format}},isExported:!0},Qh={description:vo("Rounds number up to nearest multiple of factor."),args:[nh("number (number)",vo("The value to round up to the nearest integer multiple of significance.")),nh("significance (number, default=1)",vo("The number to whose multiples number will be rounded."))],compute:function(e,t={value:1}){const o=wi(t,this.locale);return{value:Xh(wi(e,this.locale),o),format:e?.format}},isExported:!0},Jh={description:vo("Cosine of an angle provided in radians."),args:[nh("angle (number)",vo("The angle to find the cosine of, in radians."))],compute:function(e){return Math.cos(wi(e,this.locale))},isExported:!0},ed={description:vo("Hyperbolic cosine of any real number."),args:[nh("value (number)",vo("Any real value to calculate the hyperbolic cosine of."))],compute:function(e){return Math.cosh(wi(e,this.locale))},isExported:!0},td={description:vo("Cotangent of an angle provided in radians."),args:[nh("angle (number)",vo("The angle to find the cotangent of, in radians."))],compute:function(e){const t=wi(e,this.locale);return _i(t),1/Math.tan(t)},isExported:!0},od={description:vo("Hyperbolic cotangent of any real number."),args:[nh("value (number)",vo("Any real value to calculate the hyperbolic cotangent of."))],compute:function(e){const t=wi(e,this.locale);return _i(t),1/Math.tanh(t)},isExported:!0},sd={description:vo("Number of empty values."),args:[nh("value1 (any, range)",vo("The first value or range in which to count the number of blanks.")),nh("value2 (any, range, repeating)",vo("Additional values or ranges in which to count the number of blanks."))],compute:function(...e){return Hi(e,((e,t)=>void 0===t||null===t.value||""===t.value?e+1:e),0)},isExported:!0},id={description:vo("A conditional count across a range."),args:[nh("range (range)",vo("The range that is tested against criterion.")),nh("criterion (string)",vo("The pattern or test to apply to range."))],compute:function(...e){let t=0;return Xi(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0},nd={description:vo("Count values depending on multiple criteria."),args:[nh("criteria_range1 (range)",vo("The range to check against criterion1.")),nh("criterion1 (string)",vo("The pattern or test to apply to criteria_range1.")),nh("criteria_range2 (any, range, repeating)",vo("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.")),nh("criterion2 (string, repeating)",vo("Additional criteria to check."))],compute:function(...e){let t=0;return Xi(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0},rd={description:vo("Counts number of unique values in a range."),args:[nh("value1 (any, range)",vo("The first value or range to consider for uniqueness.")),nh("value2 (any, range, repeating)",vo("Additional values or ranges to consider for uniqueness."))],compute:function(...e){return Da(e)}},ad={description:vo("Counts number of unique values in a range, filtered by a set of criteria."),args:[nh("range (range)",vo("The range of cells from which the number of unique values will be counted.")),nh("criteria_range1 (range)",vo("The range of cells over which to evaluate criterion1.")),nh("criterion1 (string)",vo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),nh("criteria_range2 (any, range, repeating)",vo("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.")),nh("criterion2 (string, repeating)",vo("The pattern or test to apply to criteria_range2."))],compute:function(e,...t){let o=new Set;return Xi(t,((t,s)=>{const i=e[t]?.[s];sn(i)&&o.add(i.value)}),this.locale),o.size}},ld={description:vo("Cosecant of an angle provided in radians."),args:[nh("angle (number)",vo("The angle to find the cosecant of, in radians."))],compute:function(e){const t=wi(e,this.locale);return _i(t),1/Math.sin(t)},isExported:!0},cd={description:vo("Hyperbolic cosecant of any real number."),args:[nh("value (number)",vo("Any real value to calculate the hyperbolic cosecant of."))],compute:function(e){const t=wi(e,this.locale);return _i(t),1/Math.sinh(t)},isExported:!0},hd={description:vo("Converts from another base to decimal."),args:[nh("value (string)",vo("The number to convert.")),nh("base (number)",vo("The base to convert the value from."))],compute:function(e,t){let o=wi(t,this.locale);o=Math.floor(o),bi((()=>2<=o&&o<=36),vo("The base (%s) must be between 2 and 36 inclusive.",o.toString()));const s=Di(e);if(""===s)return 0;bi((()=>!!Vh.test(s)),vo("The value (%s) must be a valid base %s representation.",s,o.toString()));const i=parseInt(s,o);return bi((()=>!isNaN(i)),vo("The value (%s) must be a valid base %s representation.",s,o.toString())),i},isExported:!0},dd={description:vo("Converts an angle value in radians to degrees."),args:[nh("angle (number)",vo("The angle to convert from radians to degrees."))],compute:function(e){return 180*wi(e,this.locale)/Math.PI},isExported:!0},ud={description:vo("Euler's number, e (~2.718) raised to a power."),args:[nh("value (number)",vo("The exponent to raise e."))],compute:function(e){return Math.exp(wi(e,this.locale))},isExported:!0},gd={description:vo("Rounds number down to nearest multiple of factor."),args:[nh("value (number)",vo("The value to round down to the nearest integer multiple of factor.")),nh("factor (number, default=1)",vo("The number to whose multiples value will be rounded."))],compute:function(e,t={value:1}){const o=wi(e,this.locale),s=wi(t,this.locale);return bi((()=>s>=0||o<=0),vo("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 pd(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 md={description:vo("Rounds number down to nearest multiple of factor."),args:[nh("number (number)",vo("The value to round down to the nearest integer multiple of significance.")),nh("significance (number, default=1)",vo("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),nh("mode (number, default=0)",vo("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero."))],compute:function(e,t={value:1},o={value:0}){const s=wi(t,this.locale);return{value:pd(wi(e,this.locale),s,wi(o,this.locale)),format:e?.format}},isExported:!0},fd={description:vo("Rounds number down to nearest multiple of factor."),args:[nh("number (number)",vo("The value to round down to the nearest integer multiple of significance.")),nh("significance (number, default=1)",vo("The number to whose multiples number will be rounded."))],compute:function(e,t={value:1}){const o=wi(t,this.locale);return{value:pd(wi(e,this.locale),o),format:e?.format}},isExported:!0},vd={description:vo("Whether the provided value is even."),args:[nh("value (number)",vo("The value to be verified as even."))],compute:function(e){const t=Ii(e,this.locale);return!(1&Math.floor(Math.abs(t)))},isExported:!0},bd={description:vo("Rounds number up to nearest multiple of factor."),args:[nh("number (number)",vo("The value to round up to the nearest integer multiple of significance.")),nh("significance (number, default=1)",vo("The number to whose multiples number will be rounded."))],compute:function(e,t={value:1}){return{value:Xh(wi(e,this.locale),wi(t,this.locale)),format:e?.format}},isExported:!0},Sd={description:vo("Whether the provided value is even."),args:[nh("value (number)",vo("The value to be verified as even."))],compute:function(e){const t=Ii(e,this.locale);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},yd={description:vo("The logarithm of a number, base e (euler's number)."),args:[nh("value (number)",vo("The value for which to calculate the logarithm, base e."))],compute:function(e){const t=wi(e,this.locale);return bi((()=>t>0),vo("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0};function Cd(e,t){bi((()=>0!==t),vo("The divisor must be different from 0."),ci.DivisionByZero);const o=e%t;return o>0&&t<0||o<0&&t>0?o+t:o}const wd={description:vo("Modulo (remainder) operator."),args:[nh("dividend (number)",vo("The number to be divided to find the remainder.")),nh("divisor (number)",vo("The number to divide by."))],compute:function(e,t){const o=wi(t,this.locale);return{value:Cd(wi(e,this.locale),o),format:e?.format}},isExported:!0},Ed={description:vo("Returns a n x n unit matrix, where n is the input dimension."),args:[nh("dimension (number)",vo("An integer specifying the dimension size of the unit matrix. It must be positive."))],compute:function(e){const t=Ri(e,this.locale);return ch(vo("The argument dimension must be positive"),t),Oa(t)},isExported:!0},xd={description:vo("Rounds a number up to the nearest odd integer."),args:[nh("value (number)",vo("The value to round to the next greatest odd number."))],compute:function(e){const t=wi(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},Id={description:vo("The number pi."),args:[],compute:function(){return Math.PI},isExported:!0},Rd={description:vo("A number raised to a power."),args:[nh("base (number)",vo("The number to raise to the exponent power.")),nh("exponent (number)",vo("The exponent to raise base to."))],compute:function(e,t){const o=wi(e,this.locale),s=wi(t,this.locale);return bi((()=>o>=0||Number.isInteger(s)),vo("The exponent (%s) must be an integer when the base is negative.",s.toString())),{value:Math.pow(o,s),format:e?.format}},isExported:!0},Td={description:vo("Result of multiplying a series of numbers together."),args:[nh("factor1 (number, range<number>)",vo("The first number or range to calculate for the product.")),nh("factor2 (number, range<number>, repeating)",vo("More numbers or ranges to calculate for the product."))],compute:function(...e){let t=0,o=1;for(let s of e)if(ni(s))for(let e of s)for(let s of e){const e=s.value;if("number"==typeof e&&(o*=e,t+=1),yi(e))throw s}else void 0!==s&&null!==s.value&&(o*=Ii(s,this.locale),t+=1);return{value:0===t?0:o,format:Si(e[0])}},isExported:!0},Ad={description:vo("A random number between 0 inclusive and 1 exclusive."),args:[],compute:function(){return Math.random()},isExported:!0},_d={description:vo("Returns a grid of random numbers between 0 inclusive and 1 exclusive."),args:[nh("rows (number, default=1)",vo("The number of rows to be returned.")),nh("columns (number, default=1)",vo("The number of columns to be returned.")),nh("min (number, default=0)",vo("The minimum number you would like returned.")),nh("max (number, default=1)",vo("The maximum number you would like returned.")),nh("whole_number (number, default=FALSE)",vo("Return a whole number or a decimal value."))],compute:function(e={value:1},t={value:1},o={value:0},s={value:1},i={value:!1}){const n=Ri(t,this.locale),r=Ri(e,this.locale),a=wi(o,this.locale),l=wi(s,this.locale),c=Mi(i);ch(vo("The number of columns (%s) must be positive.",n.toString()),n),ch(vo("The number of rows (%s) must be positive.",r.toString()),r),bi((()=>a<=l),vo("The maximum (%s) must be greater than or equal to the minimum (%s).",l.toString(),a.toString())),c&&bi((()=>Number.isInteger(a)&&Number.isInteger(l)),vo("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},Dd={description:vo("Random integer between two values, inclusive."),args:[nh("low (number)",vo("The low end of the random range.")),nh("high (number)",vo("The high end of the random range."))],compute:function(e,t){let o=wi(e,this.locale);Number.isInteger(o)||(o=Math.ceil(o));let s=wi(t,this.locale);return Number.isInteger(s)||(s=Math.floor(s)),bi((()=>o<=s),vo("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},Od={description:vo("Rounds a number according to standard rules."),args:[nh("value (number)",vo("The value to round to places number of places.")),nh("places (number, default=0)",vo("The number of decimal places to which to round."))],compute:function(e,t={value:0}){const o=wi(e,this.locale);let s=wi(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},Fd={description:vo("Rounds down a number."),args:[nh("value (number)",vo("The value to round to places number of places, always rounding down.")),nh("places (number, default=0)",vo("The number of decimal places to which to round."))],compute:function(e,t={value:0}){const o=wi(e,this.locale);let s=wi(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},Md={description:vo("Rounds up a number."),args:[nh("value (number)",vo("The value to round to places number of places, always rounding up.")),nh("places (number, default=0)",vo("The number of decimal places to which to round."))],compute:function(e,t={value:0}){const o=wi(e,this.locale);let s=wi(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},Nd={description:vo("Secant of an angle provided in radians."),args:[nh("angle (number)",vo("The angle to find the secant of, in radians."))],compute:function(e){return 1/Math.cos(wi(e,this.locale))},isExported:!0},Pd={description:vo("Hyperbolic secant of any real number."),args:[nh("value (number)",vo("Any real value to calculate the hyperbolic secant of."))],compute:function(e){return 1/Math.cosh(wi(e,this.locale))},isExported:!0},kd={description:vo("Returns a sequence of numbers."),args:[nh("rows (number)",vo("The number of rows to return")),nh("columns (number, optional, default=1)",vo("The number of columns to return")),nh("start (number, optional, default=1)",vo("The first number in the sequence")),nh("step (number, optional, default=1)",vo("The amount to increment each value in the sequence"))],compute:function(e,t={value:1},o={value:1},s={value:1}){const i=wi(o,this.locale),n=wi(s,this.locale),r=Ri(e,this.locale),a=Ri(t,this.locale);return ch(vo("The number of columns (%s) must be positive.",a),a),ch(vo("The number of rows (%s) must be positive.",r),r),$i(a,r,((e,t)=>({value:i+t*a*n+e*n})))},isExported:!0},Ld={description:vo("Sine of an angle provided in radians."),args:[nh("angle (number)",vo("The angle to find the sine of, in radians."))],compute:function(e){return Math.sin(wi(e,this.locale))},isExported:!0},Vd={description:vo("Hyperbolic sine of any real number."),args:[nh("value (number)",vo("Any real value to calculate the hyperbolic sine of."))],compute:function(e){return Math.sinh(wi(e,this.locale))},isExported:!0},Ud={description:vo("Positive square root of a positive number."),args:[nh("value (number)",vo("The number for which to calculate the positive square root."))],compute:function(e){const t=wi(e,this.locale);return bi((()=>t>=0),vo("The value (%s) must be positive or null.",t.toString())),{value:Math.sqrt(t),format:e?.format}},isExported:!0},Hd={description:vo("Sum of a series of numbers and/or cells."),args:[nh("value1 (number, range<number>)",vo("The first number or range to add together.")),nh("value2 (number, range<number>, repeating)",vo("Additional numbers or ranges to add to value1."))],compute:function(...e){const t=e[0];return{value:_a(e,this.locale),format:Si(t)}},isExported:!0},Bd={description:vo("A conditional sum across a range."),args:[nh("criteria_range (range)",vo("The range which is tested against criterion.")),nh("criterion (string)",vo("The pattern or test to apply to range.")),nh("sum_range (range, default=criteria_range)",vo("The range to be summed, if different from range."))],compute:function(e,t,o){void 0===o&&(o=e);let s=0;return Xi([e,t],((e,t)=>{const i=o[e]?.[t]?.value;"number"==typeof i&&(s+=i)}),this.locale),s},isExported:!0},zd={description:vo("Sums a range depending on multiple criteria."),args:[nh("sum_range (range)",vo("The range to sum.")),nh("criteria_range1 (range)",vo("The range to check against criterion1.")),nh("criterion1 (string)",vo("The pattern or test to apply to criteria_range1.")),nh("criteria_range2 (any, range, repeating)",vo("Additional ranges to check.")),nh("criterion2 (string, repeating)",vo("Additional criteria to check."))],compute:function(e,...t){let o=0;return Xi(t,((t,s)=>{const i=e[t]?.[s]?.value;"number"==typeof i&&(o+=i)}),this.locale),o},isExported:!0},$d={description:vo("Tangent of an angle provided in radians."),args:[nh("angle (number)",vo("The angle to find the tangent of, in radians."))],compute:function(e){return Math.tan(wi(e,this.locale))},isExported:!0},Gd={description:vo("Hyperbolic tangent of any real number."),args:[nh("value (number)",vo("Any real value to calculate the hyperbolic tangent of."))],compute:function(e){return Math.tanh(wi(e,this.locale))},isExported:!0};function Wd(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 qd={description:vo("Truncates a number."),args:[nh("value (number)",vo("The value to be truncated.")),nh("places (number, default=0)",vo("The number of significant digits to the right of the decimal point to retain."))],compute:function(e,t={value:0}){return{value:Wd(wi(e,this.locale),wi(t,this.locale)),format:e?.format}},isExported:!0},Zd={description:vo("Rounds a number down to the nearest integer that is less than or equal to it."),args:[nh("value (number)",vo("The number to round down to the nearest integer."))],compute:function(e){return Math.floor(wi(e,this.locale))},isExported:!0};var jd=Object.freeze({__proto__:null,ABS:Uh,ACOS:Hh,ACOSH:Bh,ACOT:zh,ACOTH:$h,ASIN:Gh,ASINH:Wh,ATAN:qh,ATAN2:Zh,ATANH:jh,CEILING:Yh,CEILING_MATH:Kh,CEILING_PRECISE:Qh,COS:Jh,COSH:ed,COT:td,COTH:od,COUNTBLANK:sd,COUNTIF:id,COUNTIFS:nd,COUNTUNIQUE:rd,COUNTUNIQUEIFS:ad,CSC:ld,CSCH:cd,DECIMAL:hd,DEGREES:dd,EXP:ud,FLOOR:gd,FLOOR_MATH:md,FLOOR_PRECISE:fd,INT:Zd,ISEVEN:vd,ISODD:Sd,ISO_CEILING:bd,LN:yd,MOD:wd,MUNIT:Ed,ODD:xd,PI:Id,POWER:Rd,PRODUCT:Td,RAND:Ad,RANDARRAY:_d,RANDBETWEEN:Dd,ROUND:Od,ROUNDDOWN:Fd,ROUNDUP:Md,SEC:Nd,SECH:Pd,SEQUENCE:kd,SIN:Ld,SINH:Vd,SQRT:Ud,SUM:Hd,SUMIF:Bd,SUMIFS:zd,TAN:$d,TANH:Gd,TRUNC:qd});function Yd(e,t){const o=[],s=[];let i=0,n=0;Li([e],(e=>{o.push(e),i+=1})),Li([t],(e=>{s.push(e),n+=1})),bi((()=>i===n),vo("[[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 Xd(e,t,o){const{flatDataX:s,flatDataY:i}=Yd(e,t),n=i.length;bi((()=>0!==n&&(!o||1!==n)),vo("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."),ci.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 Kd(e,t,o,s){let i=0,n=0;const r=o?zi:Bi;n=r(e,((e,t)=>(i+=1,e+t)),0,s),bi((()=>0!==i&&(!t||1!==i)),vo("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."),ci.DivisionByZero);const a=n/i;return r(e,((e,t)=>e+Math.pow(t-a,2)),0,s)/(i-(t?1:0))}function Qd(e,t,o,s){const i=wi(t,s);bi((()=>o?0<=i&&i<=1:0<i&&i<1),vo("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let n,r=[],a=0;return Li(e,(e=>{const t=e?.value;"number"==typeof t&&(n=Ki(r,e,"nextSmaller","asc",r.length,((e,t)=>e[t])),r.splice(n+1,0,t),a++)})),bi((()=>0!==a),vo("[[FUNCTION_NAME]] has no valid input data.")),o||bi((()=>1/(a+1)<=i&&i<=a/(a+1)),vo("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),zs(r,i,o)}const Jd={description:vo("Average magnitude of deviations from mean."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the sample.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the sample."))],compute:function(...e){let t=0;const o=Bi(e,((e,o)=>(t+=1,e+o)),0,this.locale);_i(t);const s=o/t;return Bi(e,((e,t)=>e+Math.abs(s-t)),0,this.locale)/t},isExported:!0},eu={description:vo("Numerical average value in a dataset, ignoring text."),args:[nh("value1 (number, range<number>)",vo("The first value or range to consider when calculating the average value.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to consider when calculating the average value."))],compute:function(...e){return{value:La(e,this.locale),format:Si(e[0])}},isExported:!0},tu=vo("[[FUNCTION_NAME]] has mismatched range sizes."),ou=vo("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),su={description:vo("Weighted average."),args:[nh("values (number, range<number>)",vo("Values to average.")),nh("weights (number, range<number>)",vo("Weights for each corresponding value.")),nh("additional_values (number, range<number>, repeating)",vo("Additional values to average.")),nh("additional_weights (number, range<number>, repeating)",vo("Additional weights."))],compute:function(...e){let t=0,o=0;for(let s=0;s<e.length-1;s+=2){const i=e[s],n=e[s+1];if(lh(tu,i,n),ni(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=ni(n)?n?.[e][s].value:wi(n,this.locale),l="number"==typeof r,c="number"==typeof a;l&&c?(bi((()=>a>=0),ou),t+=r*a,o+=a):bi((()=>l===c),vo("[[FUNCTION_NAME]] expects number values."))}else{const e=wi(i,this.locale),s=ni(n)?n?.[0][0].value:wi(n,this.locale);"number"==typeof s&&(bi((()=>s>=0),ou),t+=e*s,o+=s)}}return _i(o),{value:t/o,format:Si(e[0])}}},iu={description:vo("Numerical average value in a dataset."),args:[nh("value1 (number, range<number>)",vo("The first value or range to consider when calculating the average value.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to consider when calculating the average value."))],compute:function(...e){let t=0;const o=zi(e,((e,o)=>(t+=1,e+o)),0,this.locale);return _i(t),{value:o/t,format:Si(e[0])}},isExported:!0},nu={description:vo("Average of values depending on criteria."),args:[nh("criteria_range (number, range<number>)",vo("The range to check against criterion.")),nh("criterion (string)",vo("The pattern or test to apply to criteria_range.")),nh("average_range (number, range<number>, default=criteria_range)",vo("The range to average. If not included, criteria_range is used for the average instead."))],compute:function(e,t,o){const s=tn(void 0===o?e:o);let i=0,n=0;return Xi([e,t],((e,t)=>{const o=s[e]?.[t]?.value;"number"==typeof o&&(i+=1,n+=o)}),this.locale),_i(i),n/i},isExported:!0},ru={description:vo("Average of values depending on multiple criteria."),args:[nh("average_range (range)",vo("The range to average.")),nh("criteria_range1 (range)",vo("The range to check against criterion1.")),nh("criterion1 (string)",vo("The pattern or test to apply to criteria_range1.")),nh("criteria_range2 (any, range, repeating)",vo("Additional criteria_range and criterion to check.")),nh("criterion2 (string, repeating)",vo("The pattern or test to apply to criteria_range2."))],compute:function(e,...t){const o=tn(e);let s=0,i=0;return Xi(t,((e,t)=>{const n=o[e]?.[t]?.value;"number"==typeof n&&(s+=1,i+=n)}),this.locale),_i(s),i/s},isExported:!0},au={description:vo("The number of numeric values in dataset."),args:[nh("value1 (number, any, range<number>)",vo("The first value or range to consider when counting.")),nh("value2 (number, any, range<number>, repeating)",vo("Additional values or ranges to consider when counting."))],compute:function(...e){return Va(e,this.locale)},isExported:!0},lu={description:vo("The number of values in a dataset."),args:[nh("value1 (any, range)",vo("The first value or range to consider when counting.")),nh("value2 (any, range, repeating)",vo("Additional values or ranges to consider when counting."))],compute:function(...e){return Ua(e)},isExported:!0},cu={description:vo("The covariance of a dataset."),args:[nh("data_y (any, range)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (any, range)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Xd(e,t,!1)},isExported:!0},hu={description:vo("The covariance of a dataset."),args:[nh("data_y (any, range)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (any, range)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Xd(e,t,!1)},isExported:!0},du={description:vo("The sample covariance of a dataset."),args:[nh("data_y (any, range)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (any, range)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Xd(e,t,!0)},isExported:!0},uu={description:vo("Calculates the expected y-value for a specified x based on a linear regression of a dataset."),args:[nh("x (number, range<number>)",vo("The value(s) on the x-axis to forecast.")),nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t,o){const{flatDataX:s,flatDataY:i}=Yd(t,o);return Ya([i],[s],Gi(tn(e),(e=>wi(e,this.locale))),!0)},isExported:!0},gu={description:vo("Fits points to exponential growth trend."),args:[nh("known_data_y (range<number>)",vo("The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.")),nh("known_data_x (range<number>, default={1;2;3;...})",vo("The values of the independent variable(s) corresponding with known_data_y.")),nh("new_data_x (any, range, default=known_data_x)",vo("The data points to return the y values for on the ideal curve fit.")),nh("b (boolean, default=TRUE)",vo("Given a general exponential form of y = b*m^x for a curve fit, calculates b if TRUE or forces b to be 1 and only calculates the m values if FALSE."))],compute:function(e,t=[[]],o=[[]],s={value:!0}){return Za(Ya(ja(xi(e,"the first argument (known_data_y)")),xi(t,"the second argument (known_data_x)"),xi(o,"the third argument (new_data_y)"),Mi(s)))}},pu={description:vo("Compute the intercept of the linear regression."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Yd(e,t),[[],[i]]=$a([o],[s]);return i},isExported:!0},mu={description:vo("Nth largest element from a data set."),args:[nh("data (any, range)",vo("Array or range containing the dataset to consider.")),nh("n (number)",vo("The rank from largest to smallest of the element to return."))],compute:function(e,t){const o=Math.trunc(wi(t?.value,this.locale));let s,i=[],n=0;Li([e],(e=>{"number"==typeof e?.value&&(s=Ki(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 bi((()=>void 0!==r),vo("[[FUNCTION_NAME]] has no valid input data.")),bi((()=>n>=o),vo("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o)),r},isExported:!0},fu={description:vo("Given partial data about a linear trend, calculates various parameters about the ideal linear trend using the least-squares method."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>, default={1;2;3;...})",vo("The range representing the array or matrix of independent data.")),nh("calculate_b (boolean, default=TRUE)",vo("A flag specifying wheter to compute the slope or not")),nh("verbose (boolean, default=FALSE)",vo("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept"))],compute:function(e,t=[[]],o={value:!0},s={value:!1}){return $a(xi(t,"the first argument (data_y)"),xi(e,"the second argument (data_x)"),Mi(o),Mi(s))},isExported:!0},vu={description:vo("Given partial data about an exponential growth curve, calculates various parameters about the best fit ideal exponential growth curve."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>, optional, default={1;2;3;...})",vo("The range representing the array or matrix of independent data.")),nh("calculate_b (boolean, default=TRUE)",vo("A flag specifying wheter to compute the slope or not")),nh("verbose (boolean, default=FALSE)",vo("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept"))],compute:function(e,t=[[]],o={value:!0},s={value:!1}){const i=$a(xi(t,"the second argument (data_x)"),ja(xi(e,"the first argument (data_y)")),Mi(o),Mi(s));for(let e=0;e<i.length;e++)i[e][0]=Math.exp(i[e][0]);return i},isExported:!0},bu={description:vo("Compute the Matthews correlation coefficient of a dataset."),args:[nh("data_x (range)",vo("The range representing the array or matrix of observed data.")),nh("data_y (range)",vo("The range representing the array or matrix of predicted data."))],compute:function(e,t){const o=e.flat(),s=t.flat();if(ka(o,s),0===o.length)throw new di(vo("[[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=Mi(o[e]);t===Mi(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},Su={description:vo("Maximum value in a numeric dataset."),args:[nh("value1 (number, range<number>)",vo("The first value or range to consider when calculating the maximum value.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to consider when calculating the maximum value."))],compute:function(...e){return Ha(e,this.locale)},isExported:!0},yu={description:vo("Maximum numeric value in a dataset."),args:[nh("value1 (any, range)",vo("The first value or range to consider when calculating the maximum value.")),nh("value2 (any, range, repeating)",vo("Additional values or ranges to consider when calculating the maximum value."))],compute:function(...e){const t=zi(e,((e,t)=>Math.max(t,e)),-1/0,this.locale);return{value:t===-1/0?0:t,format:Si(e[0])}},isExported:!0},Cu={description:vo("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:[nh("range (range)",vo("The range of cells from which the maximum will be determined.")),nh("criteria_range1 (range)",vo("The range of cells over which to evaluate criterion1.")),nh("criterion1 (string)",vo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),nh("criteria_range2 (any, range, repeating)",vo("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.")),nh("criterion2 (string, repeating)",vo("The pattern or test to apply to criteria_range2."))],compute:function(e,...t){let o=-1/0;return Xi(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},wu={description:vo("Median value in a numeric dataset."),args:[nh("value1 (any, range)",vo("The first value or range to consider when calculating the median value.")),nh("value2 (any, range, repeating)",vo("Additional values or ranges to consider when calculating the median value."))],compute:function(...e){let t=[];return Vi(e,(e=>{t.push(e)}),this.locale),{value:Qd(t,{value:.5},!0,this.locale),format:Si(t[0])}},isExported:!0},Eu={description:vo("Minimum value in a numeric dataset."),args:[nh("value1 (number, range<number>)",vo("The first value or range to consider when calculating the minimum value.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to consider when calculating the minimum value."))],compute:function(...e){return Ba(e,this.locale)},isExported:!0},xu={description:vo("Minimum numeric value in a dataset."),args:[nh("value1 (number, range<number>)",vo("The first value or range to consider when calculating the minimum value.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to consider when calculating the minimum value."))],compute:function(...e){const t=zi(e,((e,t)=>Math.min(t,e)),1/0,this.locale);return{value:t===1/0?0:t,format:Si(e[0])}},isExported:!0},Iu={description:vo("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:[nh("range (range)",vo("The range of cells from which the minimum will be determined.")),nh("criteria_range1 (range)",vo("The range of cells over which to evaluate criterion1.")),nh("criterion1 (string)",vo("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),nh("criteria_range2 (any, range, repeating)",vo("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.")),nh("criterion2 (string, repeating)",vo("The pattern or test to apply to criteria_range2."))],compute:function(e,...t){let o=1/0;return Xi(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 Ru(e,t){const{flatDataX:o,flatDataY:s}=Yd(e,t);if(0===o.length)throw new di(vo("[[FUNCTION_NAME]] expects non-empty ranges for both parameters."));if(o.length<2)throw new di(vo("[[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 Tu={description:vo("Compute the Pearson product-moment correlation coefficient of a dataset."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Ru(e,t)},isExported:!0},Au=Tu,_u={description:vo("Value at a given percentile of a dataset."),args:[nh("data (any, range)",vo("The array or range containing the dataset to consider.")),nh("percentile (number)",vo("The percentile whose value within data will be calculated and returned."))],compute:function(e,t){return Ou.compute.bind(this)(e,t)},isExported:!0},Du={description:vo("Value at a given percentile of a dataset exclusive of 0 and 1."),args:[nh("data (any, range)",vo("The array or range containing the dataset to consider.")),nh("percentile (number)",vo("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned."))],compute:function(e,t){return{value:Qd([e],t,!1,this.locale),format:Si(e)}},isExported:!0},Ou={description:vo("Value at a given percentile of a dataset."),args:[nh("data (any, range)",vo("The array or range containing the dataset to consider.")),nh("percentile (number)",vo("The percentile whose value within data will be calculated and returned."))],compute:function(e,t){return{value:Qd([e],t,!0,this.locale),format:Si(e)}},isExported:!0},Fu={description:vo("Compute the coefficients of polynomial regression of the dataset."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data.")),nh("order (number)",vo("The order of the polynomial to fit the data, between 1 and 6.")),nh("intercept (boolean, default=TRUE)",vo("A flag specifying whether to compute the intercept or not."))],compute:function(e,t,o,s={value:!0}){const{flatDataX:i,flatDataY:n}=Yd(e,t);return Ga(n,i,wi(o,this.locale),Mi(s))},isExported:!1},Mu={description:vo("Predict value by computing a polynomial regression of the dataset."),args:[nh("x (number, range<number>)",vo("The value(s) on the x-axis to forecast.")),nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data.")),nh("order (number)",vo("The order of the polynomial to fit the data, between 1 and 6.")),nh("intercept (boolean, default=TRUE)",vo("A flag specifying whether to compute the intercept or not."))],compute:function(e,t,o,s,i={value:!0}){const n=wi(s,this.locale),{flatDataX:r,flatDataY:a}=Yd(t,o),l=Ga(a,r,n,Mi(i)).flat();return Gi(tn(e),(e=>qa(l,wi(e,this.locale),n)))},isExported:!1},Nu={description:vo("Value nearest to a specific quartile of a dataset."),args:[nh("data (any, range)",vo("The array or range containing the dataset to consider.")),nh("quartile_number (number)",vo("Which quartile value to return."))],compute:function(e,t){return ku.compute.bind(this)(e,t)},isExported:!0},Pu={description:vo("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:[nh("data (any, range)",vo("The array or range containing the dataset to consider.")),nh("quartile_number (number)",vo("Which quartile value, exclusive of 0 and 4, to return."))],compute:function(e,t){return{value:Qd([e],{value:.25*Math.trunc(wi(t,this.locale))},!1,this.locale),format:Si(e)}},isExported:!0},ku={description:vo("Value nearest to a specific quartile of a dataset."),args:[nh("data (any, range)",vo("The array or range containing the dataset to consider.")),nh("quartile_number (number)",vo("Which quartile value to return."))],compute:function(e,t){return{value:Qd([e],{value:.25*Math.trunc(wi(t,this.locale))},!0,this.locale),format:Si(e)}},isExported:!0},Lu={description:vo("Returns the rank of a specified value in a dataset."),args:[nh("value (number)",vo("The value whose rank will be determined.")),nh("data (range)",vo("The range containing the dataset to consider.")),nh("is_ascending (boolean, default=FALSE)",vo("Whether to consider the values in data in descending or ascending order."))],compute:function(e,t,o={value:!1}){const s=Mi(o),i=wi(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=wi(t,this.locale);e===i?r=!0:e>i!==s&&n++}if(!r)throw new pi(vo("Value not found in the given data."));return n},isExported:!0},Vu={description:vo("Compute the square of r, the Pearson product-moment correlation coefficient of a dataset."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){return Math.pow(Ru(t,e),2)},isExported:!0},Uu={description:vo("Compute the slope of the linear regression."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Yd(e,t),[[i]]=$a([o],[s]);return i},isExported:!0},Hu={description:vo("Nth smallest element in a data set."),args:[nh("data (any, range)",vo("The array or range containing the dataset to consider.")),nh("n (number)",vo("The rank from smallest to largest of the element to return."))],compute:function(e,t){const o=Math.trunc(wi(t?.value,this.locale));let s,i=[],n=0;Li([e],(e=>{"number"==typeof e?.value&&(s=Ki(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 bi((()=>void 0!==r),vo("[[FUNCTION_NAME]] has no valid input data.")),bi((()=>n>=o),vo("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o)),r},isExported:!0},Bu={description:vo("Compute the Spearman rank correlation coefficient of a dataset."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Yd(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},zu={description:vo("Standard deviation."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the sample.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the sample."))],compute:function(...e){return Math.sqrt(Xu.compute.bind(this)(...e))},isExported:!0},$u={description:vo("Standard deviation of entire population."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the population.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the population."))],compute:function(...e){return Math.sqrt(Ku.compute.bind(this)(...e))},isExported:!0},Gu={description:vo("Standard deviation."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the sample.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the sample."))],compute:function(...e){return Math.sqrt(Qu.compute.bind(this)(...e))},isExported:!0},Wu={description:vo("Standard deviation of sample (text as 0)."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the sample.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the sample."))],compute:function(...e){return Math.sqrt(Ju.compute.bind(this)(...e))},isExported:!0},qu={description:vo("Standard deviation of entire population."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the population.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the population."))],compute:function(...e){return Math.sqrt(eg.compute.bind(this)(...e))},isExported:!0},Zu={description:vo("Standard deviation of entire population (text as 0)."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the population.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the population."))],compute:function(...e){return Math.sqrt(tg.compute.bind(this)(...e))},isExported:!0},ju={description:vo("Calculates the standard error of the predicted y-value for each x in the regression of a dataset."),args:[nh("data_y (range<number>)",vo("The range representing the array or matrix of dependent data.")),nh("data_x (range<number>)",vo("The range representing the array or matrix of independent data."))],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Yd(e,t);return $a([o],[s],!0,!0)[1][2]},isExported:!0},Yu={description:vo("Fits points to linear trend derived via least-squares."),args:[nh("known_data_y (number, range<number>)",vo("The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.")),nh("known_data_x (number, range<number>, optional, default={1;2;3;...})",vo("The values of the independent variable(s) corresponding with known_data_y.")),nh("new_data_x (number, range<number>, optional, default=known_data_x)",vo("The data points to return the y values for on the ideal curve fit.")),nh("b (boolean, optional, default=TRUE)",vo("Given a general linear form of y = m*x+b for a curve fit, calculates b if TRUE or forces b to be 0 and only calculates the m values if FALSE, i.e. forces the curve fit to pass through the origin."))],compute:function(e,t=[[]],o=[[]],s={value:!0}){return Ya(xi(e,"the first argument (known_data_y)"),xi(t,"the second argument (known_data_x)"),xi(o,"the third argument (new_data_y)"),Mi(s))}},Xu={description:vo("Variance."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the sample.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the sample."))],compute:function(...e){return Kd(e,!0,!1,this.locale)},isExported:!0},Ku={description:vo("Variance of entire population."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the population.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the population."))],compute:function(...e){return Kd(e,!1,!1,this.locale)},isExported:!0},Qu={description:vo("Variance."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the sample.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the sample."))],compute:function(...e){return Kd(e,!0,!1,this.locale)},isExported:!0},Ju={description:vo("Variance of sample (text as 0)."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the sample.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the sample."))],compute:function(...e){return Kd(e,!0,!0,this.locale)},isExported:!0},eg={description:vo("Variance of entire population."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the population.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the population."))],compute:function(...e){return Kd(e,!1,!1,this.locale)},isExported:!0},tg={description:vo("Variance of entire population (text as 0)."),args:[nh("value1 (number, range<number>)",vo("The first value or range of the population.")),nh("value2 (number, range<number>, repeating)",vo("Additional values or ranges to include in the population."))],compute:function(...e){return Kd(e,!1,!0,this.locale)},isExported:!0};var og=Object.freeze({__proto__:null,AVEDEV:Jd,AVERAGE:eu,AVERAGEA:iu,AVERAGEIF:nu,AVERAGEIFS:ru,AVERAGE_WEIGHTED:su,CORREL:Au,COUNT:au,COUNTA:lu,COVAR:cu,COVARIANCE_P:hu,COVARIANCE_S:du,FORECAST:uu,GROWTH:gu,INTERCEPT:pu,LARGE:mu,LINEST:fu,LOGEST:vu,MATTHEWS:bu,MAX:Su,MAXA:yu,MAXIFS:Cu,MEDIAN:wu,MIN:Eu,MINA:xu,MINIFS:Iu,PEARSON:Tu,PERCENTILE:_u,PERCENTILE_EXC:Du,PERCENTILE_INC:Ou,POLYFIT_COEFFS:Fu,POLYFIT_FORECAST:Mu,QUARTILE:Nu,QUARTILE_EXC:Pu,QUARTILE_INC:ku,RANK:Lu,RSQ:Vu,SLOPE:Uu,SMALL:Hu,SPEARMAN:Bu,STDEV:zu,STDEVA:Wu,STDEVP:qu,STDEVPA:Zu,STDEV_P:$u,STDEV_S:Gu,STEYX:ju,TREND:Yu,VAR:Xu,VARA:Ju,VARP:eg,VARPA:tg,VAR_P:Ku,VAR_S:Qu});function sg(e,t,o,s){const i=new Map,n=e.length;for(let t=n-1;t>=0;t--)i.set(Di(e[t][0]).toUpperCase(),t);const r=t?.value;if("number"!=typeof r&&"string"!=typeof r)throw new di(vo("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 di(vo("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=Di(t).toUpperCase();if(a=i.get(e)??-1,-1===a)throw new di(vo("The field (%s) must be one of %s.",Di(t),[...i.keys()].toString()))}const l=o[0].length;if(l<2)throw new di(vo("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=Di(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}Xi(n,((e,t)=>{c.add(t)}),s,!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const ig=[nh("database (range)",vo("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.")),nh("field (number, string)",vo("Indicates which column in database contains the values to be extracted and operated on.")),nh("criteria (range)",vo("An array or range containing zero or more criteria to filter the database values by before operating."))],ng={description:vo("Average of a set of values from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return eu.compute.bind(this)([s])},isExported:!0},rg={description:vo("Counts values from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return au.compute.bind(this)([s])},isExported:!0},ag={description:vo("Counts values and text from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return lu.compute.bind(this)([s])},isExported:!0},lg={description:vo("Single value from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return bi((()=>1===s.length),vo("More than one match found in DGET evaluation.")),s[0]},isExported:!0},cg={description:vo("Maximum of values from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return Su.compute.bind(this)([s])},isExported:!0},hg={description:vo("Minimum of values from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return Eu.compute.bind(this)([s])},isExported:!0},dg={description:vo("Product of values from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return Td.compute.bind(this)([s])},isExported:!0},ug={description:vo("Standard deviation of population sample from table."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return zu.compute.bind(this)([s])},isExported:!0},gg={description:vo("Standard deviation of entire population from table."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return qu.compute.bind(this)([s])},isExported:!0},pg={description:vo("Sum of values from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return Hd.compute.bind(this)([s])},isExported:!0},mg={description:vo("Variance of population sample from table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return Xu.compute.bind(this)([s])},isExported:!0},fg={description:vo("Variance of a population from a table-like range."),args:ig,compute:function(e,t,o){const s=sg(e,t,o,this.locale);return eg.compute.bind(this)([s])},isExported:!0};var vg=Object.freeze({__proto__:null,DAVERAGE:ng,DCOUNT:rg,DCOUNTA:ag,DGET:lg,DMAX:cg,DMIN:hg,DPRODUCT:dg,DSTDEV:ug,DSTDEVP:gg,DSUM:pg,DVAR:mg,DVARP:fg});var bg;!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"}(bg||(bg={}));const Sg={description:vo("Converts year/month/day into a date."),args:[nh("year (number)",vo("The year component of the date.")),nh("month (number)",vo("The month component of the date.")),nh("day (number)",vo("The day component of the date."))],compute:function(e,t,o){let s=Math.trunc(wi(e,this.locale));const i=Math.trunc(wi(t,this.locale)),n=Math.trunc(wi(o,this.locale));bi((()=>0<=s&&s<=9999),vo("The year (%s) must be between 0 and 9999 inclusive.",s.toString())),s<1900&&(s+=1900);const r=Rs(new cs(s,i-1,n));return bi((()=>r>=0),vo("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),{value:r,format:this.locale.dateFormat}},isExported:!0},yg={description:vo("Calculates the number of days, months, or years between two dates."),args:[nh("start_date (date)",vo("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.")),nh("end_date (date)",vo("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.")),nh("unit (string)",vo('A text abbreviation for unit of time. Accepted values are "Y" (the number of whole years between start_date and end_date), "M" (the number of whole months between start_date and end_date), "D" (the number of days between start_date and end_date), "MD" (the number of days between start_date and end_date after subtracting whole months), "YM" (the number of whole months between start_date and end_date after subtracting whole years), "YD" (the number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart).'))],compute:function(e,t,o){const s=Di(o).toUpperCase();bi((()=>Object.values(bg).includes(s)),((e,t)=>{const o=e.map((e=>`'${e}'`)).join(", ");return vo("The function [[FUNCTION_NAME]] has an argument with value '%s'. It should be one of: %s.",t,o)})(Object.values(bg),Di(o)));const i=Math.trunc(wi(e,this.locale)),n=Math.trunc(wi(t,this.locale)),r=Is(i),a=Is(n);switch(bi((()=>n>=i),vo("start_date (%s) should be on or before end_date (%s).",r.toLocaleDateString(),a.toLocaleDateString())),s){case bg.WHOLE_YEARS:return Ps(r,a);case bg.WHOLE_MONTHS:return Ms(r,a);case bg.WHOLE_DAYS:return Ns(r,a);case bg.MONTH_WITHOUT_WHOLE_YEARS:return Ms(r,a)-12*Ps(r,a);case bg.DAYS_WITHOUT_WHOLE_MONTHS:let e=a.getDate()-r.getDate();if(e<0){e=As(new cs(a.getFullYear(),a.getMonth()-1,1))-Math.abs(e)}return e;case bg.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR:{if(function(e,t){return Fs(e,t,1)<1}(i,n))return Ns(r,a);const e=new cs(r.getFullYear(),a.getMonth(),a.getDate());let t=Ns(r,e);return t<0&&(e.setFullYear(r.getFullYear()+1),t=Ns(r,e)),t}}},isExported:!0},Cg={description:vo("Converts a date string to a date value."),args:[nh("date_string (string)",vo("The string representing the date."))],compute:function(e){const t=Di(e),o=xs(t,this.locale);return bi((()=>null!==o),vo("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(o.value)},isExported:!0},wg={description:vo("Day of the month that a specific date falls on."),args:[nh("date (string)",vo("The date from which to extract the day."))],compute:function(e){return Ni(e,this.locale).getDate()},isExported:!0},Eg={description:vo("Number of days between two dates."),args:[nh("end_date (date)",vo("The end of the date range.")),nh("start_date (date)",vo("The start of the date range."))],compute:function(e,t){const o=Ni(e,this.locale),s=Ni(t,this.locale),i=o.getTime()-s.getTime();return Math.round(i/ds)},isExported:!0},xg={description:vo("Number of days between two dates on a 360-day year (months of 30 days)."),args:[nh("start_date (date)",vo("The start date to consider in the calculation.")),nh("end_date (date)",vo("The end date to consider in the calculation.")),nh("method (number, default=0)",vo("An indicator of what day count method to use. (0) US NASD method (1) European method"))],compute:function(e,t,o={value:0}){const s=Math.trunc(wi(e,this.locale)),i=Math.trunc(wi(t,this.locale)),n=Fs(s,i,Mi(o)?4:0);return Math.sign(i-s)*Math.round(360*n)},isExported:!0},Ig={description:vo("Date a number of months before/after another date."),args:[nh("start_date (date)",vo("The date from which to calculate the result.")),nh("months (number)",vo("The number of months before (negative) or after (positive) 'start_date' to calculate."))],compute:function(e,t){return{value:Rs(Ds(Ni(e,this.locale),Math.trunc(wi(t,this.locale)),!1)),format:this.locale.dateFormat}},isExported:!0},Rg={description:vo("Last day of a month before or after a date."),args:[nh("start_date (date)",vo("The date from which to calculate the result.")),nh("months (number)",vo("The number of months before (negative) or after (positive) 'start_date' to consider."))],compute:function(e,t){const o=Ni(e,this.locale),s=Math.trunc(wi(t,this.locale)),i=o.getFullYear(),n=o.getMonth();return{value:Rs(new cs(i,n+s+1,0)),format:this.locale.dateFormat}},isExported:!0},Tg={description:vo("Hour component of a specific time."),args:[nh("time (date)",vo("The time from which to calculate the hour component."))],compute:function(e){return Ni(e,this.locale).getHours()},isExported:!0},Ag={description:vo("ISO week number of the year."),args:[nh("date (date)",vo("The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number."))],compute:function(e){const t=Ni(e,this.locale),o=t.getFullYear();let s=1;for(;4!==new cs(o,0,s).getDay();)s+=1;const i=new cs(o,0,s-3);let n=31;for(;4!==new cs(o,11,n).getDay();)n-=1;const r=new cs(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 cs(o,11,n+3+1);break;case-1:let e=1;for(;4!==new cs(o-1,0,e).getDay();)e+=1;l=new cs(o-1,0,e-3)}const c=(t.getTime()-l.getTime())/ds;return Math.floor(c/7)+1},isExported:!0},_g={description:vo("Minute component of a specific time."),args:[nh("time (date)",vo("The time from which to calculate the minute component."))],compute:function(e){return Ni(e,this.locale).getMinutes()},isExported:!0},Dg={description:vo("Month of the year a specific date falls in"),args:[nh("date (date)",vo("The date from which to extract the month."))],compute:function(e){return Ni(e,this.locale).getMonth()+1},isExported:!0},Og={description:vo("Net working days between two provided days."),args:[nh("start_date (date)",vo("The start date of the period from which to calculate the number of net working days.")),nh("end_date (date)",vo("The end date of the period from which to calculate the number of net working days.")),nh("holidays (date, range<date>, optional)",vo("A range or array constant containing the date serial numbers to consider holidays."))],compute:function(e,t,o){return Mg.compute.bind(this)(e,t,{value:1},o)},isExported:!0};function Fg(e){const t=e?.value;if("string"==typeof t){bi((()=>{if(7!==t.length)return!1;for(let e of t)if("0"!==e&&"1"!==e)return!1;return!0}),vo('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 bi((()=>1<=t&&t<=7||11<=t&&t<=17),vo("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 di(vo("The weekend must be a number or a string."))}const Mg={description:vo("Net working days between two dates (specifying weekends)."),args:[nh("start_date (date)",vo("The start date of the period from which to calculate the number of net working days.")),nh("end_date (date)",vo("The end date of the period from which to calculate the number of net working days.")),nh("weekend (any, default=1)",vo("A number or string representing which days of the week are considered weekends.")),nh("holidays (date, range<date>, optional)",vo("A range or array constant containing the dates to consider as holidays."))],compute:function(e,t,o={value:1},s){const i=Ni(e,this.locale),n=Ni(t,this.locale),r=Fg(o);let a=new Set;void 0!==s&&Li([s],(e=>{const t=Ni(e,this.locale);a.add(t.getTime())}));const l=i.getTime()>n.getTime(),c=cs.fromTimestamp((l?i:n).getTime());let h=cs.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},Ng={description:vo("Current date and time as a date value."),args:[],compute:function(){const e=cs.now(),t=e.getTime()-hs.getTime(),o=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return{value:Math.floor(t/ds)+o,format:Ia(this.locale)}},isExported:!0},Pg={description:vo("Minute component of a specific time."),args:[nh("time (date)",vo("The time from which to calculate the second component."))],compute:function(e){return Ni(e,this.locale).getSeconds()},isExported:!0},kg={description:vo("Converts hour/minute/second into a time."),args:[nh("hour (number)",vo("The hour component of the time.")),nh("minute (number)",vo("The minute component of the time.")),nh("second (number)",vo("The second component of the time."))],compute:function(e,t,o){let s=Math.trunc(wi(e,this.locale)),i=Math.trunc(wi(t,this.locale)),n=Math.trunc(wi(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,bi((()=>s>=0),vo("The function [[FUNCTION_NAME]] result cannot be negative")),{value:s/24+i/1440+n/86400,format:this.locale.timeFormat}},isExported:!0},Lg={description:vo("Converts a time string into its serial number representation."),args:[nh("time_string (string)",vo("The string that holds the time representation."))],compute:function(e){const t=Di(e),o=xs(t,this.locale);bi((()=>null!==o),vo("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},Vg={description:vo("Current date as a date value."),args:[],compute:function(){const e=cs.now();return{value:Rs(new cs(e.getFullYear(),e.getMonth(),e.getDate())),format:this.locale.dateFormat}},isExported:!0},Ug={description:vo("Day of the week of the date provided (as number)."),args:[nh("date (date)",vo("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.")),nh("type (number, default=1)",vo("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1."))],compute:function(e,t={value:1}){const o=Ni(e,this.locale),s=Math.round(wi(t,this.locale)),i=o.getDay();return bi((()=>[1,2,3].includes(s)),vo("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},Hg={description:vo("Week number of the year."),args:[nh("date (date)",vo("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.")),nh("type (number, default=1)",vo("A number representing the day that a week starts on. Sunday = 1."))],compute:function(e,t={value:1}){const o=Ni(e,this.locale),s=Math.round(wi(t,this.locale));if(bi((()=>1===s||2===s||11<=s&&s<=17||21===s),vo("The type (%s) is out of range.",s.toString())),21===s)return Ag.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 cs(n,0,r);for(;a.getDay()!==i;)r+=1,a=new cs(n,0,r);const l=(o.getTime()-a.getTime())/ds;return l<0?1:Math.floor(l/7)+(1===r?1:2)},isExported:!0},Bg={description:vo("Date after a number of workdays."),args:[nh("start_date (date)",vo("The date from which to begin counting.")),nh("num_days (number)",vo("The number of working days to advance from start_date. If negative, counts backwards.")),nh("holidays (date, range<date>, optional)",vo("A range or array constant containing the dates to consider holidays."))],compute:function(e,t,o={value:null}){return zg.compute.bind(this)(e,t,{value:1},o)},isExported:!0},zg={description:vo("Date after a number of workdays (specifying weekends)."),args:[nh("start_date (date)",vo("The date from which to begin counting.")),nh("num_days (number)",vo("The number of working days to advance from start_date. If negative, counts backwards.")),nh("weekend (any, default=1)",vo("A number or string representing which days of the week are considered weekends.")),nh("holidays (date, range<date>, optional)",vo("A range or array constant containing the dates to consider holidays."))],compute:function(e,t,o={value:1},s){let i=Ni(e,this.locale),n=Math.trunc(wi(t,this.locale));"string"==typeof o.value&&bi((()=>"1111111"!==o.value),vo("The weekend must be different from '1111111'."));const r=Fg(o);let a=new Set;void 0!==s&&Li([s],(e=>{const t=Ni(e,this.locale);a.add(t.getTime())}));let l=cs.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-hs.getTime();return{value:Math.round(u/ds),format:this.locale.dateFormat}},isExported:!0},$g={description:vo("Year specified by a given date."),args:[nh("date (date)",vo("The date from which to extract the year."))],compute:function(e){return Ni(e,this.locale).getFullYear()},isExported:!0},Gg={description:vo("Exact number of years between two dates."),args:[nh("start_date (date)",vo("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.")),nh("end_date (date)",vo("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.")),nh("day_count_convention (number, default=0)",vo("An indicator of what day count method to use."))],compute:function(e,t,o={value:0}){let s=Math.trunc(wi(e,this.locale)),i=Math.trunc(wi(t,this.locale));const n=Math.trunc(wi(o,this.locale));return bi((()=>s>=0),vo("The start_date (%s) must be positive or null.",s.toString())),bi((()=>i>=0),vo("The end_date (%s) must be positive or null.",i.toString())),bi((()=>0<=n&&n<=4),vo("The day_count_convention (%s) must be between 0 and 4 inclusive.",n.toString())),Fs(s,i,n)}},Wg={description:vo("First day of the month preceding a date."),args:[nh("date (date)",vo("The date from which to calculate the result."))],compute:function(e){const t=Ni(e,this.locale),o=t.getFullYear(),s=t.getMonth();return{value:Rs(new cs(o,s,1)),format:this.locale.dateFormat}}},qg={description:vo("Last day of the month following a date."),args:[nh("date (date)",vo("The date from which to calculate the result."))],compute:function(e){return Rg.compute.bind(this)(e,{value:0})}},Zg={description:vo("Quarter of the year a specific date falls in"),args:[nh("date (date)",vo("The date from which to extract the quarter."))],compute:function(e){return Math.ceil((Ni(e,this.locale).getMonth()+1)/3)}},jg={description:vo("First day of the quarter of the year a specific date falls in."),args:[nh("date (date)",vo("The date from which to calculate the start of quarter."))],compute:function(e){const t=Zg.compute.bind(this)(e),o=$g.compute.bind(this)(e);return{value:Rs(new cs(o,3*(t-1),1)),format:this.locale.dateFormat}}},Yg={description:vo("Last day of the quarter of the year a specific date falls in."),args:[nh("date (date)",vo("The date from which to calculate the end of quarter."))],compute:function(e){const t=Zg.compute.bind(this)(e),o=$g.compute.bind(this)(e);return{value:Rs(new cs(o,3*t,0)),format:this.locale.dateFormat}}},Xg={description:vo("First day of the year a specific date falls in."),args:[nh("date (date)",vo("The date from which to calculate the start of the year."))],compute:function(e){const t=$g.compute.bind(this)(e);return{value:Rs(new cs(t,0,1)),format:this.locale.dateFormat}}},Kg={description:vo("Last day of the year a specific date falls in."),args:[nh("date (date)",vo("The date from which to calculate the end of the year."))],compute:function(e){const t=$g.compute.bind(this)(e);return{value:Rs(new cs(t+1,0,0)),format:this.locale.dateFormat}}};var Qg=Object.freeze({__proto__:null,DATE:Sg,DATEDIF:yg,DATEVALUE:Cg,DAY:wg,DAYS:Eg,DAYS360:xg,EDATE:Ig,EOMONTH:Rg,HOUR:Tg,ISOWEEKNUM:Ag,MINUTE:_g,MONTH:Dg,MONTH_END:qg,MONTH_START:Wg,NETWORKDAYS:Og,NETWORKDAYS_INTL:Mg,NOW:Ng,QUARTER:Zg,QUARTER_END:Yg,QUARTER_START:jg,SECOND:Pg,TIME:kg,TIMEVALUE:Lg,TODAY:Vg,WEEKDAY:Ug,WEEKNUM:Hg,WORKDAY:Bg,WORKDAY_INTL:zg,YEAR:$g,YEARFRAC:Gg,YEAR_END:Kg,YEAR_START:Xg});const Jg={description:vo("Compare two numeric values, returning 1 if they're equal."),args:[nh("number1 (number)",vo("The first number to compare.")),nh("number2 (number, default=0)",vo("The second number to compare."))],compute:function(e,t={value:0}){return wi(e,this.locale)===wi(t,this.locale)?1:0},isExported:!0};var ep=Object.freeze({__proto__:null,DELTA:Jg});const tp=[$s.number,$s.error,$s.text,$s.boolean];function op(e){const t="ascending"===e?1:-1;return(e,o)=>{if(e.type===$s.empty)return o.type===$s.empty?0:1;if(o.type===$s.empty)return-1;let s=tp.indexOf(e.type)-tp.indexOf(o.type);return 0===s&&(s=e.type===$s.text||e.type===$s.error?e.value.localeCompare(o.value):e.value-o.value),t*s}}function sp(e,t,o,s,i){let n=Js.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);Go(o,s)?n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:a,row:l,zone:s,sortDirection:i}):e.askConfirmation(vo("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(vo("Cannot sort. To sort, select only cells or only merges that have the same size."))}}function ip(e,t,...o){for(const[e,t]of o.entries())bi((()=>void 0!==t),vo("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(Mi(Pa(o[r+1])?.value)?"ascending":"descending");const a=o[r];if(ni(a)&&(a.length>1||a[0].length>1))bi((()=>1===a.length&&a[0].length===n),vo("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=wi(Pa(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:op("descending"),ascending:op("ascending")},a=Be(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?$s.empty:"string"==typeof i?$s.text:typeof i},c={value:a,type:null===a?$s.empty:"string"==typeof a?$s.text:typeof a},h=r[s[o]](l,c);if(0!==h)return h}return 0})),a.map((t=>e[t]))}const np={description:vo("Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions."),args:[nh("range (any, range<any>)",vo("The data to be filtered.")),nh("condition1 (boolean, range<boolean>)",vo("A column or row containing true or false values corresponding to the first column or row of range.")),nh("condition2 (boolean, range<boolean>, repeating)",vo("Additional column or row containing true or false values."))],compute:function(e,...t){let o=tn(e);const s=t.map((e=>Gi(tn(e),(e=>e.value))));s.map((e=>ah(vo("The arguments condition must be a single column or row."),e))),lh(vo("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?Wi(o):o,bi((()=>i.every((e=>e.length===o.length))),vo("FILTER has mismatched sizes on the range and conditions."));const r=[];for(let e=0;e<o.length;e++){const t=o[e];i.every((t=>("boolean"==typeof t[e]||"number"==typeof t[e])&&t[e]))&&r.push(t)}if(!r.length)throw new pi(vo("No match found in FILTER evaluation"));return"row"===n?Wi(r):r},isExported:!0},rp={description:vo("Sorts the rows of a given array or range by the values in one or more columns."),args:[nh("range (range)",vo("The data to be sorted.")),nh("sort_column (any, range<number>, repeating)",vo("The index of the column in range or a range outside of range containing the values by which to sort.")),nh("is_ascending (boolean, repeating)",vo("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order."))],compute:function(e,...t){const o=Wi(e);return Wi(ip(o,this.locale,...t))},isExported:!0},ap={description:vo("Returns the first n items in a data set after performing a sort."),args:[nh("range (range)",vo("The data to be sorted.")),nh("n (number, default=1)",vo("The number of items to return.")),nh("display_ties_mode (number, default=0)",vo("A number representing the way to display ties.")),nh("sort_column (number, range<number>, repeating)",vo("The index of the column in range or a range outside of range containing the values by which to sort.")),nh("is_ascending (boolean, repeating)",vo("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order."))],compute:function(e,t,o,...s){const i=wi(t?.value??1,this.locale);bi((()=>i>=0),vo("Wrong value of 'n'. Expected a positive number. Got %s.",i));const n=wi(o?.value??0,this.locale);bi((()=>n>=0&&n<=3),vo("Wrong value of 'display_ties_mode'. Expected a positive number between 0 and 3. Got %s.",n));const r=ip(Wi(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 Wi(r.slice(0,i));case 1:for(let e=i;e<r.length;e++)if(!a(e,i-1))return Wi(r.slice(0,e));return Wi(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 Wi(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 Wi(e)}}},isExported:!0},lp={description:vo("Unique rows in the provided source range."),args:[nh("range (any, range<any>)",vo("The data to filter by unique entries.")),nh("by_column (boolean, default=FALSE)",vo("Whether to filter the data by columns or by rows.")),nh("exactly_once (boolean, default=FALSE)",vo("Whether to return only entries with no duplicates."))],compute:function(e={value:""},t,o){if(!ni(e))return[[e]];const s=Mi(t?.value)||!1,i=Mi(o?.value)||!1;s||(e=Wi(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 di(vo("No unique values found"));return s?r:Wi(r)},isExported:!0};var cp=Object.freeze({__proto__:null,FILTER:np,SORT:rp,SORTN:ap,UNIQUE:lp});function hp(e,t){bi((()=>e<t),vo("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function dp(e,t){bi((()=>t<e),vo("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function up(e){bi((()=>[1,2,4].includes(e)),vo("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function gp(e){bi((()=>0<=e&&e<=4),vo("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function pp(e){bi((()=>e>0),vo("The redemption (%s) must be strictly positive.",e.toString()))}function mp(e){bi((()=>e>0),vo("The price (%s) must be strictly positive.",e.toString()))}function fp(e){bi((()=>e>0),vo("The number_of_periods (%s) must be greater than 0.",e.toString()))}function vp(e){bi((()=>e>0),vo("The rate (%s) must be strictly positive.",e.toString()))}function bp(e){bi((()=>e>0),vo("The life (%s) must be strictly positive.",e.toString()))}function Sp(e){bi((()=>e>=0),vo("The cost (%s) must be positive or null.",e.toString()))}function yp(e){bi((()=>e>0),vo("The period (%s) must be strictly positive.",e.toString()))}function Cp(e){bi((()=>e>=0),vo("The salvage (%s) must be positive or null.",e.toString()))}function wp(e){bi((()=>e>0),vo("The present value (%s) must be strictly positive.",e.toString()))}function Ep(e,t){bi((()=>e<=t),vo("The period (%s) must be less than or equal life (%s).",e.toString(),t.toString()))}function xp(e){bi((()=>e>0),vo("The investment (%s) must be strictly positive.",e.toString()))}function Ip(e){bi((()=>e>0),vo("The discount (%s) must be strictly positive.",e.toString()))}function Rp(e){bi((()=>e<1),vo("The discount (%s) must be smaller than 1.",e.toString()))}function Tp(e){bi((()=>e>0),vo("The depreciation factor (%s) must be strictly positive.",e.toString()))}function Ap(e,t,o){const s=Ni(e,o),i=Ni(t,o),n=Ni(e,o);n.setFullYear(s.getFullYear()+1),bi((()=>i.getTime()<=n.getTime()),vo("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function _p(e,t,o){fp(o),bi((()=>e>0),vo("The first_period (%s) must be strictly positive.",e.toString())),bi((()=>t>0),vo("The last_period (%s) must be strictly positive.",t.toString())),bi((()=>e<=t),vo("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),bi((()=>t<=o),vo("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),o.toString()))}function Dp(e){bi((()=>e>-1),vo("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function Op(e,t){bi((()=>e.length===t.length&&e[0].length===t[0].length),vo("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function Fp(e){bi((()=>e.every((t=>t>=e[0]))),vo("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const Mp=[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("frequency (number)",vo("The number of interest or coupon payments per year (1, 2, or 4).")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))];function Np(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)?(bi((()=>u<s&&void 0!==n),vo("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,bi((()=>u<s),vo("Function [[FUNCTION_NAME]] didn't find any result.")),u++)}while(!d);return h}const Pp={description:vo("Accrued interest of security paying at maturity."),args:[nh("issue (date)",vo("The date the security was initially issued.")),nh("maturity (date)",vo("The maturity date of the security.")),nh("rate (number)",vo("The annualized rate of interest.")),nh("redemption (number)",vo("The redemption amount per 100 face value, or par.")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){const n=Math.trunc(wi(e,this.locale)),r=Math.trunc(wi(t,this.locale)),a=wi(s,this.locale),l=wi(o,this.locale),c=Math.trunc(wi(i,this.locale));!function(e){bi((()=>e>=0),vo("The issue (%s) must be positive or null.",e.toString()))}(n),dp(r,n),gp(c),pp(a),vp(l);return a*l*Fs(n,r,c)},isExported:!0},kp={description:vo("Depreciation for an accounting period."),args:[nh("cost (number)",vo("The initial cost of the asset.")),nh("purchase_date (date)",vo("The date the asset was purchased.")),nh("first_period_end (date)",vo("The date the first period ended.")),nh("salvage (number)",vo("The value of the asset at the end of depreciation.")),nh("period (number)",vo("The single period within life for which to calculate depreciation.")),nh("rate (number)",vo("The deprecation rate.")),nh("day_count_convention (number, optional)",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=wi(e,this.locale),l=Math.trunc(wi(t,this.locale)),c=Math.trunc(wi(o,this.locale)),h=wi(s,this.locale),d=wi(i,this.locale),u=wi(n,this.locale),g=Math.trunc(wi(r,this.locale));!function(e){bi((()=>e>0),vo("The cost (%s) must be strictly positive.",e.toString()))}(a),function(e){bi((()=>e>=0),vo("The purchase_date (%s) must be positive or null.",e.toString()))}(l),Cp(h),function(e,t){bi((()=>e<=t),vo("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(h,a),function(e){bi((()=>e>=0),vo("The period (%s) must be positive or null.",e.toString()))}(d),vp(u),gp(g),bi((()=>l<=c),vo("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=Fs(l,c,g),v=l===c?m:m*f,b=a-v-m*p;return b>=h?0===p?v:m:h-b<m?m-(h-b):0},isExported:!0},Lp={description:vo("Days in coupon period containing settlement date."),args:Mp,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(wi(e,this.locale)),n=Math.trunc(wi(t,this.locale)),r=Math.trunc(wi(o,this.locale)),a=Math.trunc(wi(s,this.locale));if(hp(i,n),up(r),gp(a),1===a){const i=zp.compute.bind(this)(e,t,o,s).value;return Hp.compute.bind(this)(e,t,o,s).value-i}return(3===a?365:360)/r},isExported:!0},Vp={description:vo("Days from settlement until next coupon."),args:Mp,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(wi(e,this.locale)),n=Math.trunc(wi(t,this.locale)),r=Math.trunc(wi(o,this.locale)),a=Math.trunc(wi(s,this.locale));hp(i,n),up(r),gp(a);const l=zp.compute.bind(this)(e,t,o,s).value;if([1,2,3].includes(a))return i-l;if(4===a){const e=Fs(l,i,a);return Math.round(360*e)}const c=Ni(i,this.locale),h=Ni(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&&_s(h)&&_s(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&_s(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Up={description:vo("Days from settlement until next coupon."),args:Mp,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(wi(e,this.locale)),n=Math.trunc(wi(t,this.locale)),r=Math.trunc(wi(o,this.locale)),a=Math.trunc(wi(s,this.locale));hp(i,n),up(r),gp(a);const l=Hp.compute.bind(this)(e,t,o,s).value;if([1,2,3].includes(a))return l-i;if(4===a){const e=Fs(i,l,a);return Math.round(360*e)}const c=Vp.compute.bind(this)(e,t,o,s);return Lp.compute.bind(this)(e,t,o,s)-c},isExported:!0},Hp={description:vo("Next coupon date after the settlement date."),args:Mp,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(wi(e,this.locale)),n=Math.trunc(wi(t,this.locale)),r=Math.trunc(wi(o,this.locale)),a=Math.trunc(wi(s,this.locale));hp(i,n),up(r),gp(a);const l=12/r,c=Bp.compute.bind(this)(e,t,o,s);return{value:Rs(Ds(Ni(n,this.locale),-(c-1)*l,!0)),format:this.locale.dateFormat}},isExported:!0},Bp={description:vo("Number of coupons between settlement and maturity."),args:Mp,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(wi(e,this.locale)),n=Math.trunc(wi(t,this.locale)),r=Math.trunc(wi(o,this.locale)),a=Math.trunc(wi(s,this.locale));hp(i,n),up(r),gp(a);let l=1,c=n;const h=12/r;for(;c>i;)c=Rs(Ds(Ni(c,this.locale),-h,!1)),l++;return l-1},isExported:!0},zp={description:vo("Last coupon date prior to or on the settlement date."),args:Mp,compute:function(e,t,o,s={value:0}){s=s||0;const i=Math.trunc(wi(e,this.locale)),n=Math.trunc(wi(t,this.locale)),r=Math.trunc(wi(o,this.locale)),a=Math.trunc(wi(s,this.locale));hp(i,n),up(r),gp(a);const l=12/r,c=Bp.compute.bind(this)(e,t,o,s);return{value:Rs(Ds(Ni(n,this.locale),-c*l,!0)),format:this.locale.dateFormat}},isExported:!0},$p={description:vo("Cumulative interest paid over a set of periods."),args:[nh("rate (number)",vo("The interest rate.")),nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("present_value (number)",vo("The current value of the annuity.")),nh("first_period (number)",vo("The number of the payment period to begin the cumulative calculation.")),nh("last_period (number)",vo("The number of the payment period to end the cumulative calculation.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s,i,n={value:0}){const r=wi(s,this.locale),a=wi(i,this.locale),l=wi(e,this.locale),c=wi(o,this.locale),h=wi(t,this.locale),d=Mi(n)?1:0;_p(r,a,h),vp(l),wp(c);let u=0;for(let e=r;e<=a;e++)u+=sm(l,e,h,c,0,d);return u},isExported:!0},Gp={description:vo("Cumulative principal paid over a set of periods."),args:[nh("rate (number)",vo("The interest rate.")),nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("present_value (number)",vo("The current value of the annuity.")),nh("first_period (number)",vo("The number of the payment period to begin the cumulative calculation.")),nh("last_period (number)",vo("The number of the payment period to end the cumulative calculation.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s,i,n={value:0}){const r=wi(s,this.locale),a=wi(i,this.locale),l=wi(e,this.locale),c=wi(o,this.locale),h=wi(t,this.locale),d=Mi(n)?1:0;_p(r,a,h),vp(l),wp(c);let u=0;for(let e=r;e<=a;e++)u+=fm(l,e,h,c,0,d);return u},isExported:!0},Wp={description:vo("Depreciation via declining balance method."),args:[nh("cost (number)",vo("The initial cost of the asset.")),nh("salvage (number)",vo("The value of the asset at the end of depreciation.")),nh("life (number)",vo("The number of periods over which the asset is depreciated.")),nh("period (number)",vo("The single period within life for which to calculate depreciation.")),nh("month (number, optional)",vo("The number of months in the first year of depreciation."))],compute:function(e,t,o,s,...i){const n=wi(e,this.locale),r=wi(t,this.locale),a=wi(o,this.locale),l=Math.trunc(wi(s,this.locale)),c=i.length?Math.trunc(wi(i[0],this.locale)):12,h=a+(12===c?0:1);Sp(n),Cp(r),yp(l),bp(a),bi((()=>1<=c&&c<=12),vo("The month (%s) must be between 1 and 12 inclusive.",c.toString())),bi((()=>l<=h),vo("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 qp(e,t,o,s,i){if(Sp(e),Cp(t),yp(s),bp(o),Ep(s,o),Tp(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 Zp={description:vo("Depreciation via double-declining balance method."),args:[nh("cost (number)",vo("The initial cost of the asset.")),nh("salvage (number)",vo("The value of the asset at the end of depreciation.")),nh("life (number)",vo("The number of periods over which the asset is depreciated.")),nh("period (number)",vo("The single period within life for which to calculate depreciation.")),nh("factor (number, default=2)",vo("The factor by which depreciation decreases."))],compute:function(e,t,o,s,i={value:2}){return{value:qp(wi(e,this.locale),wi(t,this.locale),wi(o,this.locale),wi(s,this.locale),wi(i,this.locale)),format:"#,##0.00"}},isExported:!0},jp={description:vo("Discount rate of a security based on price."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("price (number)",vo("The price at which the security is bought per 100 face value.")),nh("redemption (number)",vo("The redemption amount per 100 face value, or par.")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(wi(e,this.locale)),r=Math.trunc(wi(t,this.locale)),a=wi(o,this.locale),l=wi(s,this.locale),c=Math.trunc(wi(i,this.locale));hp(n,r),gp(c),mp(a),pp(l);return(l-a)/l/Fs(n,r,c)},isExported:!0},Yp={description:vo("Convert a decimal fraction to decimal value."),args:[nh("fractional_price (number)",vo("The price quotation given using fractional decimal conventions.")),nh("unit (number)",vo("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],compute:function(e,t){const o=wi(e,this.locale),s=Math.trunc(wi(t,this.locale));bi((()=>s>0),vo("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},Xp={description:vo("Convert a decimal value to decimal fraction."),args:[nh("decimal_price (number)",vo("The price quotation given as a decimal value.")),nh("unit (number)",vo("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],compute:function(e,t){const o=wi(e,this.locale),s=Math.trunc(wi(t,this.locale));bi((()=>s>0),vo("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},Kp={description:vo("Number of periods for an investment to reach a value."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("rate (number)",vo("The annualized rate of interest.")),nh("yield (number)",vo("The expected annual yield of the security.")),nh("frequency (number)",vo("The number of interest or coupon payments per year (1, 2, or 4).")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n={value:0}){const r=Math.trunc(wi(e,this.locale)),a=Math.trunc(wi(t,this.locale)),l=wi(o,this.locale),c=wi(s,this.locale),h=Math.trunc(wi(i,this.locale)),d=Math.trunc(wi(n,this.locale));hp(r,a),up(h),gp(d),bi((()=>l>=0),vo("The rate (%s) must be positive or null.",l.toString())),bi((()=>c>=0),vo("The yield (%s) must be positive or null.",c.toString()));const u=Fs(r,a,d),g=u-Math.trunc(u)||1/h,p=Math.ceil(u*h),m=l/h,f=c/h;let v=0,b=0;for(let e=1;e<=p;e++){const t=(m+(e===p?1:0))/(1+f)**e;b+=(g+(e-1)/h)*t,v+=t}return 0===v?0:b/v},isExported:!0},Qp={description:vo("Annual effective interest rate."),args:[nh("nominal_rate (number)",vo("The nominal interest rate per year.")),nh("periods_per_year (number)",vo("The number of compounding periods per year."))],compute:function(e,t){const o=wi(e,this.locale),s=Math.trunc(wi(t,this.locale));return bi((()=>o>0),vo("The nominal rate (%s) must be strictly greater than 0.",o.toString())),bi((()=>s>0),vo("The number of periods by year (%s) must strictly greater than 0.",s.toString())),Math.pow(1+o/s,s)-1},isExported:!0};function Jp(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 em={description:vo("Future value of an annuity investment."),args:[nh("rate (number)",vo("The interest rate.")),nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("payment_amount (number)",vo("The amount per period to be paid.")),nh("present_value (number, default=0)",vo("The current value of the annuity.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;return{value:Jp(wi(e,this.locale),wi(t,this.locale),wi(o,this.locale),wi(s,this.locale),Mi(i)?1:0),format:"#,##0.00"}},isExported:!0},tm={description:vo("Future value of principal from series of rates."),args:[nh("principal (number)",vo("The amount of initial capital or value to compound against.")),nh("rate_schedule (number, range<number>)",vo("A series of interest rates to compound against the principal."))],compute:function(e,t){return Hi([t],((e,t)=>e*(1+wi(t,this.locale))),wi(e,this.locale))},isExported:!0},om={description:vo("Calculates effective interest rate."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("investment (number)",vo("The amount invested in the security.")),nh("redemption (number)",vo("The amount to be received at maturity.")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){const n=Math.trunc(wi(e,this.locale)),r=Math.trunc(wi(t,this.locale)),a=wi(s,this.locale),l=wi(o,this.locale),c=Math.trunc(wi(i,this.locale));hp(n,r),xp(l),pp(a),gp(c);return(a-l)/l/Fs(n,r,c)},isExported:!0};function sm(e,t,o,s,i,n){return pm(e,o,s,i,n)-fm(e,t,o,s,i,n)}const im={description:vo("Payment on the principal of an investment."),args:[nh("rate (number)",vo("The annualized rate of interest.")),nh("period (number)",vo("The amortization period, in terms of number of periods.")),nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("present_value (number)",vo("The current value of the annuity.")),nh("future_value (number, default=0)",vo("The future value remaining after the final payment has been made.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s,i={value:0},n={value:0}){return{value:sm(wi(e,this.locale),wi(t,this.locale),wi(o,this.locale),wi(s,this.locale),wi(i,this.locale),Mi(n)?1:0),format:"#,##0.00"}},isExported:!0},nm={description:vo("Internal rate of return given periodic cashflows."),args:[nh("cashflow_amounts (number, range<number>)",vo("An array or range containing the income or payments associated with the investment.")),nh("rate_guess (number, default=0.1)",vo("An estimate for what the internal rate of return will be."))],compute:function(e,t={value:.1}){const o=wi(t,this.locale);Dp(o);let s=!1,i=!1,n=[];Vi([e],(({value:e})=>{e>0&&(s=!0),e<0&&(i=!0),n.push(e)}),this.locale),bi((()=>s&&i),vo("The cashflow_amounts must include negative and positive values."));const r=n.shift();return{value:Np((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},rm={description:vo("Returns the interest paid at a particular period of an investment."),args:[nh("rate (number)",vo("The interest rate.")),nh("period (number)",vo("The period for which you want to view the interest payment.")),nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("present_value (number)",vo("The current value of the annuity."))],compute:function(e,t,o,s){const i=wi(e,this.locale),n=wi(t,this.locale),r=wi(o,this.locale),a=wi(s,this.locale);bi((()=>0!==r),vo("The number of periods must be different than 0.",r.toString()));return-1*(a-a*(n/r))*i},isExported:!0},am={description:vo("Modified Macaulay duration."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("rate (number)",vo("The annualized rate of interest.")),nh("yield (number)",vo("The expected annual yield of the security.")),nh("frequency (number)",vo("The number of interest or coupon payments per year (1, 2, or 4).")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n={value:0}){return Kp.compute.bind(this)(e,t,o,s,i,n)/(1+wi(s,this.locale)/Math.trunc(wi(i,this.locale)))},isExported:!0},lm={description:vo("Modified internal rate of return."),args:[nh("cashflow_amounts (range<number>)",vo("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")),nh("financing_rate (number)",vo("The interest rate paid on funds invested.")),nh("reinvestment_return_rate (number)",vo("The return (as a percentage) earned on reinvestment of income received from the investment."))],compute:function(e,t,o){const s=wi(t,this.locale),i=wi(o,this.locale),n=Wi(e).flat().filter((e=>null!==e.value)).map((e=>wi(e,this.locale))),r=n.length;let a=0,l=0;for(const e of Be(0,r)){const t=n[e];t>=0?a+=t*(i+1)**(r-e-1):l+=t/(s+1)**e}bi((()=>0!==l&&0!==a),vo("There must be both positive and negative values in cashflow_amounts."));return(-a/l)**(1/(r-1))-1},isExported:!0},cm={description:vo("Annual nominal interest rate."),args:[nh("effective_rate (number)",vo("The effective interest rate per year.")),nh("periods_per_year (number)",vo("The number of compounding periods per year."))],compute:function(e,t){const o=wi(e,this.locale),s=Math.trunc(wi(t,this.locale));return bi((()=>o>0),vo("The effective rate (%s) must must strictly greater than 0.",o.toString())),bi((()=>s>0),vo("The number of periods by year (%s) must strictly greater than 0.",s.toString())),(Math.pow(o+1,1/s)-1)*s},isExported:!0},hm={description:vo("Number of payment periods for an investment."),args:[nh("rate (number)",vo("The interest rate.")),nh("payment_amount (number)",vo("The amount of each payment made.")),nh("present_value (number)",vo("The current value of the annuity.")),nh("future_value (number, default=0)",vo("The future value remaining after the final payment has been made.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;const n=wi(e,this.locale),r=wi(t,this.locale),a=wi(o,this.locale),l=wi(s,this.locale),c=Mi(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 dm(e,t,o,s){let i=0;return Bi(o,((t,o)=>(i++,t+o/(1+e)**i)),t,s)}const um={description:vo("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:[nh("discount (number)",vo("The discount rate of the investment over one period.")),nh("cashflow1 (number, range<number>)",vo("The first future cash flow.")),nh("cashflow2 (number, range<number>, repeating)",vo("Additional future cash flows."))],compute:function(e,...t){const o=wi(e,this.locale);return bi((()=>-1!==o),vo("The discount (%s) must be different from -1.",o.toString())),{value:dm(o,0,t,this.locale),format:"#,##0.00"}},isExported:!0},gm={description:vo("Computes the number of periods needed for an investment to reach a value."),args:[nh("rate (number)",vo("The rate at which the investment grows each period.")),nh("present_value (number)",vo("The investment's current value.")),nh("future_value (number)",vo("The investment's desired future value."))],compute:function(e,t,o){const s=wi(e,this.locale),i=wi(t,this.locale),n=wi(o,this.locale);return vp(s),bi((()=>i>0),vo("The present_value (%s) must be strictly positive.",i.toString())),bi((()=>n>0),vo("The future_value (%s) must be strictly positive.",n.toString())),(Math.log(n)-Math.log(i))/Math.log(1+s)},isExported:!0};function pm(e,t,o,s,i){if(fp(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 mm={description:vo("Periodic payment for an annuity investment."),args:[nh("rate (number)",vo("The annualized rate of interest.")),nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("present_value (number)",vo("The current value of the annuity.")),nh("future_value (number, default=0)",vo("The future value remaining after the final payment has been made.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s={value:0},i={value:0}){const n=wi(t,this.locale),r=wi(e,this.locale),a=Mi(i)?1:0,l=wi(s,this.locale);return{value:pm(r,n,wi(o,this.locale),l,a),format:"#,##0.00"}},isExported:!0};function fm(e,t,o,s,i,n){fp(o),bi((()=>t>0&&t<=o),vo("The period must be between 1 and number_of_periods (%s)",o));const r=pm(e,o,s,i,n);if(1===n&&1===t)return r;return r+-Jp(e,0===n?t-1:t-2,r,s+r*n,0)*e}const vm={description:vo("Payment on the principal of an investment."),args:[nh("rate (number)",vo("The annualized rate of interest.")),nh("period (number)",vo("The amortization period, in terms of number of periods.")),nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("present_value (number)",vo("The current value of the annuity.")),nh("future_value (number, default=0)",vo("The future value remaining after the final payment has been made.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s,i={value:0},n={value:0}){const r=wi(o,this.locale),a=wi(e,this.locale),l=wi(t,this.locale),c=Mi(n)?1:0,h=wi(i,this.locale);return{value:fm(a,l,r,wi(s,this.locale),h,c),format:"#,##0.00"}},isExported:!0},bm={description:vo("Present value of an annuity investment."),args:[nh("rate (number)",vo("The interest rate.")),nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("payment_amount (number)",vo("The amount per period to be paid.")),nh("future_value (number, default=0)",vo("The future value remaining after the final payment has been made.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period."))],compute:function(e,t,o,s={value:0},i={value:0}){s=s||0,i=i||0;const n=wi(e,this.locale),r=wi(t,this.locale),a=wi(o,this.locale),l=wi(s,this.locale),c=Mi(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},Sm={description:vo("Price of a security paying periodic interest."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("rate (number)",vo("The annualized rate of interest.")),nh("yield (number)",vo("The expected annual yield of the security.")),nh("redemption (number)",vo("The redemption amount per 100 face value, or par.")),nh("frequency (number)",vo("The number of interest or coupon payments per year (1, 2, or 4).")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=Math.trunc(wi(e,this.locale)),l=Math.trunc(wi(t,this.locale)),c=wi(o,this.locale),h=wi(s,this.locale),d=wi(i,this.locale),u=Math.trunc(wi(n,this.locale)),g=Math.trunc(wi(r,this.locale));hp(a,l),up(u),gp(g),bi((()=>c>=0),vo("The rate (%s) must be positive or null.",c.toString())),bi((()=>h>=0),vo("The yield (%s) must be positive or null.",h.toString())),pp(d);const p=Fs(a,l,g)*u,m=Math.ceil(p),f=p-Math.floor(p)||1,v=1+h/u,b=100*c/u;if(1===m)return(b+d)/(f*h/u+1)-b*(1-f);let S=0;for(let e=1;e<=m;e++)S+=b/v**(e-1+f);return d/v**(m-1+f)+S-b*(1-f)},isExported:!0},ym={description:vo("Price of a discount security."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("discount (number)",vo("The discount rate of the security at time of purchase.")),nh("redemption (number)",vo("The redemption amount per 100 face value, or par.")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(wi(e,this.locale)),r=Math.trunc(wi(t,this.locale)),a=wi(o,this.locale),l=wi(s,this.locale),c=Math.trunc(wi(i,this.locale));hp(n,r),gp(c),Ip(a),pp(l);return l-a*l*Fs(n,r,c)},isExported:!0},Cm={description:vo("Calculates the price of a security paying interest at maturity, based on expected yield."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("issue (date)",vo("The date the security was initially issued.")),nh("rate (number)",vo("The annualized rate of interest.")),nh("yield (number)",vo("The expected annual yield of the security.")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n={value:0}){n=n||0;const r=Math.trunc(wi(e,this.locale)),a=Math.trunc(wi(t,this.locale)),l=Math.trunc(wi(o,this.locale)),c=wi(s,this.locale),h=wi(i,this.locale),d=Math.trunc(wi(n,this.locale));dp(r,l),hp(r,a),gp(d),bi((()=>c>=0),vo("The rate (%s) must be positive or null.",c.toString())),bi((()=>h>=0),vo("The yield (%s) must be positive or null.",h.toString()));const u=Fs(r,a,d),g=Fs(r,l,d);return(100+Fs(l,a,d)*c*100)/(1+u*h)-g*c*100},isExported:!0},wm=.1,Em={description:vo("Interest rate of an annuity investment."),args:[nh("number_of_periods (number)",vo("The number of payments to be made.")),nh("payment_per_period (number)",vo("The amount per period to be paid.")),nh("present_value (number)",vo("The current value of the annuity.")),nh("future_value (number, default=0)",vo("The future value remaining after the final payment has been made.")),nh("end_or_beginning (number, default=0)",vo("Whether payments are due at the end (0) or beginning (1) of each period.")),nh("rate_guess (number, default=0.1)",vo("An estimate for what the interest rate will be."))],compute:function(e,t,o,s={value:0},i={value:0},n={value:wm}){const r=wi(e,this.locale),a=wi(t,this.locale),l=Mi(i)?1:0,c=wi(n,this.locale)||wm;let h=wi(s,this.locale),d=wi(o,this.locale);fp(r),bi((()=>[a,d,h].some((e=>e>0))&&[a,d,h].some((e=>e<0))),vo("There must be both positive and negative values in [payment_amount, present_value, future_value].",r.toString())),Dp(c),h-=a*l,d+=a*l;return{value:Np((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},xm={description:vo("Amount received at maturity for a security."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("investment (number)",vo("The amount invested (irrespective of face value of each security).")),nh("discount (number)",vo("The discount rate of the security invested in.")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(wi(e,this.locale)),r=Math.trunc(wi(t,this.locale)),a=wi(o,this.locale),l=wi(s,this.locale),c=Math.trunc(wi(i,this.locale));hp(n,r),gp(c),xp(a),Ip(l);return a/(1-l*Fs(n,r,c))},isExported:!0},Im={description:vo("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:[nh("number_of_periods (number)",vo("The number of periods.")),nh("present_value (number)",vo("The present value of the investment.")),nh("future_value (number)",vo("The future value of the investment."))],compute:function(e,t,o){const s=wi(e,this.locale),i=wi(t,this.locale),n=wi(o,this.locale);return fp(s),(n/i)**(1/s)-1},isExported:!0},Rm={description:vo("Depreciation of an asset using the straight-line method."),args:[nh("cost (number)",vo("The initial cost of the asset.")),nh("salvage (number)",vo("The value of the asset at the end of depreciation.")),nh("life (number)",vo("The number of periods over which the asset is depreciated."))],compute:function(e,t,o){return{value:(wi(e,this.locale)-wi(t,this.locale))/wi(o,this.locale),format:"#,##0.00"}},isExported:!0},Tm={description:vo("Depreciation via sum of years digit method."),args:[nh("cost (number)",vo("The initial cost of the asset.")),nh("salvage (number)",vo("The value of the asset at the end of depreciation.")),nh("life (number)",vo("The number of periods over which the asset is depreciated.")),nh("period (number)",vo("The single period within life for which to calculate depreciation."))],compute:function(e,t,o,s){const i=wi(e,this.locale),n=wi(t,this.locale),r=wi(o,this.locale),a=wi(s,this.locale);yp(a),bp(r),Ep(a,r);return{value:(r-a+1)/(r*(r+1)/2)*(i-n),format:"#,##0.00"}},isExported:!0};function Am(e,t,o){return 100*(1-o*Fs(e,t,2))}const _m={description:vo("Price of a US Treasury bill."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("discount (number)",vo("The discount rate of the bill at time of purchase."))],compute:function(e,t,o){const s=Math.trunc(wi(e,this.locale)),i=Math.trunc(wi(t,this.locale)),n=wi(o,this.locale);return hp(s,i),Ap(s,i,this.locale),Ip(n),Rp(n),Am(s,i,n)},isExported:!0},Dm={description:vo("Equivalent rate of return for a US Treasury bill."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("discount (number)",vo("The discount rate of the bill at time of purchase."))],compute:function(e,t,o){const s=Math.trunc(wi(e,this.locale)),i=Math.trunc(wi(t,this.locale)),n=wi(o,this.locale);hp(s,i),Ap(s,i,this.locale),Ip(n),Rp(n);const r=Eg.compute.bind(this)({value:i},{value:s});if(r<=182)return 365*n/(360-n*r);const a=Am(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},Om={description:vo("The yield of a US Treasury bill based on price."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("price (number)",vo("The price at which the security is bought per 100 face value."))],compute:function(e,t,o){const s=Math.trunc(wi(e,this.locale)),i=Math.trunc(wi(t,this.locale)),n=wi(o,this.locale);hp(s,i),Ap(s,i,this.locale),mp(n);return(100-n)/n*(1/Fs(s,i,2))},isExported:!0},Fm={description:vo("Variable declining balance. WARNING : does not handle decimal periods."),args:[nh("cost (number)",vo("The initial cost of the asset.")),nh("salvage (number)",vo("The value of the asset at the end of depreciation.")),nh("life (number)",vo("The number of periods over which the asset is depreciated.")),nh("start (number)",vo("Starting period to calculate depreciation.")),nh("end (number)",vo("Ending period to calculate depreciation.")),nh("factor (number, default=2)",vo("The number of months in the first year of depreciation.")),nh("no_switch (number, default=false)",vo("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation."))],compute:function(e,t,o,s,i,n={value:2},r={value:false}){n=n||0;const a=wi(e,this.locale),l=wi(t,this.locale),c=wi(o,this.locale),h=Math.trunc(wi(s,this.locale)),d=Math.trunc(wi(i,this.locale)),u=wi(n,this.locale),g=Mi(r);if(Sp(a),Cp(l),function(e,t,o){bp(o),bi((()=>e>=0),vo("The start_period (%s) must be greater or equal than 0.",e.toString())),bi((()=>t>=0),vo("The end_period (%s) must be greater or equal than 0.",t.toString())),bi((()=>e<=t),vo("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),bi((()=>t<=o),vo("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),o.toString()))}(h,d,c),Tp(u),0===a)return 0;if(l>=a)return h<1?a-l:0;const p=u/c;if(p>=1)return h<1?a-l:0;let m=a,f=0,v=0,b=!1;for(let e=0;e<d;e++){if(!b||g){const t=m*p,o=(m-l)/(c-e);!g&&o>t?(b=!0,f=o):f=t}const t=Math.max(m-f,l);e>=h&&(v+=m-t),m=t}return v},isExported:!0},Mm={description:vo("Internal rate of return given non-periodic cash flows."),args:[nh("cashflow_amounts (range<number>)",vo("An range containing the income or payments associated with the investment.")),nh("cashflow_dates (range<number>)",vo("An range with dates corresponding to the cash flows in cashflow_amounts.")),nh("rate_guess (number, default=0.1)",vo("An estimate for what the internal rate of return will be."))],compute:function(e,t,o={value:wm}){const s=wi(o,this.locale),i=e.flat().map((e=>wi(e,this.locale))),n=t.flat().map((e=>wi(e,this.locale)));var r;Op(e,t),r=i,bi((()=>r.some((e=>e>0))&&r.some((e=>e<0))),vo("There must be both positive and negative values in cashflow_amounts.")),Fp(n),Dp(s);const a=new Map;for(const e of Be(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 Np((e=>{let t=c[0];for(const o of Be(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 Be(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},Nm={description:vo("Net present value given to non-periodic cash flows.."),args:[nh("discount (number)",vo("The discount rate of the investment over one period.")),nh("cashflow_amounts (number, range<number>)",vo("An range containing the income or payments associated with the investment.")),nh("cashflow_dates (number, range<number>)",vo("An range with dates corresponding to the cash flows in cashflow_amounts."))],compute:function(e,t,o){const s=wi(e,this.locale),i=ni(t)?t.flat().map((e=>Ii(e,this.locale))):[Ii(t,this.locale)],n=ni(o)?o.flat().map((e=>Ii(e,this.locale))):[Ii(o,this.locale)];if(ni(o)&&ni(t)?Op(t,o):bi((()=>i.length===n.length),vo("There must be the same number of values in cashflow_amounts and cashflow_dates.")),Fp(n),vp(s),1===i.length)return i[0];const r=new Map;for(const e of Be(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 Be(1,l.length)){const t=(a[0]-a[e])/365;c+=l[e]*(1+s)**t}return c},isExported:!0},Pm={description:vo("Annual yield of a security paying periodic interest."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("rate (number)",vo("The annualized rate of interest.")),nh("price (number)",vo("The price at which the security is bought per 100 face value.")),nh("redemption (number)",vo("The redemption amount per 100 face value, or par.")),nh("frequency (number)",vo("The number of interest or coupon payments per year (1, 2, or 4).")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n,r={value:0}){r=r||0;const a=Math.trunc(wi(e,this.locale)),l=Math.trunc(wi(t,this.locale)),c=wi(o,this.locale),h=wi(s,this.locale),d=wi(i,this.locale),u=Math.trunc(wi(n,this.locale)),g=Math.trunc(wi(r,this.locale));hp(a,l),up(u),gp(g),bi((()=>c>=0),vo("The rate (%s) must be positive or null.",c.toString())),mp(h),pp(d);const p=Fs(a,l,g)*u,m=Math.ceil(p),f=p-Math.floor(p)||1,v=100*c/u;if(1===m){const e=h+v*(1-f);return(d+v-e)*u*(1/f)/e}const b=Np((function(e){return function(e,t,o,s,i,n){let r=n-(e+i*(1-t))*s**(o-1+t);for(let e=1;e<=o;e++)r+=i*s**(e-1);return r}(h,f,m,e,v,d)}),(function(e){return function(e,t,o,s,i){let n=-(e+i*(1-t))*(o-1+t)*s**(o-2+t);for(let e=1;e<=o;e++)n+=i*(e-1)*s**(e-2);return n}(h,f,m,e,v)}),1+(c+1)/u,100,1e-5);return(b-1)*u},isExported:!0},km={description:vo("Annual yield of a discount security."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("price (number)",vo("The price at which the security is bought per 100 face value.")),nh("redemption (number)",vo("The redemption amount per 100 face value, or par.")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i={value:0}){i=i||0;const n=Math.trunc(wi(e,this.locale)),r=Math.trunc(wi(t,this.locale)),a=wi(o,this.locale),l=wi(s,this.locale),c=Math.trunc(wi(i,this.locale));hp(n,r),gp(c),mp(a),pp(l);return(l/a-1)/Fs(n,r,c)},isExported:!0},Lm={description:vo("Annual yield of a security paying interest at maturity."),args:[nh("settlement (date)",vo("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),nh("maturity (date)",vo("The maturity or end date of the security, when it can be redeemed at face, or par value.")),nh("issue (date)",vo("The date the security was initially issued.")),nh("rate (number)",vo("The annualized rate of interest.")),nh("price (number)",vo("The price at which the security is bought.")),nh("day_count_convention (number, default=0 )",vo("An indicator of what day count method to use."))],compute:function(e,t,o,s,i,n={value:0}){n=n||0;const r=Math.trunc(wi(e,this.locale)),a=Math.trunc(wi(t,this.locale)),l=Math.trunc(wi(o,this.locale)),c=wi(s,this.locale),h=wi(i,this.locale),d=Math.trunc(wi(n,this.locale));hp(r,a),gp(d),bi((()=>r>=l),vo("The settlement (%s) must be greater than or equal to the issue (%s).",r.toString(),l.toString())),bi((()=>c>=0),vo("The rate (%s) must be positive or null.",c.toString())),mp(h);const u=Fs(l,a,d),g=Fs(l,r,d),p=Fs(r,a,d);return(100*(1+c*u)/(h+100*c*g)-1)/p},isExported:!0};var Vm,Um=Object.freeze({__proto__:null,ACCRINTM:Pp,AMORLINC:kp,COUPDAYBS:Vp,COUPDAYS:Lp,COUPDAYSNC:Up,COUPNCD:Hp,COUPNUM:Bp,COUPPCD:zp,CUMIPMT:$p,CUMPRINC:Gp,DB:Wp,DDB:Zp,DISC:jp,DOLLARDE:Yp,DOLLARFR:Xp,DURATION:Kp,EFFECT:Qp,FV:em,FVSCHEDULE:tm,INTRATE:om,IPMT:im,IRR:nm,ISPMT:rm,MDURATION:am,MIRR:lm,NOMINAL:cm,NPER:hm,NPV:um,PDURATION:gm,PMT:mm,PPMT:vm,PRICE:Sm,PRICEDISC:ym,PRICEMAT:Cm,PV:bm,RATE:Em,RECEIVED:xm,RRI:Im,SLN:Rm,SYD:Tm,TBILLEQ:Dm,TBILLPRICE:_m,TBILLYIELD:Om,VDB:Fm,XIRR:Mm,XNPV:Nm,YIELD:Pm,YIELDDISC:km,YIELDMAT:Lm});!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"}(Vm||(Vm={}));const Hm=(e,t=(()=>!0))=>[{goTo:e,guard:t}],Bm=(e,t=(()=>!0))=>({goTo:e,guard:t}),zm={[Vm.LeftRef]:{REFERENCE:Hm(Vm.Separator),NUMBER:Hm(Vm.FullRowSeparator),SYMBOL:[Bm(Vm.FullColumnSeparator,(e=>Ro(e.value))),Bm(Vm.FullRowSeparator,(e=>To(e.value)))]},[Vm.FullColumnSeparator]:{SPACE:Hm(Vm.FullColumnSeparator),OPERATOR:Hm(Vm.RightColumnRef,(e=>":"===e.value))},[Vm.FullRowSeparator]:{SPACE:Hm(Vm.FullRowSeparator),OPERATOR:Hm(Vm.RightRowRef,(e=>":"===e.value))},[Vm.Separator]:{SPACE:Hm(Vm.Separator),OPERATOR:Hm(Vm.RightRef,(e=>":"===e.value))},[Vm.RightRef]:{SPACE:Hm(Vm.RightRef),NUMBER:Hm(Vm.Found),REFERENCE:Hm(Vm.Found,(e=>Do(e.value))),SYMBOL:Hm(Vm.Found,(e=>Ao(e.value)||_o(e.value)))},[Vm.RightColumnRef]:{SPACE:Hm(Vm.RightColumnRef),SYMBOL:Hm(Vm.Found,(e=>Ao(e.value))),REFERENCE:Hm(Vm.Found,(e=>Do(e.value)))},[Vm.RightRowRef]:{SPACE:Hm(Vm.RightRowRef),NUMBER:Hm(Vm.Found),REFERENCE:Hm(Vm.Found,(e=>Do(e.value))),SYMBOL:Hm(Vm.Found,(e=>_o(e.value)))},[Vm.Found]:{}};function $m(e){let t=0,o=zm[Vm.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 Vm.Found:return s+=i.value,e.splice(0,t),{type:"REFERENCE",value:s};default:o=zm[r],s+=i.value}}return null}function Gm(e,t=si){const o=Jr(e,t),s=[];for(;o.length;)s.push($m(o)||o.shift());return s}const Wm=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,qm=["-","+"],Zm=["%"],jm=["*","+","&"],Ym={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10};function Xm(e){const t=e.shift();if(!t)throw new ui;switch(t.type){case"DEBUGGER":const o=Jm(e,1e3);return o.debug=!0,o;case"NUMBER":return{type:"NUMBER",value:Bs(t.value,si)};case"STRING":return{type:"STRING",value:Me(t.value)};case"INVALID_REFERENCE":return{type:"REFERENCE",value:ci.InvalidReference};case"REFERENCE":if(":"===e[0]?.value&&"REFERENCE"===e[1]?.type){e.shift();const o=e.shift();return{type:"REFERENCE",value:`${t.value}:${o?.value}`}}return{type:"REFERENCE",value:t.value};case"SYMBOL":const s=t.value,i=e[0];if("LEFT_PAREN"===i?.type&&Wm.test(t.value)&&s===Le(s,"'")){const t=function(e){Qm(e,"LEFT_PAREN",vo("Missing opening parenthesis"));const t=e[0];if("RIGHT_PAREN"===t?.type)return Qm(e,"RIGHT_PAREN"),[];const o=[];o.push(Km(e));for(;"RIGHT_PAREN"!==e[0]?.type;)Qm(e,"ARG_SEPARATOR",vo("Wrong function call")),o.push(Km(e));return Qm(e,"RIGHT_PAREN"),o}(e);return{type:"FUNCALL",value:s,args:t}}const n=s.toUpperCase();return"TRUE"===n||"FALSE"===n?{type:"BOOLEAN",value:"TRUE"===n}:{type:"SYMBOL",value:Le(t.value,"'")};case"LEFT_PAREN":const r=Jm(e);return Qm(e,"RIGHT_PAREN",vo("Missing closing parenthesis")),r;case"OPERATOR":const a=t.value;if(qm.includes(a))return{type:"UNARY_OPERATION",value:a,operand:Jm(e,Ym[a])};throw new ui(vo("Unexpected token: %s",t.value));default:throw new ui(vo("Unexpected token: %s",t.value))}}function Km(e){const t=e[0];return"ARG_SEPARATOR"===t?.type||"RIGHT_PAREN"===t?.type?{type:"EMPTY",value:""}:Jm(e)}function Qm(e,t,o){const s=e.shift();if(!s||s.type!==t)throw new ui(o)}function Jm(e,t=0){if(0===e.length)throw new ui;let o=Xm(e);for(;"OPERATOR"===e[0]?.type&&Ym[e[0].value]>t;){const t=e.shift().value;if(Zm.includes(t))o={type:"UNARY_OPERATION",value:t,operand:o,postfix:!0};else{o={type:"BIN_OPERATION",value:t,left:o,right:Jm(e,Ym[t])}}}return o}function ef(e){return tf(Gm(e))}function tf(e){e=e.filter((e=>"SPACE"!==e.type)),"="===e[0]?.value&&e.splice(0,1);const t=Jm(e);if(e.length)throw new ui;return t}function of(e,t,o){return rf(e,(e=>e.type===t?o(e):e))}function sf(e){return Array.from(nf(e))}function*nf(e){switch(yield e,e.type){case"FUNCALL":for(const t of e.args)yield*nf(t);break;case"UNARY_OPERATION":yield*nf(e.operand);break;case"BIN_OPERATION":yield*nf(e.left),yield*nf(e.right)}}function rf(e,t){switch((e=t(e)).type){case"FUNCALL":return{...e,args:e.args.map((e=>rf(e,t)))};case"UNARY_OPERATION":return{...e,operand:rf(e.operand,t)};case"BIN_OPERATION":return{...e,right:rf(e.right,t),left:rf(e.left,t)};default:return e}}function af(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>af(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?lf(e)+e.value:e.value+cf(e);case"BIN_OPERATION":return lf(e)+e.value+cf(e)}}function lf(e){const t=e.value,o="left"in e?e.left:e.operand,s=o.value;return"BIN_OPERATION"===o.type&&Ym[s]<Ym[t]?`(${af(o)})`:af(o)}function cf(e){const t=e.value,o="right"in e?e.right:e.operand,s=Ym[o.value],i=Ym[t];let n=!1;return"BIN_OPERATION"!==o.type?n=!1:s<i?n=!0:s!==i||jm.includes(t)||(n=!0),n?`(${af(o)})`:af(o)}function hf(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(tf(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}))}(Gm(e,t)))))}function df(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:o}=Oo(e.value),[s,i]=t.split(":"),n=uf(s),r=i?`:${uf(i)}`:"";return{...e,value:Fo(o,n+r)}}function uf(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=gf(e,"colrow");break;case"colrow":e=gf(e,"row");break;case"row":e=gf(e,"col");break;case"col":e=gf(e,"none")}return e}function gf(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 pf(e,t,o){const s=(t.startsWith("=")?hf(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(df).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 mf=["address","col","contents","format","row","type"],ff={description:vo("Gets information about a cell."),args:[nh("info_type (string)",vo("The type of information requested. Can be one of %s",mf.join(", "))),nh("reference (meta)",vo("The reference to the cell."))],compute:function(e,t){const o=Di(e).toLowerCase();bi((()=>mf.includes(o)),vo("The info_type should be one of %s.",mf.join(", ")));const s=this.__originSheetId,i=Di(t),n=i.includes(":")?i.split(":")[0]:i;let{sheetName:r,xc:a}=Oo(n);r=r===this.getters.getSheetName(s)?void 0:r;const l=Fo(r,gf(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===$s.empty?"b":t===$s.text?"l":"v"}}return""},isExported:!0},vf={description:vo("Whether a value is an error other than #N/A."),args:[nh("value (any)",vo("The value to be verified as an error type."))],compute:function(e){const t=e?.value;return yi(t)&&t!==ci.NotAvailable},isExported:!0},bf={description:vo("Whether a value is an error."),args:[nh("value (any)",vo("The value to be verified as an error type."))],compute:function(e){const t=e?.value;return yi(t)},isExported:!0},Sf={description:vo("Whether a value is `true` or `false`."),args:[nh("value (any)",vo("The value to be verified as a logical TRUE or FALSE."))],compute:function(e){return"boolean"==typeof e?.value},isExported:!0},yf={description:vo("Whether a value is the error #N/A."),args:[nh("value (any)",vo("The value to be verified as an error type."))],compute:function(e){return e?.value===ci.NotAvailable},isExported:!0},Cf={description:vo("Whether a value is non-textual."),args:[nh("value (any)",vo("The value to be checked."))],compute:function(e){return!Ef.compute.bind(this)(e)},isExported:!0},wf={description:vo("Whether a value is a number."),args:[nh("value (any)",vo("The value to be verified as a number."))],compute:function(e){return"number"==typeof e?.value},isExported:!0},Ef={description:vo("Whether a value is text."),args:[nh("value (any)",vo("The value to be verified as text."))],compute:function(e){return"string"==typeof e?.value&&!1===yi(e?.value)},isExported:!0},xf={description:vo("Whether the referenced cell is empty"),args:[nh("value (any)",vo("Reference to the cell that will be checked for emptiness."))],compute:function(e){return null===e?.value},isExported:!0},If={description:vo("Returns the error value #N/A."),args:[],compute:function(){return{value:ci.NotAvailable}},isExported:!0};var Rf=Object.freeze({__proto__:null,CELL:ff,ISBLANK:xf,ISERR:vf,ISERROR:bf,ISLOGICAL:Sf,ISNA:yf,ISNONTEXT:Cf,ISNUMBER:wf,ISTEXT:Ef,NA:If});const Tf={description:vo("Logical `and` operator."),args:[nh("logical_expression1 (boolean, range<boolean>)",vo("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.")),nh("logical_expression2 (boolean, range<boolean>, repeating)",vo("More expressions that represent logical values."))],compute:function(...e){const{result:t,foundBoolean:o}=Ta(e);return bi((()=>o),vo("[[FUNCTION_NAME]] has no valid input data.")),t},isExported:!0},Af={description:vo("Logical value `false`."),args:[],compute:function(){return!1},isExported:!0},_f={description:vo("Returns value depending on logical expression."),args:[nh("logical_expression (boolean)",vo("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")),nh("value_if_true (any)",vo("The value the function returns if logical_expression is TRUE.")),nh("value_if_false (any, default=FALSE)",vo("The value the function returns if logical_expression is FALSE."))],compute:function(e,t,o){const s=Mi(e?.value)?t:o;return void 0===s?{value:""}:(null===s.value&&(s.value=""),s)},isExported:!0},Df={description:vo("Value if it is not an error, otherwise 2nd argument."),args:[nh("value (any)",vo("The value to return if value itself is not an error.")),nh('value_if_error (any, default="empty")',vo("The value the function returns if value is an error."))],compute:function(e,t={value:""}){const o=yi(e?.value)?t:e;return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)},isExported:!0},Of={description:vo("Value if it is not an #N/A error, otherwise 2nd argument."),args:[nh("value (any)",vo("The value to return if value itself is not #N/A an error.")),nh('value_if_error (any, default="empty")',vo("The value the function returns if value is an #N/A error."))],compute:function(e,t={value:""}){const o=e?.value===ci.NotAvailable?t:e;return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)},isExported:!0},Ff={description:vo("Returns a value depending on multiple logical expressions."),args:[nh("condition1 (boolean)",vo("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")),nh("value1 (any)",vo("The returned value if condition1 is TRUE.")),nh("condition2 (boolean, any, repeating)",vo("Additional conditions to be evaluated if the previous ones are FALSE.")),nh("value2 (any, repeating)",vo("Additional values to be returned if their corresponding conditions are TRUE."))],compute:function(...e){bi((()=>e.length%2==0),vo("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(Mi(e[t]?.value)){const o=e[t+1];return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)}throw new di(vo("No match."))},isExported:!0},Mf={description:vo("Returns opposite of provided logical value."),args:[nh("logical_expression (boolean)",vo("An expression or reference to a cell holding an expression that represents some logical value."))],compute:function(e){return!Mi(e)},isExported:!0},Nf={description:vo("Logical `or` operator."),args:[nh("logical_expression1 (boolean, range<boolean>)",vo("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.")),nh("logical_expression2 (boolean, range<boolean>, repeating)",vo("More expressions that evaluate to logical values."))],compute:function(...e){const{result:t,foundBoolean:o}=Aa(e);return bi((()=>o),vo("[[FUNCTION_NAME]] has no valid input data.")),t},isExported:!0},Pf={description:vo("Logical value `true`."),args:[],compute:function(){return!0},isExported:!0},kf={description:vo("Logical `xor` operator."),args:[nh("logical_expression1 (boolean, range<boolean>)",vo("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.")),nh("logical_expression2 (boolean, range<boolean>, repeating)",vo("More expressions that evaluate to logical values."))],compute:function(...e){let t=!1,o=!1;return qi(e,(e=>(t=!0,o=o?!e:e,!0))),bi((()=>t),vo("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0};var Lf=Object.freeze({__proto__:null,AND:Tf,FALSE:Af,IF:_f,IFERROR:Df,IFNA:Of,IFS:Ff,NOT:Mf,OR:Nf,TRUE:Pf,XOR:kf});function Vf(e,t){const o=t.getPivotId(e);if(!o)throw new di(vo('There is no pivot with id "%s"',e));return o}function Uf(e){if(e.length%2!=0)throw new di(vo("Function PIVOT takes an even number of arguments."))}function Hf(e,t,o){const s=[];if("SPREADSHEET"===t.type&&t.dataSet){const{sheetId:o,zone:i}=t.dataSet,n=Lo(i),r=e.getters.getRangeFromSheetXC(o,n);if(void 0===r||r.invalidXc||r.invalidSheetName)throw new gi;s.push(r)}for(const t of o)if(t.computedBy){const o=e.getters.getMeasureCompiledFormula(t);s.push(...o.dependencies.filter((e=>!e.invalidXc)))}const i=e.__originCellPosition;i&&s.length&&(e.updateDependencies?.(i),e.addDependencies?.(i,s))}const Bf=!0;function zf(e){return{value:ci.NotAvailable,message:vo("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Di(e))}}const $f={description:vo("Returns a cell reference as a string. "),args:[nh("row (number)",vo("The row number of the cell reference. ")),nh("column (number)",vo("The column number (not name) of the cell reference. A is column number 1. ")),nh("absolute_relative_mode (number, default=1)",vo("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).")),nh("use_a1_notation (boolean, default=TRUE)",vo("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).")),nh("sheet (string, optional)",vo("A string indicating the name of the sheet into which the address points."))],compute:function(e,t,o={value:1},s={value:!0},i){const n=Ti(e,this.locale),r=Ti(t,this.locale);Ai(n),Ai(r);const a=Ti(o,this.locale);var l,c;bi((()=>[1,2,3,4].includes(a)),(l=4,c=a,vo("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(Mi(s)){h=io(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?Fo(Di(i),h):h},isExported:!0},Gf={description:vo("Column number of a specified cell."),args:[nh("cell_reference (meta, default='this cell')",vo("The cell whose column number will be returned. Column A corresponds to 1. By default, the function use the cell in which the formula is entered."))],compute:function(e){if(yi(e?.value))throw e;const t=void 0===e?this.__originCellPosition?.col:No(e.value).left;return bi((()=>void 0!==t),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter."),t+1},isExported:!0},Wf={description:vo("Number of columns in a specified array or range."),args:[nh("range (meta)",vo("The range whose column count will be returned."))],compute:function(e){if(yi(e?.value))throw e;const t=No(e.value);return t.right-t.left+1},isExported:!0},qf={description:vo("Horizontal lookup"),args:[nh("search_key (string, number, boolean)",vo("The value to search for. For example, 42, 'Cats', or I24.")),nh("range (any, range)",vo("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")),nh("index (number)",vo("The row index of the value to be returned, where the first row in range is numbered 1.")),nh("is_sorted (boolean, default=true)",vo("Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned."))],compute:function(e,t,o,s={value:Bf}){const i=Math.trunc(wi(o?.value,this.locale)),n=tn(t);bi((()=>1<=i&&i<=n[0].length),vo("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const r=(e,t)=>e[t][0].value,a=Mi(s.value)?Ki(n,e,"nextSmaller","asc",n.length,r):Qi(t,e,"wildcard",n.length,r,this.lookupCaches),l=n[a];return void 0===l?zf(e):l[i-1]},isExported:!0},Zf={description:vo("Returns the content of a cell, specified by row and column offset."),args:[nh("reference (any, range)",vo("The range of cells from which the values are returned.")),nh("row (number, default=0)",vo("The index of the row to be returned from within the reference range of cells.")),nh("column (number, default=0)",vo("The index of the column to be returned from within the reference range of cells."))],compute:function(e,t={value:0},o={value:0}){const s=tn(e),i=wi(t.value,this.locale),n=wi(o.value,this.locale);return bi((()=>n>=0&&n-1<s.length&&i>=0&&i-1<s[0].length),vo("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},jf={description:vo("Returns the content of a cell, specified by a string."),args:[nh("reference (string)",vo("The range of cells from which the values are returned.")),nh("use_a1_notation (boolean, default=TRUE)",vo("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE)."))],compute:function(e,t={value:!0}){let o=e?.value?.toString();if(!o)throw new gi(vo("Reference should be defined."));if(!Mi(t))throw new di(vo("R1C1 notation is not supported."));const s=this.__originSheetId,i=this.__originCellPosition;i&&this.updateDependencies?.(i);const n=this.getters.getRangeFromSheetXC(s,o);if(void 0===n||n.invalidXc||n.invalidSheetName)throw new gi;i&&this.addDependencies?.(i,[n]);const r=[];for(let e=n.zone.left;e<=n.zone.right;e++){const t=[];for(let o=n.zone.top;o<=n.zone.bottom;o++){const s={sheetId:n.sheetId,col:e,row:o};t.push(this.getters.getEvaluatedCell(s))}r.push(t)}return 1===r.length&&1===r[0].length?r[0][0]:r},isExported:!0},Yf={description:vo("Look up a value."),args:[nh("search_key (string, number, boolean)",vo("The value to search for. For example, 42, 'Cats', or I24.")),nh("search_array (any, range)",vo("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.")),nh("result_range (any, range, optional)",vo("The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method."))],compute:function(e,t,o){const s=tn(t),i=tn(o);let n=s.length,r=s[0].length;const a=r>=n,l=a?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,c=Ki(s,e,"nextSmaller","asc",a?r:n,l);return-1===c||a&&void 0===s[0][c]||!a&&void 0===s[c][r-1]?zf(e):0===i[0].length?a?s[n-1][c]:s[c][r-1]:(n=i.length,r=i[0].length,bi((()=>1===n||1===r),vo("The result_range must be a single row or a single column.")),n>1?(bi((()=>c<=n-1),vo("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(c+1).toString())),i[c][0]):(bi((()=>c<=r-1),vo("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(c+1).toString())),i[0][c]))},isExported:!0},Xf={description:vo("Position of item in range that matches value."),args:[nh("search_key (string, number, boolean)",vo("The value to search for. For example, 42, 'Cats', or I24.")),nh("range (any, range)",vo("The one-dimensional array to be searched.")),nh("search_type (number, default=1)",vo("The search method. 1 (default) finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order."))],compute:function(e,t,o={value:1}){let s=wi(o,this.locale);const i=tn(t),n=i.length,r=i[0].length;bi((()=>1===n||1===r),vo("The range must be a single row or a single column."));let a=-1;const l=1===n?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,c=1===n?i[0].length:i.length;switch(s=Math.sign(s),s){case 1:a=Ki(i,e,"nextSmaller","asc",c,l);break;case 0:a=Qi(i,e,"wildcard",c,l,this.lookupCaches);break;case-1:a=Ki(i,e,"nextGreater","desc",c,l)}return 1===n&&void 0===i[0][a]||1!==n&&void 0===i[a]?zf(e):a+1},isExported:!0},Kf={description:vo("Row number of a specified cell."),args:[nh("cell_reference (meta, default='this cell')",vo("The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered."))],compute:function(e){if(yi(e?.value))throw e;const t=void 0===e?this.__originCellPosition?.row:No(e.value).top;return bi((()=>void 0!==t),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter."),t+1},isExported:!0},Qf={description:vo("Number of rows in a specified array or range."),args:[nh("range (meta)",vo("The range whose row count will be returned."))],compute:function(e){if(yi(e?.value))throw e;const t=No(e.value);return t.bottom-t.top+1},isExported:!0},Jf={description:vo("Vertical lookup."),args:[nh("search_key (string, number, boolean)",vo("The value to search for. For example, 42, 'Cats', or I24.")),nh("range (any, range)",vo("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")),nh("index (number)",vo("The column index of the value to be returned, where the first column in range is numbered 1.")),nh("is_sorted (boolean, default=true)",vo("Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned."))],compute:function(e,t,o,s={value:Bf}){const i=Math.trunc(wi(o?.value,this.locale)),n=tn(t);bi((()=>1<=i&&i<=n.length),vo("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const r=(e,t)=>e[0][t].value,a=Mi(s.value)?Ki(n,e,"nextSmaller","asc",n[0].length,r):Qi(n,e,"wildcard",n[0].length,r,this.lookupCaches),l=n[i-1][a];return void 0===l?zf(e):l},isExported:!0},ev={0:"strict",1:"nextGreater","-1":"nextSmaller",2:"wildcard"},tv={description:vo("Search a range for a match and return the corresponding item from a second range."),args:[nh("search_key (string,number,boolean)",vo("The value to search for.")),nh("lookup_range (any, range)",vo("The range to consider for the search. Should be a single column or a single row.")),nh("return_range (any, range)",vo("The range containing the return value. Should have the same dimensions as lookup_range.")),nh("if_not_found (any, optional)",vo("If a valid match is not found, return this value.")),nh("match_mode (any, default=0)",vo("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match. (2) Wildcard match.")),nh("search_mode (any, default=1)",vo("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. "))],compute:function(e,t,o,s,i={value:0},n={value:1}){const r=Math.trunc(wi(i.value,this.locale)),a=Math.trunc(wi(n.value,this.locale)),l=tn(t),c=tn(o);bi((()=>1===l.length||1===l[0].length),vo("lookup_range should be either a single row or single column.")),bi((()=>[-1,1,-2,2].includes(a)),vo("search_mode should be a value in [-1, 1, -2, 2].")),bi((()=>[-1,0,1,2].includes(r)),vo("match_mode should be a value in [-1, 0, 1, 2]."));const h=1===l.length?"col":"row";bi((()=>!(2===r&&[-2,2].includes(a))),vo("the search and match mode combination is not supported for XLOOKUP evaluation.")),bi((()=>"col"===h?c[0].length===l[0].length:c.length===l.length),vo("return_range should have the same dimensions as lookup_range."));const d="col"===h?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,u="col"===h?l[0].length:l.length,g=ev[r],p=-1===a,m=2===a||-2===a?Ki(l,e,g,2===a?"asc":"desc",u,d):Qi(l,e,g,u,d,this.lookupCaches,p);return-1!==m?"col"===h?c.map((e=>[e[m]])):[c[m]]:void 0===s?zf(e):[[s]]},isExported:!0},ov={description:vo("Get the value from a pivot."),args:[nh("pivot_id (number,string)",vo("ID of the pivot.")),nh("measure_name (string)",vo("Name of the measure.")),nh("domain_field_name (string,optional,repeating)",vo("Field name.")),nh("domain_value (number,string,boolean,optional,repeating)",vo("Value."))],compute:function(e,t,...o){const s=Di(e),i=Di(t),n=Vf(s,this.getters);!function(e,t,o){const{measures:s}=o.getPivotCoreDefinition(e);if(!s.find((e=>e.id===t))){const e=`(${s.map((e=>e.id)).join(", ")})`;throw new di(vo("The argument %s is not a valid measure. Here are the measures: %s",t,e))}}(n,i,this.getters),Uf(o);const r=this.getters.getPivot(n),a=this.getters.getPivotCoreDefinition(n);Hf(this,a,a.measures.filter((e=>e.id===i))),r.init({reload:r.needsReevaluation});const l=r.assertIsValid({throwOnError:!1});if(l)return l;if(!r.areDomainArgsFieldsValid(o)){const e=vo("Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.",`=PIVOT(${s})`);return{value:ci.GenericError,message:vo("Dimensions don't match the pivot definition")+". "+e}}const c=r.parseArgsToPivotDomain(o);return r.getPivotCellValueAndFormat(i,c)}},sv={description:vo("Get the header of a pivot."),args:[nh("pivot_id (number,string)",vo("ID of the pivot.")),nh("domain_field_name (string,optional,repeating)",vo("Field name.")),nh("domain_value (number,string,value,optional,repeating)",vo("Value."))],compute:function(e,...t){const o=Di(e),s=Vf(o,this.getters);Uf(t);const i=this.getters.getPivot(s);Hf(this,this.getters.getPivotCoreDefinition(s),[]),i.init({reload:i.needsReevaluation});const n=i.assertIsValid({throwOnError:!1});if(n)return n;if(!i.areDomainArgsFieldsValid(t)){const e=vo("Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.",`=PIVOT(${o})`);return{value:ci.GenericError,message:vo("Dimensions don't match the pivot definition")+". "+e}}const r=i.parseArgsToPivotDomain(t),a=r.at(-1);if("measure"===a?.field)return i.getPivotMeasureValue(Di(a.value),r);const{value:l,format:c}=i.getPivotHeaderValueAndFormat(r);return{value:l,format:a&&"measure"!==a.field&&"false"!==a.value?c:void 0}}},iv={description:vo("Get a pivot table."),args:[nh("pivot_id (string)",vo("ID of the pivot.")),nh("row_count (number, optional)",vo("number of rows")),nh("include_total (boolean, default=TRUE)",vo("Whether to include total/sub-totals or not.")),nh("include_column_titles (boolean, default=TRUE)",vo("Whether to include the column titles or not.")),nh("column_count (number, optional)",vo("number of columns"))],compute:function(e,t={value:1e4},o={value:!0},s={value:!0},i={value:Number.MAX_VALUE}){const n=Di(e),r=wi(t,this.locale);if(r<0)throw new di(vo("The number of rows must be positive."));const a=wi(i,this.locale);if(a<0)throw new di(vo("The number of columns must be positive."));const l=Mi(s),c=Mi(o),h=Vf(n,this.getters),d=this.getters.getPivot(h),u=this.getters.getPivotCoreDefinition(h);Hf(this,u,u.measures),d.init({reload:d.needsReevaluation});const g=d.assertIsValid({throwOnError:!1});if(g)return g;const p=d.getTableStructure(),m=p.getPivotCells(c,l),f=l?p.columns.length:0,v=this.getters.getPivotDisplayName(h),b=Math.min(f+r,m[0].length);if(0===b)return[[{value:v}]];const S=Math.min(1+a,m.length),y=[];for(const e of Be(0,S)){y[e]=[];for(const t of Be(0,b)){const o=m[e][t];switch(o.type){case"EMPTY":y[e].push({value:""});break;case"HEADER":const t=d.getPivotHeaderValueAndFormat(o.domain);y[e].push(zl(d,o.domain,t));break;case"MEASURE_HEADER":y[e].push(d.getPivotMeasureValue(o.measure,o.domain));break;case"VALUE":y[e].push(d.getPivotCellValueAndFormat(o.measure,o.domain))}}}return l&&(y[0][0]={value:v}),y}},nv={description:vo("Returns a range reference shifted by a specified number of rows and columns from a starting cell reference."),args:[nh("cell_reference (meta)",vo("The starting point from which to count the offset rows and columns.")),nh("offset_rows (number)",vo("The number of rows to offset by.")),nh("offset_columns (number)",vo("The number of columns to offset by.")),nh("height (number, default='height of cell_reference')",vo("The number of rows of the range to return starting at the offset target.")),nh("width (number, default='width of cell_reference')",vo("The number of columns of the range to return starting at the offset target."))],compute:function(e,t,o,s,i){if(yi(e?.value))return e;const n=e?.value;if(!n)throw new Error("In this context, the function OFFSET needs to have a cell or range in parameter.");const r=No(n);let a=r.bottom-r.top+1,l=r.right-r.left+1;if(s){const e=wi(s,this.locale);ch(vo("Height value is %(_height)s. It should be greater than or equal to 1.",{_height:e}),e),a=e}if(i){const e=wi(i,this.locale);ch(vo("Width value is %(_width)s. It should be greater than or equal to 1.",{_width:e}),e),l=e}const{sheetName:c}=Oo(n),h=c&&this.getters.getSheetIdByName(c)||this.getters.getActiveSheetId(),d=wi(t,this.locale),u=wi(o,this.locale),g=this.__originCellPosition;g&&this.updateDependencies?.(g);const p=r.left+u,m=r.top+d;if(p<0||m<0)return new gi(vo("OFFSET evaluates to an out of bounds range."));const f={left:p,top:m,right:p+l-1,bottom:m+a-1},v=this.getters.getRangeFromZone(this.__originSheetId,f);return v.invalidXc||v.invalidSheetName?new gi:(g&&this.addDependencies?.(g,[v]),$i(l,a,((e,t)=>this.getters.getEvaluatedCell({sheetId:h,col:p+e,row:m+t}))))}};var rv=Object.freeze({__proto__:null,ADDRESS:$f,COLUMN:Gf,COLUMNS:Wf,HLOOKUP:qf,INDEX:Zf,INDIRECT:jf,LOOKUP:Yf,MATCH:Xf,OFFSET:nv,PIVOT:iv,PIVOT_HEADER:sv,PIVOT_VALUE:ov,ROW:Kf,ROWS:Qf,VLOOKUP:Jf,XLOOKUP:tv});const av={description:vo("Sum of two numbers."),args:[nh("value1 (number)",vo("The first addend.")),nh("value2 (number)",vo("The second addend."))],compute:function(e,t){return{value:wi(e,this.locale)+wi(t,this.locale),format:e?.format||t?.format}}},lv={description:vo("Concatenation of two values."),args:[nh("value1 (string)",vo("The value to which value2 will be appended.")),nh("value2 (string)",vo("The value to append to value1."))],compute:function(e,t){return Di(e)+Di(t)},isExported:!0},cv={description:vo("One number divided by another."),args:[nh("dividend (number)",vo("The number to be divided.")),nh("divisor (number)",vo("The number to divide by."))],compute:function(e,t){const o=wi(t,this.locale);return bi((()=>0!==o),vo("The divisor must be different from zero."),ci.DivisionByZero),{value:wi(e,this.locale)/o,format:e?.format||t?.format}}};function hv(e){return void 0===e||null===e.value}const dv={number:0,string:"",boolean:!1},uv={description:vo("Equal."),args:[nh("value1 (string, number, boolean)",vo("The first value.")),nh("value2 (string, number, boolean)",vo("The value to test against value1 for equality."))],compute:function(e,t){let o=hv(e)?dv[typeof t?.value]:e?.value,s=hv(t)?dv[typeof e?.value]:t?.value;return"string"==typeof o&&(o=o.toUpperCase()),"string"==typeof s&&(s=s.toUpperCase()),o===s}};function gv(e,t,o){let s=hv(e)?dv[typeof t?.value]:e?.value,i=hv(t)?dv[typeof e?.value]:t?.value;if(yi(s))throw e;if(yi(i))throw t;"number"!=typeof s&&(s=Di(s).toUpperCase()),"number"!=typeof i&&(i=Di(i).toUpperCase());const n=typeof s,r=typeof i;return"string"===n&&"number"===r||("string"!==r||"number"!==n)&&o(s,i)}const pv={description:vo("Strictly greater than."),args:[nh("value1 (number, string, boolean)",vo("The value to test as being greater than value2.")),nh("value2 (number, string, boolean)",vo("The second value."))],compute:function(e,t){return gv(e,t,((e,t)=>e>t))}},mv={description:vo("Greater than or equal to."),args:[nh("value1 (number, string, boolean)",vo("The value to test as being greater than or equal to value2.")),nh("value2 (number, string, boolean)",vo("The second value."))],compute:function(e,t){return gv(e,t,((e,t)=>e>=t))}},fv={description:vo("Less than."),args:[nh("value1 (number, string, boolean)",vo("The value to test as being less than value2.")),nh("value2 (number, string, boolean)",vo("The second value."))],compute:function(e,t){return!mv.compute.bind(this)(e,t)}},vv={description:vo("Less than or equal to."),args:[nh("value1 (number, string, boolean)",vo("The value to test as being less than or equal to value2.")),nh("value2 (number, string, boolean)",vo("The second value."))],compute:function(e,t){return!pv.compute.bind(this)(e,t)}},bv={description:vo("Difference of two numbers."),args:[nh("value1 (number)",vo("The minuend, or number to be subtracted from.")),nh("value2 (number)",vo("The subtrahend, or number to subtract from value1."))],compute:function(e,t){return{value:wi(e,this.locale)-wi(t,this.locale),format:e?.format||t?.format}}},Sv={description:vo("Product of two numbers"),args:[nh("factor1 (number)",vo("The first multiplicand.")),nh("factor2 (number)",vo("The second multiplicand."))],compute:function(e,t){return{value:wi(e,this.locale)*wi(t,this.locale),format:e?.format||t?.format}}},yv={description:vo("Not equal."),args:[nh("value1 (string, number, boolean)",vo("The first value.")),nh("value2 (string, number, boolean)",vo("The value to test against value1 for inequality."))],compute:function(e,t){return!uv.compute.bind(this)(e,t)}},Cv={description:vo("A number raised to a power."),args:[nh("base (number)",vo("The number to raise to the exponent power.")),nh("exponent (number)",vo("The exponent to raise base to."))],compute:function(e,t){return Rd.compute.bind(this)(e,t)}},wv={description:vo("A number with the sign reversed."),args:[nh("value (number)",vo("The number to have its sign reversed. Equivalently, the number to multiply by -1."))],compute:function(e){return{value:-wi(e,this.locale),format:e?.format}}},Ev={description:vo("Value interpreted as a percentage."),args:[nh("percentage (number)",vo("The value to interpret as a percentage."))],compute:function(e){return wi(e,this.locale)/100}},xv={description:vo("A specified number, unchanged."),args:[nh("value (any)",vo("The number to return."))],compute:function(e={value:null}){return e}};var Iv=Object.freeze({__proto__:null,ADD:av,CONCAT:lv,DIVIDE:cv,EQ:uv,GT:pv,GTE:mv,LT:fv,LTE:vv,MINUS:bv,MULTIPLY:Sv,NE:yv,POW:Cv,UMINUS:wv,UNARY_PERCENT:Ev,UPLUS:xv});const Rv=e=>({transform:t=>t*e,inverseTransform:t=>t/e}),Tv={transform:e=>e,inverseTransform:e=>e},Av=1e-10,_v=.0254,Dv=_v/72,Ov=.3048,Fv=.9144,Mv=1609.34,Nv=1852,Pv=946073047258e4,kv={g:{...Tv,category:"weight"},u:{...Rv(166053e-29),category:"weight"},grain:{...Rv(.0647989),category:"weight"},ozm:{...Rv(28.3495),category:"weight"},lbm:{...Rv(453.592),category:"weight"},stone:{...Rv(6350.29),category:"weight"},sg:{...Rv(14593.90294),category:"weight"},cwt:{...Rv(45359.237),category:"weight"},uk_cwt:{...Rv(50802.3),category:"weight"},ton:{...Rv(907184.74),category:"weight"},uk_ton:{...Rv(1016046.9),category:"weight"},m:{...Tv,category:"distance"},km:{...Rv(1e3),category:"distance"},ang:{...Rv(Av),category:"distance"},Picapt:{...Rv(Dv),category:"distance"},pica:{...Rv(_v/6),category:"distance"},in:{...Rv(_v),category:"distance"},ft:{...Rv(Ov),category:"distance"},yd:{...Rv(Fv),category:"distance"},ell:{...Rv(1.143),category:"distance"},mi:{...Rv(Mv),category:"distance"},survey_mi:{...Rv(1609.34),category:"distance"},Nmi:{...Rv(Nv),category:"distance"},ly:{...Rv(Pv),category:"distance"},parsec:{...Rv(0x6da012f95c9fd0),category:"distance"},sec:{...Tv,category:"time"},min:{...Rv(60),category:"time"},hr:{...Rv(3600),category:"time"},day:{...Rv(86400),category:"time"},yr:{...Rv(31556952),category:"time"},Pa:{...Tv,category:"pressure"},bar:{...Rv(1e5),category:"pressure"},mmHg:{...Rv(133.322),category:"pressure"},Torr:{...Rv(133.322),category:"pressure"},psi:{...Rv(6894.76),category:"pressure"},atm:{...Rv(101325),category:"pressure"},N:{...Tv,category:"force"},dyn:{...Rv(1e-5),category:"force"},pond:{...Rv(.00980665),category:"force"},lbf:{...Rv(4.44822),category:"force"},J:{...Tv,category:"energy"},eV:{...Rv(160218e-24),category:"energy"},e:{...Rv(1e-7),category:"energy"},flb:{...Rv(1.3558179483),category:"energy"},c:{...Rv(4.184),category:"energy"},cal:{...Rv(4.1868),category:"energy"},BTU:{...Rv(1055.06),category:"energy"},Wh:{...Rv(3600),category:"energy"},HPh:{...Rv(2684520),category:"energy"},W:{...Tv,category:"power"},PS:{...Rv(735.499),category:"power"},HP:{...Rv(745.7),category:"power"},T:{...Tv,category:"magnetism"},ga:{...Rv(1e-4),category:"magnetism"},K:{...Tv,category:"temperature"},C:{transform:e=>e+273.15,inverseTransform:e=>e-273.15,category:"temperature"},F:{transform:e=>5*(e-32)/9+273.15,inverseTransform:e=>9*(e-273.15)/5+32,category:"temperature"},Rank:{...Rv(5/9),category:"temperature"},Reau:{transform:e=>1.25*e+273.15,inverseTransform:e=>(e-273.15)/1.25,category:"temperature"},"m^3":{...Tv,category:"volume",order:3},"ang^3":{...Rv(Math.pow(Av,3)),category:"volume",order:3},"Picapt^3":{...Rv(Math.pow(Dv,3)),category:"volume",order:3},tsp:{...Rv(492892e-11),category:"volume"},tspm:{...Rv(5e-6),category:"volume"},tbs:{...Rv(14786764825785619e-21),category:"volume"},"in^3":{...Rv(Math.pow(_v,3)),category:"volume",order:3},oz:{...Rv(295735295625e-16),category:"volume"},cup:{...Rv(237e-6),category:"volume"},pt:{...Rv(.0004731765),category:"volume"},uk_pt:{...Rv(568261e-9),category:"volume"},qt:{...Rv(.0009463529),category:"volume"},l:{...Rv(.001),category:"volume"},uk_qt:{...Rv(.0011365225),category:"volume"},gal:{...Rv(.0037854118),category:"volume"},uk_gal:{...Rv(.00454609),category:"volume"},"ft^3":{...Rv(Math.pow(Ov,3)),category:"volume",order:3},bushel:{...Rv(.0352390704),category:"volume"},barrel:{...Rv(.158987295),category:"volume"},"yd^3":{...Rv(Math.pow(Fv,3)),category:"volume",order:3},MTON:{...Rv(1.13267386368),category:"volume"},GRT:{...Rv(2.83168),category:"volume"},"mi^3":{...Rv(Math.pow(Mv,3)),category:"volume",order:3},"Nmi^3":{...Rv(Math.pow(Nv,3)),category:"volume",order:3},"ly^3":{...Rv(Math.pow(Pv,3)),category:"volume",order:3},"m^2":{...Tv,category:"area",order:2},"ang^2":{...Rv(Math.pow(Av,2)),category:"area",order:2},"Picapt^2":{...Rv(Math.pow(Dv,2)),category:"area",order:2},"in^2":{...Rv(Math.pow(_v,2)),category:"area",order:2},"ft^2":{...Rv(Math.pow(Ov,2)),category:"area",order:2},"yd^2":{...Rv(Math.pow(Fv,2)),category:"area",order:2},ar:{...Rv(100),category:"area"},Morgen:{...Rv(2500),category:"area"},uk_acre:{...Rv(4046.8564224),category:"area"},us_acre:{...Rv(4046.8726098743),category:"area"},ha:{...Rv(1e4),category:"area"},"mi^2":{...Rv(Math.pow(Mv,2)),category:"area",order:2},"Nmi^2":{...Rv(Math.pow(Nv,2)),category:"area",order:2},"ly^2":{...Rv(Math.pow(Pv,2)),category:"area",order:2},bit:{...Tv,category:"information"},byte:{...Rv(8),category:"information"},"m/s":{...Tv,category:"speed"},"m/hr":{...Rv(1/3600),category:"speed"},"km/hr":{...Rv(1/3.6),category:"speed"},mph:{...Rv(.44704),category:"speed"},kn:{...Rv(.5144444444),category:"speed"},admkn:{...Rv(.5147733333),category:"speed"}},Lv={shweight:"cwt",lcwt:"uk_cwt",hweight:"uk_cwt",LTON:"uk_ton",brton:"uk_ton",pc:"parsec",Pica:"Picapt",d:"day",mn:"min",s:"sec",p:"Pa",at:"atm",dy:"dyn",ev:"eV",hh:"HPh",wh:"Wh",btu:"BTU",h:"HP",cel:"C",fah:"F",kel:"K",us_pt:"pt",L:"l",lt:"l",ang3:"ang^3",ft3:"ft^3",in3:"in^3",ly3:"ly^3",m3:"m^3",mi3:"mi^3",yd3:"yd^3",Nmi3:"Nmi^3",Picapt3:"Picapt^3","Pica^3":"Picapt^3",Pica3:"Picapt^3",regton:"GRT",ang2:"ang^2",ft2:"ft^2",in2:"in^2",ly2:"ly^2",m2:"m^2",mi2:"mi^2",Nmi2:"Nmi^2",Picapt2:"Picapt^2","Pica^2":"Picapt^2",Pica2:"Picapt^2",yd2:"yd^2","m/h":"m/hr","m/sec":"m/s"},Vv={"":1,Y:1e24,Z:1e21,E:1e18,P:1e15,T:1e12,G:1e9,M:1e6,k:1e3,h:100,da:10,e:10,d:.1,c:.01,m:.001,u:1e-6,n:1e-9,p:1e-12,f:1e-15,a:1e-18,z:1e-21,y:1e-21,Yi:Math.pow(2,80),Zi:Math.pow(2,70),Ei:Math.pow(2,60),Pi:Math.pow(2,50),Ti:Math.pow(2,40),Gi:Math.pow(2,30),Mi:Math.pow(2,20),ki:Math.pow(2,10)},Uv={weight:vo("Weight"),distance:vo("Distance"),time:vo("Time"),pressure:vo("Pressure"),force:vo("Force"),energy:vo("Energy"),power:vo("Power"),magnetism:vo("Magnetism"),temperature:vo("Temperature"),volume:vo("Volume"),area:vo("Area"),information:vo("Information"),speed:vo("Speed")};function Hv(e){return Uv[e]??""}function Bv(e){for(const[t,o]of Object.entries(Vv)){if(t&&!e.startsWith(t))continue;const s=e.slice(t.length);let i=kv[s];if(!i&&Lv[s]&&(i=kv[Lv[s]]),i)return{...i,factor:i.order?Math.pow(o,i.order):o}}}const zv={description:vo("Converts a numeric value to a different unit of measure."),args:[nh("value (number)",vo("the numeric value in start_unit to convert to end_unit")),nh("start_unit (string)",vo("The starting unit, the unit currently assigned to value")),nh("end_unit (string)",vo("The unit of measure into which to convert value"))],compute:function(e,t,o){const s=wi(e,this.locale),i=Di(t),n=Di(o),r=Bv(i),a=Bv(n);return r?a?r.category!==a.category?{value:ci.GenericError,message:vo("Incompatible units of measure ('%s' vs '%s')",Hv(r.category),Hv(a.category))}:{value:a.inverseTransform(r.factor*r.transform(s))/a.factor,format:e?.format}:{value:ci.GenericError,message:vo("Invalid units of measure ('%s')",n)}:{value:ci.GenericError,message:vo("Invalid units of measure ('%s')",i)}},isExported:!0};var $v=Object.freeze({__proto__:null,CONVERT:zv});const Gv=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,Wv={description:vo("Gets character associated with number."),args:[nh("table_number (number)",vo("The number of the character to look up from the current Unicode table in decimal format."))],compute:function(e){const t=Math.trunc(wi(e,this.locale));return bi((()=>t>=1),vo("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},qv={description:vo("Remove non-printable characters from a piece of text."),args:[nh("text (string)",vo("The text whose non-printable characters are to be removed."))],compute:function(e){const t=Di(e);let o="";for(const e of t)e&&e.charCodeAt(0)>31&&(o+=e);return o},isExported:!0},Zv={description:vo("Appends strings to one another."),args:[nh("string1 (string, range<string>)",vo("The initial string.")),nh("string2 (string, range<string>, repeating)",vo("More strings to append in sequence."))],compute:function(...e){return Hi(e,((e,t)=>e+Di(t)),"")},isExported:!0},jv={description:vo("Tests whether two strings are identical."),args:[nh("string1 (string)",vo("The first string to compare.")),nh("string2 (string)",vo("The second string to compare."))],compute:function(e,t){return Di(e)===Di(t)},isExported:!0},Yv={description:vo("First position of string found in text, case-sensitive."),args:[nh("search_for (string)",vo("The string to look for within text_to_search.")),nh("text_to_search (string)",vo("The text to search for the first occurrence of search_for.")),nh("starting_at (number, default=1)",vo("The character within text_to_search at which to start the search."))],compute:function(e,t,o={value:1}){const s=Di(e),i=Di(t),n=wi(o,this.locale);bi((()=>""!==i),vo("The text_to_search must be non-empty.")),bi((()=>n>=1),vo("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const r=i.indexOf(s,n-1);return bi((()=>r>=0),vo("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",s.toString(),i)),r+1},isExported:!0},Xv={description:vo("Concatenates elements of arrays with delimiter."),args:[nh("delimiter (string)",vo("The character or string to place between each concatenated value.")),nh("value_or_array1 (string, range<string>)",vo("The value or values to be appended using delimiter.")),nh("value_or_array2 (string, range<string>, repeating)",vo("More values to be appended using delimiter."))],compute:function(e,...t){const o=Di(e);return Hi(t,((e,t)=>(e?e+o:"")+Di(t)),"")}},Kv={description:vo("Substring from beginning of specified string."),args:[nh("text (string)",vo("The string from which the left portion will be returned.")),nh("number_of_characters (number, optional)",vo("The number of characters to return from the left side of string."))],compute:function(e,...t){const o=t.length?wi(t[0],this.locale):1;return bi((()=>o>=0),vo("The number_of_characters (%s) must be positive or null.",o.toString())),Di(e).substring(0,o)},isExported:!0},Qv={description:vo("Length of a string."),args:[nh("text (string)",vo("The string whose length will be returned."))],compute:function(e){return Di(e).length},isExported:!0},Jv={description:vo("Converts a specified string to lowercase."),args:[nh("text (string)",vo("The string to convert to lowercase."))],compute:function(e){return Di(e).toLowerCase()},isExported:!0},eb={description:vo("A segment of a string."),args:[nh("text (string)",vo("The string to extract a segment from.")),nh("starting_at (number)",vo("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),nh("extract_length (number)",vo("The length of the segment to extract."))],compute:function(e,t,o){const s=Di(e),i=wi(t,this.locale),n=wi(o,this.locale);return bi((()=>i>=1),vo("The starting_at argument (%s) must be positive greater than one.",i.toString())),bi((()=>n>=0),vo("The extract_length argument (%s) must be positive or null.",n.toString())),s.slice(i-1,i+n-1)},isExported:!0},tb={description:vo("Capitalizes each word in a specified string."),args:[nh("text_to_capitalize (string)",vo("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase."))],compute:function(e){return Di(e).replace(Gv,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},ob={description:vo("Replaces part of a text string with different text."),args:[nh("text (string)",vo("The text, a part of which will be replaced.")),nh("position (number)",vo("The position where the replacement will begin (starting from 1).")),nh("length (number)",vo("The number of characters in the text to be replaced.")),nh("new_text (string)",vo("The text which will be inserted into the original text."))],compute:function(e,t,o,s){const i=wi(t,this.locale);bi((()=>i>=1),vo("The position (%s) must be greater than or equal to 1.",i.toString()));const n=Di(e),r=wi(o,this.locale),a=Di(s);return n.substring(0,i-1)+a+n.substring(i-1+r)},isExported:!0},sb={description:vo("A substring from the end of a specified string."),args:[nh("text (string)",vo("The string from which the right portion will be returned.")),nh("number_of_characters (number, optional)",vo("The number of characters to return from the right side of string."))],compute:function(e,...t){const o=t.length?wi(t[0],this.locale):1;bi((()=>o>=0),vo("The number_of_characters (%s) must be positive or null.",o.toString()));const s=Di(e),i=s.length;return s.substring(i-o,i)},isExported:!0},ib={description:vo("First position of string found in text, ignoring case."),args:[nh("search_for (string)",vo("The string to look for within text_to_search.")),nh("text_to_search (string)",vo("The text to search for the first occurrence of search_for.")),nh("starting_at (number, default=1)",vo("The character within text_to_search at which to start the search."))],compute:function(e,t,o={value:1}){const s=Di(e).toLowerCase(),i=Di(t).toLowerCase(),n=wi(o,this.locale);bi((()=>""!==i),vo("The text_to_search must be non-empty.")),bi((()=>n>=1),vo("The starting_at (%s) must be greater than or equal to 1.",n.toString()));const r=i.indexOf(s,n-1);return bi((()=>r>=0),vo("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",s,i)),r+1},isExported:!0},nb={description:vo("Split text by specific character delimiter(s)."),args:[nh("text (string)",vo("The text to divide.")),nh("delimiter (string)",vo("The character or characters to use to split text.")),nh("split_by_each (boolean, default=true})",vo("Whether or not to divide text around each character contained in delimiter.")),nh("remove_empty_text (boolean, default=true)",vo("Whether or not to remove empty text messages from the split results. The default behavior is to treat consecutive delimiters as one (if TRUE). If FALSE, empty cells values are added between consecutive delimiters."))],compute:function(e,t,o={value:true},s={value:true}){const i=Di(e),n=Ne(Di(t)),r=Mi(o),a=Mi(s);bi((()=>n.length>0),vo("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))),Wi([c])},isExported:!0},rb={description:vo("Replaces existing text with new text in a string."),args:[nh("text_to_search (string)",vo("The text within which to search and replace.")),nh("search_for (string)",vo("The string to search for within text_to_search.")),nh("replace_with (string)",vo("The string that will replace search_for.")),nh("occurrence_number (number, optional)",vo("The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced."))],compute:function(e,t,o,s){const i=wi(s,this.locale);bi((()=>i>=0),vo("The occurrenceNumber (%s) must be positive or null.",i.toString()));const n=Di(e),r=Di(t);if(""===r)return n;const a=Di(o),l=new RegExp(Ne(r),"g");if(0===i)return n.replace(l,a);let c=0;return n.replace(l,(e=>++c===i?a:e))},isExported:!0},ab={description:vo("Combines text from multiple strings and/or arrays."),args:[nh("delimiter (string)",vo(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")),nh("ignore_empty (boolean)",vo("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")),nh("text1 (string, range<string>)",vo("Any text item. This could be a string, or an array of strings in a range.")),nh("text2 (string, range<string>, repeating)",vo("Additional text item(s)."))],compute:function(e,t,...o){const s=Di(e),i=Mi(t);let n=0;return Hi(o,((e,t)=>i&&""===Di(t)?e:(n++?e+s:"")+Di(t)),"")},isExported:!0},lb={description:vo("Removes space characters."),args:[nh("text (string)",vo("The text or reference to a cell containing text to be trimmed."))],compute:function(e){return Ct(Di(e))},isExported:!0},cb={description:vo("Converts a specified string to uppercase."),args:[nh("text (string)",vo("The string to convert to uppercase."))],compute:function(e){return Di(e).toUpperCase()},isExported:!0},hb={description:vo("Converts a number to text according to a specified format."),args:[nh("number (number)",vo("The number, date or time to format.")),nh("format (string)",vo("The pattern by which to format the number, enclosed in quotation marks."))],compute:function(e,t){return kn(wi(e,this.locale),{format:Di(t),locale:this.locale})},isExported:!0},db={description:vo("Converts a string to a numeric value."),args:[nh("value (number)",vo("the string to be converted"))],compute:function(e){return wi(e,this.locale)},isExported:!0};var ub=Object.freeze({__proto__:null,CHAR:Wv,CLEAN:qv,CONCATENATE:Zv,EXACT:jv,FIND:Yv,JOIN:Xv,LEFT:Kv,LEN:Qv,LOWER:Jv,MID:eb,PROPER:tb,REPLACE:ob,RIGHT:sb,SEARCH:ib,SPLIT:nb,SUBSTITUTE:rb,TEXT:hb,TEXTJOIN:ab,TRIM:lb,UPPER:cb,VALUE:db});const gb={description:vo("Creates a hyperlink in a cell."),args:[nh("url (string)",vo("The full URL of the link enclosed in quotation marks.")),nh("link_label (string, optional)",vo("The text to display in the cell, enclosed in quotation marks."))],compute:function(e,t){const o=Di(e).trim(),s=Di(t)||o;return""===o?s:Ye(s,o)},isExported:!0};var pb=Object.freeze({__proto__:null,HYPERLINK:gb});const mb=[{name:vo("Array"),functions:Ph},{name:vo("Database"),functions:vg},{name:vo("Date"),functions:Qg},{name:vo("Filter"),functions:cp},{name:vo("Financial"),functions:Um},{name:vo("Info"),functions:Rf},{name:vo("Lookup"),functions:rv},{name:vo("Logical"),functions:Lf},{name:vo("Math"),functions:jd},{name:vo("Misc"),functions:Lh},{name:vo("Operator"),functions:Iv},{name:vo("Statistical"),functions:og},{name:vo("Text"),functions:ub},{name:vo("Engineering"),functions:ep},{name:vo("Web"),functions:pb},{name:vo("Parser"),functions:$v}],fb=/^[A-Z0-9\_\.]+$/;const vb=new class extends n{mapping={};add(e,t){if(e=e.toUpperCase(),!fb.test(e))throw new Error(vo("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const o=rh(t);return function(e){let t=!1,o=!1,s=!1;for(let i of e){if(i.type.includes("META")&&i.type.length>1)throw new Error(vo("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(vo("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(vo("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=i.repeating,o=i.optional,s=i.default}}(o.args),this.mapping[e]=function(e,t){function o(...o){let i,n=1,r=1,a=1/0,l=1/0;for(let s=0;s<o.length;s++){const c=e.args[e.getArgToFocus(s+1)-1],h=o[s];if(ni(h)&&!c.acceptMatrix){const e=h.length,t=h[0].length;1!==e||1!==t?(i??=new Array(o.length),1!==e&&1!==t?(i[s]="matrix",n=Math.max(n,e),r=Math.max(r,t),a=Math.min(a,e),l=Math.min(l,t)):1!==e?(i[s]="horizontal",n=Math.max(n,e),a=Math.min(a,e)):1!==t&&(i[s]="vertical",r=Math.max(r,t),l=Math.min(l,t))):o[s]=h[0][0]}if(!ni(h)&&c.acceptMatrixOnly)throw new ui(vo("Function %s expects the parameter '%s' to be reference to a cell or range.",t,(s+1).toString()))}if(1===n&&1===r)return s.apply(this,o);const c=(e,t)=>o.map(((o,s)=>{switch(i?.[s]){case"matrix":return o[e][t];case"horizontal":return o[e][0];case"vertical":return o[0][t];case void 0:return o}}));return $i(n,r,((e,t)=>{if(e>a-1||t>l-1)return bb;const o=s.apply(this,c(e,t));return ni(o)?o[0][0]:o}))}function s(...o){for(let t=0;t<o.length;t++){const s=o[t];if(!e.args[e.getArgToFocus(t+1)-1].acceptErrors&&!ni(s)&&yi(s?.value))return s}try{return i.apply(this,o)}catch(e){return Sb(e,t)}}function i(...o){const s=e.compute.apply(this,o);return ni(s)?"object"==typeof s[0][0]&&null!==s[0][0]&&"value"in s[0][0]?(function(e,t){const o=e.length,s=e[0]?.length??0;for(let i=0;i<o;i++)for(let o=0;o<s;o++)t(e[i][o])}(s,(e=>yb(e,t))),s):Gi(s,(e=>({value:e}))):"object"==typeof s&&null!==s&&"value"in s?(yb(s,t),s):{value:s}}return o}(o,e),super.add(e,o),this}};for(let e of mb){const t=e.functions;for(let o in t){const s=t[o];s.category=s.category||e.name,o=o.replace(/_/g,"."),vb.add(o,{isExported:!1,...s})}}const bb=new pi(vo("Array arguments to [[FUNCTION_NAME]] are of different size."));function Sb(e,t){return o=e,void 0!==o?.value&&"string"==typeof o.value&&yi(e.value)?(wb(e)&&yb(e,t),e):(console.error(e),new di(Cb+(wb(e)?" "+e.message:"")));var o}function yb(e,t){e.message?.includes("[[FUNCTION_NAME]]")&&(e.message=e.message.replace("[[FUNCTION_NAME]]",t))}const Cb=vo("An unexpected error occurred. Submit a support ticket at odoo.com/help.");function wb(e){return void 0!==e?.message&&"string"==typeof e.message}th.add("functions",{sequence:100,autoSelectFirstProposal:!0,maxDisplayedProposals:10,getProposals(e){if("SYMBOL"!==e.type)return[];const t=e.value;if(!this.composer.currentContent.startsWith("="))return[];const o=Object.entries(vb.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:o}])=>({text:e,description:o,htmlContent:oh(t,e,I,"o-semi-bold")}))).sort(((e,t)=>e.text.length-t.text.length||e.text.localeCompare(t.text)));return o},selectProposal(e,t){let o=e.end,s=e.end;["SYMBOL","FUNCTION"].includes(e.type)&&(o=e.start);const i=this.composer.currentTokens;t+="(";const n=i.map((e=>e.start)).indexOf(e.start);if(n+1<i.length){const e=i[n+1];"LEFT_PAREN"===e?.type&&s++}this.composer.changeComposerCursorSelection(o,s),this.composer.replaceComposerCursorSelection(t)}});class Eb{mutators=["setFocusableElement"];focusableElement=void 0;setFocusableElement(e){this.focusableElement=e}}const xb={};let Ib=0;function Rb(e,...t){const o="__sheet__"+Ib++;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),xb[e]=o}(o,String.raw(e,...t)),function(e){const t=xb[e];t.setAttribute("component",e),document.head.appendChild(t)}(o),o}function Tb({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function Ab(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 _b(e){let t="";for(const o in e)e[o]&&(t+=`${o}:${e[o]}; `);return t}const Db=/Mac/i,Ob=["Shift","Control","Alt","Meta"];function Fb(e,t){return!!e&&(!!t.target&&e.contains(t.target))}function Mb(){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 Nb(e){const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}function*Pb(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*Pb(t)}const kb=/^[a-zA-Z]$/;function Lb(e,t="key"){let o="";Ob.includes(e.key)||(Ub(e)&&(o+="Ctrl+"),e.altKey&&(o+="Alt+"),e.shiftKey&&(o+="Shift+"));const s="key"===t?e.key:e.code;return o+=kb.test(s)?s.toUpperCase():s,o}function Vb(){return Boolean(Db.test(navigator.userAgent))}function Ub(e){return Vb()?e.metaKey:e.ctrlKey}function Hb(){const e=t.useState({x:0,y:0,width:0,height:0});let o=null;function s(){if(o||(o=document.querySelector(".o-spreadsheet")),o){const{top:t,left:s,width:i,height:n}=o.getBoundingClientRect();e.x=s,e.y=t,e.width=i,e.height=n}}return t.onMounted(s),t.onPatched(s),e}function Bb(e){const o=t.useState({x:0,y:0,width:0,height:0});function s(){const t=e.el;if(null===t)return;const{top:s,left:i,width:n,height:r}=t.getBoundingClientRect();o.x=i,o.y=s,o.width=n,o.height=r}return t.onMounted(s),t.onPatched(s),o}const zb={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"};function $b(e,t){const o=zb[e.key];e.shiftKey?t.resizeAnchorZone(o,Ub(e)?"end":1):t.moveAnchorCell(o,Ub(e)?"end":1)}Rb`
2
2
  .o-autocomplete-dropdown {
3
3
  pointer-events: auto;
4
4
  cursor: pointer;
@@ -933,7 +933,7 @@
933
933
  outline: ${z} solid 1px;
934
934
  }
935
935
  }
936
- `;class r_ extends t.Component{static template="o-spreadsheet-IconPicker";static props={onIconPicked:Function};icons=Ey;iconSets=xy;onIconClick(e){e&&this.props.onIconPicked(e)}}function a_(){let e;const o=document.body.style.cursor;let s=[];const i=()=>{e=void 0,document.body.style.cursor=o,s.forEach((e=>e())),s=[]};t.onWillUnmount((()=>{i()}));const n=t.useState({itemsStyle:{},draggedItemId:void 0,start:(t,r)=>{n.cancel=()=>{n.draggedItemId=void 0,n.itemsStyle={},document.body.style.cursor=o,r.onCancel?.(),i()};document.body.style.cursor="move",n.draggedItemId=r.draggedItemId;const a="horizontal"===t?new d_(r.containerEl):new h_(r.containerEl);e=new l_({...r,container:a,onChange:()=>{document.body.style.cursor="move",e&&(Object.assign(n.itemsStyle,e.getItemStyles()),r.onChange?.())},onDragEnd:(e,t)=>{n.draggedItemId=void 0,n.itemsStyle={},document.body.style.cursor=o,r.onDragEnd?.(e,t),i()},onCancel:n.cancel});const l=MA(e.onMouseMove.bind(e),e.onMouseUp.bind(e));s.push(l);const c=e.onScroll.bind(e);r.containerEl.addEventListener("scroll",c),s.push((()=>r.containerEl.removeEventListener("scroll",c))),s.push(e.destroy.bind(e))},cancel:()=>{}});return n}class l_{draggedItemId;items;container;initialMousePosition;currentMousePosition;initialScroll;minPosition;maxPosition;edgeScrollIntervalId;onChange;onCancel;onDragEnd;deadZone;constructor(e){this.items=e.items.map((e=>({...e,positionAtStart:e.position}))),this.draggedItemId=e.draggedItemId,this.container=e.container,this.onChange=e.onChange,this.onCancel=e.onCancel,this.onDragEnd=e.onDragEnd,this.initialMousePosition=e.initialMousePosition,this.currentMousePosition=e.initialMousePosition,this.initialScroll=this.container.scroll,this.minPosition=this.items[0].position,this.maxPosition=this.items[this.items.length-1].position+this.items[this.items.length-1].size}getItemStyles(){const e={};for(let t of this.items)e[t.id]=this.getItemStyle(t.id);return e}getItemStyle(e){const t=this.container.cssPositionProperty,o={position:"relative"};return o[t]=(this.getItemsPositions()[e]||0)+"px",o.transition=`${t} 0.5s`,o["pointer-events"]="none",this.draggedItemId===e&&(o.transition=`${t} 0s`,o["z-index"]="1000"),_b(o)}onScroll(){this.moveDraggedItemToPosition(this.currentMousePosition+this.scrollOffset)}onMouseMove(e){if(e.button>1)return void this.onCancel();const t=this.container.getMousePosition(e);this.currentMousePosition=t,t<this.container.start||t>this.container.end?this.startEdgeScroll(t<this.container.start?-1:1):(this.stopEdgeScroll(),this.moveDraggedItemToPosition(t+this.scrollOffset))}moveDraggedItemToPosition(e){const t=this.getHoveredItemIndex(e,this.items),o=this.items.findIndex((e=>e.id===this.draggedItemId)),s=this.items[o];if(this.deadZone&&this.isInZone(e,this.deadZone))return void this.onChange(this.getItemsPositions());if(this.isInZone(e,{start:s.position,end:s.position+s.size})&&(this.deadZone=void 0),o===t)return void this.onChange(this.getItemsPositions());const i=Math.min(o,t),n=Math.max(o,t),r=Math.sign(t-o);let a=0;for(let e=i;e<=n;e++)e!==o&&(this.items[e].position-=r*s.size,a+=this.items[e].size);s.position+=r*a,this.items.sort(((e,t)=>e.position-t.position)),this.deadZone=r>0?{start:e,end:s.position}:{start:s.position+s.size,end:e},this.onChange(this.getItemsPositions())}onMouseUp(e){0!==e.button&&this.onCancel(),e.stopPropagation(),e.preventDefault();const t=this.items.findIndex((e=>e.id===this.draggedItemId));return this.onDragEnd(this.draggedItemId,t),this.stopEdgeScroll(),!1}startEdgeScroll(e){this.edgeScrollIntervalId||(this.edgeScrollIntervalId=window.setInterval((()=>{const t=3*e;let o=this.currentMousePosition+t;o<Math.min(this.container.start,this.minPosition)?o=Math.min(this.container.start,this.minPosition):o>Math.max(this.container.end,this.maxPosition)&&(o=Math.max(this.container.end,this.maxPosition)),this.container.scroll+=t}),5))}stopEdgeScroll(){window.clearInterval(this.edgeScrollIntervalId),this.edgeScrollIntervalId=void 0}getHoveredItemIndex(e,t){return e<=this.minPosition?0:e>=this.maxPosition?t.length-1:t.findIndex((t=>t.position+t.size>=e))}getItemsPositions(){const e={};for(let t of this.items){if(t.id!==this.draggedItemId){e[t.id]=t.position-t.positionAtStart;continue}let o=this.currentMousePosition-this.initialMousePosition+this.scrollOffset;o=Math.max(this.minPosition-t.positionAtStart,o),o=Math.min(this.maxPosition-t.positionAtStart-t.size,o),e[t.id]=o}return e}isInZone(e,t){return e>=t.start&&e<=t.end}get scrollOffset(){return this.container.scroll-this.initialScroll}destroy(){this.stopEdgeScroll()}}class c_{el;constructor(e){this.el=e}get containerRect(){return this.el.getBoundingClientRect()}}class h_ extends c_{get start(){return this.containerRect.top}get end(){return this.containerRect.bottom}get cssPositionProperty(){return"top"}get scroll(){return this.el.scrollTop}set scroll(e){this.el.scrollTop=e}getMousePosition(e){return e.clientY}}class d_ extends c_{get start(){return this.containerRect.left}get end(){return this.containerRect.right}get cssPositionProperty(){return"left"}get scroll(){return this.el.scrollLeft}set scroll(e){this.el.scrollLeft=e}getMousePosition(e){return e.clientX}}function u_(e,...o){t.useEffect((e=>(e?.addEventListener(...o),()=>e?.removeEventListener(...o))),(()=>[e.el]))}function g_(e,o){const s=function(e){const o=t.useState({hovered:!1});return u_(e,"mouseenter",(()=>o.hovered=!0)),u_(e,"mouseleave",(()=>o.hovered=!1)),o}(e);p_({get highlights(){return s.hovered?o.highlights:[]}})}function p_(e){const o=ec(),s=oc(fA);t.onMounted((()=>{s.register(e)}));let i=e.highlights;t.useEffect((e=>{ct(e,i)||(i=e,o.trigger("store-updated"))}),(()=>[e.highlights]))}Rb`
936
+ `;class r_ extends t.Component{static template="o-spreadsheet-IconPicker";static props={onIconPicked:Function};icons=Ey;iconSets=xy;onIconClick(e){e&&this.props.onIconPicked(e)}}function a_(){let e;const o=document.body.style.cursor;let s=[];const i=()=>{e=void 0,document.body.style.cursor=o,s.forEach((e=>e())),s=[]};t.onWillUnmount((()=>{i()}));const n=t.useState({itemsStyle:{},draggedItemId:void 0,start:(t,r)=>{n.cancel=()=>{n.draggedItemId=void 0,n.itemsStyle={},document.body.style.cursor=o,r.onCancel?.(),i()};document.body.style.cursor="move",n.draggedItemId=r.draggedItemId;const a="horizontal"===t?new d_(r.scrollableContainerEl):new h_(r.scrollableContainerEl);e=new l_({...r,container:a,onChange:()=>{document.body.style.cursor="move",e&&(Object.assign(n.itemsStyle,e.getItemStyles()),r.onChange?.())},onDragEnd:(e,t)=>{n.draggedItemId=void 0,n.itemsStyle={},document.body.style.cursor=o,r.onDragEnd?.(e,t),i()},onCancel:n.cancel});const l=MA(e.onMouseMove.bind(e),e.onMouseUp.bind(e));s.push(l);const c=e.onScroll.bind(e);r.scrollableContainerEl.addEventListener("scroll",c),s.push((()=>r.scrollableContainerEl.removeEventListener("scroll",c))),s.push(e.destroy.bind(e))},cancel:()=>{}});return n}class l_{draggedItemId;items;container;initialMousePosition;currentMousePosition;initialScroll;minPosition;maxPosition;edgeScrollIntervalId;onChange;onCancel;onDragEnd;deadZone;constructor(e){this.items=e.items.map((e=>({...e,positionAtStart:e.position}))),this.draggedItemId=e.draggedItemId,this.container=e.container,this.onChange=e.onChange,this.onCancel=e.onCancel,this.onDragEnd=e.onDragEnd,this.initialMousePosition=e.initialMousePosition,this.currentMousePosition=e.initialMousePosition,this.initialScroll=this.container.scroll,this.minPosition=this.items[0].position,this.maxPosition=this.items[this.items.length-1].position+this.items[this.items.length-1].size}getItemStyles(){const e={};for(let t of this.items)e[t.id]=this.getItemStyle(t.id);return e}getItemStyle(e){const t=this.container.cssPositionProperty,o={position:"relative"};return o[t]=(this.getItemsPositions()[e]||0)+"px",o.transition=`${t} 0.5s`,o["pointer-events"]="none",this.draggedItemId===e&&(o.transition=`${t} 0s`,o["z-index"]="1000"),_b(o)}onScroll(){this.moveDraggedItemToPosition(this.currentMousePosition+this.scrollOffset)}onMouseMove(e){if(e.button>1)return void this.onCancel();const t=this.container.getMousePosition(e);this.currentMousePosition=t,t<this.container.start||t>this.container.end?this.startEdgeScroll(t<this.container.start?-1:1):(this.stopEdgeScroll(),this.moveDraggedItemToPosition(t+this.scrollOffset))}moveDraggedItemToPosition(e){const t=this.getHoveredItemIndex(e,this.items),o=this.items.findIndex((e=>e.id===this.draggedItemId)),s=this.items[o];if(this.deadZone&&this.isInZone(e,this.deadZone))return void this.onChange(this.getItemsPositions());if(this.isInZone(e,{start:s.position,end:s.position+s.size})&&(this.deadZone=void 0),o===t)return void this.onChange(this.getItemsPositions());const i=Math.min(o,t),n=Math.max(o,t),r=Math.sign(t-o);let a=0;for(let e=i;e<=n;e++)e!==o&&(this.items[e].position-=r*s.size,a+=this.items[e].size);s.position+=r*a,this.items.sort(((e,t)=>e.position-t.position)),this.deadZone=r>0?{start:e,end:s.position}:{start:s.position+s.size,end:e},this.onChange(this.getItemsPositions())}onMouseUp(e){0!==e.button&&this.onCancel(),e.stopPropagation(),e.preventDefault();const t=this.items.findIndex((e=>e.id===this.draggedItemId));return this.onDragEnd(this.draggedItemId,t),this.stopEdgeScroll(),!1}startEdgeScroll(e){this.edgeScrollIntervalId||(this.edgeScrollIntervalId=window.setInterval((()=>{const t=3*e;let o=this.currentMousePosition+t;o<Math.min(this.container.start,this.minPosition)?o=Math.min(this.container.start,this.minPosition):o>Math.max(this.container.end,this.maxPosition)&&(o=Math.max(this.container.end,this.maxPosition)),this.container.scroll+=t}),5))}stopEdgeScroll(){window.clearInterval(this.edgeScrollIntervalId),this.edgeScrollIntervalId=void 0}getHoveredItemIndex(e,t){return e<=this.minPosition?0:e>=this.maxPosition?t.length-1:t.findIndex((t=>t.position+t.size>=e))}getItemsPositions(){const e={};for(let t of this.items){if(t.id!==this.draggedItemId){e[t.id]=t.position-t.positionAtStart;continue}let o=this.currentMousePosition-this.initialMousePosition+this.scrollOffset;o=Math.max(this.minPosition-t.positionAtStart,o),o=Math.min(this.maxPosition-t.positionAtStart-t.size,o),e[t.id]=o}return e}isInZone(e,t){return e>=t.start&&e<=t.end}get scrollOffset(){return this.container.scroll-this.initialScroll}destroy(){this.stopEdgeScroll()}}class c_{el;constructor(e){this.el=e}get containerRect(){return this.el.getBoundingClientRect()}}class h_ extends c_{get start(){return this.containerRect.top}get end(){return this.containerRect.bottom}get cssPositionProperty(){return"top"}get scroll(){return this.el.scrollTop}set scroll(e){this.el.scrollTop=e}getMousePosition(e){return e.clientY}}class d_ extends c_{get start(){return this.containerRect.left}get end(){return this.containerRect.right}get cssPositionProperty(){return"left"}get scroll(){return this.el.scrollLeft}set scroll(e){this.el.scrollLeft=e}getMousePosition(e){return e.clientX}}function u_(e,...o){t.useEffect((e=>(e?.addEventListener(...o),()=>e?.removeEventListener(...o))),(()=>[e.el]))}function g_(e,o){const s=function(e){const o=t.useState({hovered:!1});return u_(e,"mouseenter",(()=>o.hovered=!0)),u_(e,"mouseleave",(()=>o.hovered=!1)),o}(e);p_({get highlights(){return s.hovered?o.highlights:[]}})}function p_(e){const o=ec(),s=oc(fA);t.onMounted((()=>{s.register(e)}));let i=e.highlights;t.useEffect((e=>{ct(e,i)||(i=e,o.trigger("store-updated"))}),(()=>[e.highlights]))}Rb`
937
937
  .o-cf-preview {
938
938
  &.o-cf-cursor-ptr {
939
939
  cursor: pointer;
@@ -1003,7 +1003,7 @@
1003
1003
  color: #6aa84f;
1004
1004
  }
1005
1005
  }
1006
- `;class m_ extends t.Component{static template="o-spreadsheet-ConditionalFormatPreview";icons=Ey;ref=t.useRef("cfPreview");setup(){g_(this.ref,this)}getPreviewImageStyle(){const e=this.props.conditionalFormat.rule;if("CellIsRule"===e.type)return _b(Ab(e.style));if("ColorScaleRule"===e.type){const t=Ft(e.minimum.color),o=e.midpoint?Ft(e.midpoint.color):null,s=Ft(e.maximum.color),i="background-image: linear-gradient(to right, ";return o?i+t+", "+o+", "+s+")":i+t+", "+s+")"}if("DataBarRule"===e.type){return`background-image: linear-gradient(to right, ${Ft(e.color)} 50%, white 50%)`}return""}getDescription(){const e=this.props.conditionalFormat;switch(e.rule.type){case"CellIsRule":const t=gE[e.rule.operator];return 1===e.rule.values.length?`${t} ${e.rule.values[0]}`:2===e.rule.values.length?vo("%s %s and %s",t,e.rule.values[0],e.rule.values[1]):t;case"ColorScaleRule":return uE.ColorScale;case"IconSetRule":return uE.IconSet;case"DataBarRule":return uE.DataBar}}deleteConditionalFormat(){this.env.model.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:this.props.conditionalFormat.id,sheetId:this.env.model.getters.getActiveSheetId()})}onMouseDown(e){this.props.onMouseDown(e)}get highlights(){const e=this.env.model.getters.getActiveSheetId();return this.props.conditionalFormat.ranges.map((t=>({sheetId:e,zone:this.env.model.getters.getRangeFromSheetXC(e,t).zone,color:a,fillAlpha:.06})))}}m_.props={conditionalFormat:Object,onPreviewClick:Function,onMouseDown:Function,class:String};class f_ extends t.Component{static template="o-spreadsheet-ConditionalFormatPreviewList";static props={conditionalFormats:Array,onPreviewClick:Function,onAddConditionalFormat:Function};static components={ConditionalFormatPreview:m_};icons=Ey;dragAndDrop=a_();cfListRef=t.useRef("cfList");setup(){t.onWillUpdateProps((e=>{ct(this.props.conditionalFormats,e.conditionalFormats)||this.dragAndDrop.cancel()}))}getPreviewDivStyle(e){return this.dragAndDrop.itemsStyle[e.id]||""}onPreviewMouseDown(e,t){if(0!==t.button)return;const o=Array.from(this.cfListRef.el.children).map((e=>Nb(e))),s=this.props.conditionalFormats.map(((e,t)=>({id:e.id,size:o[t].height,position:o[t].y})));this.dragAndDrop.start("vertical",{draggedItemId:e.id,initialMousePosition:t.clientY,items:s,containerEl:this.cfListRef.el,onDragEnd:(e,t)=>this.onDragEnd(e,t)})}onDragEnd(e,t){const o=this.props.conditionalFormats.findIndex((t=>t.id===e))-t;0!==o&&this.env.model.dispatch("CHANGE_CONDITIONAL_FORMAT_PRIORITY",{cfId:e,delta:o,sheetId:this.env.model.getters.getActiveSheetId()})}}Rb`
1006
+ `;class m_ extends t.Component{static template="o-spreadsheet-ConditionalFormatPreview";icons=Ey;ref=t.useRef("cfPreview");setup(){g_(this.ref,this)}getPreviewImageStyle(){const e=this.props.conditionalFormat.rule;if("CellIsRule"===e.type)return _b(Ab(e.style));if("ColorScaleRule"===e.type){const t=Ft(e.minimum.color),o=e.midpoint?Ft(e.midpoint.color):null,s=Ft(e.maximum.color),i="background-image: linear-gradient(to right, ";return o?i+t+", "+o+", "+s+")":i+t+", "+s+")"}if("DataBarRule"===e.type){return`background-image: linear-gradient(to right, ${Ft(e.color)} 50%, white 50%)`}return""}getDescription(){const e=this.props.conditionalFormat;switch(e.rule.type){case"CellIsRule":const t=gE[e.rule.operator];return 1===e.rule.values.length?`${t} ${e.rule.values[0]}`:2===e.rule.values.length?vo("%s %s and %s",t,e.rule.values[0],e.rule.values[1]):t;case"ColorScaleRule":return uE.ColorScale;case"IconSetRule":return uE.IconSet;case"DataBarRule":return uE.DataBar}}deleteConditionalFormat(){this.env.model.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:this.props.conditionalFormat.id,sheetId:this.env.model.getters.getActiveSheetId()})}onMouseDown(e){this.props.onMouseDown(e)}get highlights(){const e=this.env.model.getters.getActiveSheetId();return this.props.conditionalFormat.ranges.map((t=>({sheetId:e,zone:this.env.model.getters.getRangeFromSheetXC(e,t).zone,color:a,fillAlpha:.06})))}}m_.props={conditionalFormat:Object,onPreviewClick:Function,onMouseDown:Function,class:String};class f_ extends t.Component{static template="o-spreadsheet-ConditionalFormatPreviewList";static props={conditionalFormats:Array,onPreviewClick:Function,onAddConditionalFormat:Function};static components={ConditionalFormatPreview:m_};icons=Ey;dragAndDrop=a_();cfListRef=t.useRef("cfList");setup(){t.onWillUpdateProps((e=>{ct(this.props.conditionalFormats,e.conditionalFormats)||this.dragAndDrop.cancel()}))}getPreviewDivStyle(e){return this.dragAndDrop.itemsStyle[e.id]||""}onPreviewMouseDown(e,t){if(0!==t.button)return;const o=Array.from(this.cfListRef.el.children).map((e=>Nb(e))),s=this.props.conditionalFormats.map(((e,t)=>({id:e.id,size:o[t].height,position:o[t].y})));this.dragAndDrop.start("vertical",{draggedItemId:e.id,initialMousePosition:t.clientY,items:s,scrollableContainerEl:this.cfListRef.el,onDragEnd:(e,t)=>this.onDragEnd(e,t)})}onDragEnd(e,t){const o=this.props.conditionalFormats.findIndex((t=>t.id===e))-t;0!==o&&this.env.model.dispatch("CHANGE_CONDITIONAL_FORMAT_PRIORITY",{cfId:e,delta:o,sheetId:this.env.model.getters.getActiveSheetId()})}}Rb`
1007
1007
  .o-cf-ruleEditor {
1008
1008
  .o-cf-preview-display {
1009
1009
  border: 1px solid ${D};
@@ -1277,7 +1277,7 @@
1277
1277
  .add-calculated-measure {
1278
1278
  cursor: pointer;
1279
1279
  }
1280
- `;class eD extends t.Component{static template="o-spreadsheet-PivotLayoutConfigurator";static components={AddDimensionButton:Z_,PivotDimension:X_,PivotDimensionOrder:Q_,PivotDimensionGranularity:K_,PivotMeasureEditor:J_};static props={definition:Object,onDimensionsUpdated:Function,unusedGroupableFields:Array,measureFields:Array,unusedGranularities:Object,dateGranularities:Array,datetimeGranularities:Array,pivotId:String};dimensionsRef=t.useRef("pivot-dimensions");dragAndDrop=a_();AGGREGATORS=Il;composerFocus;isDateOrDatetimeField=Ol;setup(){this.composerFocus=tc(dc)}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=i.concat(n),l=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:l,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((e=>a.find((t=>t.nameWithGranularity===e)))).filter(tt),rows:n.map((e=>a.find((t=>t.nameWithGranularity===e)))).filter(tt)})}})}getGranularitiesFor(e){return Ol(e)?"date"===e.type?this.props.dateGranularities:this.props.datetimeGranularities:[]}startDragAndDropMeasures(e,t){if(0!==t.button||"SELECT"===t.target.tagName||"INPUT"===t.target.tagName||"inactive"!==this.composerFocus.focusMode)return;const o=this.getDimensionElementsRects(),s=this.props.definition,{measures:i,columns:n,rows:r}=s,a=i.map((e=>e.id)),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.id,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.id===e)))).filter(tt)})}})}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.id!==e.id))})}addColumnDimension(e){const{columns:t}=this.props.definition;this.props.onDimensionsUpdated({columns:t.concat([{fieldName:e,order:"asc"}])})}addRowDimension(e){const{rows:t}=this.props.definition;this.props.onDimensionsUpdated({rows:t.concat([{fieldName:e,order:"asc"}])})}addMeasureDimension(e){const{measures:t}=this.props.definition,o=this.getDefaultMeasureAggregator(e);this.props.onDimensionsUpdated({measures:t.concat([{id:this.getMeasureId(e,o),fieldName:e,aggregator:o}])})}updateMeasure(e,t){const{measures:o}=this.props.definition;this.props.onDimensionsUpdated({measures:o.map((o=>o.id===e.id?t:o))})}getMeasureId(e,t){const o=e+(t?`:${t}`:"");let s=o,i=2;for(;this.props.definition.measures.some((e=>e.id===s));)s=`${o}:${i}`,i++;return s}getDefaultMeasureAggregator(e){const t=this.props.measureFields.find((t=>t.name===e));return t?.aggregator?t.aggregator:"count"}addCalculatedMeasure(){const{measures:e}=this.props.definition,t=this.env.model.getters.generateNewCalculatedMeasureName(e);this.props.onDimensionsUpdated({measures:e.concat([{id:this.getMeasureId(t),fieldName:t,aggregator:"sum",computedBy:{sheetId:this.env.model.getters.getActiveSheetId(),formula:"=0"}}])})}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))})}getMeasureDescription(e){const t=e.display;if(!t||"no_calculations"===t.type)return"";const o=this.env.model.getters.getPivot(this.props.pivotId),s=[...o.definition.columns,...o.definition.rows].find((e=>e.nameWithGranularity===t.fieldNameWithGranularity)),i=s?Bl(s):"";return CE.descriptions[t.type](i)}}class tD extends t.Component{static template="o-spreadsheet-PivotTitleSection";static components={CogWheelMenu:Y_,Section:yA,TextInput:j_};static props={pivotId:String,flipAxis:Function};get cogWheelMenuItems(){return[{name:vo("Flip axes"),icon:"o-spreadsheet-Icon.EXCHANGE",execute:this.props.flipAxis},{name:vo("Duplicate"),icon:"o-spreadsheet-Icon.COPY",execute:()=>this.duplicatePivot()},{name:vo("Delete"),icon:"o-spreadsheet-Icon.TRASH",execute:()=>this.delete()}]}get name(){return this.env.model.getters.getPivotName(this.props.pivotId)}get displayName(){return this.env.model.getters.getPivotDisplayName(this.props.pivotId)}duplicatePivot(){const e=this.env.model.uuidGenerator.uuidv4(),t=this.env.model.uuidGenerator.uuidv4(),o=this.env.model.dispatch("DUPLICATE_PIVOT_IN_NEW_SHEET",{pivotId:this.props.pivotId,newPivotId:e,newSheetId:t});let s;s=o.isSuccessful?vo("Pivot duplicated."):o.isCancelledBecause("PivotInError")?vo("Cannot duplicate a pivot in error."):vo("Pivot duplication failed.");const i=o.isSuccessful?"success":"danger";this.env.notifyUser({text:s,sticky:!1,type:i}),o.isSuccessful&&this.env.openSidePanel("PivotSidePanel",{pivotId:e})}delete(){this.env.askConfirmation(vo("Are you sure you want to delete this pivot?"),(()=>{this.env.model.dispatch("REMOVE_PIVOT",{pivotId:this.props.pivotId})}))}onNameChanged(e){const t=this.env.model.getters.getPivotCoreDefinition(this.props.pivotId);this.env.model.dispatch("UPDATE_PIVOT",{pivotId:this.props.pivotId,pivot:{...t,name:e}})}}class oD{measures;columns;rows;constructor(e,t){this.measures=e.measures.map((e=>function(e,t){const o=t.fieldName,s="__count"===o?{name:"__count",string:vo("Count"),type:"integer",aggregator:"sum"}:e[o],i=t.aggregator;return{id:t.id,get displayName(){return t.userDefinedName??s?.string??t.fieldName},userDefinedName:t.userDefinedName,fieldName:o,aggregator:i,type:"__count"===o?"integer":s?.type??"integer",isValid:!(!s&&!t.computedBy),isHidden:t.isHidden,format:t.format,computedBy:t.computedBy,display:t.display}}(t,e))),this.columns=e.columns.map((e=>sD(t,e))),this.rows=e.rows.map((e=>sD(t,e)))}getDimension(e){const t=this.columns.find((t=>t.nameWithGranularity===e))||this.rows.find((t=>t.nameWithGranularity===e));if(!t)throw new di(vo("Dimension %s does not exist",e));return t}getMeasure(e){const t=this.measures.find((t=>t.id===e));if(!t)throw new di(vo("Field %s is not a measure",e));return t}}function sD(e,t){const o=e[t.fieldName],s=o?.type??"integer",i=o&&Ol(o)?t.granularity:void 0;return{displayName:o?.string??t.fieldName,nameWithGranularity:t.fieldName+(i?`:${i}`:""),fieldName:t.fieldName,granularity:i,type:s,order:t.order,isValid:!!o}}class iD extends oD{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 nD{columns;rows;measures;fieldsType;maxIndent;pivotCells={};rowTree;colTree;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.fieldsType=s,this.maxIndent=Math.max(...this.rows.map((e=>e.indent))),this.rowTree=rt((()=>this.buildRowsTree())),this.colTree=rt((()=>this.buildColumnsTree()))}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]}getRowTree(){return this.rowTree()}getColTree(){return this.colTree()}isTotalRow(e){return this.rows[e].indent!==this.maxIndent}getPivotCell(e,t,o=!0){const s=this.columns.length;if(e>0&&t===s-1){const o=this.getColHeaderDomain(e,t);if(!o)return rD;const s=o.at(-1)?.value?.toString()||"";return{type:"MEASURE_HEADER",domain:o.slice(0,-1),measure:s}}if(t<=s-1){const o=this.getColHeaderDomain(e,t);return o?{type:"HEADER",domain:o}:rD}if(0===e){const e=t-s;return{type:"HEADER",domain:this.getRowDomain(e)}}{const i=t-s;if(!o&&this.isTotalRow(i))return rD;return{type:"VALUE",domain:[...this.getRowDomain(i),...this.getColDomain(e)],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++){const t=s.fields[e];if("measure"===t)o.push({type:"char",field:t,value:Pl({displayName:"measure",type:"char"},s.values[e])});else{const{fieldName:i,granularity:n}=Dl(t),r=this.fieldsType[i]||"char";o.push({type:r,field:t,value:Pl({displayName:i,type:r,granularity:n},s.values[e])})}}return o}}getColDomain(e){const t=this.getColHeaderDomain(e,this.columns.length-1);return t?t.slice(0,-1):[]}getColMeasure(e){const t=this.getColHeaderDomain(e,this.columns.length-1),o=t?.at(-1)?.value;if(null==o)throw new Error("Measure is missing");return o.toString()}getRowDomain(e){const t=[];for(let o=0;o<this.rows[e].fields.length;o++){const s=this.rows[e].fields[o],{fieldName:i,granularity:n}=Dl(s),r=this.fieldsType[i]||"char";t.push({type:r,field:s,value:Pl({displayName:i,type:r,granularity:n},this.rows[e].values[o])})}return t}buildRowsTree(){const e=[];let t=0;const o={};o[0]=e;for(const s of this.rows){if(0===s.fields.length||0===s.values.length)return e;const i=s.fields.length-1,n=s.fields[i],{fieldName:r,granularity:a}=Dl(n),l=Pl({displayName:r,type:this.fieldsType[r]??"char",granularity:a},s.values[i]);if(i>t){t=i,o[t]=[];const e=o[t-1].at(-1);e&&(e.children=o[t])}t=i;const c={value:l,field:s.fields[i],children:[],width:0};o[t].push(c)}return e}buildColumnsTree(){const e=[],t=this.columns.at(-2)||[],o={};o[0]=e;for(const e of t)for(let t=0;t<e.fields.length;t++){const s=e.fields[t],{fieldName:i,granularity:n}=Dl(s),r=Pl({displayName:i,type:this.fieldsType[i]??"char",granularity:n},e.values[t]),a={value:r,field:e.fields[t],children:[],width:e.width};o[t]?.at(-1)?.value!==r&&(o[t+1]=[],a.children=o[t+1],o[t].push(a))}return e}export(){return{cols:this.columns,rows:this.rows,measures:this.measures,fieldsType:this.fieldsType}}}const rD={type:"EMPTY"};function aD(e,t){const o=t.measures.filter((e=>!e.isHidden)).map((e=>e.id)),s=cD(e,t.columns,0);hD(s,o.length);const i=function(e,t){const o=t.columns.map((e=>e.nameWithGranularity)),s=o.length,i=t.measures.filter((e=>!e.isHidden)),n=i.length,r=new Array(s).fill(0).map((()=>[]));function a(e,t,i){const n=r[t];for(const r of e){const e=i.concat([r.value]),l={fields:o.slice(0,t+1),values:e,width:r.width,offset:0};n.push(l),t<=s-1&&a(r.children,t+1,e)}}a(e,0,[]);const l=o.length>0,c=[];l&&r[r.length-1].forEach((e=>{i.forEach((t=>{const o={fields:[...e.fields,"measure"],values:[...e.values,t.id],width:1,offset:0};c.push(o)}))}));i.forEach((e=>{const t={fields:["measure"],values:[e.id],width:1,offset:0};c.push(t)})),r.push(c),1===r.length&&r.unshift([]);return r[r.length-2].push({fields:[],values:[],width:n,offset:0}),r}(s,t),n=lD(e,0,t.rows,[],[]);n.push({fields:[],values:[],indent:0});const r={};for(const e of t.columns)r[e.fieldName]=e.type;for(const e of t.rows)r[e.fieldName]=e.type;return new nD(i,n,o,r)}function lD(e,t,o,s,i){if(t>=o.length)return[];const n=o[t],r=n.nameWithGranularity,a=dD(e,n),l=uD(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(...lD(n,t+1,o,h,s))}return c}function cD(e,t,o){if(o>=t.length)return[];const s=t[o],i=t[o].nameWithGranularity,n=dD(e,s);return uD(n,t[o]).map((e=>({value:n[e]?.[0]?.[s.nameWithGranularity]?.value??null,field:i,children:cD(n[e]||[],t,o+1),width:0})))}function hD(e,t){for(const o in e){const s=e[o];0===s.children.length?s.width=t:(hD(s.children,t),s.width=s.children.reduce(((e,t)=>e+t.width),0))}}function dD(e,t){return Object.groupBy(e,function(e){const t=e.nameWithGranularity;return e=>`${e[t]?.value??null}`}(t))}function uD(e,t){return t.order?Object.keys(e).sort(((e,o)=>function(e,t,o){if("null"===t)return"asc"===e.order?1:-1;if("null"===o)return"asc"===e.order?-1:1;if("integer"===e.type||"datetime"===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)}const gD=Symbol("NULL");function pD(e,t,o){const s=e.granularity;if(!s||!(s in mD))throw new Error(`Unknown date granularity: ${s}`);const i="number"==typeof t||"string"==typeof t?t:gD;if(!mD[s].set.has(t)){mD[s].set.add(t);let n=null;if("number"==typeof t||"string"==typeof t){const e=Ni(t,o);switch(s){case"year":n=e.getFullYear();break;case"quarter_number":n=Math.floor(e.getMonth()/3)+1;break;case"month_number":n=e.getMonth()+1;break;case"iso_week_number":n=e.getIsoWeek();break;case"day_of_month":n=e.getDate();break;case"day":n=Math.floor(wi(t,o));break;case"day_of_week":n=(e.getDay()+7-o.weekStart)%7+1;break;case"hour_number":n=e.getHours();break;case"minute_number":n=e.getMinutes();break;case"second_number":n=e.getSeconds()}}mD[s].values[i]=Pl(e,n)}return mD[s].values[i]}const mD={year:{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:{}},day_of_week:{set:new Set,values:{}},hour_number:{set:new Set,values:{}},minute_number:{set:new Set,values:{}},second_number:{set:new Set,values:{}}};var fD;!function(e){e[e.NONE=0]="NONE",e[e.TABLE=1]="TABLE",e[e.DATA=2]="DATA",e[e.DEFINITION=3]="DEFINITION",e[e.ALL=4]="ALL"}(fD||(fD={}));const vD=new n,bD=["year","quarter_number","month_number","iso_week_number","day_of_month","day","day_of_week"];vD.add("SPREADSHEET",{ui:class{type="SPREADSHEET";getters;_definition;coreDefinition;metaData={fields:{},fieldKeys:[]};dataEntries=[];table;invalidRangeError;needsReevaluation=!0;constructor(e,t){this.getters=t.getters,this.coreDefinition=t.definition}init(e={}){this._definition&&!e.reload||(this.reload(fD.ALL),this.needsReevaluation=!1)}reload(e){e===fD.ALL&&(this.metaData=this.loadMetaData()),e>=fD.DEFINITION&&(this._definition=this.loadRuntimeDefinition()),e>=fD.DATA&&(this.dataEntries=this.loadData()),e>=fD.TABLE&&(this.table=void 0)}onDefinitionChange(e){const t=this.coreDefinition;if(this.coreDefinition=e,this._definition){const o=Math.max(this.computeShouldReload(t,e),fD.NONE);this.reload(o)}}computeShouldReload(e,t){return ct(e.dataSet,t.dataSet)?fD.DEFINITION:fD.ALL}get isInvalidRange(){return!!this.invalidRangeError}get invalidRangeMessage(){return this.invalidRangeError?.message}get definition(){if(this._definition||this.init(),!this._definition)throw new Error("Pivot definition should be defined at this point.");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 di(vo("At least one measure and/or dimension is not correct."));return{value:ci.GenericError,message:this.invalidRangeError?.message??vo("At least one measure and/or dimension is not correct.")}}}areDomainArgsFieldsValid(e){let t=e.filter(((e,t)=>t%2==0)).map(Di);return t.length&&"measure"===t.at(-1)&&(t=t.slice(0,-1)),Ml(t,this.definition)}parseArgsToPivotDomain(e){const t=[];for(let o=0;o<e.length-1;o+=2){const s=Di(e[o]),i=this.getTypeOfDimension(s),n="measure"===s?Di(e[o+1]):Pl(this.getDimension(s),e[o+1]);t.push({field:s,value:n,type:i})}return t}markAsDirtyForEvaluation(){this.needsReevaluation=!0}getMeasure(e){return this.definition.getMeasure(e)}getPivotMeasureValue(e){return{value:this.getMeasure(e).displayName}}getPivotHeaderValueAndFormat(e){const t=e.at(-1);if(!t)return{value:vo("Total")};const o=this.getDimension(t.field),s=this.filterDataEntriesFromDomain(this.dataEntries,e),i=s[0]?.[o.nameWithGranularity];if("datetime"===o.type){return hl(o.granularity).toValueAndFormat(t.value,this.getters.getLocale())}return i?null===i.value?{value:vo("(Undefined)")}:{value:i.value,format:i.format}:{value:""}}getPivotCellValueAndFormat(e,t){const o=this.filterDataEntriesFromDomain(this.dataEntries,t);if(0===o.length)return{value:""};const s=this.getMeasure(e),i=o.map((e=>e[s.fieldName])).filter(tt),n=i.filter((e=>e.type!==$s.empty)),r=s.aggregator,a=Rl[r];if(!a)throw new Error(`Aggregator ${r} does not exist`);try{const e=a([i],this.getters.getLocale());return 0===n.length?{...e,value:""}:e}catch(e){return Sb(e,r.toUpperCase())}}getPossibleFieldValues(e){const t=[],o=dD(this.dataEntries,e),s=uD(o,e);for(const i of s)t.push({value:o[i]?.[0]?.[e.nameWithGranularity]?.value??"",label:o[i]?.[0]?.[e.nameWithGranularity]?.formattedValue||""});return t}getTableStructure(){if(!this.isValid())throw new Error("Pivot is not valid !");return this.table||(this.table=aD(this.dataEntries,this.definition)),this.table}getFields(){return this.metaData.fields}get fields(){return this.getFields()}loadMetaData(){if(this.invalidRangeError=void 0,!this.coreDefinition.dataSet)return this.invalidRangeError=new di(vo("The pivot cannot be created because the dataset is missing.")),{fields:{},fieldKeys:[]};{const{zone:e,sheetId:t}=this.coreDefinition.dataSet,o=this.getters.getRangeFromZone(t,e);try{return this.extractFieldsFromRange(o)}catch(e){return this.invalidRangeError=e,{fields:{},fieldKeys:[]}}}}loadRuntimeDefinition(){return new iD(this.coreDefinition,this.fields,this.getters)}loadData(){const e=this._definition?.range;return this.isValid()&&e?this.extractDataEntriesFromRange(e):[]}getTypeOfDimension(e){if("measure"===e)return"char";const{fieldName:t}=Dl(e),o=this.fields[t]?.type;if(!o)throw new Error(`Field ${t} does not exist`);return o}filterDataEntriesFromDomain(e,t){return t.reduce(((e,t)=>this.filterDataEntriesFromDomainNode(e,t)),e)}filterDataEntriesFromDomainNode(e,t){const{field:o,value:s}=t,{nameWithGranularity:i}=this.getDimension(o);return e.filter((e=>e[i]?.value===s))}getDimension(e){return this.definition.getDimension(e)}getTypeFromZone(e,t){const o=this.getters.getEvaluatedCellsInZone(e,t).filter((e=>e.type!==$s.empty));return 0===o.length?"integer":o.every((e=>e.format&&Gn(e.format)))?"datetime":o.every((e=>e.type===$s.boolean))?"boolean":o.some((e=>e.type===$s.text))?"char":"integer"}assertCellIsValidField(e,t,o){if(o.type===$s.error)throw new di(vo("The pivot cannot be created because cell %s contains an error",io(e,t)));if(o.type===$s.empty||""===o.value)throw new di(vo("The pivot cannot be created because cell %s is empty",io(e,t)));if("__count"===o.value)throw new di(vo("The pivot cannot be created because cell %s contains a reserved value",io(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.metaData.fieldKeys[e]];if(!o)throw new Error(`Field ${this.metaData.fieldKeys[e]} does not exist`);""===t.value?n[o.name]={value:null,type:$s.empty,formattedValue:""}:n[o.name]=t}n.__count={value:1,type:$s.number,formattedValue:"1"},t.push(n)}const o=this.definition.columns.concat(this.definition.rows).filter((e=>"datetime"===e.type));if(o.length){const e=this.getters.getLocale();for(const s of t)for(const t of o){const o=pD(t,s[t.fieldName]?.value||null,this.getters.getLocale()),i=hl(t.granularity),{format:n,value:r}=i.toValueAndFormat(o,e);s[t.nameWithGranularity]={value:o,type:s[t.fieldName]?.type||$s.empty,format:s[t.fieldName]?.format,formattedValue:kn(r,{locale:e,format:n})}}}return t}},definition:iD,externalData:!1,onIterationEndEvaluation:e=>e.markAsDirtyForEvaluation(),dateGranularities:[...bD],datetimeGranularities:[...bD,"hour_number","minute_number","second_number"],isMeasureCandidate:e=>!["datetime","boolean"].includes(e.type),isGroupable:()=>!0});class SD extends cc{pivotId;mutators=["reset","deferUpdates","applyUpdate","discardPendingUpdate","update"];updatesAreDeferred=!1;draft=null;notification=this.get(o_);alreadyNotified=!1;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(){return this.pivot.getFields()}get pivot(){return this.getters.getPivot(this.pivotId)}get definition(){const e=vD.get(this.pivot.type).definition;return this.draft?new e(this.draft,this.fields,this.getters):this.pivot.definition}get isDirty(){return!!this.draft}get measureFields(){const e=[{name:"__count",string:vo("Count"),type:"integer",aggregator:"sum"}],t=this.fields;for(const o in t){const s=t[o];s&&(vD.get(this.pivot.type).isMeasureCandidate(s)&&e.push(s))}return e.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&&(vD.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.fieldName)),r=this.unusedGranularities;return e.filter((e=>Ol(e)?!n.includes(e.name)||r[e.name].size>0:!n.includes(e.name))).sort(((e,t)=>e.string.localeCompare(t.string)))}get datetimeGranularities(){return vD.get(this.pivot.type).datetimeGranularities}get dateGranularities(){return vD.get(this.pivot.type).dateGranularities}get unusedGranularities(){return this.getUnusedGranularities(this.fields,this.draft??this.getters.getPivotCoreDefinition(this.pivotId))}reset(e){this.pivotId=e,this.updatesAreDeferred=!0,this.draft=null}deferUpdates(e){this.updatesAreDeferred=e,!1===e&&this.draft&&this.applyUpdate()}applyUpdate(){if(this.draft&&(this.model.dispatch("UPDATE_PIVOT",{pivotId:this.pivotId,pivot:this.draft}),this.draft=null,!this.alreadyNotified&&!this.isDynamicPivotInViewport()&&this.isStaticPivotInViewport())){const e=`=PIVOT(${this.getters.getPivotFormulaId(this.pivotId)})`;this.alreadyNotified=!0,this.notification.notifyUser({type:"info",text:vo("Pivot updates only work with dynamic pivot tables. Use %s or re-insert the static pivot from the Data menu.",e),sticky:!1})}}discardPendingUpdate(){this.draft=null}update(e){const t=this.getters.getPivotCoreDefinition(this.pivotId),o={...t,...this.draft,...e},s={...o,columns:o.columns.map((e=>({fieldName:e.fieldName,order:e.order,granularity:e.granularity}))),rows:o.rows.map((e=>({fieldName:e.fieldName,order:e.order,granularity:e.granularity}))),measures:o.measures.map((e=>({id:e.id,fieldName:e.fieldName,aggregator:e.aggregator,userDefinedName:e.userDefinedName,computedBy:e.computedBy,isHidden:e.isHidden,format:e.format,display:e.display})))};if(!this.draft&&ct(t,s))return;const i=this.addDefaultDateTimeGranularity(this.fields,s);this.draft=i,this.updatesAreDeferred||this.applyUpdate()}isDynamicPivotInViewport(){const e=this.getters.getActiveSheetId();for(const t of this.getters.getSheetViewVisibleCols())for(const o of this.getters.getSheetViewVisibleRows()){if(this.getters.isSpillPivotFormula({sheetId:e,col:t,row:o}))return!0}return!1}isStaticPivotInViewport(){for(const e of this.getters.getVisibleCellPositions()){const t=this.getters.getCell(e);if(t?.isFormula){const e=CS(t.compiledFormula.tokens);if(e&&"PIVOT"!==e.functionName)return!0}}return!1}addDefaultDateTimeGranularity(e,t){const{columns:o,rows:s}=t,i=Pe(o),n=Pe(s),r=this.getUnusedGranularities(e,t);for(const t of i.concat(n)){const o=e[t.fieldName]?.type;if(("date"===o||"datetime"===o)&&!t.granularity){const e=r[t.fieldName]?.values().next().value||"year";r[t.fieldName]?.delete(e),t.granularity=e}}return{...t,columns:i,rows:n}}getUnusedGranularities(e,t){const{columns:o,rows:s}=t,i=o.concat(s).filter((t=>{const o=e[t.fieldName]?.type;return"date"===o||"datetime"===o})),n={};for(const t of i)n[t.fieldName]=new Set("date"===e[t.fieldName]?.type?this.dateGranularities:this.datetimeGranularities);for(const e of i)n[e.fieldName].delete(e.granularity);return n}}class yD extends t.Component{static template="o-spreadsheet-PivotSpreadsheetSidePanel";static props={pivotId:String,onCloseSidePanel:Function};static components={PivotLayoutConfigurator:eD,Section:yA,SelectionInput:EA,Checkbox:SA,PivotDeferUpdate:q_,PivotTitleSection:tD};store;state;setup(){this.store=oc(SD,this.props.pivotId),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 definition(){return this.store.definition}onSelectionChanged(e){this.state.rangeHasChanged=!0,this.state.range=e[0]}onSelectionConfirmed(){if(this.state.range){const e=this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(),this.state.range);if(e.invalidSheetName||e.invalidXc)return;const t={sheetId:e.sheetId,zone:e.zone};this.store.update({dataSet:t}),this.store.applyUpdate()}}flipAxis(){const{rows:e,columns:t}=this.definition;this.onDimensionsUpdated({rows:t,columns:e})}onDimensionsUpdated(e){this.store.update(e)}}const CD=new n;CD.add("SPREADSHEET",{editor:yD});class wD extends t.Component{static template="o-spreadsheet-PivotSidePanel";static props={pivotId:String,onCloseSidePanel:Function};static components={PivotLayoutConfigurator:eD,Section:yA};get sidePanelEditor(){const e=this.env.model.getters.getPivotCoreDefinition(this.props.pivotId);if(!e)throw new Error("pivotId does not correspond to a pivot.");return CD.get(e.type).editor}}Rb`
1280
+ `;class eD extends t.Component{static template="o-spreadsheet-PivotLayoutConfigurator";static components={AddDimensionButton:Z_,PivotDimension:X_,PivotDimensionOrder:Q_,PivotDimensionGranularity:K_,PivotMeasureEditor:J_};static props={definition:Object,onDimensionsUpdated:Function,unusedGroupableFields:Array,measureFields:Array,unusedGranularities:Object,dateGranularities:Array,datetimeGranularities:Array,getScrollableContainerEl:{type:Function,optional:!0},pivotId:String};dimensionsRef=t.useRef("pivot-dimensions");dragAndDrop=a_();AGGREGATORS=Il;composerFocus;isDateOrDatetimeField=Ol;setup(){this.composerFocus=tc(dc)}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=i.concat(n),l=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:l,scrollableContainerEl:this.props.getScrollableContainerEl?.()||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((e=>a.find((t=>t.nameWithGranularity===e)))).filter(tt),rows:n.map((e=>a.find((t=>t.nameWithGranularity===e)))).filter(tt)})}})}getGranularitiesFor(e){return Ol(e)?"date"===e.type?this.props.dateGranularities:this.props.datetimeGranularities:[]}startDragAndDropMeasures(e,t){if(0!==t.button||"SELECT"===t.target.tagName||"INPUT"===t.target.tagName||"inactive"!==this.composerFocus.focusMode)return;const o=this.getDimensionElementsRects(),s=this.props.definition,{measures:i,columns:n,rows:r}=s,a=i.map((e=>e.id)),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.id,initialMousePosition:t.clientY,items:c,scrollableContainerEl:this.props.getScrollableContainerEl?.()||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.id===e)))).filter(tt)})}})}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.id!==e.id))})}addColumnDimension(e){const{columns:t}=this.props.definition;this.props.onDimensionsUpdated({columns:t.concat([{fieldName:e,order:"asc"}])})}addRowDimension(e){const{rows:t}=this.props.definition;this.props.onDimensionsUpdated({rows:t.concat([{fieldName:e,order:"asc"}])})}addMeasureDimension(e){const{measures:t}=this.props.definition,o=this.getDefaultMeasureAggregator(e);this.props.onDimensionsUpdated({measures:t.concat([{id:this.getMeasureId(e,o),fieldName:e,aggregator:o}])})}updateMeasure(e,t){const{measures:o}=this.props.definition;this.props.onDimensionsUpdated({measures:o.map((o=>o.id===e.id?t:o))})}getMeasureId(e,t){const o=e+(t?`:${t}`:"");let s=o,i=2;for(;this.props.definition.measures.some((e=>e.id===s));)s=`${o}:${i}`,i++;return s}getDefaultMeasureAggregator(e){const t=this.props.measureFields.find((t=>t.name===e));return t?.aggregator?t.aggregator:"count"}addCalculatedMeasure(){const{measures:e}=this.props.definition,t=this.env.model.getters.generateNewCalculatedMeasureName(e);this.props.onDimensionsUpdated({measures:e.concat([{id:this.getMeasureId(t),fieldName:t,aggregator:"sum",computedBy:{sheetId:this.env.model.getters.getActiveSheetId(),formula:"=0"}}])})}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))})}getMeasureDescription(e){const t=e.display;if(!t||"no_calculations"===t.type)return"";const o=this.env.model.getters.getPivot(this.props.pivotId),s=[...o.definition.columns,...o.definition.rows].find((e=>e.nameWithGranularity===t.fieldNameWithGranularity)),i=s?Bl(s):"";return CE.descriptions[t.type](i)}}class tD extends t.Component{static template="o-spreadsheet-PivotTitleSection";static components={CogWheelMenu:Y_,Section:yA,TextInput:j_};static props={pivotId:String,flipAxis:Function};get cogWheelMenuItems(){return[{name:vo("Flip axes"),icon:"o-spreadsheet-Icon.EXCHANGE",execute:this.props.flipAxis},{name:vo("Duplicate"),icon:"o-spreadsheet-Icon.COPY",execute:()=>this.duplicatePivot()},{name:vo("Delete"),icon:"o-spreadsheet-Icon.TRASH",execute:()=>this.delete()}]}get name(){return this.env.model.getters.getPivotName(this.props.pivotId)}get displayName(){return this.env.model.getters.getPivotDisplayName(this.props.pivotId)}duplicatePivot(){const e=this.env.model.uuidGenerator.uuidv4(),t=this.env.model.uuidGenerator.uuidv4(),o=this.env.model.dispatch("DUPLICATE_PIVOT_IN_NEW_SHEET",{pivotId:this.props.pivotId,newPivotId:e,newSheetId:t});let s;s=o.isSuccessful?vo("Pivot duplicated."):o.isCancelledBecause("PivotInError")?vo("Cannot duplicate a pivot in error."):vo("Pivot duplication failed.");const i=o.isSuccessful?"success":"danger";this.env.notifyUser({text:s,sticky:!1,type:i}),o.isSuccessful&&this.env.openSidePanel("PivotSidePanel",{pivotId:e})}delete(){this.env.askConfirmation(vo("Are you sure you want to delete this pivot?"),(()=>{this.env.model.dispatch("REMOVE_PIVOT",{pivotId:this.props.pivotId})}))}onNameChanged(e){const t=this.env.model.getters.getPivotCoreDefinition(this.props.pivotId);this.env.model.dispatch("UPDATE_PIVOT",{pivotId:this.props.pivotId,pivot:{...t,name:e}})}}class oD{measures;columns;rows;constructor(e,t){this.measures=e.measures.map((e=>function(e,t){const o=t.fieldName,s="__count"===o?{name:"__count",string:vo("Count"),type:"integer",aggregator:"sum"}:e[o],i=t.aggregator;return{id:t.id,get displayName(){return t.userDefinedName??s?.string??t.fieldName},userDefinedName:t.userDefinedName,fieldName:o,aggregator:i,type:"__count"===o?"integer":s?.type??"integer",isValid:!(!s&&!t.computedBy),isHidden:t.isHidden,format:t.format,computedBy:t.computedBy,display:t.display}}(t,e))),this.columns=e.columns.map((e=>sD(t,e))),this.rows=e.rows.map((e=>sD(t,e)))}getDimension(e){const t=this.columns.find((t=>t.nameWithGranularity===e))||this.rows.find((t=>t.nameWithGranularity===e));if(!t)throw new di(vo("Dimension %s does not exist",e));return t}getMeasure(e){const t=this.measures.find((t=>t.id===e));if(!t)throw new di(vo("Field %s is not a measure",e));return t}}function sD(e,t){const o=e[t.fieldName],s=o?.type??"integer",i=o&&Ol(o)?t.granularity:void 0;return{displayName:o?.string??t.fieldName,nameWithGranularity:t.fieldName+(i?`:${i}`:""),fieldName:t.fieldName,granularity:i,type:s,order:t.order,isValid:!!o}}class iD extends oD{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 nD{columns;rows;measures;fieldsType;maxIndent;pivotCells={};rowTree;colTree;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.fieldsType=s,this.maxIndent=Math.max(...this.rows.map((e=>e.indent))),this.rowTree=rt((()=>this.buildRowsTree())),this.colTree=rt((()=>this.buildColumnsTree()))}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]}getRowTree(){return this.rowTree()}getColTree(){return this.colTree()}isTotalRow(e){return this.rows[e].indent!==this.maxIndent}getPivotCell(e,t,o=!0){const s=this.columns.length;if(e>0&&t===s-1){const o=this.getColHeaderDomain(e,t);if(!o)return rD;const s=o.at(-1)?.value?.toString()||"";return{type:"MEASURE_HEADER",domain:o.slice(0,-1),measure:s}}if(t<=s-1){const o=this.getColHeaderDomain(e,t);return o?{type:"HEADER",domain:o}:rD}if(0===e){const e=t-s;return{type:"HEADER",domain:this.getRowDomain(e)}}{const i=t-s;if(!o&&this.isTotalRow(i))return rD;return{type:"VALUE",domain:[...this.getRowDomain(i),...this.getColDomain(e)],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++){const t=s.fields[e];if("measure"===t)o.push({type:"char",field:t,value:Pl({displayName:"measure",type:"char"},s.values[e])});else{const{fieldName:i,granularity:n}=Dl(t),r=this.fieldsType[i]||"char";o.push({type:r,field:t,value:Pl({displayName:i,type:r,granularity:n},s.values[e])})}}return o}}getColDomain(e){const t=this.getColHeaderDomain(e,this.columns.length-1);return t?t.slice(0,-1):[]}getColMeasure(e){const t=this.getColHeaderDomain(e,this.columns.length-1),o=t?.at(-1)?.value;if(null==o)throw new Error("Measure is missing");return o.toString()}getRowDomain(e){const t=[];for(let o=0;o<this.rows[e].fields.length;o++){const s=this.rows[e].fields[o],{fieldName:i,granularity:n}=Dl(s),r=this.fieldsType[i]||"char";t.push({type:r,field:s,value:Pl({displayName:i,type:r,granularity:n},this.rows[e].values[o])})}return t}buildRowsTree(){const e=[];let t=0;const o={};o[0]=e;for(const s of this.rows){if(0===s.fields.length||0===s.values.length)return e;const i=s.fields.length-1,n=s.fields[i],{fieldName:r,granularity:a}=Dl(n),l=Pl({displayName:r,type:this.fieldsType[r]??"char",granularity:a},s.values[i]);if(i>t){t=i,o[t]=[];const e=o[t-1].at(-1);e&&(e.children=o[t])}t=i;const c={value:l,field:s.fields[i],children:[],width:0};o[t].push(c)}return e}buildColumnsTree(){const e=[],t=this.columns.at(-2)||[],o={};o[0]=e;for(const e of t)for(let t=0;t<e.fields.length;t++){const s=e.fields[t],{fieldName:i,granularity:n}=Dl(s),r=Pl({displayName:i,type:this.fieldsType[i]??"char",granularity:n},e.values[t]),a={value:r,field:e.fields[t],children:[],width:e.width};o[t]?.at(-1)?.value!==r&&(o[t+1]=[],a.children=o[t+1],o[t].push(a))}return e}export(){return{cols:this.columns,rows:this.rows,measures:this.measures,fieldsType:this.fieldsType}}}const rD={type:"EMPTY"};function aD(e,t){const o=t.measures.filter((e=>!e.isHidden)).map((e=>e.id)),s=cD(e,t.columns,0);hD(s,o.length);const i=function(e,t){const o=t.columns.map((e=>e.nameWithGranularity)),s=o.length,i=t.measures.filter((e=>!e.isHidden)),n=i.length,r=new Array(s).fill(0).map((()=>[]));function a(e,t,i){const n=r[t];for(const r of e){const e=i.concat([r.value]),l={fields:o.slice(0,t+1),values:e,width:r.width,offset:0};n.push(l),t<=s-1&&a(r.children,t+1,e)}}a(e,0,[]);const l=o.length>0,c=[];l&&r[r.length-1].forEach((e=>{i.forEach((t=>{const o={fields:[...e.fields,"measure"],values:[...e.values,t.id],width:1,offset:0};c.push(o)}))}));i.forEach((e=>{const t={fields:["measure"],values:[e.id],width:1,offset:0};c.push(t)})),r.push(c),1===r.length&&r.unshift([]);return r[r.length-2].push({fields:[],values:[],width:n,offset:0}),r}(s,t),n=lD(e,0,t.rows,[],[]);n.push({fields:[],values:[],indent:0});const r={};for(const e of t.columns)r[e.fieldName]=e.type;for(const e of t.rows)r[e.fieldName]=e.type;return new nD(i,n,o,r)}function lD(e,t,o,s,i){if(t>=o.length)return[];const n=o[t],r=n.nameWithGranularity,a=dD(e,n),l=uD(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(...lD(n,t+1,o,h,s))}return c}function cD(e,t,o){if(o>=t.length)return[];const s=t[o],i=t[o].nameWithGranularity,n=dD(e,s);return uD(n,t[o]).map((e=>({value:n[e]?.[0]?.[s.nameWithGranularity]?.value??null,field:i,children:cD(n[e]||[],t,o+1),width:0})))}function hD(e,t){for(const o in e){const s=e[o];0===s.children.length?s.width=t:(hD(s.children,t),s.width=s.children.reduce(((e,t)=>e+t.width),0))}}function dD(e,t){return Object.groupBy(e,function(e){const t=e.nameWithGranularity;return e=>`${e[t]?.value??null}`}(t))}function uD(e,t){return t.order?Object.keys(e).sort(((e,o)=>function(e,t,o){if("null"===t)return"asc"===e.order?1:-1;if("null"===o)return"asc"===e.order?-1:1;if("integer"===e.type||"datetime"===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)}const gD=Symbol("NULL");function pD(e,t,o){const s=e.granularity;if(!s||!(s in mD))throw new Error(`Unknown date granularity: ${s}`);const i="number"==typeof t||"string"==typeof t?t:gD;if(!mD[s].set.has(t)){mD[s].set.add(t);let n=null;if("number"==typeof t||"string"==typeof t){const e=Ni(t,o);switch(s){case"year":n=e.getFullYear();break;case"quarter_number":n=Math.floor(e.getMonth()/3)+1;break;case"month_number":n=e.getMonth()+1;break;case"iso_week_number":n=e.getIsoWeek();break;case"day_of_month":n=e.getDate();break;case"day":n=Math.floor(wi(t,o));break;case"day_of_week":n=(e.getDay()+7-o.weekStart)%7+1;break;case"hour_number":n=e.getHours();break;case"minute_number":n=e.getMinutes();break;case"second_number":n=e.getSeconds()}}mD[s].values[i]=Pl(e,n)}return mD[s].values[i]}const mD={year:{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:{}},day_of_week:{set:new Set,values:{}},hour_number:{set:new Set,values:{}},minute_number:{set:new Set,values:{}},second_number:{set:new Set,values:{}}};var fD;!function(e){e[e.NONE=0]="NONE",e[e.TABLE=1]="TABLE",e[e.DATA=2]="DATA",e[e.DEFINITION=3]="DEFINITION",e[e.ALL=4]="ALL"}(fD||(fD={}));const vD=new n,bD=["year","quarter_number","month_number","iso_week_number","day_of_month","day","day_of_week"];vD.add("SPREADSHEET",{ui:class{type="SPREADSHEET";getters;_definition;coreDefinition;metaData={fields:{},fieldKeys:[]};dataEntries=[];table;invalidRangeError;needsReevaluation=!0;constructor(e,t){this.getters=t.getters,this.coreDefinition=t.definition}init(e={}){this._definition&&!e.reload||(this.reload(fD.ALL),this.needsReevaluation=!1)}reload(e){e===fD.ALL&&(this.metaData=this.loadMetaData()),e>=fD.DEFINITION&&(this._definition=this.loadRuntimeDefinition()),e>=fD.DATA&&(this.dataEntries=this.loadData()),e>=fD.TABLE&&(this.table=void 0)}onDefinitionChange(e){const t=this.coreDefinition;if(this.coreDefinition=e,this._definition){const o=Math.max(this.computeShouldReload(t,e),fD.NONE);this.reload(o)}}computeShouldReload(e,t){return ct(e.dataSet,t.dataSet)?fD.DEFINITION:fD.ALL}get isInvalidRange(){return!!this.invalidRangeError}get invalidRangeMessage(){return this.invalidRangeError?.message}get definition(){if(this._definition||this.init(),!this._definition)throw new Error("Pivot definition should be defined at this point.");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 di(vo("At least one measure and/or dimension is not correct."));return{value:ci.GenericError,message:this.invalidRangeError?.message??vo("At least one measure and/or dimension is not correct.")}}}areDomainArgsFieldsValid(e){let t=e.filter(((e,t)=>t%2==0)).map(Di);return t.length&&"measure"===t.at(-1)&&(t=t.slice(0,-1)),Ml(t,this.definition)}parseArgsToPivotDomain(e){const t=[];for(let o=0;o<e.length-1;o+=2){const s=Di(e[o]),i=this.getTypeOfDimension(s),n="measure"===s?Di(e[o+1]):Pl(this.getDimension(s),e[o+1]);t.push({field:s,value:n,type:i})}return t}markAsDirtyForEvaluation(){this.needsReevaluation=!0}getMeasure(e){return this.definition.getMeasure(e)}getPivotMeasureValue(e){return{value:this.getMeasure(e).displayName}}getPivotHeaderValueAndFormat(e){const t=e.at(-1);if(!t)return{value:vo("Total")};const o=this.getDimension(t.field),s=this.filterDataEntriesFromDomain(this.dataEntries,e),i=s[0]?.[o.nameWithGranularity];if("datetime"===o.type){return hl(o.granularity).toValueAndFormat(t.value,this.getters.getLocale())}return i?null===i.value?{value:vo("(Undefined)")}:{value:i.value,format:i.format}:{value:""}}getPivotCellValueAndFormat(e,t){const o=this.filterDataEntriesFromDomain(this.dataEntries,t);if(0===o.length)return{value:""};const s=this.getMeasure(e),i=o.map((e=>e[s.fieldName])).filter(tt),n=i.filter((e=>e.type!==$s.empty)),r=s.aggregator,a=Rl[r];if(!a)throw new Error(`Aggregator ${r} does not exist`);try{const e=a([i],this.getters.getLocale());return 0===n.length?{...e,value:""}:e}catch(e){return Sb(e,r.toUpperCase())}}getPossibleFieldValues(e){const t=[],o=dD(this.dataEntries,e),s=uD(o,e);for(const i of s)t.push({value:o[i]?.[0]?.[e.nameWithGranularity]?.value??"",label:o[i]?.[0]?.[e.nameWithGranularity]?.formattedValue||""});return t}getTableStructure(){if(!this.isValid())throw new Error("Pivot is not valid !");return this.table||(this.table=aD(this.dataEntries,this.definition)),this.table}getFields(){return this.metaData.fields}get fields(){return this.getFields()}loadMetaData(){if(this.invalidRangeError=void 0,!this.coreDefinition.dataSet)return this.invalidRangeError=new di(vo("The pivot cannot be created because the dataset is missing.")),{fields:{},fieldKeys:[]};{const{zone:e,sheetId:t}=this.coreDefinition.dataSet,o=this.getters.getRangeFromZone(t,e);try{return this.extractFieldsFromRange(o)}catch(e){return this.invalidRangeError=e,{fields:{},fieldKeys:[]}}}}loadRuntimeDefinition(){return new iD(this.coreDefinition,this.fields,this.getters)}loadData(){const e=this._definition?.range;return this.isValid()&&e?this.extractDataEntriesFromRange(e):[]}getTypeOfDimension(e){if("measure"===e)return"char";const{fieldName:t}=Dl(e),o=this.fields[t]?.type;if(!o)throw new Error(`Field ${t} does not exist`);return o}filterDataEntriesFromDomain(e,t){return t.reduce(((e,t)=>this.filterDataEntriesFromDomainNode(e,t)),e)}filterDataEntriesFromDomainNode(e,t){const{field:o,value:s}=t,{nameWithGranularity:i}=this.getDimension(o);return e.filter((e=>e[i]?.value===s))}getDimension(e){return this.definition.getDimension(e)}getTypeFromZone(e,t){const o=this.getters.getEvaluatedCellsInZone(e,t).filter((e=>e.type!==$s.empty));return 0===o.length?"integer":o.every((e=>e.format&&Gn(e.format)))?"datetime":o.every((e=>e.type===$s.boolean))?"boolean":o.some((e=>e.type===$s.text))?"char":"integer"}assertCellIsValidField(e,t,o){if(o.type===$s.error)throw new di(vo("The pivot cannot be created because cell %s contains an error",io(e,t)));if(o.type===$s.empty||""===o.value)throw new di(vo("The pivot cannot be created because cell %s is empty",io(e,t)));if("__count"===o.value)throw new di(vo("The pivot cannot be created because cell %s contains a reserved value",io(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.metaData.fieldKeys[e]];if(!o)throw new Error(`Field ${this.metaData.fieldKeys[e]} does not exist`);""===t.value?n[o.name]={value:null,type:$s.empty,formattedValue:""}:n[o.name]=t}n.__count={value:1,type:$s.number,formattedValue:"1"},t.push(n)}const o=this.definition.columns.concat(this.definition.rows).filter((e=>"datetime"===e.type));if(o.length){const e=this.getters.getLocale();for(const s of t)for(const t of o){const o=pD(t,s[t.fieldName]?.value||null,this.getters.getLocale()),i=hl(t.granularity),{format:n,value:r}=i.toValueAndFormat(o,e);s[t.nameWithGranularity]={value:o,type:s[t.fieldName]?.type||$s.empty,format:s[t.fieldName]?.format,formattedValue:kn(r,{locale:e,format:n})}}}return t}},definition:iD,externalData:!1,onIterationEndEvaluation:e=>e.markAsDirtyForEvaluation(),dateGranularities:[...bD],datetimeGranularities:[...bD,"hour_number","minute_number","second_number"],isMeasureCandidate:e=>!["datetime","boolean"].includes(e.type),isGroupable:()=>!0});class SD extends cc{pivotId;mutators=["reset","deferUpdates","applyUpdate","discardPendingUpdate","update"];updatesAreDeferred=!1;draft=null;notification=this.get(o_);alreadyNotified=!1;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(){return this.pivot.getFields()}get pivot(){return this.getters.getPivot(this.pivotId)}get definition(){const e=vD.get(this.pivot.type).definition;return this.draft?new e(this.draft,this.fields,this.getters):this.pivot.definition}get isDirty(){return!!this.draft}get measureFields(){const e=[{name:"__count",string:vo("Count"),type:"integer",aggregator:"sum"}],t=this.fields;for(const o in t){const s=t[o];s&&(vD.get(this.pivot.type).isMeasureCandidate(s)&&e.push(s))}return e.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&&(vD.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.fieldName)),r=this.unusedGranularities;return e.filter((e=>Ol(e)?!n.includes(e.name)||r[e.name].size>0:!n.includes(e.name))).sort(((e,t)=>e.string.localeCompare(t.string)))}get datetimeGranularities(){return vD.get(this.pivot.type).datetimeGranularities}get dateGranularities(){return vD.get(this.pivot.type).dateGranularities}get unusedGranularities(){return this.getUnusedGranularities(this.fields,this.draft??this.getters.getPivotCoreDefinition(this.pivotId))}reset(e){this.pivotId=e,this.updatesAreDeferred=!0,this.draft=null}deferUpdates(e){this.updatesAreDeferred=e,!1===e&&this.draft&&this.applyUpdate()}applyUpdate(){if(this.draft&&(this.model.dispatch("UPDATE_PIVOT",{pivotId:this.pivotId,pivot:this.draft}),this.draft=null,!this.alreadyNotified&&!this.isDynamicPivotInViewport()&&this.isStaticPivotInViewport())){const e=`=PIVOT(${this.getters.getPivotFormulaId(this.pivotId)})`;this.alreadyNotified=!0,this.notification.notifyUser({type:"info",text:vo("Pivot updates only work with dynamic pivot tables. Use %s or re-insert the static pivot from the Data menu.",e),sticky:!1})}}discardPendingUpdate(){this.draft=null}update(e){const t=this.getters.getPivotCoreDefinition(this.pivotId),o={...t,...this.draft,...e},s={...o,columns:o.columns.map((e=>({fieldName:e.fieldName,order:e.order,granularity:e.granularity}))),rows:o.rows.map((e=>({fieldName:e.fieldName,order:e.order,granularity:e.granularity}))),measures:o.measures.map((e=>({id:e.id,fieldName:e.fieldName,aggregator:e.aggregator,userDefinedName:e.userDefinedName,computedBy:e.computedBy,isHidden:e.isHidden,format:e.format,display:e.display})))};if(!this.draft&&ct(t,s))return;const i=this.addDefaultDateTimeGranularity(this.fields,s);this.draft=i,this.updatesAreDeferred||this.applyUpdate()}isDynamicPivotInViewport(){const e=this.getters.getActiveSheetId();for(const t of this.getters.getSheetViewVisibleCols())for(const o of this.getters.getSheetViewVisibleRows()){if(this.getters.isSpillPivotFormula({sheetId:e,col:t,row:o}))return!0}return!1}isStaticPivotInViewport(){for(const e of this.getters.getVisibleCellPositions()){const t=this.getters.getCell(e);if(t?.isFormula){const e=CS(t.compiledFormula.tokens);if(e&&"PIVOT"!==e.functionName)return!0}}return!1}addDefaultDateTimeGranularity(e,t){const{columns:o,rows:s}=t,i=Pe(o),n=Pe(s),r=this.getUnusedGranularities(e,t);for(const t of i.concat(n)){const o=e[t.fieldName]?.type;if(("date"===o||"datetime"===o)&&!t.granularity){const e=r[t.fieldName]?.values().next().value||"year";r[t.fieldName]?.delete(e),t.granularity=e}}return{...t,columns:i,rows:n}}getUnusedGranularities(e,t){const{columns:o,rows:s}=t,i=o.concat(s).filter((t=>{const o=e[t.fieldName]?.type;return"date"===o||"datetime"===o})),n={};for(const t of i)n[t.fieldName]=new Set("date"===e[t.fieldName]?.type?this.dateGranularities:this.datetimeGranularities);for(const e of i)n[e.fieldName].delete(e.granularity);return n}}class yD extends t.Component{static template="o-spreadsheet-PivotSpreadsheetSidePanel";static props={pivotId:String,onCloseSidePanel:Function};static components={PivotLayoutConfigurator:eD,Section:yA,SelectionInput:EA,Checkbox:SA,PivotDeferUpdate:q_,PivotTitleSection:tD};store;state;pivotSidePanelRef=t.useRef("pivotSidePanel");setup(){this.store=oc(SD,this.props.pivotId),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 definition(){return this.store.definition}getScrollableContainerEl(){return this.pivotSidePanelRef.el}onSelectionChanged(e){this.state.rangeHasChanged=!0,this.state.range=e[0]}onSelectionConfirmed(){if(this.state.range){const e=this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(),this.state.range);if(e.invalidSheetName||e.invalidXc)return;const t={sheetId:e.sheetId,zone:e.zone};this.store.update({dataSet:t}),this.store.applyUpdate()}}flipAxis(){const{rows:e,columns:t}=this.definition;this.onDimensionsUpdated({rows:t,columns:e})}onDimensionsUpdated(e){this.store.update(e)}}const CD=new n;CD.add("SPREADSHEET",{editor:yD});class wD extends t.Component{static template="o-spreadsheet-PivotSidePanel";static props={pivotId:String,onCloseSidePanel:Function};static components={PivotLayoutConfigurator:eD,Section:yA};get sidePanelEditor(){const e=this.env.model.getters.getPivotCoreDefinition(this.props.pivotId);if(!e)throw new Error("pivotId does not correspond to a pivot.");return CD.get(e.type).editor}}Rb`
1281
1281
  .o-checkbox-selection {
1282
1282
  max-height: 300px;
1283
1283
  }
@@ -1943,7 +1943,7 @@
1943
1943
  }
1944
1944
  }
1945
1945
  }
1946
- `;class PM extends t.Component{static template="o-spreadsheet-BottomBar";static props={onClick:Function};static components={Menu:Yx,Ripple:DM,BottomBarSheet:OM,BottomBarStatistic:NM};bottomBarRef=t.useRef("bottomBar");sheetListRef=t.useRef("sheetList");dragAndDrop=a_();targetScroll=void 0;state=t.useState({isSheetListScrollableLeft:!1,isSheetListScrollableRight:!1});menuMaxHeight=250;menuState=t.useState({isOpen:!1,menuId:void 0,position:null,menuItems:[]});sheetList=this.getVisibleSheets();setup(){t.onWillUpdateProps((()=>{this.updateScrollState();const e=this.getVisibleSheets();ct(this.sheetList,e)||this.dragAndDrop.cancel(),this.sheetList=e}))}clickAddSheet(e){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getSheetIds().findIndex((e=>e===t))+1,s=this.env.model.uuidGenerator.uuidv4(),i=this.env.model.getters.getNextSheetName(vo("Sheet"));this.env.model.dispatch("CREATE_SHEET",{sheetId:s,position:o,name:i}),this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:s})}getVisibleSheets(){return this.env.model.getters.getVisibleSheetIds().map((e=>{const t=this.env.model.getters.getSheet(e);return{id:t.id,name:t.name}}))}clickListSheets(e){const t=new yx,o=this.env.model.getters.getActiveSheetId();let s=0;for(const e of this.env.model.getters.getSheetIds()){const i=this.env.model.getters.getSheet(e);t.add(e,{name:i.name,sequence:s,isReadonlyAllowed:!0,textColor:i.isVisible?void 0:"#808080",execute:t=>{this.env.model.getters.isSheetVisible(e)||this.env.model.dispatch("SHOW_SHEET",{sheetId:e}),t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:o,sheetIdTo:e})},isEnabled:e=>!e.model.getters.isReadonly()||i.isVisible,icon:i.color?"o-spreadsheet-Icon.SMALL_DOT_RIGHT_ALIGN":void 0,iconColor:i.color}),s++}const i=e.currentTarget,{left:n}=i.getBoundingClientRect(),r=this.bottomBarRef.el.getBoundingClientRect().top;this.openContextMenu(n,r,"listSheets",t)}openContextMenu(e,t,o,s){this.menuState.isOpen=!0,this.menuState.menuId=o,this.menuState.menuItems=s.getMenuItems(),this.menuState.position={x:e,y:t}}onSheetContextMenu(e,t,o){const s=o.currentTarget,{top:i,left:n}=s.getBoundingClientRect();o.closedMenuId!==e?this.openContextMenu(n,i,e,t):this.closeMenu()}closeMenu(){this.menuState.isOpen=!1,this.menuState.menuId=void 0,this.menuState.menuItems=[],this.menuState.position=null}closeContextMenuWithId(e){this.menuState.menuId===e&&this.closeMenu()}onWheel(e){this.targetScroll=void 0;e.currentTarget.scrollLeft+=.5*e.deltaY}onScroll(){this.updateScrollState(),this.targetScroll===this.sheetListCurrentScroll&&(this.targetScroll=void 0)}onArrowLeft(e){if(!this.state.isSheetListScrollableLeft)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll-this.sheetListWidth;this.scrollSheetListTo(Math.max(0,t))}onArrowRight(e){if(!this.state.isSheetListScrollableRight)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll+this.sheetListWidth;this.scrollSheetListTo(Math.min(this.sheetListMaxScroll,t))}updateScrollState(){this.state.isSheetListScrollableLeft=this.sheetListCurrentScroll>0,this.state.isSheetListScrollableRight=this.sheetListCurrentScroll<this.sheetListMaxScroll}scrollSheetListTo(e){this.sheetListRef.el&&(this.targetScroll=e,this.sheetListRef.el.scrollTo({top:0,left:e,behavior:"smooth"}))}onSheetMouseDown(e,t){if(0!==t.button||this.env.model.getters.isReadonly())return;this.closeMenu();const o=this.getVisibleSheets(),s=this.getSheetItemRects(),i=o.map(((e,t)=>({id:e.id,size:s[t].width,position:s[t].x})));this.dragAndDrop.start("horizontal",{draggedItemId:e,initialMousePosition:t.clientX,items:i,containerEl:this.sheetListRef.el,onDragEnd:(e,t)=>this.onDragEnd(e,t)})}onDragEnd(e,t){const o=t-this.getVisibleSheets().findIndex((t=>t.id===e));e&&0!==o&&this.env.model.dispatch("MOVE_SHEET",{sheetId:e,delta:o})}getSheetStyle(e){return this.dragAndDrop.itemsStyle[e]||""}getSheetItemRects(){return Array.from(this.bottomBarRef.el.querySelectorAll(".o-sheet")).map((e=>e.getBoundingClientRect())).map((e=>({x:e.x,width:e.width-1,y:e.y,height:e.height})))}get sheetListCurrentScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollLeft:0}get sheetListWidth(){return this.sheetListRef.el?this.sheetListRef.el.clientWidth:0}get sheetListMaxScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollWidth-this.sheetListRef.el.clientWidth:0}}class kM extends cc{_clickableCells=t.markRaw({});_registryItems=t.markRaw(RM.getAll().sort(((e,t)=>e.sequence-t.sequence)));handle(e){(Ws.has(e.type)||"EVALUATE_CELLS"===e.type||"UPDATE_CELL"===e.type&&("content"in e||"format"in e))&&(this._clickableCells=t.markRaw({}),this._registryItems=t.markRaw(RM.getAll().sort(((e,t)=>e.sequence-t.sequence))))}getClickableAction(e){const{sheetId:t,col:o,row:s}=e,i=this._clickableCells,n=io(o,s);return i[t]||(i[t]={}),n in i[t]||(i[t][n]=this.findClickableAction(e)),i[t][n]}findClickableAction(e){const t=this.getters;for(const o of this._registryItems)if(o.condition(e,t))return o.execute;return!1}get clickableCells(){const e=[],t=this.getters,o=t.getActiveSheetId();for(const s of t.getSheetViewVisibleCols())for(const i of t.getSheetViewVisibleRows()){const n={sheetId:o,col:s,row:i};if(!t.isMainCellPosition(n))continue;const r=this.getClickableAction(n);if(!r)continue;const a=t.expandZone(o,ts(n));e.push({coordinates:t.getVisibleRect(a),position:n,action:r})}return e}}Rb`
1946
+ `;class PM extends t.Component{static template="o-spreadsheet-BottomBar";static props={onClick:Function};static components={Menu:Yx,Ripple:DM,BottomBarSheet:OM,BottomBarStatistic:NM};bottomBarRef=t.useRef("bottomBar");sheetListRef=t.useRef("sheetList");dragAndDrop=a_();targetScroll=void 0;state=t.useState({isSheetListScrollableLeft:!1,isSheetListScrollableRight:!1});menuMaxHeight=250;menuState=t.useState({isOpen:!1,menuId:void 0,position:null,menuItems:[]});sheetList=this.getVisibleSheets();setup(){t.onWillUpdateProps((()=>{this.updateScrollState();const e=this.getVisibleSheets();ct(this.sheetList,e)||this.dragAndDrop.cancel(),this.sheetList=e}))}clickAddSheet(e){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getSheetIds().findIndex((e=>e===t))+1,s=this.env.model.uuidGenerator.uuidv4(),i=this.env.model.getters.getNextSheetName(vo("Sheet"));this.env.model.dispatch("CREATE_SHEET",{sheetId:s,position:o,name:i}),this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:s})}getVisibleSheets(){return this.env.model.getters.getVisibleSheetIds().map((e=>{const t=this.env.model.getters.getSheet(e);return{id:t.id,name:t.name}}))}clickListSheets(e){const t=new yx,o=this.env.model.getters.getActiveSheetId();let s=0;for(const e of this.env.model.getters.getSheetIds()){const i=this.env.model.getters.getSheet(e);t.add(e,{name:i.name,sequence:s,isReadonlyAllowed:!0,textColor:i.isVisible?void 0:"#808080",execute:t=>{this.env.model.getters.isSheetVisible(e)||this.env.model.dispatch("SHOW_SHEET",{sheetId:e}),t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:o,sheetIdTo:e})},isEnabled:e=>!e.model.getters.isReadonly()||i.isVisible,icon:i.color?"o-spreadsheet-Icon.SMALL_DOT_RIGHT_ALIGN":void 0,iconColor:i.color}),s++}const i=e.currentTarget,{left:n}=i.getBoundingClientRect(),r=this.bottomBarRef.el.getBoundingClientRect().top;this.openContextMenu(n,r,"listSheets",t)}openContextMenu(e,t,o,s){this.menuState.isOpen=!0,this.menuState.menuId=o,this.menuState.menuItems=s.getMenuItems(),this.menuState.position={x:e,y:t}}onSheetContextMenu(e,t,o){const s=o.currentTarget,{top:i,left:n}=s.getBoundingClientRect();o.closedMenuId!==e?this.openContextMenu(n,i,e,t):this.closeMenu()}closeMenu(){this.menuState.isOpen=!1,this.menuState.menuId=void 0,this.menuState.menuItems=[],this.menuState.position=null}closeContextMenuWithId(e){this.menuState.menuId===e&&this.closeMenu()}onWheel(e){this.targetScroll=void 0;e.currentTarget.scrollLeft+=.5*e.deltaY}onScroll(){this.updateScrollState(),this.targetScroll===this.sheetListCurrentScroll&&(this.targetScroll=void 0)}onArrowLeft(e){if(!this.state.isSheetListScrollableLeft)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll-this.sheetListWidth;this.scrollSheetListTo(Math.max(0,t))}onArrowRight(e){if(!this.state.isSheetListScrollableRight)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll+this.sheetListWidth;this.scrollSheetListTo(Math.min(this.sheetListMaxScroll,t))}updateScrollState(){this.state.isSheetListScrollableLeft=this.sheetListCurrentScroll>0,this.state.isSheetListScrollableRight=this.sheetListCurrentScroll<this.sheetListMaxScroll}scrollSheetListTo(e){this.sheetListRef.el&&(this.targetScroll=e,this.sheetListRef.el.scrollTo({top:0,left:e,behavior:"smooth"}))}onSheetMouseDown(e,t){if(0!==t.button||this.env.model.getters.isReadonly())return;this.closeMenu();const o=this.getVisibleSheets(),s=this.getSheetItemRects(),i=o.map(((e,t)=>({id:e.id,size:s[t].width,position:s[t].x})));this.dragAndDrop.start("horizontal",{draggedItemId:e,initialMousePosition:t.clientX,items:i,scrollableContainerEl:this.sheetListRef.el,onDragEnd:(e,t)=>this.onDragEnd(e,t)})}onDragEnd(e,t){const o=t-this.getVisibleSheets().findIndex((t=>t.id===e));e&&0!==o&&this.env.model.dispatch("MOVE_SHEET",{sheetId:e,delta:o})}getSheetStyle(e){return this.dragAndDrop.itemsStyle[e]||""}getSheetItemRects(){return Array.from(this.bottomBarRef.el.querySelectorAll(".o-sheet")).map((e=>e.getBoundingClientRect())).map((e=>({x:e.x,width:e.width-1,y:e.y,height:e.height})))}get sheetListCurrentScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollLeft:0}get sheetListWidth(){return this.sheetListRef.el?this.sheetListRef.el.clientWidth:0}get sheetListMaxScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollWidth-this.sheetListRef.el.clientWidth:0}}class kM extends cc{_clickableCells=t.markRaw({});_registryItems=t.markRaw(RM.getAll().sort(((e,t)=>e.sequence-t.sequence)));handle(e){(Ws.has(e.type)||"EVALUATE_CELLS"===e.type||"UPDATE_CELL"===e.type&&("content"in e||"format"in e))&&(this._clickableCells=t.markRaw({}),this._registryItems=t.markRaw(RM.getAll().sort(((e,t)=>e.sequence-t.sequence))))}getClickableAction(e){const{sheetId:t,col:o,row:s}=e,i=this._clickableCells,n=io(o,s);return i[t]||(i[t]={}),n in i[t]||(i[t][n]=this.findClickableAction(e)),i[t][n]}findClickableAction(e){const t=this.getters;for(const o of this._registryItems)if(o.condition(e,t))return o.execute;return!1}get clickableCells(){const e=[],t=this.getters,o=t.getActiveSheetId();for(const s of t.getSheetViewVisibleCols())for(const i of t.getSheetViewVisibleRows()){const n={sheetId:o,col:s,row:i};if(!t.isMainCellPosition(n))continue;const r=this.getClickableAction(n);if(!r)continue;const a=t.expandZone(o,ts(n));e.push({coordinates:t.getVisibleRect(a),position:n,action:r})}return e}}Rb`
1947
1947
  .o-dashboard-clickable-cell {
1948
1948
  position: absolute;
1949
1949
  cursor: pointer;
@@ -3216,4 +3216,4 @@
3216
3216
  <tableParts count="${e.tables.length}">
3217
3217
  ${_w(a)}
3218
3218
  </tableParts>
3219
- `}var dP;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(dP||(dP={}));function uP(e,t={}){const o=Pe(t);return o.type=e,o}const gP={},pP={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:Y,HEADER_WIDTH:X,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:K,DEFAULT_CELL_HEIGHT:Q,SCROLLBAR_WIDTH:J},mP={autoCompleteProviders:th,autofillModifiersRegistry:xS,autofillRulesRegistry:IS,cellMenuRegistry:ER,colMenuRegistry:cA,errorTypes:hi,linkMenuRegistry:jx,functionRegistry:vb,featurePluginRegistry:EM,iconsOnCellRegistry:Cy,statefulUIPluginRegistry:xM,coreViewsPluginRegistry:IM,corePluginRegistry:wM,rowMenuRegistry:gA,sidePanelRegistry:WD,figureRegistry:px,chartSidePanelComponentRegistry:QA,chartComponentRegistry:ax,chartRegistry:rx,chartSubtypeRegistry:cx,topbarMenuRegistry:vA,topbarComponentRegistry:qD,clickableCellRegistry:RM,otRegistry:bA,inverseCommandRegistry:bx,urlRegistry:rn,cellPopoverRegistry:FS,numberFormatMenuRegistry:hA,repeatLocalCommandTransformRegistry:bM,repeatCommandTransformRegistry:vM,clipboardHandlersRegistries:Zl,pivotRegistry:vD,pivotTimeAdapterRegistry:cl,pivotSidePanelRegistry:CD,pivotNormalizationValueRegistry:Ul,supportedPivotPositionalFormulaRegistry:ES,pivotToFunctionValueRegistry:Hl,migrationStepRegistry:Qw},fP={arg:nh,isEvaluationError:yi,toBoolean:Mi,toJsDate:Ni,toNumber:wi,toString:Di,toNormalizedPivotValue:Pl,toXC:io,toZone:No,toUnboundedZone:Mo,toCartesian:so,numberToLetters:eo,lettersToNumber:to,UuidGenerator:Gr,formatValue:kn,createCurrencyFormat:Xn,ColorGenerator:Jt,computeTextWidth:Or,createEmptyWorkbookData:rE,createEmptySheet:nE,createEmptyExcelSheet:aE,getDefaultChartJsRuntime:RE,chartFontColor:wc,getChartAxisTitleRuntime:Rc,getChartAxisType:BE,getTrendDatasetForBarChart:_c,getTrendDatasetForLineChart:WE,getFillingMode:OE,rgbaToHex:Vt,colorToRGBA:Ut,positionToZone:ts,isDefined:tt,isMatrix:ni,lazy:rt,genericRepeat:SM,createAction:i,createActions:o,transformRangeData:Yl,deepEquals:ct,overlap:Wo,union:zo,isInside:qo,deepCopy:Pe,expandZoneOnInsertion:Vo,reduceZoneOnDeletion:Bo,unquote:Le,getMaxObjectId:Tl,getFunctionsFromTokens:mS,getFirstPivotFunction:CS,getNumberOfPivotFunctions:wS,parseDimension:Dl,isDateOrDatetimeField:Ol,makeFieldProposal:vS,insertTokenAfterArgSeparator:bS,insertTokenAfterLeftParenthesis:SS,mergeContiguousZones:rs,getPivotHighlights:pA,pivotTimeAdapter:hl,UNDO_REDO_PIVOT_COMMANDS:GF,createPivotFormula:Nl,areDomainArgsFieldsValid:Ml,splitReference:Oo,formatTickValue:Fc,sanitizeSheetName:Ue,isNumber:Us,isDateTime:ws},vP={isMarkdownLink:Ze,parseMarkdownLink:Xe,markdownLink:Ye,openLink:dn,urlRepresentation:hn},bP={Checkbox:SA,Section:yA,RoundColorPicker:UA,ChartDataSeries:xA,ChartErrorSection:RA,ChartLabelRange:TA,ChartTitle:BA,ChartPanel:t_,ChartFigure:dx,ChartJsComponent:Hc,Grid:qO,GridOverlay:IO,ScorecardChart:eh,LineConfigPanel:ZA,BarConfigPanel:_A,PieChartDesignPanel:jA,GenericChartConfigPanel:AA,ChartWithAxisDesignPanel:GA,GaugeChartConfigPanel:WA,GaugeChartDesignPanel:qA,ScorecardChartConfigPanel:YA,ScorecardChartDesignPanel:XA,ChartTypePicker:JA,FigureComponent:ZD,Menu:Yx,Popover:Ax,SelectionInput:EA,ValidationMessages:IA,AddDimensionButton:Z_,PivotDimensionGranularity:K_,PivotDimensionOrder:Q_,PivotDimension:X_,PivotLayoutConfigurator:eD,EditableName:ZO,PivotDeferUpdate:q_,PivotTitleSection:tD,CogWheelMenu:Y_,TextInput:j_,SidePanelCollapsible:OA},SP={useDragAndDropListItems:a_,useHighlights:p_,useHighlightsOnHover:g_},yP={useStoreProvider:ec,DependencyContainer:Kl,CellPopoverStore:xx,ComposerFocusStore:dc,CellComposerStore:iO,FindAndReplaceStore:H_,HighlightStore:fA,HoveredCellStore:Ex,ModelStore:rc,NotificationStore:o_,RendererStore:lc,SelectionInputStore:wA,SpreadsheetStore:cc,useStore:tc,useLocalStore:oc,SidePanelStore:zO,PivotSidePanelStore:SD,PivotMeasureDisplayPanelStore:G_};const CP={DEFAULT_LOCALE:si,HIGHLIGHT_COLOR:a,PIVOT_TABLE_CONFIG:De,TREND_LINE_XAXIS_ID:uc,CHART_AXIS_CHOICES:Nc,ChartTerms:pE};e.AbstractCellClipboardHandler=Yr,e.AbstractChart=Bc,e.AbstractFigureClipboardHandler=Gl,e.CellErrorType=ci,e.CorePlugin=YO,e.DispatchResult=Js,e.EvaluationError=di,e.Model=class extends Xl{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 Gr,n=!1){const r=performance.now();console.debug("##### Model creation #####"),super(),po===uo&&mo===go&&(mo=()=>!0),s=sE(e,s);const a=oE(e,n);this.state=new gN,this.uuidGenerator=i,this.config=this.setupConfig(o),this.session=this.setupSession(a.revisionId),this.coreGetters={},this.range=new oF(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.selection=new dN(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of wM.getAll())this.setupCorePlugin(e,a);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(s);for(let e of IM.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 xM.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of EM.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||e["[Content_Types].xml"]&&!this.getters.isReadonly()){const e=performance.now();console.debug("Snapshot requested"),this.session.snapshot(this.exportData()),this.garbageCollectExternalResources(),console.debug("Snapshot taken in",performance.now()-e,"ms")}t.markRaw(this),console.debug("Model created in",performance.now()-r,"ms"),console.debug("######")}joinSession(){this.session.join(this.config.client)}async leaveSession(){const e=this.getters.isReadonly()?void 0:rt((()=>this.exportData()));await this.session.leave(e)}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}for(const o of e.layers)this.renderers[o]||(this.renderers[o]=[]),this.renderers[o].push(t);return t}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 nM(lN({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:vo("Anonymous").toString()},o=e.transportService||new eN;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(oi));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,canDispatch:this.canDispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[]}}checkDispatchAllowed(e){const t=Qs(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some((e=>"Success"!==e))?new Js(t.flat()):Js.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(uP(e,t));dispatch=(e,t)=>{const o=uP(e,t);let s=this.status;if(this.getters.isReadonly()&&(i=o,!Xs.has(i.type)))return new Js("Readonly");var i;if(!this.session.canApplyOptimisticUpdate())return new Js("WaitingSessionConfirmation");switch(s){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return this.trigger("update"),t;this.status=1;const{changes:s,commands:i}=this.state.recordChanges((()=>{const t=performance.now();Qs(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize();const s=performance.now()-t;s>5&&console.debug(e,s,"ms")}));this.session.save(o,i,s),this.status=0,this.trigger("update");break;case 1:if(Qs(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(Qs(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return Js.Success};dispatchFromCorePlugin=(e,t)=>{const o=uP(e,t),s=this.status;this.status=2;const i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,o),this.status=s,Js.Success};dispatchToHandlers(e,t){const o=Qs(t);for(const s of e)!o&&s instanceof YO||s.beforeHandle(t);for(const s of e)!o&&s instanceof YO||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=rE();for(let t of this.handlers)t instanceof YO&&t.export(e);return e.revisionId=this.session.getRevisionId()||pe,e=Pe(e),e}updateMode(e){this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...rE(),sheets:[aE(tE,"Sheet1")]};for(let t of this.handlers)t instanceof jO&&t.exportForExcel(e);return e=Pe(e),cP(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.PivotRuntimeDefinition=oD,e.Registry=n,e.Revision=sM,e.SPREADSHEET_DIMENSIONS=pP,e.Spreadsheet=JM,e.SpreadsheetPivotTable=nD,e.UIPlugin=iF,e.__info__=gP,e.addFunction=function e(t,o){return vb.add(t,o),{addFunction:(t,o)=>e(t,o)}},e.addRenderingLayer=function(e,t){if(ai[e])throw new Error(`Layer ${e} already exists`);ai[e]=t},e.astToFormula=af,e.compile=hS,e.compileTokens=dS,e.components=bP,e.constants=CP,e.convertAstNodes=of,e.coreTypes=Ks,e.findCellInNewZone=es,e.functionCache=cS,e.helpers=fP,e.hooks=SP,e.invalidateCFEvaluationCommands=js,e.invalidateDependenciesCommands=Zs,e.invalidateEvaluationCommands=Ws,e.iterateAstNodes=sf,e.links=vP,e.load=oE,e.parse=ef,e.parseTokens=tf,e.readonlyAllowedCommands=Xs,e.registries=mP,e.setDefaultSheetViewSize=function(e){Re=e},e.setTranslationMethod=function(e,t=(()=>!0)){po=e,mo=t},e.stores=yP,e.tokenColors=eS,e.tokenize=Jr,gP.version="18.0.14",gP.date="2025-02-05T06:47:33.041Z",gP.hash="90f2af4"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
3219
+ `}var dP;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(dP||(dP={}));function uP(e,t={}){const o=Pe(t);return o.type=e,o}const gP={},pP={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:Y,HEADER_WIDTH:X,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:K,DEFAULT_CELL_HEIGHT:Q,SCROLLBAR_WIDTH:J},mP={autoCompleteProviders:th,autofillModifiersRegistry:xS,autofillRulesRegistry:IS,cellMenuRegistry:ER,colMenuRegistry:cA,errorTypes:hi,linkMenuRegistry:jx,functionRegistry:vb,featurePluginRegistry:EM,iconsOnCellRegistry:Cy,statefulUIPluginRegistry:xM,coreViewsPluginRegistry:IM,corePluginRegistry:wM,rowMenuRegistry:gA,sidePanelRegistry:WD,figureRegistry:px,chartSidePanelComponentRegistry:QA,chartComponentRegistry:ax,chartRegistry:rx,chartSubtypeRegistry:cx,topbarMenuRegistry:vA,topbarComponentRegistry:qD,clickableCellRegistry:RM,otRegistry:bA,inverseCommandRegistry:bx,urlRegistry:rn,cellPopoverRegistry:FS,numberFormatMenuRegistry:hA,repeatLocalCommandTransformRegistry:bM,repeatCommandTransformRegistry:vM,clipboardHandlersRegistries:Zl,pivotRegistry:vD,pivotTimeAdapterRegistry:cl,pivotSidePanelRegistry:CD,pivotNormalizationValueRegistry:Ul,supportedPivotPositionalFormulaRegistry:ES,pivotToFunctionValueRegistry:Hl,migrationStepRegistry:Qw},fP={arg:nh,isEvaluationError:yi,toBoolean:Mi,toJsDate:Ni,toNumber:wi,toString:Di,toNormalizedPivotValue:Pl,toXC:io,toZone:No,toUnboundedZone:Mo,toCartesian:so,numberToLetters:eo,lettersToNumber:to,UuidGenerator:Gr,formatValue:kn,createCurrencyFormat:Xn,ColorGenerator:Jt,computeTextWidth:Or,createEmptyWorkbookData:rE,createEmptySheet:nE,createEmptyExcelSheet:aE,getDefaultChartJsRuntime:RE,chartFontColor:wc,getChartAxisTitleRuntime:Rc,getChartAxisType:BE,getTrendDatasetForBarChart:_c,getTrendDatasetForLineChart:WE,getFillingMode:OE,rgbaToHex:Vt,colorToRGBA:Ut,positionToZone:ts,isDefined:tt,isMatrix:ni,lazy:rt,genericRepeat:SM,createAction:i,createActions:o,transformRangeData:Yl,deepEquals:ct,overlap:Wo,union:zo,isInside:qo,deepCopy:Pe,expandZoneOnInsertion:Vo,reduceZoneOnDeletion:Bo,unquote:Le,getMaxObjectId:Tl,getFunctionsFromTokens:mS,getFirstPivotFunction:CS,getNumberOfPivotFunctions:wS,parseDimension:Dl,isDateOrDatetimeField:Ol,makeFieldProposal:vS,insertTokenAfterArgSeparator:bS,insertTokenAfterLeftParenthesis:SS,mergeContiguousZones:rs,getPivotHighlights:pA,pivotTimeAdapter:hl,UNDO_REDO_PIVOT_COMMANDS:GF,createPivotFormula:Nl,areDomainArgsFieldsValid:Ml,splitReference:Oo,formatTickValue:Fc,sanitizeSheetName:Ue,isNumber:Us,isDateTime:ws},vP={isMarkdownLink:Ze,parseMarkdownLink:Xe,markdownLink:Ye,openLink:dn,urlRepresentation:hn},bP={Checkbox:SA,Section:yA,RoundColorPicker:UA,ChartDataSeries:xA,ChartErrorSection:RA,ChartLabelRange:TA,ChartTitle:BA,ChartPanel:t_,ChartFigure:dx,ChartJsComponent:Hc,Grid:qO,GridOverlay:IO,ScorecardChart:eh,LineConfigPanel:ZA,BarConfigPanel:_A,PieChartDesignPanel:jA,GenericChartConfigPanel:AA,ChartWithAxisDesignPanel:GA,GaugeChartConfigPanel:WA,GaugeChartDesignPanel:qA,ScorecardChartConfigPanel:YA,ScorecardChartDesignPanel:XA,ChartTypePicker:JA,FigureComponent:ZD,Menu:Yx,Popover:Ax,SelectionInput:EA,ValidationMessages:IA,AddDimensionButton:Z_,PivotDimensionGranularity:K_,PivotDimensionOrder:Q_,PivotDimension:X_,PivotLayoutConfigurator:eD,EditableName:ZO,PivotDeferUpdate:q_,PivotTitleSection:tD,CogWheelMenu:Y_,TextInput:j_,SidePanelCollapsible:OA},SP={useDragAndDropListItems:a_,useHighlights:p_,useHighlightsOnHover:g_},yP={useStoreProvider:ec,DependencyContainer:Kl,CellPopoverStore:xx,ComposerFocusStore:dc,CellComposerStore:iO,FindAndReplaceStore:H_,HighlightStore:fA,HoveredCellStore:Ex,ModelStore:rc,NotificationStore:o_,RendererStore:lc,SelectionInputStore:wA,SpreadsheetStore:cc,useStore:tc,useLocalStore:oc,SidePanelStore:zO,PivotSidePanelStore:SD,PivotMeasureDisplayPanelStore:G_};const CP={DEFAULT_LOCALE:si,HIGHLIGHT_COLOR:a,PIVOT_TABLE_CONFIG:De,TREND_LINE_XAXIS_ID:uc,CHART_AXIS_CHOICES:Nc,ChartTerms:pE};e.AbstractCellClipboardHandler=Yr,e.AbstractChart=Bc,e.AbstractFigureClipboardHandler=Gl,e.CellErrorType=ci,e.CorePlugin=YO,e.DispatchResult=Js,e.EvaluationError=di,e.Model=class extends Xl{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 Gr,n=!1){const r=performance.now();console.debug("##### Model creation #####"),super(),po===uo&&mo===go&&(mo=()=>!0),s=sE(e,s);const a=oE(e,n);this.state=new gN,this.uuidGenerator=i,this.config=this.setupConfig(o),this.session=this.setupSession(a.revisionId),this.coreGetters={},this.range=new oF(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.selection=new dN(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of wM.getAll())this.setupCorePlugin(e,a);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(s);for(let e of IM.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 xM.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of EM.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||e["[Content_Types].xml"]&&!this.getters.isReadonly()){const e=performance.now();console.debug("Snapshot requested"),this.session.snapshot(this.exportData()),this.garbageCollectExternalResources(),console.debug("Snapshot taken in",performance.now()-e,"ms")}t.markRaw(this),console.debug("Model created in",performance.now()-r,"ms"),console.debug("######")}joinSession(){this.session.join(this.config.client)}async leaveSession(){const e=this.getters.isReadonly()?void 0:rt((()=>this.exportData()));await this.session.leave(e)}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}for(const o of e.layers)this.renderers[o]||(this.renderers[o]=[]),this.renderers[o].push(t);return t}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 nM(lN({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:vo("Anonymous").toString()},o=e.transportService||new eN;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(oi));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,canDispatch:this.canDispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[]}}checkDispatchAllowed(e){const t=Qs(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some((e=>"Success"!==e))?new Js(t.flat()):Js.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(uP(e,t));dispatch=(e,t)=>{const o=uP(e,t);let s=this.status;if(this.getters.isReadonly()&&(i=o,!Xs.has(i.type)))return new Js("Readonly");var i;if(!this.session.canApplyOptimisticUpdate())return new Js("WaitingSessionConfirmation");switch(s){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return this.trigger("update"),t;this.status=1;const{changes:s,commands:i}=this.state.recordChanges((()=>{const t=performance.now();Qs(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize();const s=performance.now()-t;s>5&&console.debug(e,s,"ms")}));this.session.save(o,i,s),this.status=0,this.trigger("update");break;case 1:if(Qs(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(Qs(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return Js.Success};dispatchFromCorePlugin=(e,t)=>{const o=uP(e,t),s=this.status;this.status=2;const i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,o),this.status=s,Js.Success};dispatchToHandlers(e,t){const o=Qs(t);for(const s of e)!o&&s instanceof YO||s.beforeHandle(t);for(const s of e)!o&&s instanceof YO||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=rE();for(let t of this.handlers)t instanceof YO&&t.export(e);return e.revisionId=this.session.getRevisionId()||pe,e=Pe(e),e}updateMode(e){this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...rE(),sheets:[aE(tE,"Sheet1")]};for(let t of this.handlers)t instanceof jO&&t.exportForExcel(e);return e=Pe(e),cP(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.PivotRuntimeDefinition=oD,e.Registry=n,e.Revision=sM,e.SPREADSHEET_DIMENSIONS=pP,e.Spreadsheet=JM,e.SpreadsheetPivotTable=nD,e.UIPlugin=iF,e.__info__=gP,e.addFunction=function e(t,o){return vb.add(t,o),{addFunction:(t,o)=>e(t,o)}},e.addRenderingLayer=function(e,t){if(ai[e])throw new Error(`Layer ${e} already exists`);ai[e]=t},e.astToFormula=af,e.compile=hS,e.compileTokens=dS,e.components=bP,e.constants=CP,e.convertAstNodes=of,e.coreTypes=Ks,e.findCellInNewZone=es,e.functionCache=cS,e.helpers=fP,e.hooks=SP,e.invalidateCFEvaluationCommands=js,e.invalidateDependenciesCommands=Zs,e.invalidateEvaluationCommands=Ws,e.iterateAstNodes=sf,e.links=vP,e.load=oE,e.parse=ef,e.parseTokens=tf,e.readonlyAllowedCommands=Xs,e.registries=mP,e.setDefaultSheetViewSize=function(e){Re=e},e.setTranslationMethod=function(e,t=(()=>!0)){po=e,mo=t},e.stores=yP,e.tokenColors=eS,e.tokenize=Jr,gP.version="18.0.15",gP.date="2025-02-10T08:59:22.993Z",gP.hash="5b19f88"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);